diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-12 21:48:10 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-12 21:48:10 +0000 |
commit | 84064220a7e5a37715aeb428a80b6474f9799cc2 (patch) | |
tree | 42c39d3d503379a65e35a56da12a4fbb1604ac91 /chrome/browser/notifications/notifications_prefs_cache.cc | |
parent | 9a371cd2332d32818bdeb783d364c108faf1dd53 (diff) | |
download | chromium_src-84064220a7e5a37715aeb428a80b6474f9799cc2.zip chromium_src-84064220a7e5a37715aeb428a80b6474f9799cc2.tar.gz chromium_src-84064220a7e5a37715aeb428a80b6474f9799cc2.tar.bz2 |
Add notifications to allow desktop notification permissions to be synced.
Fix a bug where sites can be added to allow and deny lists multiple times.
BUG=none
TEST=Open two browsers with separate profiles. Request permission for notifications on a site on one. Check that the permissions are the same on the other browser.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=44234
Review URL: http://codereview.chromium.org/1578023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44283 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/notifications/notifications_prefs_cache.cc')
-rw-r--r-- | chrome/browser/notifications/notifications_prefs_cache.cc | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/chrome/browser/notifications/notifications_prefs_cache.cc b/chrome/browser/notifications/notifications_prefs_cache.cc index b127282..6a5172b 100644 --- a/chrome/browser/notifications/notifications_prefs_cache.cc +++ b/chrome/browser/notifications/notifications_prefs_cache.cc @@ -10,23 +10,8 @@ #include "chrome/browser/pref_service.h" #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h" -NotificationsPrefsCache::NotificationsPrefsCache( - const ListValue* allowed, const ListValue* denied) +NotificationsPrefsCache::NotificationsPrefsCache() : is_initialized_(false) { - ListValue::const_iterator i; - std::wstring origin; - if (allowed) { - for (i = allowed->begin(); i != allowed->end(); ++i) { - (*i)->GetAsString(&origin); - allowed_origins_.insert(GURL(WideToUTF8(origin))); - } - } - if (denied) { - for (i = denied->begin(); i != denied->end(); ++i) { - (*i)->GetAsString(&origin); - denied_origins_.insert(GURL(WideToUTF8(origin))); - } - } } void NotificationsPrefsCache::CacheAllowedOrigin( @@ -47,6 +32,30 @@ void NotificationsPrefsCache::CacheDeniedOrigin( allowed_origins_.erase(iter); } +void NotificationsPrefsCache::SetCacheAllowedOrigins( + const std::vector<GURL>& allowed) { + allowed_origins_.clear(); + allowed_origins_.insert(allowed.begin(), allowed.end()); +} + +void NotificationsPrefsCache::SetCacheDeniedOrigins( + const std::vector<GURL>& denied) { + denied_origins_.clear(); + denied_origins_.insert(denied.begin(), denied.end()); +} + +// static +void NotificationsPrefsCache::ListValueToGurlVector( + const ListValue& origin_list, + std::vector<GURL>* origin_vector) { + ListValue::const_iterator i; + std::wstring origin; + for (i = origin_list.begin(); i != origin_list.end(); ++i) { + (*i)->GetAsString(&origin); + origin_vector->push_back(GURL(WideToUTF8(origin))); + } +} + int NotificationsPrefsCache::HasPermission(const GURL& origin) { if (IsOriginAllowed(origin)) return WebKit::WebNotificationPresenter::PermissionAllowed; |