summaryrefslogtreecommitdiffstats
path: root/chrome/browser/notifications
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/notifications')
-rw-r--r--chrome/browser/notifications/message_center_notification_manager.cc7
-rw-r--r--chrome/browser/notifications/message_center_notification_manager.h7
-rw-r--r--chrome/browser/notifications/message_center_notifications_unittest_win.cc9
-rw-r--r--chrome/browser/notifications/message_center_settings_controller.cc169
-rw-r--r--chrome/browser/notifications/message_center_settings_controller.h42
-rw-r--r--chrome/browser/notifications/message_center_settings_controller_unittest.cc71
-rw-r--r--chrome/browser/notifications/notification_ui_manager.cc15
-rw-r--r--chrome/browser/notifications/notification_ui_manager_mac.mm12
8 files changed, 269 insertions, 63 deletions
diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc
index b249f49..5661734 100644
--- a/chrome/browser/notifications/message_center_notification_manager.cc
+++ b/chrome/browser/notifications/message_center_notification_manager.cc
@@ -36,21 +36,22 @@ const int kFirstRunIdleDelaySeconds = 1;
MessageCenterNotificationManager::MessageCenterNotificationManager(
message_center::MessageCenter* message_center,
- PrefService* local_state)
+ PrefService* local_state,
+ scoped_ptr<message_center::NotifierSettingsProvider> settings_provider)
: message_center_(message_center),
#if defined(OS_WIN)
first_run_idle_timeout_(
base::TimeDelta::FromSeconds(kFirstRunIdleDelaySeconds)),
weak_factory_(this),
#endif
- settings_controller_(new MessageCenterSettingsController) {
+ settings_provider_(settings_provider.Pass()) {
#if defined(OS_WIN)
first_run_pref_.Init(prefs::kMessageCenterShowedFirstRunBalloon, local_state);
#endif
message_center_->SetDelegate(this);
message_center_->AddObserver(this);
- message_center_->SetNotifierSettingsProvider(settings_controller_.get());
+ message_center_->SetNotifierSettingsProvider(settings_provider_.get());
#if defined(OS_WIN) || defined(OS_MACOSX) \
|| (defined(USE_AURA) && !defined(USE_ASH))
diff --git a/chrome/browser/notifications/message_center_notification_manager.h b/chrome/browser/notifications/message_center_notification_manager.h
index 91701d2..be2621e 100644
--- a/chrome/browser/notifications/message_center_notification_manager.h
+++ b/chrome/browser/notifications/message_center_notification_manager.h
@@ -34,9 +34,10 @@ class MessageCenterNotificationManager
public message_center::MessageCenter::Delegate,
public message_center::MessageCenterObserver {
public:
- explicit MessageCenterNotificationManager(
+ MessageCenterNotificationManager(
message_center::MessageCenter* message_center,
- PrefService* local_state);
+ PrefService* local_state,
+ scoped_ptr<message_center::NotifierSettingsProvider> settings_provider);
virtual ~MessageCenterNotificationManager();
// NotificationUIManager
@@ -220,7 +221,7 @@ class MessageCenterNotificationManager
base::WeakPtrFactory<MessageCenterNotificationManager> weak_factory_;
#endif
- scoped_ptr<MessageCenterSettingsController> settings_controller_;
+ scoped_ptr<message_center::NotifierSettingsProvider> settings_provider_;
// Registrar for the other kind of notifications (event signaling).
content::NotificationRegistrar registrar_;
diff --git a/chrome/browser/notifications/message_center_notifications_unittest_win.cc b/chrome/browser/notifications/message_center_notifications_unittest_win.cc
index fd674e63..01c8534 100644
--- a/chrome/browser/notifications/message_center_notifications_unittest_win.cc
+++ b/chrome/browser/notifications/message_center_notifications_unittest_win.cc
@@ -17,9 +17,11 @@
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/message_center/fake_notifier_settings_provider.h"
#include "ui/message_center/message_center_impl.h"
#include "ui/message_center/message_center_tray.h"
#include "ui/message_center/message_center_tray_delegate.h"
+#include "ui/message_center/notifier_settings.h"
namespace message_center {
class FakeMessageCenterTrayDelegate : public MessageCenterTrayDelegate {
@@ -72,8 +74,10 @@ class MessageCenterNotificationManagerTest : public testing::Test {
// Initialize message center infrastructure with mock tray delegate.
MessageCenter::Initialize();
message_center_ = MessageCenter::Get();
- notification_manager_.reset(
- new MessageCenterNotificationManager(message_center_, &local_state_));
+ scoped_ptr<NotifierSettingsProvider> settings_provider(
+ new FakeNotifierSettingsProvider(notifiers_));
+ notification_manager_.reset(new MessageCenterNotificationManager(
+ message_center_, &local_state_, settings_provider.Pass()));
delegate_ = new FakeMessageCenterTrayDelegate(message_center_,
run_loop_->QuitClosure());
notification_manager_->SetMessageCenterTrayDelegateForTest(delegate_);
@@ -111,6 +115,7 @@ class MessageCenterNotificationManagerTest : public testing::Test {
scoped_ptr<base::RunLoop> run_loop_;
TestingPrefServiceSimple local_state_;
MessageCenter* message_center_;
+ std::vector<Notifier*> notifiers_;
scoped_ptr<MessageCenterNotificationManager> notification_manager_;
FakeMessageCenterTrayDelegate* delegate_;
content::TestBrowserThreadBundle thread_bundle_;
diff --git a/chrome/browser/notifications/message_center_settings_controller.cc b/chrome/browser/notifications/message_center_settings_controller.cc
index 5e9a588..ef91c33 100644
--- a/chrome/browser/notifications/message_center_settings_controller.cc
+++ b/chrome/browser/notifications/message_center_settings_controller.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/i18n/string_compare.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/app_icon_loader_impl.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -19,6 +20,8 @@
#include "chrome/browser/notifications/desktop_notification_service_factory.h"
#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/cancelable_task_tracker.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -32,16 +35,39 @@
#include "ui/gfx/image/image.h"
#include "ui/message_center/message_center_style.h"
-#if defined(USE_ASH)
-#include "ash/shell.h"
-#include "ash/system/web_notification/web_notification_tray.h"
-#endif
-
using message_center::Notifier;
using message_center::NotifierId;
-namespace {
+namespace message_center {
+class ProfileNotifierGroup : public message_center::NotifierGroup {
+ public:
+ ProfileNotifierGroup(const gfx::Image& icon,
+ const string16& display_name,
+ const string16& login_info,
+ size_t index,
+ const base::FilePath& profile_path);
+ virtual ~ProfileNotifierGroup() {}
+
+ Profile* profile() const { return profile_; }
+
+ private:
+ Profile* profile_;
+};
+
+ProfileNotifierGroup::ProfileNotifierGroup(const gfx::Image& icon,
+ const string16& display_name,
+ const string16& login_info,
+ size_t index,
+ const base::FilePath& profile_path)
+ : message_center::NotifierGroup(icon, display_name, login_info, index),
+ profile_(NULL) {
+ // Try to get the profile
+ profile_ =
+ g_browser_process->profile_manager()->GetProfileByPath(profile_path);
+}
+} // namespace message_center
+namespace {
class NotifierComparator {
public:
explicit NotifierComparator(icu::Collator* collator) : collator_(collator) {}
@@ -61,13 +87,26 @@ bool SimpleCompareNotifiers(Notifier* n1, Notifier* n2) {
} // namespace
-MessageCenterSettingsController::MessageCenterSettingsController()
- : profile_(NULL) {
- // We set the profile associated with the settings at the beginning and fail
- // silently if this profile is destroyed later. This is a temporary fix for
- // http://crbug.com/263193
- registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
- content::NotificationService::AllSources());
+MessageCenterSettingsController::MessageCenterSettingsController(
+ ProfileInfoCache* profile_info_cache)
+ : current_notifier_group_(0), profile_info_cache_(profile_info_cache) {
+ DCHECK(profile_info_cache_);
+ // The following events all represent changes that may need to be reflected in
+ // the profile selector context menu, so listen for them all. We'll just
+ // rebuild the list when we get any of them.
+ registrar_.Add(this,
+ chrome::NOTIFICATION_PROFILE_CREATED,
+ content::NotificationService::AllBrowserContextsAndSources());
+ registrar_.Add(this,
+ chrome::NOTIFICATION_PROFILE_ADDED,
+ content::NotificationService::AllBrowserContextsAndSources());
+ registrar_.Add(this,
+ chrome::NOTIFICATION_PROFILE_DESTROYED,
+ content::NotificationService::AllBrowserContextsAndSources());
+ registrar_.Add(this,
+ chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
+ content::NotificationService::AllBrowserContextsAndSources());
+ RebuildNotifierGroups();
}
MessageCenterSettingsController::~MessageCenterSettingsController() {
@@ -83,15 +122,47 @@ void MessageCenterSettingsController::RemoveObserver(
observers_.RemoveObserver(observer);
}
+size_t MessageCenterSettingsController::GetNotifierGroupCount() const {
+ return notifier_groups_.size();
+}
+
+const message_center::NotifierGroup&
+MessageCenterSettingsController::GetNotifierGroupAt(size_t index) const {
+ DCHECK_LT(index, notifier_groups_.size());
+ return *(notifier_groups_[index]);
+}
+
+const message_center::NotifierGroup&
+MessageCenterSettingsController::GetActiveNotifierGroup() const {
+ DCHECK_LT(current_notifier_group_, notifier_groups_.size());
+ return *(notifier_groups_[current_notifier_group_]);
+}
+
+void MessageCenterSettingsController::SwitchToNotifierGroup(size_t index) {
+ DCHECK_LT(index, notifier_groups_.size());
+ if (current_notifier_group_ == index)
+ return;
+
+ current_notifier_group_ = index;
+ FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver,
+ observers_,
+ NotifierGroupChanged());
+}
+
void MessageCenterSettingsController::GetNotifierList(
std::vector<Notifier*>* notifiers) {
DCHECK(notifiers);
// TODO(mukai): Fix this for multi-profile.
// Temporarily use the last used profile to prevent chrome from crashing when
// the default profile is not loaded.
- profile_ = ProfileManager::GetLastUsedProfileAllowedByPolicy();
+ message_center::ProfileNotifierGroup* group =
+ notifier_groups_[current_notifier_group_];
+ Profile* profile = group->profile();
+ if (!profile)
+ return;
+
DesktopNotificationService* notification_service =
- DesktopNotificationServiceFactory::GetForProfile(profile_);
+ DesktopNotificationServiceFactory::GetForProfile(profile);
UErrorCode error;
scoped_ptr<icu::Collator> collator(icu::Collator::createInstance(error));
@@ -99,7 +170,7 @@ void MessageCenterSettingsController::GetNotifierList(
if (!U_FAILURE(error))
comparator.reset(new NotifierComparator(collator.get()));
- ExtensionService* extension_service = profile_->GetExtensionService();
+ ExtensionService* extension_service = profile->GetExtensionService();
const ExtensionSet* extension_set = extension_service->extensions();
// The extension icon size has to be 32x32 at least to load bigger icons if
// the icon doesn't exist for the specified size, and in that case it falls
@@ -107,9 +178,10 @@ void MessageCenterSettingsController::GetNotifierList(
// dialog. See chrome/browser/extensions/extension_icon_image.cc and
// crbug.com/222931
app_icon_loader_.reset(new extensions::AppIconLoaderImpl(
- profile_, extension_misc::EXTENSION_ICON_SMALL, this));
+ profile, extension_misc::EXTENSION_ICON_SMALL, this));
for (ExtensionSet::const_iterator iter = extension_set->begin();
- iter != extension_set->end(); ++iter) {
+ iter != extension_set->end();
+ ++iter) {
const extensions::Extension* extension = iter->get();
if (!extension->HasAPIPermission(
extensions::APIPermission::kNotification)) {
@@ -128,7 +200,7 @@ void MessageCenterSettingsController::GetNotifierList(
CommandLine::ForCurrentProcess())) {
notifier::ChromeNotifierService* sync_notifier_service =
notifier::ChromeNotifierServiceFactory::GetInstance()->GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
+ profile, Profile::EXPLICIT_ACCESS);
sync_notifier_service->GetSyncedNotificationServices(notifiers);
if (comparator)
@@ -141,8 +213,8 @@ void MessageCenterSettingsController::GetNotifierList(
ContentSettingsForOneType settings;
notification_service->GetNotificationsSettings(&settings);
- FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
+ FaviconService* favicon_service =
+ FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
favicon_tracker_.reset(new CancelableTaskTracker());
patterns_.clear();
for (ContentSettingsForOneType::const_iterator iter = settings.begin();
@@ -163,7 +235,9 @@ void MessageCenterSettingsController::GetNotifierList(
notification_service->IsNotifierEnabled(notifier_id)));
patterns_[name] = iter->primary_pattern;
FaviconService::FaviconForURLParams favicon_params(
- profile_, url, chrome::FAVICON | chrome::TOUCH_ICON,
+ profile,
+ url,
+ chrome::FAVICON | chrome::TOUCH_ICON,
message_center::kSettingsIconSize);
// Note that favicon service obtains the favicon from history. This means
// that it will fail to obtain the image if there are no history data for
@@ -201,12 +275,11 @@ void MessageCenterSettingsController::GetNotifierList(
void MessageCenterSettingsController::SetNotifierEnabled(
const Notifier& notifier,
bool enabled) {
- // TODO(mukai): Fix this for multi-profile.
- // If the profile has been destroyed, fail silently.
- if (!profile_)
- return;
+ Profile* profile = notifier_groups_[current_notifier_group_]->profile();
+ DCHECK(profile);
+
DesktopNotificationService* notification_service =
- DesktopNotificationServiceFactory::GetForProfile(profile_);
+ DesktopNotificationServiceFactory::GetForProfile(profile);
if (notifier.notifier_id.type == NotifierId::WEB_PAGE) {
// WEB_PAGE notifier cannot handle in DesktopNotificationService
@@ -243,7 +316,7 @@ void MessageCenterSettingsController::SetNotifierEnabled(
if (notifier.notifier_id.type == NotifierId::SYNCED_NOTIFICATION_SERVICE) {
notifier::ChromeNotifierService* notifier_service =
notifier::ChromeNotifierServiceFactory::GetInstance()->GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
+ profile, Profile::EXPLICIT_ACCESS);
notifier_service->OnSyncedNotificationServiceEnabled(
notifier.notifier_id.id, enabled);
}
@@ -256,17 +329,6 @@ void MessageCenterSettingsController::OnNotifierSettingsClosing() {
patterns_.clear();
}
-void MessageCenterSettingsController::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- if (type == chrome::NOTIFICATION_PROFILE_DESTROYED &&
- content::Source<Profile>(source).ptr() == profile_) {
- // Our profile just got destroyed, so we delete our pointer to it.
- profile_ = NULL;
- }
-}
-
void MessageCenterSettingsController::OnFaviconLoaded(
const GURL& url,
const chrome::FaviconImageResult& favicon_result) {
@@ -283,3 +345,32 @@ void MessageCenterSettingsController::SetAppImage(const std::string& id,
UpdateIconImage(NotifierId(NotifierId::APPLICATION, id),
gfx::Image(image)));
}
+
+void MessageCenterSettingsController::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ RebuildNotifierGroups();
+ FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver,
+ observers_,
+ NotifierGroupChanged());
+}
+
+void MessageCenterSettingsController::RebuildNotifierGroups() {
+ notifier_groups_.clear();
+ current_notifier_group_ = 0;
+
+ const size_t count = profile_info_cache_->GetNumberOfProfiles();
+ for (size_t i = 0; i < count; ++i) {
+ message_center::ProfileNotifierGroup* group =
+ new message_center::ProfileNotifierGroup(
+ profile_info_cache_->GetAvatarIconOfProfileAtIndex(i),
+ profile_info_cache_->GetNameOfProfileAtIndex(i),
+ profile_info_cache_->GetUserNameOfProfileAtIndex(i),
+ i,
+ profile_info_cache_->GetPathOfProfileAtIndex(i));
+ if (group->profile() != NULL) {
+ notifier_groups_.push_back(group);
+ }
+ }
+}
diff --git a/chrome/browser/notifications/message_center_settings_controller.h b/chrome/browser/notifications/message_center_settings_controller.h
index 1a66099..4adc136 100644
--- a/chrome/browser/notifications/message_center_settings_controller.h
+++ b/chrome/browser/notifications/message_center_settings_controller.h
@@ -10,28 +10,36 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "base/observer_list.h"
#include "chrome/browser/extensions/app_icon_loader.h"
-#include "chrome/browser/profiles/profile.h"
#include "chrome/common/content_settings.h"
+#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/notification_source.h"
#include "ui/message_center/notifier_settings.h"
class CancelableTaskTracker;
+class ProfileInfoCache;
namespace chrome {
struct FaviconImageResult;
}
+namespace message_center {
+class ProfileNotifierGroup;
+}
+
// The class to bridge between the settings UI of notifiers and the preference
// storage.
class MessageCenterSettingsController
: public message_center::NotifierSettingsProvider,
- public extensions::AppIconLoader::Delegate,
- public content::NotificationObserver {
+ public content::NotificationObserver,
+ public extensions::AppIconLoader::Delegate {
public:
- MessageCenterSettingsController();
+ explicit MessageCenterSettingsController(
+ ProfileInfoCache* profile_info_cache);
virtual ~MessageCenterSettingsController();
// Overridden from message_center::NotifierSettingsProvider.
@@ -39,12 +47,16 @@ class MessageCenterSettingsController
message_center::NotifierSettingsObserver* observer) OVERRIDE;
virtual void RemoveObserver(
message_center::NotifierSettingsObserver* observer) OVERRIDE;
- virtual void GetNotifierList(
- std::vector<message_center::Notifier*>* notifiers)
+ virtual size_t GetNotifierGroupCount() const OVERRIDE;
+ virtual const message_center::NotifierGroup& GetNotifierGroupAt(
+ size_t index) const OVERRIDE;
+ virtual void SwitchToNotifierGroup(size_t index) OVERRIDE;
+ virtual const message_center::NotifierGroup& GetActiveNotifierGroup() const
OVERRIDE;
- virtual void SetNotifierEnabled(
- const message_center::Notifier& notifier,
- bool enabled) OVERRIDE;
+ virtual void GetNotifierList(
+ std::vector<message_center::Notifier*>* notifiers) OVERRIDE;
+ virtual void SetNotifierEnabled(const message_center::Notifier& notifier,
+ bool enabled) OVERRIDE;
virtual void OnNotifierSettingsClosing() OVERRIDE;
// Overridden from extensions::AppIconLoader::Delegate.
@@ -60,6 +72,8 @@ class MessageCenterSettingsController
void OnFaviconLoaded(const GURL& url,
const chrome::FaviconImageResult& favicon_result);
+ void RebuildNotifierGroups();
+
// The views displaying notifier settings.
ObserverList<message_center::NotifierSettingsObserver> observers_;
@@ -70,12 +84,14 @@ class MessageCenterSettingsController
std::map<string16, ContentSettingsPattern> patterns_;
- // The Registrar used to register for notifications.
+ // The list of all configurable notifier groups. This is each profile that is
+ // loaded (and in the ProfileInfoCache - so no incognito profiles go here).
+ ScopedVector<message_center::ProfileNotifierGroup> notifier_groups_;
+ size_t current_notifier_group_;
+
content::NotificationRegistrar registrar_;
- // TODO(sidharthms): Fix this for multi-profile.
- // The profile associated with message center settings.
- Profile* profile_;
+ ProfileInfoCache* profile_info_cache_;
DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsController);
};
diff --git a/chrome/browser/notifications/message_center_settings_controller_unittest.cc b/chrome/browser/notifications/message_center_settings_controller_unittest.cc
new file mode 100644
index 0000000..e46505c
--- /dev/null
+++ b/chrome/browser/notifications/message_center_settings_controller_unittest.cc
@@ -0,0 +1,71 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/notifications/message_center_settings_controller.h"
+#include "chrome/browser/prefs/pref_service_syncable.h"
+#include "chrome/browser/profiles/profile_info_cache.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/test/base/testing_browser_process.h"
+#include "chrome/test/base/testing_profile_manager.h"
+#include "content/public/test/test_browser_thread_bundle.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/message_center/notifier_settings.h"
+
+class MessageCenterSettingsControllerTest : public testing::Test {
+ protected:
+ MessageCenterSettingsControllerTest()
+ : testing_profile_manager_(TestingBrowserProcess::GetGlobal()) {};
+ virtual ~MessageCenterSettingsControllerTest() {};
+
+ base::FilePath GetProfilePath(const std::string& base_name) {
+ return testing_profile_manager_.profile_manager()->user_data_dir()
+ .AppendASCII(base_name);
+ }
+
+ virtual void SetUp() OVERRIDE {
+ ASSERT_TRUE(testing_profile_manager_.SetUp());
+ }
+
+ ProfileInfoCache* GetCache() {
+ return testing_profile_manager_.profile_info_cache();
+ }
+
+ void CreateProfile(const std::string& name) {
+ testing_profile_manager_.CreateTestingProfile(name);
+ }
+
+ TestingProfileManager testing_profile_manager_;
+};
+
+TEST_F(MessageCenterSettingsControllerTest, NotifierGroups) {
+ CreateProfile("Profile-1");
+ CreateProfile("Profile-2");
+
+ scoped_ptr<MessageCenterSettingsController> controller(
+ new MessageCenterSettingsController(GetCache()));
+
+ EXPECT_EQ(controller->GetNotifierGroupCount(), 2u);
+
+ EXPECT_EQ(controller->GetNotifierGroupAt(0).name, UTF8ToUTF16("Profile-1"));
+ EXPECT_EQ(controller->GetNotifierGroupAt(0).index, 0u);
+
+ EXPECT_EQ(controller->GetNotifierGroupAt(1).name, UTF8ToUTF16("Profile-2"));
+ EXPECT_EQ(controller->GetNotifierGroupAt(1).index, 1u);
+
+ EXPECT_EQ(controller->GetActiveNotifierGroup().name,
+ UTF8ToUTF16("Profile-1"));
+ EXPECT_EQ(controller->GetActiveNotifierGroup().index, 0u);
+
+ controller->SwitchToNotifierGroup(1);
+ EXPECT_EQ(controller->GetActiveNotifierGroup().name,
+ UTF8ToUTF16("Profile-2"));
+ EXPECT_EQ(controller->GetActiveNotifierGroup().index, 1u);
+
+ controller->SwitchToNotifierGroup(0);
+ EXPECT_EQ(controller->GetActiveNotifierGroup().name,
+ UTF8ToUTF16("Profile-1"));
+}
diff --git a/chrome/browser/notifications/notification_ui_manager.cc b/chrome/browser/notifications/notification_ui_manager.cc
index 8bbafe7..19e6c24 100644
--- a/chrome/browser/notifications/notification_ui_manager.cc
+++ b/chrome/browser/notifications/notification_ui_manager.cc
@@ -4,10 +4,14 @@
#include "chrome/browser/notifications/notification_ui_manager.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/notifications/balloon_notification_ui_manager.h"
#include "chrome/browser/notifications/message_center_notification_manager.h"
+#include "chrome/browser/notifications/message_center_settings_controller.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_info_cache.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "ui/message_center/message_center_util.h"
// static
@@ -24,9 +28,16 @@ bool NotificationUIManager::DelegatesToMessageCenter() {
#if !defined(OS_MACOSX)
// static
NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) {
- if (DelegatesToMessageCenter())
+ if (DelegatesToMessageCenter()) {
+ ProfileInfoCache* profile_info_cache =
+ &g_browser_process->profile_manager()->GetProfileInfoCache();
+ scoped_ptr<message_center::NotifierSettingsProvider> settings_provider(
+ new MessageCenterSettingsController(profile_info_cache));
return new MessageCenterNotificationManager(
- g_browser_process->message_center(), local_state);
+ g_browser_process->message_center(),
+ local_state,
+ settings_provider.Pass());
+ }
BalloonNotificationUIManager* balloon_manager =
new BalloonNotificationUIManager(local_state);
diff --git a/chrome/browser/notifications/notification_ui_manager_mac.mm b/chrome/browser/notifications/notification_ui_manager_mac.mm
index 5222aa1..d0b783c 100644
--- a/chrome/browser/notifications/notification_ui_manager_mac.mm
+++ b/chrome/browser/notifications/notification_ui_manager_mac.mm
@@ -6,12 +6,16 @@
#include "base/mac/cocoa_protocols.h"
#include "base/mac/mac_util.h"
+#include "base/memory/scoped_ptr.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/balloon_notification_ui_manager.h"
#include "chrome/browser/notifications/message_center_notification_manager.h"
+#include "chrome/browser/notifications/message_center_settings_controller.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_info_cache.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "ui/message_center/message_center_util.h"
@class NSUserNotificationCenter;
@@ -101,8 +105,14 @@ NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) {
// TODO(rsesek): Remove this function and merge it with the one in
// notification_ui_manager.cc.
if (DelegatesToMessageCenter()) {
+ ProfileInfoCache* profile_info_cache =
+ &g_browser_process->profile_manager()->GetProfileInfoCache();
+ scoped_ptr<message_center::NotifierSettingsProvider> settings_provider(
+ new MessageCenterSettingsController(profile_info_cache));
return new MessageCenterNotificationManager(
- g_browser_process->message_center(), local_state);
+ g_browser_process->message_center(),
+ local_state,
+ settings_provider.Pass());
}
BalloonNotificationUIManager* balloon_manager = NULL;