diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 23:14:37 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 23:14:37 +0000 |
commit | e9abea4d758cc579079d7763b430d09b987a4f64 (patch) | |
tree | d0c2fa833c974d34d7916c704d816185dfb12393 /chrome/browser/status_icons | |
parent | 4e76528d453e7aae31bc646a93448ca44c7cb19a (diff) | |
download | chromium_src-e9abea4d758cc579079d7763b430d09b987a4f64.zip chromium_src-e9abea4d758cc579079d7763b430d09b987a4f64.tar.gz chromium_src-e9abea4d758cc579079d7763b430d09b987a4f64.tar.bz2 |
Add DesktopNotificationService::AddNotification
Convert BackgroundContentsService, FileBrowserNotifications, CloudPrintProxyService, and DesktopNotificationBalloon to use DesktopNotificationService::AdddNotification.
Includes some significant re-factoring of FileBrowserNotifications to support Ash notifications (apologies).
BUG=124914
TEST=Notification tests pass. Desktop notifications (e.g. cloud print, file browser) work with --ash-notify
For CloudPrintProxyService:
TBR=scottbyer@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10548052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142259 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/status_icons')
-rw-r--r-- | chrome/browser/status_icons/desktop_notification_balloon.cc | 26 | ||||
-rw-r--r-- | chrome/browser/status_icons/desktop_notification_balloon.h | 5 |
2 files changed, 12 insertions, 19 deletions
diff --git a/chrome/browser/status_icons/desktop_notification_balloon.cc b/chrome/browser/status_icons/desktop_notification_balloon.cc index d49a8bb..fb22c91 100644 --- a/chrome/browser/status_icons/desktop_notification_balloon.cc +++ b/chrome/browser/status_icons/desktop_notification_balloon.cc @@ -67,28 +67,22 @@ DesktopNotificationBalloon::DesktopNotificationBalloon() { } DesktopNotificationBalloon::~DesktopNotificationBalloon() { - if (notification_.get()) - CloseBalloon(notification_->notification_id()); + if (!notification_id_.empty()) + CloseBalloon(notification_id_); } void DesktopNotificationBalloon::DisplayBalloon(const SkBitmap& icon, const string16& title, const string16& contents) { - GURL icon_url; - if (!icon.empty()) - icon_url = GURL(web_ui_util::GetImageDataUrl(gfx::ImageSkia(icon))); - - GURL content_url(DesktopNotificationService::CreateDataUrl( - icon_url, title, contents, WebKit::WebTextDirectionDefault)); - - notification_.reset(new Notification( - GURL(), content_url, string16(), string16(), - new DummyNotificationDelegate(base::IntToString(id_count_++)))); - // Allowing IO access is required here to cover the corner case where // there is no last used profile and the default one is loaded. // IO access won't be required for normal uses. - base::ThreadRestrictions::ScopedAllowIO allow_io; - g_browser_process->notification_ui_manager()->Add( - *notification_.get(), ProfileManager::GetLastUsedProfile()); + Profile* profile; + { + base::ThreadRestrictions::ScopedAllowIO allow_io; + profile = ProfileManager::GetLastUsedProfile(); + } + notification_id_ = DesktopNotificationService::AddIconNotification( + GURL(), title, contents, gfx::ImageSkia(icon), + new DummyNotificationDelegate(base::IntToString(id_count_++)), profile); } diff --git a/chrome/browser/status_icons/desktop_notification_balloon.h b/chrome/browser/status_icons/desktop_notification_balloon.h index 2a44f2b..f3b9195 100644 --- a/chrome/browser/status_icons/desktop_notification_balloon.h +++ b/chrome/browser/status_icons/desktop_notification_balloon.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -25,8 +25,7 @@ class DesktopNotificationBalloon { const string16& contents); private: - // Notification balloon. - scoped_ptr<Notification> notification_; + std::string notification_id_; // Counter to provide unique ids to notifications. static int id_count_; |