Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5316)

Unified Diff: chrome/renderer/chrome_render_view_observer.cc

Issue 9235004: [Garbled Text][Infobar] Adding infobar to suggest turning on encoding detection. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.h ('k') | chrome/test/data/garbled_text/foo.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/chrome_render_view_observer.cc
diff --git a/chrome/renderer/chrome_render_view_observer.cc b/chrome/renderer/chrome_render_view_observer.cc
index 55b3ddad597430a0fecc7289d7e2a316f4912cdc..a7a622ee71d87ff0041adad37521a9c64e60781b 100644
--- a/chrome/renderer/chrome_render_view_observer.cc
+++ b/chrome/renderer/chrome_render_view_observer.cc
@@ -230,6 +230,7 @@ ChromeRenderViewObserver::ChromeRenderViewObserver(
last_indexed_page_id_(-1),
allow_displaying_insecure_content_(false),
allow_running_insecure_content_(false),
+ garbled_text_detection_enabled_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kDomAutomationController)) {
@@ -270,6 +271,9 @@ bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ChromeViewMsg_AddStrictSecurityHost,
OnAddStrictSecurityHost)
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAsInterstitial, OnSetAsInterstitial)
+ IPC_MESSAGE_HANDLER(ChromeViewMsg_ReloadFromCache, OnReloadFromCache)
+ IPC_MESSAGE_HANDLER(ChromeViewMsg_SetGarbledTextDetectionEnableState,
+ OnSetGarbledTextDetectionEnableState)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -371,6 +375,17 @@ void ChromeRenderViewObserver::OnSetAsInterstitial() {
content_settings_->SetAsInterstitial();
}
+void ChromeRenderViewObserver::OnReloadFromCache() {
+ WebFrame* main_frame = render_view()->GetWebView()->mainFrame();
+ if (main_frame)
+ main_frame->reloadFromCache();
+}
+
+void ChromeRenderViewObserver::OnSetGarbledTextDetectionEnableState(
+ bool enabled) {
+ garbled_text_detection_enabled_ = enabled;
+}
+
void ChromeRenderViewObserver::Navigate(const GURL& url) {
// Execute cache clear operations that were postponed until a navigation
// event (including tab reload).
@@ -810,6 +825,20 @@ void ChromeRenderViewObserver::CapturePageInfo(int load_id,
return;
}
+ if (garbled_text_detection_enabled_) {
+ std::vector<GURL> garbled_urls;
+ for (WebKit::WebFrame* frame = render_view()->GetWebView()->mainFrame();
+ frame; frame = frame->traverseNext(false)) {
+ if (frame->document().shouldUseEncodingDetector())
+ garbled_urls.push_back(frame->document().url());
+ }
+
+ if (!garbled_urls.empty()) {
+ Send(new ChromeViewHostMsg_GarbledTextDetected(
+ routing_id(), garbled_urls));
+ }
+ }
+
// If the page id is unchanged, check whether the URL (ignoring fragments)
// has changed. If so, we need to reindex. Otherwise, assume this is a
// reload, in-page navigation, or some other load type where we don't want to
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.h ('k') | chrome/test/data/garbled_text/foo.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698