OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
Pam (message me for reviews)
2013/01/14 14:12:42
2013
...even though most of this comes straight fr
| |
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_MANAGED_MODE_MANAGED_USER_SERVICE_H_ | |
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/prefs/public/pref_change_registrar.h" | |
11 #include "base/string16.h" | |
12 #include "chrome/browser/extensions/management_policy.h" | |
13 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" | |
14 #include "chrome/browser/profiles/profile_keyed_service.h" | |
15 #include "content/public/browser/notification_observer.h" | |
16 #include "content/public/browser/notification_registrar.h" | |
17 | |
18 class ManagedModeURLFilter; | |
19 class ManagedModeSiteList; | |
20 class PrefServiceSyncable; | |
21 class Profile; | |
22 | |
23 class ManagedUserService : public ProfileKeyedService, | |
Pam (message me for reviews)
2013/01/14 14:12:42
Please add a brief comment describing what this th
Bernhard Bauer
2013/01/15 14:24:44
Done.
| |
24 public extensions::ManagementPolicy::Provider, | |
25 public content::NotificationObserver { | |
26 public: | |
27 typedef std::vector<string16> CategoryList; | |
28 | |
29 explicit ManagedUserService(Profile* profile); | |
30 virtual ~ManagedUserService(); | |
31 | |
32 bool ProfileIsManaged() const; | |
33 | |
34 static void RegisterUserPrefs(PrefServiceSyncable* prefs); | |
35 | |
36 // Returns the URL filter for the IO thread, for filtering network requests | |
37 // (in ChromeNetworkDelegate). | |
38 scoped_refptr<const ManagedModeURLFilter> GetURLFilterForIOThread(); | |
39 | |
40 // Returns the URL filter for the UI thread, for filtering navigations and | |
41 // classifying sites in the history view. | |
42 const ManagedModeURLFilter* GetURLFilterForUIThread(); | |
43 | |
44 // Returns the URL's category. | |
Pam (message me for reviews)
2013/01/14 14:12:42
...obtained from one of the installed content-pack
Bernhard Bauer
2013/01/15 14:24:44
Done.
| |
45 int GetCategory(const GURL& url); | |
46 | |
47 // Called in the critical path of drawing the history UI, so needs to be fast. | |
Pam (message me for reviews)
2013/01/14 14:12:42
Returns the list of all known human-readable categ
Bernhard Bauer
2013/01/15 14:24:44
Done.
| |
48 void GetCategoryNames(CategoryList* list); | |
49 | |
50 // The functions that handle manual whitelists use |url_pattern| or lists | |
51 // of "url patterns". An "url pattern" is a pattern in the format used by the | |
52 // policy::URLBlacklist filter. A description of the format used can be found | |
53 // here: http://dev.chromium.org/administrators/url-blacklist-filter-format. | |
54 // They all receive the |is_whitelist| parameter which dictates whether they | |
55 // act on the whitelist (for |is_whitelist| == true) or on the blacklist (for | |
56 // |is_whitelist| == false). | |
57 | |
58 // Checks if the |url_pattern| is in the manual whitelist. | |
59 bool IsInManualList(const bool is_whitelist, | |
60 const std::string& url_pattern); | |
61 | |
62 // Appends |list| to the manual white/black list (according to |is_whitelist|) | |
63 // both in URL filter and in preferences. | |
64 void AddToManualList(const bool is_whitelist, | |
65 const base::ListValue& list); | |
66 | |
67 // Removes |list| from the manual white/black list (according to | |
68 // |is_whitelist|) both in URL filter and in preferences. | |
69 void RemoveFromManualList(const bool is_whitelist, | |
70 const base::ListValue& list); | |
71 | |
72 // Updates the whitelist and the blacklist from the prefs. | |
73 void UpdateManualLists(); | |
74 | |
75 // ExtensionManagementPolicy::Provider implementation: | |
76 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; | |
77 virtual bool UserMayLoad(const extensions::Extension* extension, | |
78 string16* error) const OVERRIDE; | |
79 virtual bool UserMayModifySettings(const extensions::Extension* extension, | |
80 string16* error) const OVERRIDE; | |
81 | |
82 // content::NotificationObserver implementation: | |
83 virtual void Observe(int type, | |
84 const content::NotificationSource& source, | |
85 const content::NotificationDetails& details) OVERRIDE; | |
86 | |
87 private: | |
88 // A bridge from ManagedMode (which lives on the UI thread) to a | |
89 // ManagedModeURLFilter living on the IO thread. | |
Pam (message me for reviews)
2013/01/14 14:12:42
More than that, really. A bridge from ManagedMode
| |
90 class URLFilterContext { | |
91 public: | |
92 URLFilterContext(); | |
93 ~URLFilterContext(); | |
94 | |
95 ManagedModeURLFilter* ui_url_filter() const; | |
96 ManagedModeURLFilter* io_url_filter() const; | |
97 | |
98 void SetDefaultFilteringBehavior( | |
99 ManagedModeURLFilter::FilteringBehavior behavior); | |
100 void LoadWhitelists(ScopedVector<ManagedModeSiteList> site_lists); | |
101 void SetManualLists(scoped_ptr<base::ListValue> whitelist, | |
102 scoped_ptr<base::ListValue> blacklist); | |
103 void AddURLPatternToManualList(const bool isWhitelist, | |
104 const std::string& url); | |
105 | |
106 private: | |
107 scoped_refptr<ManagedModeURLFilter> ui_url_filter_; | |
Pam (message me for reviews)
2013/01/14 14:12:42
It would be worth explaining a little bit here why
Bernhard Bauer
2013/01/15 14:24:44
Done.
| |
108 scoped_refptr<ManagedModeURLFilter> io_url_filter_; | |
109 | |
110 DISALLOW_COPY_AND_ASSIGN(URLFilterContext); | |
111 }; | |
112 | |
113 // Internal implementation for ExtensionManagementPolicy::Delegate methods. | |
114 // If |error| is not NULL, it will be filled with an error message if the | |
115 // requested extension action (install, modify status, etc.) is not permitted. | |
116 bool ExtensionManagementPolicyImpl(string16* error) const; | |
117 | |
118 // Returns a list of all installed and enabled site lists in the current | |
119 // managed profile. | |
120 // This method should only be called if managed mode is active. | |
Pam (message me for reviews)
2013/01/14 14:12:42
I'd say that managed mode is always active in a ma
Bernhard Bauer
2013/01/15 14:24:44
The restriction is not really needed anymore (it w
| |
121 ScopedVector<ManagedModeSiteList> GetActiveSiteLists(); | |
122 | |
123 void OnDefaultFilteringBehaviorChanged(); | |
124 | |
125 void UpdateSiteLists(); | |
126 | |
127 // Adds the |url_pattern| to the manual lists in the URL filter. This is used | |
128 // by AddToManualListImpl(). | |
129 void AddURLPatternToManualList(const bool is_whitelist, | |
130 const std::string& url_pattern); | |
131 | |
132 // Returns a copy of the manual whitelist which is stored in each profile. | |
133 scoped_ptr<base::ListValue> GetWhitelist(); | |
134 | |
135 // Returns a copy of the manual whitelist which is stored in each profile. | |
Pam (message me for reviews)
2013/01/14 14:12:42
whitelist -> blacklist
Bernhard Bauer
2013/01/15 14:24:44
Done.
| |
136 scoped_ptr<base::ListValue> GetBlacklist(); | |
137 | |
138 // Owns us. | |
Pam (message me for reviews)
2013/01/14 14:12:42
Not anymore.
Bernhard Bauer
2013/01/15 14:24:44
It does, via the ProfileKeyedService mechanism. I
| |
139 Profile* profile_; | |
140 | |
141 content::NotificationRegistrar registrar_; | |
142 PrefChangeRegistrar pref_change_registrar_; | |
143 | |
144 URLFilterContext url_filter_context_; | |
145 }; | |
146 | |
147 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_SERVICE_H_ | |
OLD | NEW |