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

Unified Diff: chrome/browser/status_icons/desktop_notification_balloon.cc

Issue 8417027: Revert 107722 - Implement notifications for the DisplayBalloon method on Linux and Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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/status_icons/desktop_notification_balloon.cc
===================================================================
--- chrome/browser/status_icons/desktop_notification_balloon.cc (revision 107726)
+++ chrome/browser/status_icons/desktop_notification_balloon.cc (working copy)
@@ -1,82 +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/status_icons/desktop_notification_balloon.h"
-
-#include "base/bind.h"
-#include "base/string_number_conversions.h"
-#include "base/threading/thread_restrictions.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/notifications/desktop_notification_service.h"
-#include "chrome/browser/notifications/notification.h"
-#include "chrome/browser/notifications/notification_delegate.h"
-#include "chrome/browser/notifications/notification_ui_manager.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/webui/web_ui_util.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-namespace {
-
-void CloseBalloon(const std::string& id) {
- g_browser_process->notification_ui_manager()->CancelById(id);
-}
-
-// Prefix added to the notification ids.
-const char kNotificationPrefix[] = "desktop_notification_balloon.";
-
-// Timeout for automatically dismissing the notification balloon.
-const size_t kTimeoutMilliseconds = 6000;
-
-class DummyNotificationDelegate : public NotificationDelegate {
- public:
- explicit DummyNotificationDelegate(const std::string& id)
- : id_(kNotificationPrefix + id) {}
- virtual ~DummyNotificationDelegate() {}
-
- virtual void Display() OVERRIDE {
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- base::Bind(&CloseBalloon, id()), kTimeoutMilliseconds);
- }
- virtual void Error() OVERRIDE {}
- virtual void Close(bool by_user) OVERRIDE {}
- virtual void Click() OVERRIDE {}
- virtual std::string id() const OVERRIDE { return id_; }
-
- private:
- std::string id_;
-};
-
-} // anonymous namespace
-
-int DesktopNotificationBalloon::id_count_ = 1;
-
-DesktopNotificationBalloon::DesktopNotificationBalloon() {
-}
-
-DesktopNotificationBalloon::~DesktopNotificationBalloon() {
- if (notification_.get())
- CloseBalloon(notification_->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(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());
-}
« no previous file with comments | « chrome/browser/status_icons/desktop_notification_balloon.h ('k') | chrome/browser/ui/cocoa/status_icons/status_icon_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698