diff options
author | dimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-25 21:50:49 +0000 |
---|---|---|
committer | dimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-25 21:50:49 +0000 |
commit | cdf594b2db94ff9c66d3f552a063706c16015c2b (patch) | |
tree | f8d385a5b143b24031267be45f0db4ad6e6d4165 /chrome/browser/notifications | |
parent | 4053a48edfd0dccb03cc2792d363b29ab87d1992 (diff) | |
download | chromium_src-cdf594b2db94ff9c66d3f552a063706c16015c2b.zip chromium_src-cdf594b2db94ff9c66d3f552a063706c16015c2b.tar.gz chromium_src-cdf594b2db94ff9c66d3f552a063706c16015c2b.tar.bz2 |
Revert 178898
> Adding implementation for MessageCenter::Delegate on MessageCeneterNotificationManager.
> Also adding a simple browsertest.
>
> BUG=168605
>
>
> Review URL: https://chromiumcodereview.appspot.com/11896085
TBR=dimich@chromium.org
Review URL: https://codereview.chromium.org/12051097
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178900 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/notifications')
3 files changed, 6 insertions, 163 deletions
diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc index b6a876d..030b5fa 100644 --- a/chrome/browser/notifications/message_center_notification_manager.cc +++ b/chrome/browser/notifications/message_center_notification_manager.cc @@ -7,14 +7,9 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/extensions/extension_service.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/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/browser_finder.h" -#include "chrome/browser/ui/chrome_pages.h" -#include "chrome/browser/ui/host_desktop.h" #include "chrome/common/extensions/extension_set.h" #include "chrome/common/pref_names.h" @@ -140,42 +135,22 @@ bool MessageCenterNotificationManager::UpdateNotification( void MessageCenterNotificationManager::DisableExtension( const std::string& notification_id) { - ProfileNotification* profile_notification = - FindProfileNotification(notification_id); - std::string extension_id = profile_notification->GetExtensionId(); - DCHECK(!extension_id.empty()); // or UI should not have enabled the command. - profile_notification->profile()->GetExtensionService()->DisableExtension( - extension_id, extensions::Extension::DISABLE_USER_ACTION); + NOTIMPLEMENTED(); } void MessageCenterNotificationManager::DisableNotificationsFromSource( const std::string& notification_id) { - ProfileNotification* profile_notification = - FindProfileNotification(notification_id); - // UI should not have enabled the command if there is no valid source. - DCHECK(profile_notification->notification().origin_url().is_valid()); - DesktopNotificationService* service = - DesktopNotificationServiceFactory::GetForProfile( - profile_notification->profile()); - service->DenyPermission(profile_notification->notification().origin_url()); + NOTIMPLEMENTED(); } void MessageCenterNotificationManager::NotificationRemoved( const std::string& notification_id) { - RemoveProfileNotification(FindProfileNotification(notification_id)); + NOTIMPLEMENTED(); } void MessageCenterNotificationManager::ShowSettings( const std::string& notification_id) { - ProfileNotification* profile_notification = - FindProfileNotification(notification_id); - Browser* browser = - chrome::FindOrCreateTabbedBrowser(profile_notification->profile(), - chrome::HOST_DESKTOP_TYPE_NATIVE); - if (profile_notification->GetExtensionId().empty()) - chrome::ShowContentSettings(browser, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); - else - chrome::ShowExtensions(browser); + NOTIMPLEMENTED(); } void MessageCenterNotificationManager::ShowSettingsDialog( @@ -185,13 +160,12 @@ void MessageCenterNotificationManager::ShowSettingsDialog( void MessageCenterNotificationManager::OnClicked( const std::string& notification_id) { - FindProfileNotification(notification_id)->notification().Click(); + NOTIMPLEMENTED(); } void MessageCenterNotificationManager::OnButtonClicked( const std::string& notification_id, int button_index) { - FindProfileNotification(notification_id)->notification().ButtonClick( - button_index); + NOTIMPLEMENTED(); } //////////////////////////////////////////////////////////////////////////////// @@ -242,13 +216,3 @@ void MessageCenterNotificationManager::RemoveProfileNotification( profile_notifications_.erase(id); delete profile_notification; } - -MessageCenterNotificationManager::ProfileNotification* - MessageCenterNotificationManager::FindProfileNotification( - const std::string& id) const { - NotificationMap::const_iterator iter = profile_notifications_.find(id); - // If the notification is shown in UI, it must be in the map. - DCHECK(iter != profile_notifications_.end()); - DCHECK((*iter).second); - return (*iter).second; -} diff --git a/chrome/browser/notifications/message_center_notification_manager.h b/chrome/browser/notifications/message_center_notification_manager.h index 397cc22..8fd4e62 100644 --- a/chrome/browser/notifications/message_center_notification_manager.h +++ b/chrome/browser/notifications/message_center_notification_manager.h @@ -90,8 +90,6 @@ class MessageCenterNotificationManager void AddProfileNotification(ProfileNotification* profile_notification); void RemoveProfileNotification(ProfileNotification* profile_notification); - ProfileNotification* FindProfileNotification(const std::string& id) const; - DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager); }; diff --git a/chrome/browser/notifications/message_center_notifications_browsertest.cc b/chrome/browser/notifications/message_center_notifications_browsertest.cc deleted file mode 100644 index 9cd1255..0000000 --- a/chrome/browser/notifications/message_center_notifications_browsertest.cc +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) 2013 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 <string> - -#include "base/command_line.h" -#include "base/string_number_conversions.h" -#include "base/string_util.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/notifications/message_center_notification_manager.h" -#include "chrome/browser/notifications/notification.h" -#include "chrome/browser/notifications/notification_ui_manager.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "ui/message_center/message_center.h" - -class MessageCenterNotificationsTest : public InProcessBrowserTest { - public: - MessageCenterNotificationsTest() {} - - virtual void SetUpCommandLine(CommandLine* command_line) { - // This switch enables the new piping of Notifications through Message - // Center. - command_line->AppendSwitch(switches::kEnableRichNotifications); - } - - MessageCenterNotificationManager* manager() { - return static_cast<MessageCenterNotificationManager*>( - g_browser_process->notification_ui_manager()); - } - - message_center::MessageCenter* message_center() { - return g_browser_process->message_center(); - } - - Profile* profile() { return browser()->profile(); } - - class TestDelegate : public NotificationDelegate { - public: - explicit TestDelegate(const std::string& id) : id_(id) {} - - void Display() OVERRIDE { log_ += "Display_"; } - void Error() OVERRIDE { log_ += "Error_"; } - void Close(bool by_user) OVERRIDE { - log_ += "Close_"; - log_ += ( by_user ? "by_user_" : "programmatically_"); - } - void Click() OVERRIDE { log_ += "Click_"; } - void ButtonClick(int button_index) OVERRIDE { - log_ += "ButtonClick_"; - log_ += base::IntToString(button_index) + "_"; - } - std::string id() const OVERRIDE { return id_; } - content::RenderViewHost* GetRenderViewHost() const OVERRIDE { return NULL; } - - const std::string& log() { return log_; } - - private: - std::string id_; - std::string log_; - }; - - Notification CreateTestNotification(const std::string& id, - TestDelegate** delegate = NULL) { - TestDelegate* new_delegate = new TestDelegate(id); - if (delegate) { - *delegate = new_delegate; - new_delegate->AddRef(); - } - - return Notification(GURL(), - GURL(), - ASCIIToUTF16("title"), - ASCIIToUTF16("message"), - WebKit::WebTextDirectionDefault, - EmptyString16(), - EmptyString16(), - new_delegate); - } -}; - -IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, RetrieveBaseParts) { - // Make sure comamnd-line switch has an effect. - EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); - EXPECT_TRUE(manager()); - EXPECT_TRUE(message_center()); -} - -IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicAddCancel) { - manager()->Add(CreateTestNotification("hey"), profile()); - EXPECT_EQ(1u, message_center()->NotificationCount()); - manager()->CancelById("hey"); - EXPECT_EQ(0u, message_center()->NotificationCount()); -} - -IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicDelegate) { - TestDelegate* delegate; - manager()->Add(CreateTestNotification("hey", &delegate), profile()); - // Verify that delegate accumulated correct log of events. - EXPECT_EQ("Display_", delegate->log()); - manager()->CancelById("hey"); - // Verify that delegate accumulated correct log of events. - EXPECT_EQ("Display_Close_programmatically_", delegate->log()); - delegate->Release(); -} - -IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, ButtonClickedDelegate) { - TestDelegate* delegate; - manager()->Add(CreateTestNotification("n", &delegate), profile()); - message_center()->OnButtonClicked("n", 1); - // Verify that delegate accumulated correct log of events. - EXPECT_EQ("Display_ButtonClick_1_", delegate->log()); - delegate->Release(); -} - |