From eeba91ac5369e2e11b5a8dece974399de09454aa Mon Sep 17 00:00:00 2001
From: "johnnyg@chromium.org"
 <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Fri, 30 Oct 2009 20:00:48 +0000
Subject: Need to load the permissions lists every time at startup for
 notifications.

BUG=26274
TEST=grant notifications permissions and restart browser

Review URL: http://codereview.chromium.org/339077

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30623 0039d316-1c4b-4281-b951-d872f2087c98
---
 .../notifications/desktop_notification_service.cc        | 16 ++++++----------
 .../browser/notifications/notifications_prefs_cache.cc   |  2 +-
 chrome/browser/notifications/notifications_prefs_cache.h |  2 +-
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index 0df73d7..76a7bd9 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -153,20 +153,16 @@ DesktopNotificationService::~DesktopNotificationService() {
 // create the preferences if they don't exist yet.
 void DesktopNotificationService::InitPrefs() {
   PrefService* prefs = profile_->GetPrefs();
-  ListValue* allowed_sites = NULL;
-  ListValue* denied_sites = NULL;
+  const ListValue* allowed_sites;
+  const ListValue* denied_sites;
 
-  if (prefs->FindPreference(prefs::kDesktopNotificationAllowedOrigins))
-    allowed_sites =
-        prefs->GetMutableList(prefs::kDesktopNotificationAllowedOrigins);
-  else
+  if (!prefs->FindPreference(prefs::kDesktopNotificationAllowedOrigins))
     prefs->RegisterListPref(prefs::kDesktopNotificationAllowedOrigins);
+  allowed_sites = prefs->GetList(prefs::kDesktopNotificationAllowedOrigins);
 
-  if (prefs->FindPreference(prefs::kDesktopNotificationDeniedOrigins))
-    denied_sites =
-        prefs->GetMutableList(prefs::kDesktopNotificationDeniedOrigins);
-  else
+  if (!prefs->FindPreference(prefs::kDesktopNotificationDeniedOrigins))
     prefs->RegisterListPref(prefs::kDesktopNotificationDeniedOrigins);
+  denied_sites = prefs->GetList(prefs::kDesktopNotificationDeniedOrigins);
 
   prefs_cache_ = new NotificationsPrefsCache(allowed_sites, denied_sites);
 }
diff --git a/chrome/browser/notifications/notifications_prefs_cache.cc b/chrome/browser/notifications/notifications_prefs_cache.cc
index c5663e4..3ff90d7 100644
--- a/chrome/browser/notifications/notifications_prefs_cache.cc
+++ b/chrome/browser/notifications/notifications_prefs_cache.cc
@@ -11,7 +11,7 @@
 #include "webkit/api/public/WebNotificationPresenter.h"
 
 NotificationsPrefsCache::NotificationsPrefsCache(
-    ListValue* allowed, ListValue* denied) {
+    const ListValue* allowed, const ListValue* denied) {
   ListValue::const_iterator i;
   std::wstring origin;
   if (allowed) {
diff --git a/chrome/browser/notifications/notifications_prefs_cache.h b/chrome/browser/notifications/notifications_prefs_cache.h
index e873da7..8edbc36 100644
--- a/chrome/browser/notifications/notifications_prefs_cache.h
+++ b/chrome/browser/notifications/notifications_prefs_cache.h
@@ -19,7 +19,7 @@ class ListValue;
 class NotificationsPrefsCache :
     public base::RefCountedThreadSafe<NotificationsPrefsCache> {
  public:
-  NotificationsPrefsCache(ListValue* allowed, ListValue* denied);
+  NotificationsPrefsCache(const ListValue* allowed, const ListValue* denied);
 
   // Checks to see if a given origin has permission to create desktop
   // notifications.  Returns a constant from WebNotificationPresenter
-- 
cgit v1.1