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

Unified Diff: chrome/browser/garbled_text_url_tracker.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_test_helper.cc ('k') | chrome/browser/garbled_text_url_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/garbled_text_url_tracker.h
diff --git a/chrome/browser/garbled_text_url_tracker.h b/chrome/browser/garbled_text_url_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..0fcc08b79b48c4e432c61cdd8ea34ab0c7fb9067
--- /dev/null
+++ b/chrome/browser/garbled_text_url_tracker.h
@@ -0,0 +1,58 @@
+// 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_URL_TRACKER_H_
+#define CHROME_BROWSER_GARBLED_TEXT_URL_TRACKER_H_
+#pragma once
+
+#include <set>
+#include <string>
+#include <vector>
+
+#include "base/memory/weak_ptr.h"
+#include "base/threading/non_thread_safe.h"
+#include "chrome/browser/prefs/pref_member.h"
+
+class GURL;
+
+// Holds URLs for which we want to run the encoding detector. The instance is
+// held by ProfileIOData and lives on IO thread.
+class GarbledTextURLTracker
+ : public base::SupportsWeakPtr<GarbledTextURLTracker>,
+ public base::NonThreadSafe {
+ public:
+ typedef std::vector<GURL> GarbledURLs;
+ typedef std::set<std::string> Blacklist;
+
+ GarbledTextURLTracker(const BooleanPrefMember& enabled,
+ const Blacklist& blacklist);
+ ~GarbledTextURLTracker();
+
+ // Returns true if we should run the encoding detector for the resource.
+ // If |enabled_| is false, the function returns false.
+ bool NeedsEncodingDetection(const GURL& url) const;
+
+ // Adds normalized |garbled_urls| to the blacklist and return the delta as
+ // |blacklist_delta|. Does nothing if |enabled_| is false.
+ void UpdateBlacklist(const GarbledURLs& garbled_urls,
+ Blacklist* blacklist_delta);
+
+ private:
+ friend class GarbledTextHelperTest;
+ friend class GarbledTextServiceTest;
+
+ // Returns the normalized representation of the given |url|, with which we
+ // actually register and compare URLs internally.
+ // Currently this method naively returns the host part of the given |url|
+ // (i.e. url.host()), assuming that if a page needs encoding detection other
+ // pages on the same site would need it as well.
+ std::string Normalize(const GURL& url) const;
+
+ const BooleanPrefMember& enabled_;
+ Blacklist blacklist_;
+
+ DISALLOW_COPY_AND_ASSIGN(GarbledTextURLTracker);
+};
+
+#endif // CHROME_BROWSER_GARBLED_TEXT_URL_TRACKER_H_
« no previous file with comments | « chrome/browser/garbled_text_test_helper.cc ('k') | chrome/browser/garbled_text_url_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698