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

Unified Diff: chrome/browser/garbled_text_helper.h

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/browser/garbled_text_browsertest.cc ('k') | chrome/browser/garbled_text_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/garbled_text_helper.h
diff --git a/chrome/browser/garbled_text_helper.h b/chrome/browser/garbled_text_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..d3232c6e8d9a943a4dea47fa1eed1817e44c1d01
--- /dev/null
+++ b/chrome/browser/garbled_text_helper.h
@@ -0,0 +1,68 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_GARBLED_TEXT_HELPER_H_
+#define CHROME_BROWSER_GARBLED_TEXT_HELPER_H_
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/garbled_text_url_tracker.h"
+#include "chrome/browser/prefs/pref_change_registrar.h"
+#include "content/public/browser/web_contents_observer.h"
+
+class Profile;
+
+namespace content {
+class WebContents;
+}
+
+// This class is instantiated per tab and lives on UI thread.
+// Once containing text of the page is detected as garbled, the instance prompts
+// the user to enable encoding detection for this site through infobar, and
+// redirects the approval to |GarbledTextService|.
+class GarbledTextHelper : public base::SupportsWeakPtr<GarbledTextHelper>,
+ public content::WebContentsObserver,
+ public content::NotificationObserver {
+ public:
+ typedef GarbledTextURLTracker::GarbledURLs GarbledURLs;
+
+ explicit GarbledTextHelper(content::WebContents* web_contents);
+ virtual ~GarbledTextHelper();
+
+ private:
+ friend class GarbledTextHelperTest;
+
+ Profile* GetProfile();
+
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+ virtual void DidNavigateAnyFrame(
+ const content::LoadCommittedDetails& details,
+ const content::FrameNavigateParams& params) OVERRIDE;
+ virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
+
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ // Handles |ViewHostMsg_GarbledTextDetected|.
+ void OnGarbledTextDetected(const GarbledURLs& garbled_urls);
+
+ // Completion callback for |GrabledTextService::UpdateBlacklist()|.
+ void WillFinishUpdatingBlacklist();
+
+ void OnEnableStateChanged(bool enabled);
+
+ // Called when the user accepts enabling encoding detection for |garbled_urls|
+ // through infobar.
+ void EnableEncodingDetection(const GarbledURLs& garbled_urls);
+
+ PrefChangeRegistrar pref_change_registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(GarbledTextHelper);
+};
+
+#endif // CHROME_BROWSER_GARBLED_TEXT_HELPER_H_
« no previous file with comments | « chrome/browser/garbled_text_browsertest.cc ('k') | chrome/browser/garbled_text_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698