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

Side by Side Diff: content/shell/browser/layout_test/layout_test_notification_manager.cc

Issue 1262893006: Enable testing NotificationEvent.action (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@click_actions
Patch Set: Remove check Created 5 years, 4 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 "content/shell/browser/layout_test/layout_test_notification_manager.h" 5 #include "content/shell/browser/layout_test/layout_test_notification_manager.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/desktop_notification_delegate.h" 10 #include "content/public/browser/desktop_notification_delegate.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 bool LayoutTestNotificationManager::GetDisplayedPersistentNotifications( 100 bool LayoutTestNotificationManager::GetDisplayedPersistentNotifications(
101 BrowserContext* browser_context, 101 BrowserContext* browser_context,
102 std::set<std::string>* displayed_notifications) { 102 std::set<std::string>* displayed_notifications) {
103 DCHECK(displayed_notifications); 103 DCHECK(displayed_notifications);
104 104
105 // Notifications will never outlive the lifetime of running layout tests. 105 // Notifications will never outlive the lifetime of running layout tests.
106 return false; 106 return false;
107 } 107 }
108 108
109 void LayoutTestNotificationManager::SimulateClick(const std::string& title) { 109 void LayoutTestNotificationManager::SimulateClick(const std::string& title,
110 int action_index) {
110 DCHECK_CURRENTLY_ON(BrowserThread::UI); 111 DCHECK_CURRENTLY_ON(BrowserThread::UI);
111 112
112 // First check for page-notifications with the given title. 113 // First check for page-notifications with the given title.
113 const auto& page_iterator = page_notifications_.find(title); 114 const auto& page_iterator = page_notifications_.find(title);
114 if (page_iterator != page_notifications_.end()) { 115 if (page_iterator != page_notifications_.end()) {
116 // TODO(johnme): Pass action_index once it's supported.
115 page_iterator->second->NotificationClick(); 117 page_iterator->second->NotificationClick();
116 return; 118 return;
117 } 119 }
118 120
119 // Then check for persistent notifications with the given title. 121 // Then check for persistent notifications with the given title.
120 const auto& persistent_iterator = persistent_notifications_.find(title); 122 const auto& persistent_iterator = persistent_notifications_.find(title);
121 if (persistent_iterator == persistent_notifications_.end()) 123 if (persistent_iterator == persistent_notifications_.end())
122 return; 124 return;
123 125
124 const PersistentNotification& notification = persistent_iterator->second; 126 const PersistentNotification& notification = persistent_iterator->second;
125 content::NotificationEventDispatcher::GetInstance() 127 content::NotificationEventDispatcher::GetInstance()
126 ->DispatchNotificationClickEvent( 128 ->DispatchNotificationClickEvent(
127 notification.browser_context, 129 notification.browser_context,
128 notification.persistent_id, 130 notification.persistent_id,
129 notification.origin, 131 notification.origin,
130 -1 /* action_index */, 132 action_index,
131 base::Bind(&OnEventDispatchComplete)); 133 base::Bind(&OnEventDispatchComplete));
132 } 134 }
133 135
134 blink::WebNotificationPermission 136 blink::WebNotificationPermission
135 LayoutTestNotificationManager::CheckPermissionOnUIThread( 137 LayoutTestNotificationManager::CheckPermissionOnUIThread(
136 BrowserContext* browser_context, 138 BrowserContext* browser_context,
137 const GURL& origin, 139 const GURL& origin,
138 int render_process_id) { 140 int render_process_id) {
139 DCHECK_CURRENTLY_ON(BrowserThread::UI); 141 DCHECK_CURRENTLY_ON(BrowserThread::UI);
140 return CheckPermission(origin); 142 return CheckPermission(origin);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 LayoutTestNotificationManager::CheckPermission(const GURL& origin) { 195 LayoutTestNotificationManager::CheckPermission(const GURL& origin) {
194 return ToWebNotificationPermission(LayoutTestContentBrowserClient::Get() 196 return ToWebNotificationPermission(LayoutTestContentBrowserClient::Get()
195 ->GetLayoutTestBrowserContext() 197 ->GetLayoutTestBrowserContext()
196 ->GetLayoutTestPermissionManager() 198 ->GetLayoutTestPermissionManager()
197 ->GetPermissionStatus(PermissionType::NOTIFICATIONS, 199 ->GetPermissionStatus(PermissionType::NOTIFICATIONS,
198 origin, 200 origin,
199 origin)); 201 origin));
200 } 202 }
201 203
202 } // namespace content 204 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698