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

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: TestRunnerBindings::SimulateWebNotificationClick throws for non int index 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): Implement this.
117 CHECK(action_index < 0) << "Simulating action clicks for page notifications"
118 << " is not yet implemented";
115 page_iterator->second->NotificationClick(); 119 page_iterator->second->NotificationClick();
116 return; 120 return;
117 } 121 }
118 122
119 // Then check for persistent notifications with the given title. 123 // Then check for persistent notifications with the given title.
120 const auto& persistent_iterator = persistent_notifications_.find(title); 124 const auto& persistent_iterator = persistent_notifications_.find(title);
121 if (persistent_iterator == persistent_notifications_.end()) 125 if (persistent_iterator == persistent_notifications_.end())
122 return; 126 return;
123 127
124 const PersistentNotification& notification = persistent_iterator->second; 128 const PersistentNotification& notification = persistent_iterator->second;
125 content::NotificationEventDispatcher::GetInstance() 129 content::NotificationEventDispatcher::GetInstance()
126 ->DispatchNotificationClickEvent( 130 ->DispatchNotificationClickEvent(
127 notification.browser_context, 131 notification.browser_context,
128 notification.persistent_id, 132 notification.persistent_id,
129 notification.origin, 133 notification.origin,
130 -1 /* action_index */, 134 action_index,
131 base::Bind(&OnEventDispatchComplete)); 135 base::Bind(&OnEventDispatchComplete));
132 } 136 }
133 137
134 blink::WebNotificationPermission 138 blink::WebNotificationPermission
135 LayoutTestNotificationManager::CheckPermissionOnUIThread( 139 LayoutTestNotificationManager::CheckPermissionOnUIThread(
136 BrowserContext* browser_context, 140 BrowserContext* browser_context,
137 const GURL& origin, 141 const GURL& origin,
138 int render_process_id) { 142 int render_process_id) {
139 DCHECK_CURRENTLY_ON(BrowserThread::UI); 143 DCHECK_CURRENTLY_ON(BrowserThread::UI);
140 return CheckPermission(origin); 144 return CheckPermission(origin);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 LayoutTestNotificationManager::CheckPermission(const GURL& origin) { 197 LayoutTestNotificationManager::CheckPermission(const GURL& origin) {
194 return ToWebNotificationPermission(LayoutTestContentBrowserClient::Get() 198 return ToWebNotificationPermission(LayoutTestContentBrowserClient::Get()
195 ->GetLayoutTestBrowserContext() 199 ->GetLayoutTestBrowserContext()
196 ->GetLayoutTestPermissionManager() 200 ->GetLayoutTestPermissionManager()
197 ->GetPermissionStatus(PermissionType::NOTIFICATIONS, 201 ->GetPermissionStatus(PermissionType::NOTIFICATIONS,
198 origin, 202 origin,
199 origin)); 203 origin));
200 } 204 }
201 205
202 } // namespace content 206 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698