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

Unified Diff: chrome/browser/chromeos/notifications/system_notification.cc

Issue 10947046: Eliminate kAshNotifyDisabled and SystemNotification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit Created 8 years, 3 months 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
Index: chrome/browser/chromeos/notifications/system_notification.cc
diff --git a/chrome/browser/chromeos/notifications/system_notification.cc b/chrome/browser/chromeos/notifications/system_notification.cc
deleted file mode 100644
index 077a5ff9944e4d2ce3370b2ef4f3cda19c1554a1..0000000000000000000000000000000000000000
--- a/chrome/browser/chromeos/notifications/system_notification.cc
+++ /dev/null
@@ -1,147 +0,0 @@
-// 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.
-
-#include "chrome/browser/chromeos/notifications/system_notification.h"
-
-#include "base/callback.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chromeos/notifications/system_notification_factory.h"
-#include "chrome/browser/notifications/notification.h"
-#include "chrome/browser/notifications/notification_ui_manager.h"
-#include "chrome/browser/ui/views/ash/balloon_collection_impl_ash.h"
-#include "chrome/browser/ui/webui/web_ui_util.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-
-namespace chromeos {
-
-void SystemNotification::Init(int icon_resource_id) {
- DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
- collection_ = static_cast<BalloonCollectionImplAsh*>(
- g_browser_process->notification_ui_manager()->balloon_collection());
- std::string url = web_ui_util::GetImageDataUrlFromResource(icon_resource_id);
- DCHECK(!url.empty());
- GURL tmp_gurl(url);
- icon_.Swap(&tmp_gurl);
-}
-
-SystemNotification::SystemNotification(Profile* profile,
- NotificationDelegate* delegate,
- int icon_resource_id,
- const string16& title)
- : profile_(profile),
- collection_(NULL),
- delegate_(delegate),
- title_(title),
- visible_(false),
- sticky_(false),
- urgent_(false),
- show_on_unlock_(false) {
- Init(icon_resource_id);
-}
-
-SystemNotification::SystemNotification(Profile* profile,
- const std::string& id,
- int icon_resource_id,
- const string16& title)
- : profile_(profile),
- collection_(NULL),
- delegate_(new Delegate(id)),
- title_(title),
- visible_(false),
- sticky_(false),
- urgent_(false),
- show_on_unlock_(false) {
- Init(icon_resource_id);
-}
-
-SystemNotification::~SystemNotification() {
- DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
-}
-
-void SystemNotification::UnlockScreen() {
- if (show_on_unlock_) {
- DCHECK(!visible_);
- Notification notify = SystemNotificationFactory::Create(
- icon_, title_, message_, link_, delegate_.get());
- ShowNotification(notify);
- }
-}
-
-void SystemNotification::Show(const string16& message,
- bool urgent,
- bool sticky) {
- Show(message, string16(), BalloonViewHost::MessageCallback(), urgent, sticky);
-}
-
-void SystemNotification::Show(const string16& message,
- const string16& link,
- const BalloonViewHost::MessageCallback& callback,
- bool urgent,
- bool sticky) {
- message_ = message;
- link_ = link;
- callback_ = callback;
- sticky_ = sticky;
-
- if (DBusThreadManager::Get()->GetSessionManagerClient()->
- GetIsScreenLocked()) {
- if (visible_ && urgent && !urgent_) {
- // Hide the notification so that we show/update it on unlock.
- Hide();
- urgent_ = true;
- }
- if (!visible_)
- show_on_unlock_ = true;
- return;
- }
-
- Notification notify = SystemNotificationFactory::Create(
- icon_, title_, message_, link_, delegate_.get());
- if (visible_) {
- // Force showing a user hidden notification on an urgent transition.
- if (urgent && !urgent_) {
- if (!collection_->UpdateAndShowNotification(notify))
- visible_ = false; // re-show
- } else {
- collection_->UpdateNotification(notify);
- }
- }
- if (!visible_)
- ShowNotification(notify);
- urgent_ = urgent;
-}
-
-void SystemNotification::ShowNotification(const Notification& notify) {
- collection_->AddSystemNotification(notify, profile_, sticky_);
- collection_->AddWebUIMessageCallback(notify, "link", callback_);
- visible_ = true;
-}
-
-void SystemNotification::Hide() {
- if (visible_) {
- collection_->RemoveById(delegate_->id());
- visible_ = false;
- urgent_ = false;
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// SystemNotification::Delegate
-
-SystemNotification::Delegate::Delegate(const std::string& id)
- : id_(id) {
-}
-
-std::string SystemNotification::Delegate::id() const {
- return id_;
-}
-
-content::RenderViewHost*
-SystemNotification::Delegate::GetRenderViewHost() const {
- return NULL;
-}
-
-SystemNotification::Delegate::~Delegate() {}
-
-} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698