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

Unified Diff: chrome/browser/garbled_text_service.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_infobar_delegate.cc ('k') | chrome/browser/garbled_text_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/garbled_text_service.h
diff --git a/chrome/browser/garbled_text_service.h b/chrome/browser/garbled_text_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..603fd94b472dd00fe9d03c85b82e45d534fd304a
--- /dev/null
+++ b/chrome/browser/garbled_text_service.h
@@ -0,0 +1,102 @@
+// Copyright (c) 2011 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_SERVICE_H_
+#define CHROME_BROWSER_GARBLED_TEXT_SERVICE_H_
+#pragma once
+
+#include "base/callback_forward.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/singleton.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/non_thread_safe.h"
+#include "chrome/browser/garbled_text_url_tracker.h"
+#include "chrome/browser/prefs/pref_change_registrar.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
+#include "chrome/browser/profiles/profile_keyed_service_factory.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+class Profile;
+namespace content {
+class NotificationDetails;
+class NotificationSource;
+}
+
+class GarbledTextService;
+
+// Factory class of GarbledTextURLTracker. This class is instantiated on UI
+// thread and create GarbledTextURLTracker on IO thread.
+class GarbledTextServiceParams {
+ public:
+ explicit GarbledTextServiceParams(PrefService* user_prefs,
+ GarbledTextService* service);
+ ~GarbledTextServiceParams();
+ scoped_ptr<GarbledTextURLTracker> CreateTracker(
+ const BooleanPrefMember& enabled);
+
+ private:
+ base::WeakPtr<GarbledTextService> service_;
+ GarbledTextURLTracker::Blacklist blacklist_;
+
+ DISALLOW_COPY_AND_ASSIGN(GarbledTextServiceParams);
+};
+
+// Factory class of GarbledTextService.
+class GarbledTextServiceFactory : public ProfileKeyedServiceFactory {
+ public:
+ static GarbledTextService* GetForProfile(Profile* profile);
+ static GarbledTextServiceFactory* GetInstance();
+
+ virtual void RegisterUserPrefs(PrefService* user_prefs) OVERRIDE;
+ virtual bool ServiceHasOwnInstanceInIncognito() OVERRIDE;
+ virtual bool ServiceIsNULLWhileTesting() OVERRIDE;
+
+ private:
+ friend struct DefaultSingletonTraits<GarbledTextServiceFactory>;
+
+ GarbledTextServiceFactory();
+ virtual ~GarbledTextServiceFactory();
+
+ virtual ProfileKeyedService* BuildServiceInstanceFor(
+ Profile* profile) const OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(GarbledTextServiceFactory);
+};
+
+// Proxy class for GarbledTextURLTracker from UI thread. This class is
+// instantiated per Profile instance and held as ProfileKeyedService.
+class GarbledTextService
+ : public base::NonThreadSafe,
+ public base::SupportsWeakPtr<GarbledTextService>,
+ public ProfileKeyedService {
+ public:
+ typedef GarbledTextURLTracker::Blacklist Blacklist;
+ typedef GarbledTextURLTracker::GarbledURLs GarbledURLs;
+
+ static const char kPrefGarbledTextBlacklist[];
+
+ explicit GarbledTextService(Profile* profile);
+ virtual ~GarbledTextService();
+
+ // Appends normalized |garbled_urls| to the blacklist asynchronously.
+ void UpdateBlacklist(const GarbledURLs& garbled_urls,
+ const base::Closure& callback);
+
+ void SetTracker(base::WeakPtr<GarbledTextURLTracker> tracker);
+
+ private:
+ friend class GarbledTextHelperTest;
+ friend class GarbledTextServiceTest;
+
+ void UpdatePref(const Blacklist* blacklist_delta,
+ const base::Closure& callback);
+
+ Profile* profile_;
+ base::WeakPtr<GarbledTextURLTracker> tracker_;
+
+ DISALLOW_COPY_AND_ASSIGN(GarbledTextService);
+};
+
+#endif // CHROME_BROWSER_GARBLED_TEXT_SERVICE_H_
« no previous file with comments | « chrome/browser/garbled_text_infobar_delegate.cc ('k') | chrome/browser/garbled_text_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698