| Index: chrome/browser/notifications/platform_notification_service_impl.cc
|
| diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc
|
| index e8a668d30dfa1c77c4041830b5fcf9f3aca3ab3b..e22e04e126a5cc039b7c6f4956f0c1b88393977d 100644
|
| --- a/chrome/browser/notifications/platform_notification_service_impl.cc
|
| +++ b/chrome/browser/notifications/platform_notification_service_impl.cc
|
| @@ -25,8 +25,6 @@
|
| #include "chrome/browser/profiles/profile_io_data.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/ui/browser.h"
|
| -#include "chrome/browser/ui/chrome_pages.h"
|
| -#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/grit/generated_resources.h"
|
| @@ -83,40 +81,7 @@ void OnCloseNonPersistentNotificationProfileLoaded(
|
| const std::string& notification_id,
|
| Profile* profile) {
|
| NotificationDisplayServiceFactory::GetForProfile(profile)->Close(
|
| - notification_id);
|
| -}
|
| -
|
| -// Callback to run once the profile has been loaded in order to perform a
|
| -// given |operation| in a notification.
|
| -void ProfileLoadedCallback(
|
| - PlatformNotificationServiceImpl::NotificationOperation operation,
|
| - const GURL& origin,
|
| - int64_t persistent_notification_id,
|
| - int action_index,
|
| - Profile* profile) {
|
| - if (!profile) {
|
| - // TODO(miguelg): Add UMA for this condition.
|
| - // Perhaps propagate this through PersistentNotificationStatus.
|
| - LOG(WARNING) << "Profile not loaded correctly";
|
| - return;
|
| - }
|
| -
|
| - switch (operation) {
|
| - case PlatformNotificationServiceImpl::NOTIFICATION_CLICK:
|
| - PlatformNotificationServiceImpl::GetInstance()
|
| - ->OnPersistentNotificationClick(profile, persistent_notification_id,
|
| - origin, action_index);
|
| - break;
|
| - case PlatformNotificationServiceImpl::NOTIFICATION_CLOSE:
|
| - PlatformNotificationServiceImpl::GetInstance()
|
| - ->OnPersistentNotificationClose(profile, persistent_notification_id,
|
| - origin, true);
|
| - break;
|
| - case PlatformNotificationServiceImpl::NOTIFICATION_SETTINGS:
|
| - PlatformNotificationServiceImpl::GetInstance()->OpenNotificationSettings(
|
| - profile);
|
| - break;
|
| - }
|
| + notification_operation_common::INPAGE_NOTIFICATION, notification_id);
|
| }
|
|
|
| // Callback used to close an non-persistent notification from blink.
|
| @@ -148,22 +113,6 @@ PlatformNotificationServiceImpl::PlatformNotificationServiceImpl()
|
|
|
| PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {}
|
|
|
| -void PlatformNotificationServiceImpl::ProcessPersistentNotificationOperation(
|
| - NotificationOperation operation,
|
| - const std::string& profile_id,
|
| - bool incognito,
|
| - const GURL& origin,
|
| - int64_t persistent_notification_id,
|
| - int action_index) {
|
| - ProfileManager* profile_manager = g_browser_process->profile_manager();
|
| - DCHECK(profile_manager);
|
| -
|
| - profile_manager->LoadProfile(
|
| - profile_id, incognito,
|
| - base::Bind(&ProfileLoadedCallback, operation, origin,
|
| - persistent_notification_id, action_index));
|
| -}
|
| -
|
| void PlatformNotificationServiceImpl::OnPersistentNotificationClick(
|
| BrowserContext* browser_context,
|
| int64_t persistent_notification_id,
|
| @@ -341,8 +290,10 @@ void PlatformNotificationServiceImpl::DisplayNotification(
|
| new NotificationObjectProxy(browser_context, std::move(delegate));
|
| Notification notification = CreateNotificationFromData(
|
| profile, origin, notification_data, notification_resources, proxy);
|
| - GetNotificationDisplayService(profile)->Display(notification.delegate_id(),
|
| - notification);
|
| +
|
| + GetNotificationDisplayService(profile)->Display(
|
| + notification_operation_common::INPAGE_NOTIFICATION,
|
| + notification.delegate_id(), notification);
|
| if (cancel_callback) {
|
| #if defined(OS_WIN)
|
| std::string profile_id =
|
| @@ -385,6 +336,7 @@ void PlatformNotificationServiceImpl::DisplayPersistentNotification(
|
| persistent_notifications_[persistent_notification_id] = notification.id();
|
|
|
| GetNotificationDisplayService(profile)->Display(
|
| + notification_operation_common::PERSISTENT_NOTIFICATION,
|
| base::Int64ToString(delegate->persistent_notification_id()),
|
| notification);
|
| content::RecordAction(
|
| @@ -411,19 +363,19 @@ void PlatformNotificationServiceImpl::ClosePersistentNotification(
|
| GetNotificationDisplayService(profile)->SupportsNotificationCenter();
|
| #endif
|
|
|
| + auto iter = persistent_notifications_.find(persistent_notification_id);
|
| + if (iter == persistent_notifications_.end())
|
| + return;
|
| if (cancel_by_persistent_id) {
|
| // TODO(peter): Remove this conversion when the notification ids are being
|
| // generated by the caller of this method.
|
| GetNotificationDisplayService(profile)->Close(
|
| + notification_operation_common::PERSISTENT_NOTIFICATION,
|
| base::Int64ToString(persistent_notification_id));
|
| + } else {
|
| + GetNotificationDisplayService(profile)->Close(
|
| + notification_operation_common::PERSISTENT_NOTIFICATION, iter->second);
|
| }
|
| -
|
| - auto iter = persistent_notifications_.find(persistent_notification_id);
|
| - if (iter == persistent_notifications_.end())
|
| - return;
|
| -
|
| - GetNotificationDisplayService(profile)->Close(iter->second);
|
| -
|
| persistent_notifications_.erase(iter);
|
| }
|
|
|
| @@ -528,27 +480,6 @@ PlatformNotificationServiceImpl::GetNotificationDisplayService(
|
| return NotificationDisplayServiceFactory::GetForProfile(profile);
|
| }
|
|
|
| -void PlatformNotificationServiceImpl::OpenNotificationSettings(
|
| - BrowserContext* browser_context) {
|
| -#if defined(OS_ANDROID)
|
| - NOTIMPLEMENTED();
|
| -#else
|
| -
|
| - Profile* profile = Profile::FromBrowserContext(browser_context);
|
| - DCHECK(profile);
|
| -
|
| - if (switches::SettingsWindowEnabled()) {
|
| - chrome::ShowContentSettingsExceptionsInWindow(
|
| - profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
|
| - } else {
|
| - chrome::ScopedTabbedBrowserDisplayer browser_displayer(profile);
|
| - chrome::ShowContentSettingsExceptions(browser_displayer.browser(),
|
| - CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
|
| - }
|
| -
|
| -#endif // defined(OS_ANDROID)
|
| -}
|
| -
|
| base::string16 PlatformNotificationServiceImpl::DisplayNameForContextMessage(
|
| Profile* profile,
|
| const GURL& origin) const {
|
|
|