summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-24 14:38:33 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-24 14:38:33 +0000
commita69b6f874fe568cdeb4810034b15d58d5bac1e08 (patch)
tree7b8e1713cd99988d005d032f392d0237b3dc14d1
parent28fb77a6148d028bce84e9c8a62ba98c02e5484d (diff)
downloadchromium_src-a69b6f874fe568cdeb4810034b15d58d5bac1e08.zip
chromium_src-a69b6f874fe568cdeb4810034b15d58d5bac1e08.tar.gz
chromium_src-a69b6f874fe568cdeb4810034b15d58d5bac1e08.tar.bz2
Cleanup: do not use extension_id, use notifier's id.
It will remove unnecessary methods. Also, each ash notifications has its own notifier id as SYSTEM_COMPONENT. Then we can distinguish those notification types, which means this will enable to allow some urgent system notifications (like power) in the lock screen. BUG=250937 R=dewittj@chromium.org, stevenjb@chromium.org TEST=no breaks on existing tests Review URL: https://chromiumcodereview.appspot.com/23340002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219437 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/display/display_error_observer_chromeos.cc3
-rw-r--r--ash/display/resolution_notification_controller.cc3
-rw-r--r--ash/shell/window_type_launcher.cc2
-rw-r--r--ash/system/chromeos/managed/tray_locally_managed_user.cc3
-rw-r--r--ash/system/chromeos/network/network_connect.cc2
-rw-r--r--ash/system/chromeos/network/network_state_notifier.cc9
-rw-r--r--ash/system/chromeos/power/tray_power.cc3
-rw-r--r--ash/system/chromeos/screen_security/screen_capture_tray_item.cc3
-rw-r--r--ash/system/chromeos/screen_security/screen_share_tray_item.cc3
-rw-r--r--ash/system/chromeos/tray_display.cc3
-rw-r--r--ash/system/ime/tray_ime.cc3
-rw-r--r--ash/system/locale/locale_notification_controller.cc3
-rw-r--r--ash/system/system_notifier.cc20
-rw-r--r--ash/system/system_notifier.h37
-rw-r--r--ash/system/web_notification/web_notification_tray_unittest.cc4
-rw-r--r--chrome/browser/chromeos/status/data_promo_notification.cc2
-rw-r--r--chrome/browser/extensions/api/notifications/notifications_api.cc3
-rw-r--r--chrome/browser/notifications/desktop_notification_service.cc23
-rw-r--r--chrome/browser/notifications/message_center_notification_manager.cc45
-rw-r--r--chrome/browser/notifications/message_center_notification_manager.h3
-rw-r--r--chrome/browser/notifications/message_center_notifications_browsertest.cc3
-rw-r--r--chrome/browser/notifications/message_center_settings_controller.cc6
-rw-r--r--chrome/browser/notifications/notification.cc9
-rw-r--r--chrome/browser/notifications/notification.h1
-rw-r--r--chrome/browser/notifications/sync_notifier/synced_notification.cc1
-rw-r--r--chrome/browser/ui/ash/screenshot_taker.cc10
-rw-r--r--chrome/browser/ui/cocoa/notifications/message_center_tray_bridge_unittest.mm2
-rw-r--r--ui/base/strings/ui_strings.grd7
-rw-r--r--ui/message_center/cocoa/notification_controller_unittest.mm14
-rw-r--r--ui/message_center/cocoa/popup_collection_unittest.mm20
-rw-r--r--ui/message_center/cocoa/popup_controller_unittest.mm2
-rw-r--r--ui/message_center/cocoa/tray_view_controller_unittest.mm12
-rw-r--r--ui/message_center/fake_message_center.cc6
-rw-r--r--ui/message_center/fake_message_center.h4
-rw-r--r--ui/message_center/message_center.h15
-rw-r--r--ui/message_center/message_center_impl.cc25
-rw-r--r--ui/message_center/message_center_impl.h4
-rw-r--r--ui/message_center/message_center_tray_unittest.cc4
-rw-r--r--ui/message_center/notification.cc11
-rw-r--r--ui/message_center/notification.h12
-rw-r--r--ui/message_center/notification_list.cc27
-rw-r--r--ui/message_center/notification_list.h3
-rw-r--r--ui/message_center/notification_list_unittest.cc103
-rw-r--r--ui/message_center/notifier_settings.cc38
-rw-r--r--ui/message_center/notifier_settings.h22
-rw-r--r--ui/message_center/views/message_center_view_unittest.cc2
-rw-r--r--ui/message_center/views/message_popup_collection_unittest.cc2
-rw-r--r--ui/message_center/views/message_view.cc30
49 files changed, 308 insertions, 266 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index a91b268..8070974 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -286,6 +286,8 @@
'system/status_area_widget.h',
'system/status_area_widget_delegate.cc',
'system/status_area_widget_delegate.h',
+ 'system/system_notifier.cc',
+ 'system/system_notifier.h',
'system/tray/actionable_view.cc',
'system/tray/actionable_view.h',
'system/tray/fixed_sized_image_view.cc',
diff --git a/ash/display/display_error_observer_chromeos.cc b/ash/display/display_error_observer_chromeos.cc
index f12b61e..f098f25 100644
--- a/ash/display/display_error_observer_chromeos.cc
+++ b/ash/display/display_error_observer_chromeos.cc
@@ -4,6 +4,7 @@
#include "ash/display/display_error_observer_chromeos.h"
+#include "ash/system/system_notifier.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
@@ -67,7 +68,7 @@ void DisplayErrorObserver::OnDisplayModeChangeFailed(
base::string16(), // message
bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY),
base::string16(), // display_source
- std::string(), // extension_id
+ message_center::NotifierId(NOTIFIER_DISPLAY_ERROR),
message_center::RichNotificationData(),
new DisplayErrorNotificationDelegate()));
message_center::MessageCenter::Get()->AddNotification(notification.Pass());
diff --git a/ash/display/resolution_notification_controller.cc b/ash/display/resolution_notification_controller.cc
index e2755a0..d19e776 100644
--- a/ash/display/resolution_notification_controller.cc
+++ b/ash/display/resolution_notification_controller.cc
@@ -7,6 +7,7 @@
#include "ash/display/display_controller.h"
#include "ash/display/display_manager.h"
#include "ash/shell.h"
+#include "ash/system/system_notifier.h"
#include "base/strings/utf_string_conversions.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
@@ -224,7 +225,7 @@ void ResolutionNotificationController::CreateOrUpdateNotification() {
timeout_message,
bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY),
base::string16() /* display_source */,
- std::string() /* extension_id */,
+ message_center::NotifierId(NOTIFIER_DISPLAY_RESOLUTION_CHANGE),
data,
new ResolutionChangeNotificationDelegate(
this, change_info_->timeout_count > 0)));
diff --git a/ash/shell/window_type_launcher.cc b/ash/shell/window_type_launcher.cc
index 799c34c..949b3ae 100644
--- a/ash/shell/window_type_launcher.cc
+++ b/ash/shell/window_type_launcher.cc
@@ -345,7 +345,7 @@ void WindowTypeLauncher::ButtonPressed(views::Button* sender,
ASCIIToUTF16("Notification message body."),
gfx::Image(),
ASCIIToUTF16("www.testshell.org"),
- "" /* extension id */,
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL /* delegate */));
diff --git a/ash/system/chromeos/managed/tray_locally_managed_user.cc b/ash/system/chromeos/managed/tray_locally_managed_user.cc
index e42ea6f..4038b323 100644
--- a/ash/system/chromeos/managed/tray_locally_managed_user.cc
+++ b/ash/system/chromeos/managed/tray_locally_managed_user.cc
@@ -5,6 +5,7 @@
#include "ash/system/chromeos/managed/tray_locally_managed_user.h"
#include "ash/system/chromeos/label_tray_view.h"
+#include "ash/system/system_notifier.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/system/tray/tray_notification_view.h"
#include "ash/system/user/login_status.h"
@@ -82,7 +83,7 @@ void TrayLocallyManagedUser::CreateOrUpdateNotification(
base::string16() /* body is empty */,
bundle.GetImageNamed(IDR_AURA_UBER_TRAY_MANAGED_USER),
base::string16() /* display_source */,
- std::string() /* extension_id */,
+ message_center::NotifierId(NOTIFIER_LOCALLY_MANAGED_USER),
message_center::RichNotificationData(),
NULL /* no delegate */));
notification->SetSystemPriority();
diff --git a/ash/system/chromeos/network/network_connect.cc b/ash/system/chromeos/network/network_connect.cc
index 534b706..8f016d1 100644
--- a/ash/system/chromeos/network/network_connect.cc
+++ b/ash/system/chromeos/network/network_connect.cc
@@ -6,6 +6,7 @@
#include "ash/shell.h"
#include "ash/system/chromeos/network/network_state_notifier.h"
+#include "ash/system/system_notifier.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "base/bind.h"
@@ -382,6 +383,7 @@ void ShowMobileSetup(const std::string& service_path) {
UTF8ToUTF16(cellular->name())),
ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_AURA_UBER_TRAY_CELLULAR_NETWORK_FAILED),
+ ash::NOTIFIER_NETWORK,
base::Bind(&ash::network_connect::ShowNetworkSettings,
service_path)));
return;
diff --git a/ash/system/chromeos/network/network_state_notifier.cc b/ash/system/chromeos/network/network_state_notifier.cc
index dbd8702..1baa151 100644
--- a/ash/system/chromeos/network/network_state_notifier.cc
+++ b/ash/system/chromeos/network/network_state_notifier.cc
@@ -6,6 +6,7 @@
#include "ash/shell.h"
#include "ash/system/chromeos/network/network_connect.h"
+#include "ash/system/system_notifier.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
@@ -60,7 +61,12 @@ void ShowErrorNotification(const std::string& notification_id,
ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id);
message_center::MessageCenter::Get()->AddNotification(
message_center::Notification::CreateSystemNotification(
- notification_id, title, message, icon, callback));
+ notification_id,
+ title,
+ message,
+ icon,
+ ash::NOTIFIER_NETWORK_ERROR,
+ callback));
}
void ConfigureNetwork(const std::string& service_path) {
@@ -182,6 +188,7 @@ void NetworkStateNotifier::UpdateCellularActivating(
l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED,
UTF8ToUTF16((cellular->name()))),
icon,
+ NOTIFIER_NETWORK,
base::Bind(&ash::network_connect::ShowNetworkSettings,
cellular->path())));
}
diff --git a/ash/system/chromeos/power/tray_power.cc b/ash/system/chromeos/power/tray_power.cc
index cdf5300..0125d1e 100644
--- a/ash/system/chromeos/power/tray_power.cc
+++ b/ash/system/chromeos/power/tray_power.cc
@@ -7,6 +7,7 @@
#include "ash/ash_switches.h"
#include "ash/system/chromeos/power/power_status_view.h"
#include "ash/system/date/date_view.h"
+#include "ash/system/system_notifier.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_notification_view.h"
#include "ash/system/tray/tray_utils.h"
@@ -207,7 +208,7 @@ bool TrayPower::MaybeShowUsbChargerNotification() {
rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOW_POWER_CHARGER_MESSAGE),
rb.GetImageNamed(IDR_AURA_NOTIFICATION_LOW_POWER_CHARGER),
base::string16(),
- std::string(),
+ message_center::NotifierId(NOTIFIER_POWER),
message_center::RichNotificationData(),
NULL));
message_center_->AddNotification(notification.Pass());
diff --git a/ash/system/chromeos/screen_security/screen_capture_tray_item.cc b/ash/system/chromeos/screen_security/screen_capture_tray_item.cc
index 6563e4b..6d67f5f 100644
--- a/ash/system/chromeos/screen_security/screen_capture_tray_item.cc
+++ b/ash/system/chromeos/screen_security/screen_capture_tray_item.cc
@@ -5,6 +5,7 @@
#include "ash/system/chromeos/screen_security/screen_capture_tray_item.h"
#include "ash/shell.h"
+#include "ash/system/system_notifier.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
@@ -62,7 +63,7 @@ void ScreenCaptureTrayItem::CreateOrUpdateNotification() {
base::string16() /* body is blank */,
resource_bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY),
base::string16() /* display_source */,
- std::string() /* extension_id */,
+ message_center::NotifierId(NOTIFIER_SCREEN_CAPTURE),
data,
new tray::ScreenNotificationDelegate(this)));
notification->SetSystemPriority();
diff --git a/ash/system/chromeos/screen_security/screen_share_tray_item.cc b/ash/system/chromeos/screen_security/screen_share_tray_item.cc
index 18dd317..78d99f1 100644
--- a/ash/system/chromeos/screen_security/screen_share_tray_item.cc
+++ b/ash/system/chromeos/screen_security/screen_share_tray_item.cc
@@ -5,6 +5,7 @@
#include "ash/system/chromeos/screen_security/screen_share_tray_item.h"
#include "ash/shell.h"
+#include "ash/system/system_notifier.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
@@ -72,7 +73,7 @@ void ScreenShareTrayItem::CreateOrUpdateNotification() {
base::string16() /* body is blank */,
resource_bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY),
base::string16() /* display_source */,
- std::string() /* extension_id */,
+ message_center::NotifierId(NOTIFIER_SCREEN_SHARE),
data,
new tray::ScreenNotificationDelegate(this)));
notification->SetSystemPriority();
diff --git a/ash/system/chromeos/tray_display.cc b/ash/system/chromeos/tray_display.cc
index 0231c5d..6498fd7 100644
--- a/ash/system/chromeos/tray_display.cc
+++ b/ash/system/chromeos/tray_display.cc
@@ -7,6 +7,7 @@
#include "ash/display/display_controller.h"
#include "ash/display/display_manager.h"
#include "ash/shell.h"
+#include "ash/system/system_notifier.h"
#include "ash/system/tray/actionable_view.h"
#include "ash/system/tray/fixed_sized_image_view.h"
#include "ash/system/tray/system_tray.h"
@@ -398,7 +399,7 @@ void TrayDisplay::CreateOrUpdateNotification(
additional_message,
bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY),
base::string16(), // display_source
- "", // extension_id
+ message_center::NotifierId(NOTIFIER_DISPLAY),
message_center::RichNotificationData(),
new message_center::HandleNotificationClickedDelegate(
base::Bind(&OpenSettings,
diff --git a/ash/system/ime/tray_ime.cc b/ash/system/ime/tray_ime.cc
index e8c9eda..7fd3b3d 100644
--- a/ash/system/ime/tray_ime.cc
+++ b/ash/system/ime/tray_ime.cc
@@ -9,6 +9,7 @@
#include "ash/root_window_controller.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
+#include "ash/system/system_notifier.h"
#include "ash/system/tray/hover_highlight_view.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_delegate.h"
@@ -230,7 +231,7 @@ void TrayIME::UpdateOrCreateNotification() {
base::string16(), // message
bundle.GetImageNamed(IDR_AURA_UBER_TRAY_IME),
base::string16(), // display_source
- "", // extension_id
+ message_center::NotifierId(NOTIFIER_INPUT_METHOD),
message_center::RichNotificationData(),
new message_center::HandleNotificationClickedDelegate(
base::Bind(&TrayIME::PopupDetailedView,
diff --git a/ash/system/locale/locale_notification_controller.cc b/ash/system/locale/locale_notification_controller.cc
index 9f368b0..b23bf6d 100644
--- a/ash/system/locale/locale_notification_controller.cc
+++ b/ash/system/locale/locale_notification_controller.cc
@@ -5,6 +5,7 @@
#include "ash/system/locale/locale_notification_controller.h"
#include "ash/shell.h"
+#include "ash/system/system_notifier.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "base/strings/string16.h"
#include "grit/ash_resources.h"
@@ -116,7 +117,7 @@ void LocaleNotificationController::OnLocaleChanged(
base::string16() /* message */,
bundle.GetImageNamed(IDR_AURA_UBER_TRAY_LOCALE),
base::string16() /* display_source */,
- std::string() /* extension_id */,
+ message_center::NotifierId(NOTIFIER_LOCALE),
optional,
new LocaleNotificationDelegate(delegate)));
message_center::MessageCenter::Get()->AddNotification(notification.Pass());
diff --git a/ash/system/system_notifier.cc b/ash/system/system_notifier.cc
new file mode 100644
index 0000000..a765ee1
--- /dev/null
+++ b/ash/system/system_notifier.cc
@@ -0,0 +1,20 @@
+// Copyright 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 "ash/system/system_notifier.h"
+
+#include "base/logging.h"
+
+namespace ash {
+
+std::string SystemComponentTypeToString(AshSystemComponentNotifierType type) {
+ if (type == NOTIFIER_SCREENSHOT)
+ return "screenshot";
+
+ // TODO(mukai): fill the names of other components.
+ NOTIMPLEMENTED();
+ return std::string();
+}
+
+} // namespace
diff --git a/ash/system/system_notifier.h b/ash/system/system_notifier.h
new file mode 100644
index 0000000..119ed5b
--- /dev/null
+++ b/ash/system/system_notifier.h
@@ -0,0 +1,37 @@
+// Copyright 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.
+
+#ifndef ASH_SYSTEM_SYSTEM_NOTIFIER_H_
+#define ASH_SYSTEM_SYSTEM_NOTIFIER_H_
+
+#include <string>
+
+#include "ash/ash_export.h"
+
+namespace ash {
+
+enum AshSystemComponentNotifierType {
+ NOTIFIER_NO_SYSTEM_COMPONENT = -1,
+
+ // Alphabetical order.
+ NOTIFIER_DISPLAY,
+ NOTIFIER_DISPLAY_RESOLUTION_CHANGE,
+ NOTIFIER_DISPLAY_ERROR,
+ NOTIFIER_INPUT_METHOD,
+ NOTIFIER_LOCALE,
+ NOTIFIER_LOCALLY_MANAGED_USER,
+ NOTIFIER_NETWORK,
+ NOTIFIER_NETWORK_ERROR,
+ NOTIFIER_SCREENSHOT,
+ NOTIFIER_SCREEN_CAPTURE,
+ NOTIFIER_SCREEN_SHARE,
+ NOTIFIER_POWER,
+};
+
+ASH_EXPORT std::string SystemComponentTypeToString(
+ AshSystemComponentNotifierType type);
+
+} // namespace ash
+
+#endif // ASH_SYSTEM_SYSTEM_NOTIFIER_H_
diff --git a/ash/system/web_notification/web_notification_tray_unittest.cc b/ash/system/web_notification/web_notification_tray_unittest.cc
index 5b67b7d..ff1728e 100644
--- a/ash/system/web_notification/web_notification_tray_unittest.cc
+++ b/ash/system/web_notification/web_notification_tray_unittest.cc
@@ -112,7 +112,7 @@ class WebNotificationTrayTest : public test::AshTestBase {
ASCIIToUTF16("Notification message body."),
gfx::Image(),
ASCIIToUTF16("www.test.org"),
- "" /* extension id */,
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL /* delegate */));
GetMessageCenter()->AddNotification(notification.Pass());
@@ -128,7 +128,7 @@ class WebNotificationTrayTest : public test::AshTestBase {
ASCIIToUTF16("Updated message body."),
gfx::Image(),
ASCIIToUTF16("www.test.org"),
- "" /* extension id */,
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL /* delegate */));
GetMessageCenter()->UpdateNotification(old_id, notification.Pass());
diff --git a/chrome/browser/chromeos/status/data_promo_notification.cc b/chrome/browser/chromeos/status/data_promo_notification.cc
index 3ea4dce..d9b1da2 100644
--- a/chrome/browser/chromeos/status/data_promo_notification.cc
+++ b/chrome/browser/chromeos/status/data_promo_notification.cc
@@ -7,6 +7,7 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/system/chromeos/network/network_connect.h"
+#include "ash/system/system_notifier.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "base/prefs/pref_registry_simple.h"
@@ -226,6 +227,7 @@ void DataPromoNotification::ShowOptionalMobileDataPromoNotification() {
base::string16() /* title */,
message,
icon,
+ ash::NOTIFIER_NETWORK,
base::Bind(&NotificationClicked,
default_network->path(), info_url)));
diff --git a/chrome/browser/extensions/api/notifications/notifications_api.cc b/chrome/browser/extensions/api/notifications/notifications_api.cc
index 9c330aa..51089fa 100644
--- a/chrome/browser/extensions/api/notifications/notifications_api.cc
+++ b/chrome/browser/extensions/api/notifications/notifications_api.cc
@@ -331,6 +331,9 @@ bool NotificationsApiFunction::CreateNotification(
message,
icon,
WebKit::WebTextDirectionDefault,
+ message_center::NotifierId(
+ message_center::NotifierId::APPLICATION,
+ extension_->id()),
UTF8ToUTF16(extension_->name()),
UTF8ToUTF16(api_delegate->id()),
optional_fields,
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index 45eb30c..814949f 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -48,6 +48,10 @@
#include "ui/message_center/notifier_settings.h"
#include "ui/webui/web_ui_util.h"
+#if defined(OS_CHROMEOS)
+#include "ash/system/system_notifier.h"
+#endif
+
using content::BrowserThread;
using content::RenderViewHost;
using content::WebContents;
@@ -566,9 +570,15 @@ bool DesktopNotificationService::IsNotifierEnabled(
case NotifierId::WEB_PAGE:
return GetContentSetting(notifier_id.url) == CONTENT_SETTING_ALLOW;
case NotifierId::SYSTEM_COMPONENT:
+#if defined(OS_CHROMEOS)
return disabled_system_component_ids_.find(
- message_center::ToString(notifier_id.system_component_type)) ==
- disabled_system_component_ids_.end();
+ ash::SystemComponentTypeToString(
+ static_cast<ash::AshSystemComponentNotifierType>(
+ notifier_id.system_component_type)))
+ == disabled_system_component_ids_.end();
+#else
+ return false;
+#endif
case NotifierId::SYNCED_NOTIFICATION_SERVICE:
return enabled_sync_notifier_ids_.find(notifier_id.id) !=
enabled_sync_notifier_ids_.end();
@@ -593,10 +603,15 @@ void DesktopNotificationService::SetNotifierEnabled(
id.reset(new base::StringValue(notifier_id.id));
break;
case NotifierId::SYSTEM_COMPONENT:
+#if defined(OS_CHROMEOS)
pref_name = prefs::kMessageCenterDisabledSystemComponentIds;
add_new_item = !enabled;
- id.reset(new base::StringValue(
- message_center::ToString(notifier_id.system_component_type)));
+ id.reset(new base::StringValue(ash::SystemComponentTypeToString(
+ static_cast<ash::AshSystemComponentNotifierType>(
+ notifier_id.system_component_type))));
+#else
+ return;
+#endif
break;
case NotifierId::SYNCED_NOTIFICATION_SERVICE:
pref_name = prefs::kMessageCenterEnabledSyncNotifierIds;
diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc
index 2054a7f..21e902c 100644
--- a/chrome/browser/notifications/message_center_notification_manager.cc
+++ b/chrome/browser/notifications/message_center_notification_manager.cc
@@ -218,8 +218,6 @@ bool MessageCenterNotificationManager::UpdateNotification(
// Now pass a copy to message center.
scoped_ptr<message_center::Notification> message_center_notification(
make_scoped_ptr(new message_center::Notification(notification)));
- message_center_notification->set_extension_id(
- new_notification->GetExtensionId());
message_center_->UpdateNotification(old_id,
message_center_notification.Pass());
@@ -233,47 +231,6 @@ bool MessageCenterNotificationManager::UpdateNotification(
////////////////////////////////////////////////////////////////////////////////
// MessageCenter::Delegate
-void MessageCenterNotificationManager::DisableExtension(
- const std::string& notification_id) {
- ProfileNotification* profile_notification =
- FindProfileNotification(notification_id);
- if (!profile_notification)
- return;
-
- std::string extension_id = profile_notification->GetExtensionId();
- DCHECK(!extension_id.empty()); // or UI should not have enabled the command.
- DesktopNotificationService* service =
- DesktopNotificationServiceFactory::GetForProfile(
- profile_notification->profile());
- message_center::NotifierId notifier_id(
- message_center::NotifierId::APPLICATION, extension_id);
- service->SetNotifierEnabled(notifier_id, false);
-}
-
-void MessageCenterNotificationManager::DisableNotificationsFromSource(
- const std::string& notification_id) {
- ProfileNotification* profile_notification =
- FindProfileNotification(notification_id);
- if (!profile_notification)
- return;
-
- // 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());
- if (profile_notification->notification().origin_url().scheme() ==
- chrome::kChromeUIScheme) {
- const std::string name =
- profile_notification->notification().origin_url().host();
- message_center::NotifierId notifier_id(
- message_center::ParseSystemComponentName(name));
- service->SetNotifierEnabled(notifier_id, false);
- } else {
- service->DenyPermission(profile_notification->notification().origin_url());
- }
-}
-
void MessageCenterNotificationManager::ShowSettings(
const std::string& notification_id) {
// The per-message-center Settings button passes an empty string.
@@ -541,8 +498,6 @@ void MessageCenterNotificationManager::AddProfileNotification(
// Create the copy for message center, and ensure the extension ID is correct.
scoped_ptr<message_center::Notification> message_center_notification(
new message_center::Notification(notification));
- message_center_notification->set_extension_id(
- profile_notification->GetExtensionId());
message_center_->AddNotification(message_center_notification.Pass());
profile_notification->StartDownloads();
diff --git a/chrome/browser/notifications/message_center_notification_manager.h b/chrome/browser/notifications/message_center_notification_manager.h
index 4589645..cb5dc79 100644
--- a/chrome/browser/notifications/message_center_notification_manager.h
+++ b/chrome/browser/notifications/message_center_notification_manager.h
@@ -58,9 +58,6 @@ class MessageCenterNotificationManager
Profile* profile) OVERRIDE;
// MessageCenter::Delegate
- virtual void DisableExtension(const std::string& notification_id) OVERRIDE;
- virtual void DisableNotificationsFromSource(
- const std::string& notification_id) OVERRIDE;
virtual void ShowSettings(const std::string& notification_id) OVERRIDE;
// MessageCenterObserver
diff --git a/chrome/browser/notifications/message_center_notifications_browsertest.cc b/chrome/browser/notifications/message_center_notifications_browsertest.cc
index 03f8012..84cde47 100644
--- a/chrome/browser/notifications/message_center_notifications_browsertest.cc
+++ b/chrome/browser/notifications/message_center_notifications_browsertest.cc
@@ -140,6 +140,9 @@ class MessageCenterNotificationsTest : public InProcessBrowserTest {
ASCIIToUTF16("message"),
gfx::Image(),
WebKit::WebTextDirectionDefault,
+ message_center::NotifierId(
+ message_center::NotifierId::APPLICATION,
+ "extension_id"),
UTF8ToUTF16("chrome-test://testing/"),
UTF8ToUTF16("REPLACE-ME"),
data,
diff --git a/chrome/browser/notifications/message_center_settings_controller.cc b/chrome/browser/notifications/message_center_settings_controller.cc
index 66175a7..e1d017a 100644
--- a/chrome/browser/notifications/message_center_settings_controller.cc
+++ b/chrome/browser/notifications/message_center_settings_controller.cc
@@ -35,6 +35,10 @@
#include "ui/gfx/image/image.h"
#include "ui/message_center/message_center_style.h"
+#if defined(OS_CHROMEOS)
+#include "ash/system/system_notifier.h"
+#endif
+
using message_center::Notifier;
using message_center::NotifierId;
@@ -258,7 +262,7 @@ void MessageCenterSettingsController::GetNotifierList(
#if defined(OS_CHROMEOS)
const string16 screenshot_name =
l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NOTIFIER_SCREENSHOT_NAME);
- NotifierId screenshot_notifier_id(NotifierId::SCREENSHOT);
+ NotifierId screenshot_notifier_id(ash::NOTIFIER_SCREENSHOT);
Notifier* const screenshot_notifier = new Notifier(
screenshot_notifier_id,
screenshot_name,
diff --git a/chrome/browser/notifications/notification.cc b/chrome/browser/notifications/notification.cc
index 315e12b..61110a1 100644
--- a/chrome/browser/notifications/notification.cc
+++ b/chrome/browser/notifications/notification.cc
@@ -20,7 +20,7 @@ Notification::Notification(const GURL& origin_url,
EmptyString16(),
gfx::Image(),
display_source,
- origin_url.spec(),
+ message_center::NotifierId(origin_url),
message_center::RichNotificationData(),
delegate),
origin_url_(origin_url),
@@ -43,7 +43,7 @@ Notification::Notification(const GURL& origin_url,
body,
gfx::Image(),
display_source,
- origin_url.spec(),
+ message_center::NotifierId(origin_url),
message_center::RichNotificationData(),
delegate),
origin_url_(origin_url),
@@ -63,6 +63,7 @@ Notification::Notification(
const string16& body,
const gfx::Image& icon,
WebKit::WebTextDirection dir,
+ const message_center::NotifierId& notifier_id,
const string16& display_source,
const string16& replace_id,
const message_center::RichNotificationData& rich_notification_data,
@@ -73,7 +74,7 @@ Notification::Notification(
body,
icon,
display_source,
- origin_url.spec(),
+ notifier_id,
rich_notification_data,
delegate),
origin_url_(origin_url),
@@ -105,7 +106,7 @@ Notification::Notification(const GURL& origin_url,
body,
icon,
display_source,
- origin_url.spec(),
+ message_center::NotifierId(origin_url),
message_center::RichNotificationData(),
delegate),
origin_url_(origin_url),
diff --git a/chrome/browser/notifications/notification.h b/chrome/browser/notifications/notification.h
index 3e4685c..94850a1 100644
--- a/chrome/browser/notifications/notification.h
+++ b/chrome/browser/notifications/notification.h
@@ -60,6 +60,7 @@ class Notification : public message_center::Notification {
const string16& body,
const gfx::Image& icon,
WebKit::WebTextDirection dir,
+ const message_center::NotifierId& notifier_id,
const string16& display_source,
const string16& replace_id,
const message_center::RichNotificationData& rich_notification_data,
diff --git a/chrome/browser/notifications/sync_notifier/synced_notification.cc b/chrome/browser/notifications/sync_notifier/synced_notification.cc
index abffe93..00e8df2 100644
--- a/chrome/browser/notifications/sync_notifier/synced_notification.cc
+++ b/chrome/browser/notifications/sync_notifier/synced_notification.cc
@@ -292,6 +292,7 @@ void SyncedNotification::Show(NotificationUIManager* notification_manager,
notification_text,
icon_bitmap,
WebKit::WebTextDirectionDefault,
+ message_center::NotifierId(GetOriginUrl()),
display_source,
replace_key,
rich_notification_data,
diff --git a/chrome/browser/ui/ash/screenshot_taker.cc b/chrome/browser/ui/ash/screenshot_taker.cc
index 13cf3b9..86e4429 100644
--- a/chrome/browser/ui/ash/screenshot_taker.cc
+++ b/chrome/browser/ui/ash/screenshot_taker.cc
@@ -8,6 +8,7 @@
#include <string>
#include "ash/shell.h"
+#include "ash/system/system_notifier.h"
#include "base/bind.h"
#include "base/file_util.h"
#include "base/i18n/time_formatting.h"
@@ -398,9 +399,8 @@ Notification* ScreenshotTaker::CreateNotification(
bool success =
(screenshot_result == ScreenshotTakerObserver::SCREENSHOT_SUCCESS);
return new Notification(
+ message_center::NOTIFICATION_TYPE_SIMPLE,
GURL(kNotificationOriginUrl),
- ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- IDR_SCREENSHOT_NOTIFICATION_ICON),
l10n_util::GetStringUTF16(
success ?
IDS_ASH_SCREENSHOT_NOTIFICATION_TITLE_SUCCESS :
@@ -409,9 +409,13 @@ Notification* ScreenshotTaker::CreateNotification(
success ?
IDS_ASH_SCREENSHOT_NOTIFICATION_TEXT_SUCCESS :
IDS_ASH_SCREENSHOT_NOTIFICATION_TEXT_FAIL),
+ ui::ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_SCREENSHOT_NOTIFICATION_ICON),
WebKit::WebTextDirectionDefault,
+ message_center::NotifierId(ash::NOTIFIER_SCREENSHOT),
l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NOTIFIER_SCREENSHOT_NAME),
replace_id,
+ message_center::RichNotificationData(),
new ScreenshotTakerNotificationDelegate(success, screenshot_path));
}
@@ -430,7 +434,7 @@ void ScreenshotTaker::ShowNotification(
DesktopNotificationService* const service =
DesktopNotificationServiceFactory::GetForProfile(GetProfile());
if (service->IsNotifierEnabled(
- message_center::NotifierId(message_center::NotifierId::SCREENSHOT))) {
+ message_center::NotifierId(ash::NOTIFIER_SCREENSHOT))) {
scoped_ptr<Notification> notification(
CreateNotification(screenshot_result, screenshot_path));
g_browser_process->notification_ui_manager()->Add(*notification,
diff --git a/chrome/browser/ui/cocoa/notifications/message_center_tray_bridge_unittest.mm b/chrome/browser/ui/cocoa/notifications/message_center_tray_bridge_unittest.mm
index 57008c0..e8755f7 100644
--- a/chrome/browser/ui/cocoa/notifications/message_center_tray_bridge_unittest.mm
+++ b/chrome/browser/ui/cocoa/notifications/message_center_tray_bridge_unittest.mm
@@ -51,7 +51,7 @@ TEST_F(MessageCenterTrayBridgeTest, StatusItemOnlyAfterFirstNotification) {
ASCIIToUTF16("This is a simple test."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
data,
NULL));
center_->AddNotification(notification.Pass());
diff --git a/ui/base/strings/ui_strings.grd b/ui/base/strings/ui_strings.grd
index fd4eb5a6..e412ed6 100644
--- a/ui/base/strings/ui_strings.grd
+++ b/ui/base/strings/ui_strings.grd
@@ -1515,11 +1515,8 @@ need to be translated for each locale.-->
<message name="IDS_MESSAGE_CENTER_ACCESSIBLE_NAME" desc="The accessible name for the Notification Center window.">
Notification Center
</message>
- <message name="IDS_MESSAGE_CENTER_EXTENSIONS_DISABLE" desc="The menu entry for disabling extensions from a notification.">
- Disable notifications from <ph name="extension_name">$1<ex>Notification Galore!</ex></ph>
- </message>
- <message name="IDS_MESSAGE_CENTER_SITE_DISABLE" desc="The menu entry for disabling notification from a site.">
- Disable notifications from <ph name="site">$1<ex>mail.google.com</ex></ph>
+ <message name="IDS_MESSAGE_CENTER_NOTIFIER_DISABLE" desc="The menu entry for disabling a notifier from a notification.">
+ Disable notifications from <ph name="notifier_name">$1<ex>Notification Galore!</ex></ph>
</message>
<message name="IDS_MESSAGE_CENTER_FOOTER_TITLE" desc="The label in the footer of the message center">
Notifications
diff --git a/ui/message_center/cocoa/notification_controller_unittest.mm b/ui/message_center/cocoa/notification_controller_unittest.mm
index ea7968e..87aced2 100644
--- a/ui/message_center/cocoa/notification_controller_unittest.mm
+++ b/ui/message_center/cocoa/notification_controller_unittest.mm
@@ -105,7 +105,7 @@ TEST_F(NotificationControllerTest, BasicLayout) {
ASCIIToUTF16("Jonathan and 5 others"),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
notification->set_icon(gfx::Image([TestIcon() retain]));
@@ -135,7 +135,7 @@ TEST_F(NotificationControllerTest, OverflowText) {
"entire thing?"),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
base::scoped_nsobject<MCNotificationController> controller(
@@ -156,7 +156,7 @@ TEST_F(NotificationControllerTest, Close) {
string16(),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
MockMessageCenter message_center;
@@ -183,7 +183,7 @@ TEST_F(NotificationControllerTest, Update) {
"default bounds."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
base::scoped_nsobject<MCNotificationController> controller(
@@ -219,7 +219,7 @@ TEST_F(NotificationControllerTest, Buttons) {
string16(),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
optional,
NULL));
MockMessageCenter message_center;
@@ -244,7 +244,7 @@ TEST_F(NotificationControllerTest, Image) {
string16(),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
NSImage* image = [NSImage imageNamed:NSImageNameFolder];
@@ -281,7 +281,7 @@ TEST_F(NotificationControllerTest, List) {
UTF8ToUTF16("Notification Message - should be hidden"),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
optional,
NULL));
diff --git a/ui/message_center/cocoa/popup_collection_unittest.mm b/ui/message_center/cocoa/popup_collection_unittest.mm
index 105c824..2b8d140 100644
--- a/ui/message_center/cocoa/popup_collection_unittest.mm
+++ b/ui/message_center/cocoa/popup_collection_unittest.mm
@@ -51,7 +51,7 @@ class PopupCollectionTest : public ui::CocoaTest {
" be displayed"),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification.Pass());
@@ -63,7 +63,7 @@ class PopupCollectionTest : public ui::CocoaTest {
ASCIIToUTF16("This is the second notification."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification.Pass());
@@ -79,7 +79,7 @@ class PopupCollectionTest : public ui::CocoaTest {
"set the screen size too small."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification.Pass());
@@ -134,7 +134,7 @@ TEST_F(PopupCollectionTest, AttemptFourOneOffscreen) {
ASCIIToUTF16("This is the fourth notification."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification.Pass());
@@ -183,7 +183,7 @@ TEST_F(PopupCollectionTest, LayoutSpacing) {
ASCIIToUTF16("This is the fourth notification."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
optional,
NULL));
center_->AddNotification(notification.Pass());
@@ -221,7 +221,7 @@ TEST_F(PopupCollectionTest, TinyScreen) {
" be displayed"),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification.Pass());
@@ -243,7 +243,7 @@ TEST_F(PopupCollectionTest, TinyScreen) {
"long notification."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->UpdateNotification("1", notification.Pass());
@@ -287,7 +287,7 @@ TEST_F(PopupCollectionTest, UpdateIconAndBody) {
"longer body"),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification.Pass());
@@ -316,7 +316,7 @@ TEST_F(PopupCollectionTest, CloseCollectionBeforeNewPopupAnimationEnds) {
" be displayed"),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification.Pass());
@@ -349,7 +349,7 @@ TEST_F(PopupCollectionTest, CloseCollectionBeforeUpdatePopupAnimationEnds) {
ASCIIToUTF16("New message."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->UpdateNotification("1", notification.Pass());
diff --git a/ui/message_center/cocoa/popup_controller_unittest.mm b/ui/message_center/cocoa/popup_controller_unittest.mm
index 41f6279..c39d163 100644
--- a/ui/message_center/cocoa/popup_controller_unittest.mm
+++ b/ui/message_center/cocoa/popup_controller_unittest.mm
@@ -23,7 +23,7 @@ TEST_F(PopupControllerTest, Creation) {
ASCIIToUTF16("Jonathan and 5 others"),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
diff --git a/ui/message_center/cocoa/tray_view_controller_unittest.mm b/ui/message_center/cocoa/tray_view_controller_unittest.mm
index 6c82777..ce9b080 100644
--- a/ui/message_center/cocoa/tray_view_controller_unittest.mm
+++ b/ui/message_center/cocoa/tray_view_controller_unittest.mm
@@ -71,7 +71,7 @@ TEST_F(TrayViewControllerTest, AddRemoveOne) {
ASCIIToUTF16("This is a simple test."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification_data.Pass());
@@ -105,7 +105,7 @@ TEST_F(TrayViewControllerTest, AddThreeClearAll) {
ASCIIToUTF16("This is a simple test."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification.Pass());
@@ -116,7 +116,7 @@ TEST_F(TrayViewControllerTest, AddThreeClearAll) {
ASCIIToUTF16("This is a simple test."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification.Pass());
@@ -127,7 +127,7 @@ TEST_F(TrayViewControllerTest, AddThreeClearAll) {
ASCIIToUTF16("This is a simple test."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification.Pass());
@@ -160,7 +160,7 @@ TEST_F(TrayViewControllerTest, NoClearAllWhenNoNotifications) {
ASCIIToUTF16("This is a simple test."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification.Pass());
@@ -179,7 +179,7 @@ TEST_F(TrayViewControllerTest, NoClearAllWhenNoNotifications) {
ASCIIToUTF16("This is a simple test."),
gfx::Image(),
string16(),
- std::string(),
+ message_center::NotifierId(),
message_center::RichNotificationData(),
NULL));
center_->AddNotification(notification.Pass());
diff --git a/ui/message_center/fake_message_center.cc b/ui/message_center/fake_message_center.cc
index 4deff26..c397475 100644
--- a/ui/message_center/fake_message_center.cc
+++ b/ui/message_center/fake_message_center.cc
@@ -83,10 +83,8 @@ void FakeMessageCenter::SetNotificationButtonIcon(
const gfx::Image& image) {
}
-void FakeMessageCenter::DisableNotificationsByExtension(const std::string& id) {
-}
-
-void FakeMessageCenter::DisableNotificationsByUrl(const std::string& id) {
+void FakeMessageCenter::DisableNotificationsByNotifier(
+ const NotifierId& notifier_id) {
}
void FakeMessageCenter::ShowNotificationSettings(const std::string& id) {
diff --git a/ui/message_center/fake_message_center.h b/ui/message_center/fake_message_center.h
index ebb9be2..40ad90e 100644
--- a/ui/message_center/fake_message_center.h
+++ b/ui/message_center/fake_message_center.h
@@ -45,8 +45,8 @@ class FakeMessageCenter : public MessageCenter {
virtual void SetNotificationButtonIcon(const std::string& notification_id,
int button_index,
const gfx::Image& image) OVERRIDE;
- virtual void DisableNotificationsByExtension(const std::string& id) OVERRIDE;
- virtual void DisableNotificationsByUrl(const std::string& id) OVERRIDE;
+ virtual void DisableNotificationsByNotifier(
+ const NotifierId& notifier_id) OVERRIDE;
virtual void ShowNotificationSettings(const std::string& id) OVERRIDE;
virtual void ExpandNotification(const std::string& id) OVERRIDE;
virtual void ClickOnNotification(const std::string& id) OVERRIDE;
diff --git a/ui/message_center/message_center.h b/ui/message_center/message_center.h
index c055664..880540d 100644
--- a/ui/message_center/message_center.h
+++ b/ui/message_center/message_center.h
@@ -49,13 +49,6 @@ class MESSAGE_CENTER_EXPORT MessageCenter {
public:
virtual ~Delegate();
- // Request to disable the extension associated with |notification_id|.
- virtual void DisableExtension(const std::string& notification_id) = 0;
-
- // Request to disable notifications from the source of |notification_id|.
- virtual void DisableNotificationsFromSource(
- const std::string& notification_id) = 0;
-
// Request to show the notification settings (|notification_id| is used
// to identify the requesting browser context).
virtual void ShowSettings(const std::string& notification_id) = 0;
@@ -115,12 +108,8 @@ class MESSAGE_CENTER_EXPORT MessageCenter {
// and settings.
// Searches through the notifications and disables any that match the
// extension id given.
- virtual void DisableNotificationsByExtension(const std::string& id) = 0;
-
- // Disables all notifications that match the given url by querying the
- // delegate and also by matching display_source.
- // TODO(dewittj): Is display_source matching necessary?
- virtual void DisableNotificationsByUrl(const std::string& url) = 0;
+ virtual void DisableNotificationsByNotifier(
+ const NotifierId& notifier_id) = 0;
// TODO(mukai): settings can be in another class?
// Shows the settings for a web notification (profile is identified by the
diff --git a/ui/message_center/message_center_impl.cc b/ui/message_center/message_center_impl.cc
index c1d0179..ab6a24e 100644
--- a/ui/message_center/message_center_impl.cc
+++ b/ui/message_center/message_center_impl.cc
@@ -374,27 +374,16 @@ void MessageCenterImpl::SetNotificationButtonIcon(
}
}
-void MessageCenterImpl::DisableNotificationsByExtension(
- const std::string& id) {
- if (delegate_)
- delegate_->DisableExtension(id);
-
- NotificationList::Notifications notifications =
- notification_list_->GetNotificationsByExtension(id);
- for (NotificationList::Notifications::const_iterator iter =
- notifications.begin(); iter != notifications.end();) {
- std::string id = (*iter)->id();
- iter++;
- RemoveNotification(id, false);
+void MessageCenterImpl::DisableNotificationsByNotifier(
+ const NotifierId& notifier_id) {
+ if (settings_provider_) {
+ // TODO(mukai): SetNotifierEnabled can just accept notifier_id?
+ Notifier notifier(notifier_id, base::string16(), true);
+ settings_provider_->SetNotifierEnabled(notifier, false);
}
-}
-
-void MessageCenterImpl::DisableNotificationsByUrl(const std::string& id) {
- if (delegate_)
- delegate_->DisableNotificationsFromSource(id);
NotificationList::Notifications notifications =
- notification_list_->GetNotificationsBySource(id);
+ notification_list_->GetNotificationsByNotifierId(notifier_id);
for (NotificationList::Notifications::const_iterator iter =
notifications.begin(); iter != notifications.end();) {
std::string id = (*iter)->id();
diff --git a/ui/message_center/message_center_impl.h b/ui/message_center/message_center_impl.h
index 412e0b3..a9df52e 100644
--- a/ui/message_center/message_center_impl.h
+++ b/ui/message_center/message_center_impl.h
@@ -161,8 +161,8 @@ class MessageCenterImpl : public MessageCenter {
virtual void SetNotificationButtonIcon(const std::string& notification_id,
int button_index,
const gfx::Image& image) OVERRIDE;
- virtual void DisableNotificationsByExtension(const std::string& id) OVERRIDE;
- virtual void DisableNotificationsByUrl(const std::string& id) OVERRIDE;
+ virtual void DisableNotificationsByNotifier(
+ const NotifierId& notifier_id) OVERRIDE;
virtual void ShowNotificationSettings(const std::string& id) OVERRIDE;
virtual void ExpandNotification(const std::string& id) OVERRIDE;
virtual void ClickOnNotification(const std::string& id) OVERRIDE;
diff --git a/ui/message_center/message_center_tray_unittest.cc b/ui/message_center/message_center_tray_unittest.cc
index 108cee7..7517507 100644
--- a/ui/message_center/message_center_tray_unittest.cc
+++ b/ui/message_center/message_center_tray_unittest.cc
@@ -71,7 +71,7 @@ class MessageCenterTrayTest : public testing::Test {
ASCIIToUTF16("Notification message body."),
gfx::Image(),
ASCIIToUTF16("www.test.org"),
- "" /* extension id */,
+ NotifierId(),
message_center::RichNotificationData(),
NULL /* delegate */));
message_center_->AddNotification(notification.Pass());
@@ -171,7 +171,7 @@ TEST_F(MessageCenterTrayTest, MessageCenterReopenPopupsForSystemPriority) {
ASCIIToUTF16("Notification message body."),
gfx::Image(),
ASCIIToUTF16("www.test.org"),
- "" /* extension id */,
+ NotifierId(),
message_center::RichNotificationData(),
NULL /* delegate */));
notification->SetSystemPriority();
diff --git a/ui/message_center/notification.cc b/ui/message_center/notification.cc
index 692d140..eb4c8a8 100644
--- a/ui/message_center/notification.cc
+++ b/ui/message_center/notification.cc
@@ -48,7 +48,7 @@ Notification::Notification(NotificationType type,
const string16& message,
const gfx::Image& icon,
const string16& display_source,
- const std::string& extension_id,
+ const NotifierId& notifier_id,
const RichNotificationData& optional_fields,
NotificationDelegate* delegate)
: type_(type),
@@ -57,7 +57,7 @@ Notification::Notification(NotificationType type,
message_(message),
icon_(icon),
display_source_(display_source),
- extension_id_(extension_id),
+ notifier_id_(notifier_id),
serial_number_(g_next_serial_number_++),
optional_fields_(optional_fields),
shown_as_popup_(false),
@@ -72,7 +72,7 @@ Notification::Notification(const Notification& other)
message_(other.message_),
icon_(other.icon_),
display_source_(other.display_source_),
- extension_id_(other.extension_id_),
+ notifier_id_(other.notifier_id_),
serial_number_(other.serial_number_),
optional_fields_(other.optional_fields_),
shown_as_popup_(other.shown_as_popup_),
@@ -87,7 +87,7 @@ Notification& Notification::operator=(const Notification& other) {
message_ = other.message_;
icon_ = other.icon_;
display_source_ = other.display_source_;
- extension_id_ = other.extension_id_;
+ notifier_id_ = other.notifier_id_;
serial_number_ = other.serial_number_;
optional_fields_ = other.optional_fields_;
shown_as_popup_ = other.shown_as_popup_;
@@ -126,6 +126,7 @@ scoped_ptr<Notification> Notification::CreateSystemNotification(
const base::string16& title,
const base::string16& message,
const gfx::Image& icon,
+ int system_component_id,
const base::Closure& click_callback) {
scoped_ptr<Notification> notification(
new Notification(
@@ -135,7 +136,7 @@ scoped_ptr<Notification> Notification::CreateSystemNotification(
message,
icon,
base::string16() /* display_source */,
- std::string() /* extension_id */,
+ NotifierId(system_component_id),
RichNotificationData(),
new HandleNotificationClickedDelegate(click_callback)));
notification->SetSystemPriority();
diff --git a/ui/message_center/notification.h b/ui/message_center/notification.h
index cfcef43..6a742e0 100644
--- a/ui/message_center/notification.h
+++ b/ui/message_center/notification.h
@@ -15,6 +15,7 @@
#include "ui/message_center/message_center_export.h"
#include "ui/message_center/notification_delegate.h"
#include "ui/message_center/notification_types.h"
+#include "ui/message_center/notifier_settings.h"
namespace message_center {
@@ -56,7 +57,7 @@ class MESSAGE_CENTER_EXPORT Notification {
const string16& message,
const gfx::Image& icon,
const string16& display_source,
- const std::string& extension_id,
+ const NotifierId& notifier_id,
const RichNotificationData& optional_fields,
NotificationDelegate* delegate);
@@ -81,10 +82,8 @@ class MESSAGE_CENTER_EXPORT Notification {
// A display string for the source of the notification.
const string16& display_source() const { return display_source_; }
- const std::string& extension_id() const { return extension_id_; }
- void set_extension_id(const std::string& extension_id) {
- extension_id_ = extension_id;
- }
+
+ const NotifierId& notifier_id() const { return notifier_id_; }
// Begin unpacked values from optional_fields.
int priority() const { return optional_fields_.priority; }
@@ -174,6 +173,7 @@ class MESSAGE_CENTER_EXPORT Notification {
const base::string16& title,
const base::string16& message,
const gfx::Image& icon,
+ int system_component_id,
const base::Closure& click_callback);
protected:
@@ -192,7 +192,7 @@ class MESSAGE_CENTER_EXPORT Notification {
string16 display_source_;
private:
- std::string extension_id_;
+ NotifierId notifier_id_;
unsigned serial_number_;
RichNotificationData optional_fields_;
bool shown_as_popup_; // True if this has been shown as a popup.
diff --git a/ui/message_center/notification_list.cc b/ui/message_center/notification_list.cc
index d052792..423c09f 100644
--- a/ui/message_center/notification_list.cc
+++ b/ui/message_center/notification_list.cc
@@ -114,33 +114,12 @@ void NotificationList::RemoveAllNotifications() {
unread_count_ = 0;
}
-NotificationList::Notifications NotificationList::GetNotificationsBySource(
- const std::string& id) {
+NotificationList::Notifications NotificationList::GetNotificationsByNotifierId(
+ const NotifierId& notifier_id) {
Notifications notifications;
- Notifications::iterator source_iter = GetNotification(id);
- if (source_iter == notifications_.end())
- return notifications;
-
- string16 display_source = (*source_iter)->display_source();
- for (Notifications::iterator iter = notifications_.begin();
- iter != notifications_.end(); ++iter) {
- if ((*iter)->display_source() == display_source)
- notifications.insert(*iter);
- }
- return notifications;
-}
-
-NotificationList::Notifications NotificationList::GetNotificationsByExtension(
- const std::string& id) {
- Notifications notifications;
- Notifications::iterator source_iter = GetNotification(id);
- if (source_iter == notifications_.end())
- return notifications;
-
- std::string extension_id = (*source_iter)->extension_id();
for (Notifications::iterator iter = notifications_.begin();
iter != notifications_.end(); ++iter) {
- if ((*iter)->extension_id() == extension_id)
+ if ((*iter)->notifier_id() == notifier_id)
notifications.insert(*iter);
}
return notifications;
diff --git a/ui/message_center/notification_list.h b/ui/message_center/notification_list.h
index ce24498..b1a3bb7 100644
--- a/ui/message_center/notification_list.h
+++ b/ui/message_center/notification_list.h
@@ -67,8 +67,7 @@ class MESSAGE_CENTER_EXPORT NotificationList {
void RemoveAllNotifications();
- Notifications GetNotificationsBySource(const std::string& id);
- Notifications GetNotificationsByExtension(const std::string& id);
+ Notifications GetNotificationsByNotifierId(const NotifierId& notifier_id);
// Returns true if the notification exists and was updated.
bool SetNotificationIcon(const std::string& notification_id,
diff --git a/ui/message_center/notification_list_unittest.cc b/ui/message_center/notification_list_unittest.cc
index cdd6ad4..8195d0a 100644
--- a/ui/message_center/notification_list_unittest.cc
+++ b/ui/message_center/notification_list_unittest.cc
@@ -40,7 +40,7 @@ class NotificationListTest : public testing::Test {
UTF8ToUTF16(base::StringPrintf(kMessageFormat, counter_)),
gfx::Image(),
UTF8ToUTF16(kDisplaySource),
- kExtensionId,
+ NotifierId(NotifierId::APPLICATION, kExtensionId),
optional_fields,
NULL));
notification_list_->AddNotification(notification.Pass());
@@ -172,7 +172,7 @@ TEST_F(NotificationListTest, UpdateNotification) {
UTF8ToUTF16("newbody"),
gfx::Image(),
UTF8ToUTF16(kDisplaySource),
- kExtensionId,
+ NotifierId(NotifierId::APPLICATION, kExtensionId),
message_center::RichNotificationData(),
NULL));
notification_list()->UpdateNotificationMessage(id0, notification.Pass());
@@ -184,7 +184,11 @@ TEST_F(NotificationListTest, UpdateNotification) {
EXPECT_EQ(UTF8ToUTF16("newbody"), (*notifications.begin())->message());
}
-TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) {
+TEST_F(NotificationListTest, GetNotificationsByNotifierId) {
+ NotifierId id0(NotifierId::APPLICATION, "ext0");
+ NotifierId id1(NotifierId::APPLICATION, "ext1");
+ NotifierId id2(GURL("http://example.com"));
+ NotifierId id3(0);
scoped_ptr<Notification> notification(
new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
"id0",
@@ -192,7 +196,7 @@ TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) {
UTF8ToUTF16("message0"),
gfx::Image(),
UTF8ToUTF16("source0"),
- "ext0",
+ id0,
message_center::RichNotificationData(),
NULL));
notification_list()->AddNotification(notification.Pass());
@@ -202,7 +206,7 @@ TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) {
UTF8ToUTF16("message1"),
gfx::Image(),
UTF8ToUTF16("source0"),
- "ext0",
+ id0,
message_center::RichNotificationData(),
NULL));
notification_list()->AddNotification(notification.Pass());
@@ -212,7 +216,7 @@ TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) {
UTF8ToUTF16("message1"),
gfx::Image(),
UTF8ToUTF16("source1"),
- "ext0",
+ id0,
message_center::RichNotificationData(),
NULL));
notification_list()->AddNotification(notification.Pass());
@@ -222,24 +226,63 @@ TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) {
UTF8ToUTF16("message1"),
gfx::Image(),
UTF8ToUTF16("source2"),
- "ext1",
+ id1,
+ message_center::RichNotificationData(),
+ NULL));
+ notification_list()->AddNotification(notification.Pass());
+ notification.reset(new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
+ "id4",
+ UTF8ToUTF16("title1"),
+ UTF8ToUTF16("message1"),
+ gfx::Image(),
+ UTF8ToUTF16("source2"),
+ id2,
+ message_center::RichNotificationData(),
+ NULL));
+ notification_list()->AddNotification(notification.Pass());
+ notification.reset(new Notification(message_center::NOTIFICATION_TYPE_SIMPLE,
+ "id5",
+ UTF8ToUTF16("title1"),
+ UTF8ToUTF16("message1"),
+ gfx::Image(),
+ UTF8ToUTF16("source2"),
+ id3,
message_center::RichNotificationData(),
NULL));
notification_list()->AddNotification(notification.Pass());
- NotificationList::Notifications by_source =
- notification_list()->GetNotificationsBySource("id0");
- EXPECT_TRUE(IsInNotifications(by_source, "id0"));
- EXPECT_TRUE(IsInNotifications(by_source, "id1"));
- EXPECT_FALSE(IsInNotifications(by_source, "id2"));
- EXPECT_FALSE(IsInNotifications(by_source, "id3"));
-
- NotificationList::Notifications by_extension =
- notification_list()->GetNotificationsByExtension("id0");
- EXPECT_TRUE(IsInNotifications(by_extension, "id0"));
- EXPECT_TRUE(IsInNotifications(by_extension, "id1"));
- EXPECT_TRUE(IsInNotifications(by_extension, "id2"));
- EXPECT_FALSE(IsInNotifications(by_extension, "id3"));
+ NotificationList::Notifications by_notifier_id =
+ notification_list()->GetNotificationsByNotifierId(id0);
+ EXPECT_TRUE(IsInNotifications(by_notifier_id, "id0"));
+ EXPECT_TRUE(IsInNotifications(by_notifier_id, "id1"));
+ EXPECT_TRUE(IsInNotifications(by_notifier_id, "id2"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id3"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id4"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id5"));
+
+ by_notifier_id = notification_list()->GetNotificationsByNotifierId(id1);
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id0"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id1"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id2"));
+ EXPECT_TRUE(IsInNotifications(by_notifier_id, "id3"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id4"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id5"));
+
+ by_notifier_id = notification_list()->GetNotificationsByNotifierId(id2);
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id0"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id1"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id2"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id3"));
+ EXPECT_TRUE(IsInNotifications(by_notifier_id, "id4"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id5"));
+
+ by_notifier_id = notification_list()->GetNotificationsByNotifierId(id3);
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id0"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id1"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id2"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id3"));
+ EXPECT_FALSE(IsInNotifications(by_notifier_id, "id4"));
+ EXPECT_TRUE(IsInNotifications(by_notifier_id, "id5"));
}
TEST_F(NotificationListTest, OldPopupShouldNotBeHidden) {
@@ -355,7 +398,7 @@ TEST_F(NotificationListTest, PriorityPromotion) {
UTF8ToUTF16("newbody"),
gfx::Image(),
UTF8ToUTF16(kDisplaySource),
- kExtensionId,
+ NotifierId(NotifierId::APPLICATION, kExtensionId),
optional,
NULL));
notification_list()->UpdateNotificationMessage(id0, notification.Pass());
@@ -386,7 +429,7 @@ TEST_F(NotificationListTest, PriorityPromotionWithPopups) {
UTF8ToUTF16("newbody"),
gfx::Image(),
UTF8ToUTF16(kDisplaySource),
- kExtensionId,
+ NotifierId(NotifierId::APPLICATION, kExtensionId),
priority,
NULL));
notification_list()->UpdateNotificationMessage(id0, notification.Pass());
@@ -401,7 +444,8 @@ TEST_F(NotificationListTest, PriorityPromotionWithPopups) {
UTF8ToUTF16("newbody2"),
gfx::Image(),
UTF8ToUTF16(kDisplaySource),
- kExtensionId,
+ NotifierId(NotifierId::APPLICATION,
+ kExtensionId),
priority,
NULL));
notification_list()->UpdateNotificationMessage(id0, notification.Pass());
@@ -415,7 +459,8 @@ TEST_F(NotificationListTest, PriorityPromotionWithPopups) {
UTF8ToUTF16("newbody"),
gfx::Image(),
UTF8ToUTF16(kDisplaySource),
- kExtensionId,
+ NotifierId(NotifierId::APPLICATION,
+ kExtensionId),
priority,
NULL));
notification_list()->UpdateNotificationMessage(id1, notification.Pass());
@@ -431,7 +476,8 @@ TEST_F(NotificationListTest, PriorityPromotionWithPopups) {
UTF8ToUTF16("newbody2"),
gfx::Image(),
UTF8ToUTF16(kDisplaySource),
- kExtensionId,
+ NotifierId(NotifierId::APPLICATION,
+ kExtensionId),
priority,
NULL));
notification_list()->UpdateNotificationMessage(id1, notification.Pass());
@@ -447,7 +493,8 @@ TEST_F(NotificationListTest, PriorityPromotionWithPopups) {
UTF8ToUTF16("newbody3"),
gfx::Image(),
UTF8ToUTF16(kDisplaySource),
- kExtensionId,
+ NotifierId(NotifierId::APPLICATION,
+ kExtensionId),
priority,
NULL));
notification_list()->UpdateNotificationMessage(id1, notification.Pass());
@@ -588,7 +635,7 @@ TEST_F(NotificationListTest, UpdateAfterMarkedAsShown) {
UTF8ToUTF16("newbody"),
gfx::Image(),
UTF8ToUTF16(kDisplaySource),
- kExtensionId,
+ NotifierId(NotifierId::APPLICATION, kExtensionId),
message_center::RichNotificationData(),
NULL));
notification_list()->UpdateNotificationMessage(id1, notification.Pass());
@@ -634,7 +681,7 @@ TEST_F(NotificationListTest, UnreadCountNoNegative) {
UTF8ToUTF16("updated"),
gfx::Image(),
base::string16(),
- std::string(),
+ NotifierId(),
RichNotificationData(),
NULL));
notification_list()->AddNotification(updated_notification.Pass());
diff --git a/ui/message_center/notifier_settings.cc b/ui/message_center/notifier_settings.cc
index 4355b94..861e65b 100644
--- a/ui/message_center/notifier_settings.cc
+++ b/ui/message_center/notifier_settings.cc
@@ -11,15 +11,26 @@ NotifierId::NotifierId(NotifierType type,
const std::string& id)
: type(type),
id(id),
- system_component_type(NONE) {
+ system_component_type(-1) {
DCHECK(type == APPLICATION || type == SYNCED_NOTIFICATION_SERVICE);
+ DCHECK(!id.empty());
}
NotifierId::NotifierId(const GURL& url)
- : type(WEB_PAGE), url(url), system_component_type(NONE) {}
+ : type(WEB_PAGE),
+ url(url),
+ system_component_type(-1) {}
-NotifierId::NotifierId(SystemComponentNotifierType system_component_type)
- : type(SYSTEM_COMPONENT), system_component_type(system_component_type) {}
+NotifierId::NotifierId(int type)
+ : type(SYSTEM_COMPONENT),
+ system_component_type(type) {
+ DCHECK_LE(0, system_component_type);
+}
+
+NotifierId::NotifierId()
+ : type(SYSTEM_COMPONENT),
+ system_component_type(-1) {
+}
bool NotifierId::operator==(const NotifierId& other) const {
if (type != other.type)
@@ -58,23 +69,4 @@ NotifierGroup::NotifierGroup(const gfx::Image& icon,
NotifierGroup::~NotifierGroup() {}
-std::string ToString(NotifierId::SystemComponentNotifierType type) {
- switch (type) {
- case NotifierId::SCREENSHOT:
- return "screenshot";
- default:
- NOTREACHED();
- return "";
- }
-}
-
-NotifierId::SystemComponentNotifierType
-ParseSystemComponentName(const std::string& name) {
- if (name == "screenshot") {
- return NotifierId::SCREENSHOT;
- } else {
- NOTREACHED();
- return NotifierId::NONE;
- }
-}
} // namespace message_center
diff --git a/ui/message_center/notifier_settings.h b/ui/message_center/notifier_settings.h
index b8771a3..6188599 100644
--- a/ui/message_center/notifier_settings.h
+++ b/ui/message_center/notifier_settings.h
@@ -33,19 +33,17 @@ struct MESSAGE_CENTER_EXPORT NotifierId {
SYNCED_NOTIFICATION_SERVICE,
};
- enum SystemComponentNotifierType {
- NONE,
- SCREENSHOT,
- };
-
// Constructor for APPLICATION and SYNCED_NOTIFICATION_SERVICE type.
NotifierId(NotifierType type, const std::string& id);
// Constructor for WEB_PAGE type.
explicit NotifierId(const GURL& url);
- // Constructor for SYSTEM_COMPONENT type.
- explicit NotifierId(SystemComponentNotifierType type);
+ // Constructor for system component types. The type should be positive.
+ explicit NotifierId(int type);
+
+ // The default constructor which doesn't specify the notifier. Used for tests.
+ NotifierId();
bool operator==(const NotifierId& other) const;
@@ -58,8 +56,9 @@ struct MESSAGE_CENTER_EXPORT NotifierId {
// The URL pattern of the notifer.
GURL url;
- // The type of system component notifier.
- SystemComponentNotifierType system_component_type;
+ // The type of system component notifier, usually used in ash. -1 if it's not
+ // the system component. See also: ash/system/system_notifier.h
+ int system_component_type;
};
// The struct to hold the information of notifiers. The information will be
@@ -108,11 +107,6 @@ struct MESSAGE_CENTER_EXPORT NotifierGroup {
DISALLOW_COPY_AND_ASSIGN(NotifierGroup);
};
-MESSAGE_CENTER_EXPORT std::string ToString(
- NotifierId::SystemComponentNotifierType type);
-MESSAGE_CENTER_EXPORT NotifierId::SystemComponentNotifierType
- ParseSystemComponentName(const std::string& name);
-
// An observer class implemented by the view of the NotifierSettings to get
// notified when the controller has changed data.
class MESSAGE_CENTER_EXPORT NotifierSettingsObserver {
diff --git a/ui/message_center/views/message_center_view_unittest.cc b/ui/message_center/views/message_center_view_unittest.cc
index f6e05f4..b9e34a1 100644
--- a/ui/message_center/views/message_center_view_unittest.cc
+++ b/ui/message_center/views/message_center_view_unittest.cc
@@ -133,7 +133,7 @@ void MessageCenterViewTest::SetUp() {
UTF8ToUTF16("message"),
gfx::Image(),
UTF8ToUTF16("display source"),
- std::string("extension id"),
+ NotifierId(NotifierId::APPLICATION, "extension_id"),
message_center::RichNotificationData(),
NULL);
diff --git a/ui/message_center/views/message_popup_collection_unittest.cc b/ui/message_center/views/message_popup_collection_unittest.cc
index 942c09d..f431997 100644
--- a/ui/message_center/views/message_popup_collection_unittest.cc
+++ b/ui/message_center/views/message_popup_collection_unittest.cc
@@ -83,7 +83,7 @@ class MessagePopupCollectionTest : public views::ViewsTestBase {
UTF8ToUTF16("test message"),
gfx::Image(),
string16() /* display_source */,
- "" /* extension_id */,
+ NotifierId(),
message_center::RichNotificationData(),
NULL /* delegate */));
MessageCenter::Get()->AddNotification(notification.Pass());
diff --git a/ui/message_center/views/message_view.cc b/ui/message_center/views/message_view.cc
index 7eb9838..93a5dd3 100644
--- a/ui/message_center/views/message_view.cc
+++ b/ui/message_center/views/message_view.cc
@@ -35,8 +35,7 @@ const int kShadowBlur = 4;
// Menu constants
const int kTogglePermissionCommand = 0;
-const int kToggleExtensionCommand = 1;
-const int kShowSettingsCommand = 2;
+const int kShowSettingsCommand = 1;
// ControlButtons are ImageButtons whose image can be padded within the button.
// This allows the creation of buttons like the notification close and expand
@@ -170,7 +169,7 @@ class MenuModel : public ui::SimpleMenuModel,
message_center::MessageCenterTray* tray,
const std::string& notification_id,
const string16& display_source,
- const std::string& extension_id);
+ const message_center::NotifierId& notifier_id);
virtual ~MenuModel();
// Overridden from ui::SimpleMenuModel::Delegate:
@@ -186,6 +185,7 @@ class MenuModel : public ui::SimpleMenuModel,
message_center::MessageCenter* message_center_; // Weak reference.
message_center::MessageCenterTray* tray_; // Weak reference.
std::string notification_id_;
+ message_center::NotifierId notifier_id_;
DISALLOW_COPY_AND_ASSIGN(MenuModel);
};
@@ -194,19 +194,16 @@ MenuModel::MenuModel(message_center::MessageCenter* message_center,
message_center::MessageCenterTray* tray,
const std::string& notification_id,
const string16& display_source,
- const std::string& extension_id)
+ const message_center::NotifierId& notifier_id)
: ui::SimpleMenuModel(this),
message_center_(message_center),
tray_(tray),
- notification_id_(notification_id) {
+ notification_id_(notification_id),
+ notifier_id_(notifier_id) {
// Add 'disable notifications' menu item.
- if (!extension_id.empty() && !display_source.empty()) {
- AddItem(kToggleExtensionCommand,
- l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_EXTENSIONS_DISABLE,
- display_source));
- } else if (!display_source.empty()) {
+ if (!display_source.empty()) {
AddItem(kTogglePermissionCommand,
- l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_SITE_DISABLE,
+ l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_NOTIFIER_DISABLE,
display_source));
}
// Add settings menu item.
@@ -236,11 +233,8 @@ bool MenuModel::GetAcceleratorForCommandId(int command_id,
void MenuModel::ExecuteCommand(int command_id, int event_flags) {
switch (command_id) {
- case kToggleExtensionCommand:
- message_center_->DisableNotificationsByExtension(notification_id_);
- break;
case kTogglePermissionCommand:
- message_center_->DisableNotificationsByUrl(notification_id_);
+ message_center_->DisableNotificationsByNotifier(notifier_id_);
break;
case kShowSettingsCommand:
// |tray_| may be NULL in tests.
@@ -276,7 +270,7 @@ class MessageViewContextMenuController : public views::ContextMenuController {
MessageCenterTray* tray_; // Weak reference.
std::string notification_id_;
string16 display_source_;
- std::string extension_id_;
+ NotifierId notifier_id_;
};
MessageViewContextMenuController::MessageViewContextMenuController(
@@ -287,7 +281,7 @@ MessageViewContextMenuController::MessageViewContextMenuController(
tray_(tray),
notification_id_(notification.id()),
display_source_(notification.display_source()),
- extension_id_(notification.extension_id()) {
+ notifier_id_(notification.notifier_id()) {
}
MessageViewContextMenuController::~MessageViewContextMenuController() {
@@ -298,7 +292,7 @@ void MessageViewContextMenuController::ShowContextMenuForView(
const gfx::Point& point,
ui::MenuSourceType source_type) {
MenuModel menu_model(message_center_, tray_, notification_id_,
- display_source_, extension_id_);
+ display_source_, notifier_id_);
if (menu_model.GetItemCount() == 0)
return;