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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_GARBLED_TEXT_SERVICE_H_
6 #define CHROME_BROWSER_GARBLED_TEXT_SERVICE_H_
7 #pragma once
8
9 #include "base/callback_forward.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/singleton.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/non_thread_safe.h"
14 #include "chrome/browser/garbled_text_url_tracker.h"
15 #include "chrome/browser/prefs/pref_change_registrar.h"
16 #include "chrome/browser/profiles/profile_keyed_service.h"
17 #include "chrome/browser/profiles/profile_keyed_service_factory.h"
18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h"
20
21 class Profile;
22 namespace content {
23 class NotificationDetails;
24 class NotificationSource;
25 }
26
27 class GarbledTextService;
28
29 // Factory class of GarbledTextURLTracker. This class is instantiated on UI
30 // thread and create GarbledTextURLTracker on IO thread.
31 class GarbledTextServiceParams {
32 public:
33 explicit GarbledTextServiceParams(PrefService* user_prefs,
34 GarbledTextService* service);
35 ~GarbledTextServiceParams();
36 scoped_ptr<GarbledTextURLTracker> CreateTracker(
37 const BooleanPrefMember& enabled);
38
39 private:
40 base::WeakPtr<GarbledTextService> service_;
41 GarbledTextURLTracker::Blacklist blacklist_;
42
43 DISALLOW_COPY_AND_ASSIGN(GarbledTextServiceParams);
44 };
45
46 // Factory class of GarbledTextService.
47 class GarbledTextServiceFactory : public ProfileKeyedServiceFactory {
48 public:
49 static GarbledTextService* GetForProfile(Profile* profile);
50 static GarbledTextServiceFactory* GetInstance();
51
52 virtual void RegisterUserPrefs(PrefService* user_prefs) OVERRIDE;
53 virtual bool ServiceHasOwnInstanceInIncognito() OVERRIDE;
54 virtual bool ServiceIsNULLWhileTesting() OVERRIDE;
55
56 private:
57 friend struct DefaultSingletonTraits<GarbledTextServiceFactory>;
58
59 GarbledTextServiceFactory();
60 virtual ~GarbledTextServiceFactory();
61
62 virtual ProfileKeyedService* BuildServiceInstanceFor(
63 Profile* profile) const OVERRIDE;
64
65 DISALLOW_COPY_AND_ASSIGN(GarbledTextServiceFactory);
66 };
67
68 // Proxy class for GarbledTextURLTracker from UI thread. This class is
69 // instantiated per Profile instance and held as ProfileKeyedService.
70 class GarbledTextService
71 : public base::NonThreadSafe,
72 public base::SupportsWeakPtr<GarbledTextService>,
73 public ProfileKeyedService {
74 public:
75 typedef GarbledTextURLTracker::Blacklist Blacklist;
76 typedef GarbledTextURLTracker::GarbledURLs GarbledURLs;
77
78 static const char kPrefGarbledTextBlacklist[];
79
80 explicit GarbledTextService(Profile* profile);
81 virtual ~GarbledTextService();
82
83 // Appends normalized |garbled_urls| to the blacklist asynchronously.
84 void UpdateBlacklist(const GarbledURLs& garbled_urls,
85 const base::Closure& callback);
86
87 void SetTracker(base::WeakPtr<GarbledTextURLTracker> tracker);
88
89 private:
90 friend class GarbledTextHelperTest;
91 friend class GarbledTextServiceTest;
92
93 void UpdatePref(const Blacklist* blacklist_delta,
94 const base::Closure& callback);
95
96 Profile* profile_;
97 base::WeakPtr<GarbledTextURLTracker> tracker_;
98
99 DISALLOW_COPY_AND_ASSIGN(GarbledTextService);
100 };
101
102 #endif // CHROME_BROWSER_GARBLED_TEXT_SERVICE_H_
OLDNEW
« 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