diff options
Diffstat (limited to 'chrome/browser/notifications')
7 files changed, 8 insertions, 99 deletions
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index bfe85ab..ef5bf76 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -9,7 +9,6 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/content_settings/content_settings_provider.h" #include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/notifications/desktop_notification_service_factory.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification_object_proxy.h" #include "chrome/browser/notifications/notification_ui_manager.h" @@ -188,16 +187,14 @@ string16 NotificationPermissionInfoBarDelegate::GetButtonLabel( bool NotificationPermissionInfoBarDelegate::Accept() { UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Allowed", 1); - DesktopNotificationServiceFactory::GetForProfile(profile_)-> - GrantPermission(origin_); + profile_->GetDesktopNotificationService()->GrantPermission(origin_); action_taken_ = true; return true; } bool NotificationPermissionInfoBarDelegate::Cancel() { UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Denied", 1); - DesktopNotificationServiceFactory::GetForProfile(profile_)-> - DenyPermission(origin_); + profile_->GetDesktopNotificationService()->DenyPermission(origin_); action_taken_ = true; return true; } diff --git a/chrome/browser/notifications/desktop_notification_service.h b/chrome/browser/notifications/desktop_notification_service.h index 50f28f5..a5c05a9 100644 --- a/chrome/browser/notifications/desktop_notification_service.h +++ b/chrome/browser/notifications/desktop_notification_service.h @@ -16,7 +16,6 @@ #include "chrome/browser/content_settings/content_settings_notification_provider.h" #include "chrome/browser/content_settings/content_settings_provider.h" #include "chrome/browser/prefs/pref_change_registrar.h" -#include "chrome/browser/profiles/profile_keyed_service.h" #include "chrome/common/content_settings.h" #include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" @@ -33,8 +32,7 @@ struct DesktopNotificationHostMsg_Show_Params; // The DesktopNotificationService is an object, owned by the Profile, // which provides the creation of desktop "toasts" to web pages and workers. -class DesktopNotificationService : public NotificationObserver, - public ProfileKeyedService { +class DesktopNotificationService : public NotificationObserver { public: enum DesktopNotificationSource { PageNotification, diff --git a/chrome/browser/notifications/desktop_notification_service_factory.cc b/chrome/browser/notifications/desktop_notification_service_factory.cc deleted file mode 100644 index 1e24345..0000000 --- a/chrome/browser/notifications/desktop_notification_service_factory.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2011 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 "chrome/browser/notifications/desktop_notification_service_factory.h" - -#include "chrome/browser/browser_process.h" -#include "chrome/browser/notifications/desktop_notification_service.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_dependency_manager.h" -#include "content/browser/browser_thread.h" - -// static -DesktopNotificationService* DesktopNotificationServiceFactory::GetForProfile( - Profile* profile) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - return static_cast<DesktopNotificationService*>( - GetInstance()->GetServiceForProfile(profile)); -} - -// static -DesktopNotificationServiceFactory* DesktopNotificationServiceFactory:: - GetInstance() { - return Singleton<DesktopNotificationServiceFactory>::get(); -} - -DesktopNotificationServiceFactory::DesktopNotificationServiceFactory() - : ProfileKeyedServiceFactory(ProfileDependencyManager::GetInstance()) { -} - -DesktopNotificationServiceFactory::~DesktopNotificationServiceFactory() { -} - -ProfileKeyedService* DesktopNotificationServiceFactory::BuildServiceInstanceFor( - Profile* profile) const { - DesktopNotificationService* service = new DesktopNotificationService(profile, - g_browser_process->notification_ui_manager()); - - return service; -} - -bool DesktopNotificationServiceFactory::ServiceHasOwnInstanceInIncognito() { - return true; -} diff --git a/chrome/browser/notifications/desktop_notification_service_factory.h b/chrome/browser/notifications/desktop_notification_service_factory.h deleted file mode 100644 index 10211b2..0000000 --- a/chrome/browser/notifications/desktop_notification_service_factory.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_FACTORY_H_ -#define CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_FACTORY_H_ - -#include "base/compiler_specific.h" -#include "base/memory/singleton.h" -#include "chrome/browser/profiles/profile_keyed_service_factory.h" - -class DesktopNotificationService; -class Profile; - -// Singleton that owns all DesktopNotificationServices and associates them with -// Profiles. Listens for the Profile's destruction notification and cleans up -// the associated DesktopNotificationService. -class DesktopNotificationServiceFactory : public ProfileKeyedServiceFactory { - public: - // Returns the DesktopNotificationService that provides desktop notifications - // for |profile|. - static DesktopNotificationService* GetForProfile(Profile* profile); - - static DesktopNotificationServiceFactory* GetInstance(); - - private: - friend struct DefaultSingletonTraits<DesktopNotificationServiceFactory>; - - DesktopNotificationServiceFactory(); - virtual ~DesktopNotificationServiceFactory(); - - // ProfileKeyedServiceFactory: - virtual ProfileKeyedService* BuildServiceInstanceFor( - Profile* profile) const OVERRIDE; - // Use a separate desktop notification service for incognito. - virtual bool ServiceHasOwnInstanceInIncognito() OVERRIDE; -}; - -#endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_FACTORY_H_ diff --git a/chrome/browser/notifications/desktop_notification_service_unittest.cc b/chrome/browser/notifications/desktop_notification_service_unittest.cc index a8fbbe3..0ad39cb 100644 --- a/chrome/browser/notifications/desktop_notification_service_unittest.cc +++ b/chrome/browser/notifications/desktop_notification_service_unittest.cc @@ -7,7 +7,6 @@ #include "base/memory/ref_counted.h" #include "base/message_loop.h" #include "base/synchronization/waitable_event.h" -#include "chrome/browser/notifications/desktop_notification_service_factory.h" #include "chrome/browser/notifications/notifications_prefs_cache.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" @@ -103,7 +102,7 @@ class DesktopNotificationServiceTest : public RenderViewHostTestHarness { // Creates the service, calls InitPrefs() on it which loads data from the // profile into the cache and then puts the cache in io thread mode. - service_ = DesktopNotificationServiceFactory::GetForProfile(profile()); + service_ = profile()->GetDesktopNotificationService(); cache_ = service_->prefs_cache(); } diff --git a/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc b/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc index 25f2680..6c6c182 100644 --- a/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc +++ b/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc @@ -1,11 +1,10 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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 "chrome/browser/notifications/notification_exceptions_table_model.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/notifications/desktop_notification_service_factory.h" #include "chrome/test/testing_profile.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/test_render_view_host.h" @@ -24,7 +23,7 @@ class NotificationExceptionsTableModelTest : public RenderViewHostTestHarness { virtual void SetUp() { RenderViewHostTestHarness::SetUp(); - service_ = DesktopNotificationServiceFactory::GetForProfile(profile()); + service_ = profile()->GetDesktopNotificationService(); ResetModel(); } diff --git a/chrome/browser/notifications/notification_options_menu_model.cc b/chrome/browser/notifications/notification_options_menu_model.cc index 7024142..0bf7533 100644 --- a/chrome/browser/notifications/notification_options_menu_model.cc +++ b/chrome/browser/notifications/notification_options_menu_model.cc @@ -12,7 +12,6 @@ #include "chrome/browser/notifications/balloon_collection.h" #include "chrome/browser/notifications/balloon_host.h" #include "chrome/browser/notifications/desktop_notification_service.h" -#include "chrome/browser/notifications/desktop_notification_service_factory.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification_ui_manager.h" #include "chrome/browser/notifications/notifications_prefs_cache.h" @@ -161,7 +160,7 @@ string16 NotificationOptionsMenuModel::GetLabelForCommandId(int command_id) const GURL& origin = notification.origin_url(); DesktopNotificationService* service = - DesktopNotificationServiceFactory::GetForProfile(balloon_->profile()); + balloon_->profile()->GetDesktopNotificationService(); if (origin.SchemeIs(chrome::kExtensionScheme)) { ExtensionService* ext_service = balloon_->profile()->GetExtensionService(); @@ -211,7 +210,7 @@ bool NotificationOptionsMenuModel::GetAcceleratorForCommandId( void NotificationOptionsMenuModel::ExecuteCommand(int command_id) { DesktopNotificationService* service = - DesktopNotificationServiceFactory::GetForProfile(balloon_->profile()); + balloon_->profile()->GetDesktopNotificationService(); ExtensionService* ext_service = balloon_->profile()->GetExtensionService(); const GURL& origin = balloon_->notification().origin_url(); |