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_ |