Locally managed profiles: Change manual white-/blacklist API to support hosts and exact URLs.
BUG=168772
Review URL: https://chromiumcodereview.appspot.com/11896035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180986 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/managed_mode/managed_user_service.h b/chrome/browser/managed_mode/managed_user_service.h
index bdcfea1..7120eee 100644
--- a/chrome/browser/managed_mode/managed_user_service.h
+++ b/chrome/browser/managed_mode/managed_user_service.h
@@ -29,6 +29,12 @@
public:
typedef std::vector<string16> CategoryList;
+ enum ManualBehavior {
+ MANUAL_NONE = 0,
+ MANUAL_ALLOW,
+ MANUAL_BLOCK
+ };
+
explicit ManagedUserService(Profile* profile);
virtual ~ManagedUserService();
@@ -52,28 +58,23 @@
// be fast.
void GetCategoryNames(CategoryList* list);
- // The functions that handle manual whitelists use |url_pattern| or lists
- // of "url patterns". An "url pattern" is a pattern in the format used by the
- // policy::URLBlacklist filter. A description of the format used can be found
- // here: http://dev.chromium.org/administrators/url-blacklist-filter-format.
- // They all receive the |is_whitelist| parameter which dictates whether they
- // act on the whitelist (for |is_whitelist| == true) or on the blacklist (for
- // |is_whitelist| == false).
+ // These methods allow querying and modifying the manual filtering behavior.
+ // The manual behavior is set by the user and overrides all other settings
+ // (whitelists or the default behavior).
- // Checks if the |url_pattern| is in the manual whitelist.
- bool IsInManualList(const bool is_whitelist, const std::string& url_pattern);
+ // Returns the manual behavior for the given host.
+ ManualBehavior GetManualBehaviorForHost(const std::string& hostname);
- // Appends |list| to the manual white/black list (according to |is_whitelist|)
- // both in URL filter and in preferences.
- void AddToManualList(const bool is_whitelist, const base::ListValue& list);
+ // Sets the manual behavior for the given host.
+ void SetManualBehaviorForHosts(const std::vector<std::string>& hostnames,
+ ManualBehavior behavior);
- // Removes |list| from the manual white/black list (according to
- // |is_whitelist|) both in URL filter and in preferences.
- void RemoveFromManualList(const bool is_whitelist,
- const base::ListValue& list);
+ // Returns the manual behavior for the given URL.
+ ManualBehavior GetManualBehaviorForURL(const GURL& url);
- // Updates the whitelist and the blacklist from the prefs.
- void UpdateManualLists();
+ // Sets the manual behavior for the given URL.
+ void SetManualBehaviorForURLs(const std::vector<GURL>& url,
+ ManualBehavior behavior);
void SetElevatedForTesting(bool is_elevated);
@@ -112,10 +113,8 @@
void SetDefaultFilteringBehavior(
ManagedModeURLFilter::FilteringBehavior behavior);
void LoadWhitelists(ScopedVector<ManagedModeSiteList> site_lists);
- void SetManualLists(scoped_ptr<base::ListValue> whitelist,
- scoped_ptr<base::ListValue> blacklist);
- void AddURLPatternToManualList(const bool isWhitelist,
- const std::string& url);
+ void SetManualHosts(scoped_ptr<std::map<std::string, bool> > host_map);
+ void SetManualURLs(scoped_ptr<std::map<GURL, bool> > url_map);
private:
// ManagedModeURLFilter is refcounted because the IO thread filter is used
@@ -143,16 +142,13 @@
void UpdateSiteLists();
- // Adds the |url_pattern| to the manual lists in the URL filter. This is used
- // by AddToManualListImpl().
- void AddURLPatternToManualList(const bool is_whitelist,
- const std::string& url_pattern);
+ // Updates the manual overrides for hosts in the URL filters when the
+ // corresponding preference is changed.
+ void UpdateManualHosts();
- // Returns a copy of the manual whitelist which is stored in each profile.
- scoped_ptr<base::ListValue> GetWhitelist();
-
- // Returns a copy of the manual blacklist which is stored in each profile.
- scoped_ptr<base::ListValue> GetBlacklist();
+ // Updates the manual overrides for URLs in the URL filters when the
+ // corresponding preference is changed.
+ void UpdateManualURLs();
// Owns us via the ProfileKeyedService mechanism.
Profile* profile_;