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

Side by Side Diff: chrome/browser/notifications/platform_notification_service_impl.cc

Issue 2392343002: Plumbing in notification replies: PlatformNotificationService -> SW (Closed)
Patch Set: Remove todo as it doesn't seem necessary after all Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/notifications/platform_notification_service_impl.h" 5 #include "chrome/browser/notifications/platform_notification_service_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "base/metrics/user_metrics_action.h" 11 #include "base/metrics/user_metrics_action.h"
12 #include "base/strings/nullable_string16.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 14 #include "build/build_config.h"
14 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
16 #include "chrome/browser/notifications/notification_display_service_factory.h" 17 #include "chrome/browser/notifications/notification_display_service_factory.h"
17 #include "chrome/browser/notifications/notification_object_proxy.h" 18 #include "chrome/browser/notifications/notification_object_proxy.h"
18 #include "chrome/browser/notifications/persistent_notification_delegate.h" 19 #include "chrome/browser/notifications/persistent_notification_delegate.h"
19 #include "chrome/browser/permissions/permission_manager.h" 20 #include "chrome/browser/permissions/permission_manager.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_attributes_storage.h" 22 #include "chrome/browser/profiles/profile_attributes_storage.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 pending_click_dispatch_events_ = 0; 101 pending_click_dispatch_events_ = 0;
101 #endif 102 #endif
102 } 103 }
103 104
104 PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {} 105 PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {}
105 106
106 void PlatformNotificationServiceImpl::OnPersistentNotificationClick( 107 void PlatformNotificationServiceImpl::OnPersistentNotificationClick(
107 BrowserContext* browser_context, 108 BrowserContext* browser_context,
108 const std::string& notification_id, 109 const std::string& notification_id,
109 const GURL& origin, 110 const GURL& origin,
110 int action_index) { 111 int action_index,
112 const base::NullableString16& reply) {
111 DCHECK_CURRENTLY_ON(BrowserThread::UI); 113 DCHECK_CURRENTLY_ON(BrowserThread::UI);
112 blink::mojom::PermissionStatus permission_status = 114 blink::mojom::PermissionStatus permission_status =
113 CheckPermissionOnUIThread(browser_context, origin, 115 CheckPermissionOnUIThread(browser_context, origin,
114 kInvalidRenderProcessId); 116 kInvalidRenderProcessId);
115 117
116 // TODO(peter): Change this to a CHECK() when Issue 555572 is resolved. 118 // TODO(peter): Change this to a CHECK() when Issue 555572 is resolved.
117 // Also change this method to be const again. 119 // Also change this method to be const again.
118 if (permission_status != blink::mojom::PermissionStatus::GRANTED) { 120 if (permission_status != blink::mojom::PermissionStatus::GRANTED) {
119 content::RecordAction(base::UserMetricsAction( 121 content::RecordAction(base::UserMetricsAction(
120 "Notifications.Persistent.ClickedWithoutPermission")); 122 "Notifications.Persistent.ClickedWithoutPermission"));
(...skipping 12 matching lines...) Expand all
133 // Ensure the browser stays alive while the event is processed. 135 // Ensure the browser stays alive while the event is processed.
134 if (pending_click_dispatch_events_++ == 0) { 136 if (pending_click_dispatch_events_++ == 0) {
135 click_dispatch_keep_alive_.reset( 137 click_dispatch_keep_alive_.reset(
136 new ScopedKeepAlive(KeepAliveOrigin::PENDING_NOTIFICATION_CLICK_EVENT, 138 new ScopedKeepAlive(KeepAliveOrigin::PENDING_NOTIFICATION_CLICK_EVENT,
137 KeepAliveRestartOption::DISABLED)); 139 KeepAliveRestartOption::DISABLED));
138 } 140 }
139 #endif 141 #endif
140 142
141 content::NotificationEventDispatcher::GetInstance() 143 content::NotificationEventDispatcher::GetInstance()
142 ->DispatchNotificationClickEvent( 144 ->DispatchNotificationClickEvent(
143 browser_context, notification_id, origin, action_index, 145 browser_context, notification_id, origin, action_index, reply,
144 base::Bind( 146 base::Bind(
145 &PlatformNotificationServiceImpl::OnClickEventDispatchComplete, 147 &PlatformNotificationServiceImpl::OnClickEventDispatchComplete,
146 base::Unretained(this))); 148 base::Unretained(this)));
147 } 149 }
148 150
149 void PlatformNotificationServiceImpl::OnPersistentNotificationClose( 151 void PlatformNotificationServiceImpl::OnPersistentNotificationClose(
150 BrowserContext* browser_context, 152 BrowserContext* browser_context,
151 const std::string& notification_id, 153 const std::string& notification_id,
152 const GURL& origin, 154 const GURL& origin,
153 bool by_user) { 155 bool by_user) {
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 } 497 }
496 #endif 498 #endif
497 499
498 return base::string16(); 500 return base::string16();
499 } 501 }
500 502
501 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( 503 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting(
502 NotificationDisplayService* display_service) { 504 NotificationDisplayService* display_service) {
503 test_display_service_ = display_service; 505 test_display_service_ = display_service;
504 } 506 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698