Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2374)

Unified Diff: chrome/browser/notifications/desktop_notification_service.cc

Issue 8550003: Defer construction of NotificationUIManager to fix notification initialization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-enable pyauto test Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.h ('k') | chrome/test/functional/PYAUTO_TESTS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/notifications/desktop_notification_service.cc
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index c9d144dcdfd7b0181d46a782ae8e963b2e3b924a..a5a51ef1cd3e2536489e65e3245ad0a980e7f4f2 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -7,6 +7,7 @@
#include "base/metrics/histogram.h"
#include "base/threading/thread.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/content_settings_details.h"
#include "chrome/browser/content_settings/content_settings_provider.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
@@ -224,12 +225,6 @@ DesktopNotificationService::~DesktopNotificationService() {
StopObserving();
}
-void DesktopNotificationService::SetUIManager(
- NotificationUIManager* ui_manager) {
- DCHECK(!ui_manager_);
- ui_manager_ = ui_manager;
-}
-
void DesktopNotificationService::StartObserving() {
if (!profile_->IsOffTheRecord()) {
notification_registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
@@ -274,8 +269,8 @@ void DesktopNotificationService::Observe(
// which was unloaded.
const Extension* extension =
content::Details<UnloadedExtensionInfo>(details)->extension;
- if (extension && ui_manager_)
- ui_manager_->CancelAllBySourceOrigin(extension->url());
+ if (extension)
+ GetUIManager()->CancelAllBySourceOrigin(extension->url());
} else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) {
StopObserving();
}
@@ -371,8 +366,7 @@ void DesktopNotificationService::RequestPermission(
void DesktopNotificationService::ShowNotification(
const Notification& notification) {
- // ui_manager_ should never be NULL here.
- ui_manager_->Add(notification, profile_);
+ GetUIManager()->Add(notification, profile_);
}
bool DesktopNotificationService::CancelDesktopNotification(
@@ -380,9 +374,7 @@ bool DesktopNotificationService::CancelDesktopNotification(
scoped_refptr<NotificationObjectProxy> proxy(
new NotificationObjectProxy(process_id, route_id, notification_id,
false));
- if (ui_manager_)
- return ui_manager_->CancelById(proxy->id());
- return false;
+ return GetUIManager()->CancelById(proxy->id());
}
bool DesktopNotificationService::ShowDesktopNotification(
@@ -431,6 +423,14 @@ void DesktopNotificationService::NotifySettingsChange() {
content::NotificationService::NoDetails());
}
+NotificationUIManager* DesktopNotificationService::GetUIManager() {
+ // We defer setting ui_manager_ to the global singleton until we need it
+ // in order to avoid UI dependent construction during startup.
+ if (!ui_manager_)
+ ui_manager_ = g_browser_process->notification_ui_manager();
+ return ui_manager_;
+}
+
WebKit::WebNotificationPresenter::Permission
DesktopNotificationService::HasPermission(const GURL& origin) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.h ('k') | chrome/test/functional/PYAUTO_TESTS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698