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

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

Issue 955383003: ContentBrowserClient::RequestPermission replies with PermissionStatus instead of bool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android geolocation breakage Created 5 years, 9 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_content_browser_client.h " 5 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h "
6 6
7 #include "content/public/browser/browser_context.h" 7 #include "content/public/browser/browser_context.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/render_process_host.h" 9 #include "content/public/browser/render_process_host.h"
10 #include "content/public/browser/storage_partition.h" 10 #include "content/public/browser/storage_partition.h"
11 #include "content/shell/browser/layout_test/layout_test_browser_context.h" 11 #include "content/shell/browser/layout_test/layout_test_browser_context.h"
12 #include "content/shell/browser/layout_test/layout_test_message_filter.h" 12 #include "content/shell/browser/layout_test/layout_test_message_filter.h"
13 #include "content/shell/browser/layout_test/layout_test_notification_manager.h" 13 #include "content/shell/browser/layout_test/layout_test_notification_manager.h"
14 #include "content/shell/browser/shell_browser_context.h" 14 #include "content/shell/browser/shell_browser_context.h"
15 #include "content/shell/common/shell_messages.h" 15 #include "content/shell/common/shell_messages.h"
16 #include "content/shell/common/webkit_test_helpers.h" 16 #include "content/shell/common/webkit_test_helpers.h"
17 17
18 namespace content { 18 namespace content {
19 namespace { 19 namespace {
20 20
21 LayoutTestContentBrowserClient* g_layout_test_browser_client; 21 LayoutTestContentBrowserClient* g_layout_test_browser_client;
22 22
23 void RequestDesktopNotificationPermissionOnIO( 23 void RequestDesktopNotificationPermissionOnIO(
24 const GURL& source_origin, 24 const GURL& source_origin,
25 const base::Callback<void(bool)>& callback) { 25 const base::Callback<void(PermissionStatus)>& callback) {
26 LayoutTestNotificationManager* manager = 26 LayoutTestNotificationManager* manager =
27 LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager(); 27 LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager();
28 bool allowed = manager ? manager->RequestPermission(source_origin) 28 bool allowed = manager ? manager->RequestPermission(source_origin)
29 : true; 29 : true;
30 30
31 // The callback came from the UI thread, we need to run it from there again. 31 // The callback came from the UI thread, we need to run it from there again.
32 BrowserThread::PostTask( 32 BrowserThread::PostTask(
33 BrowserThread::UI, 33 BrowserThread::UI,
34 FROM_HERE, 34 FROM_HERE,
35 base::Bind(callback, allowed)); 35 base::Bind(callback,
36 allowed ? PERMISSION_STATUS_GRANTED : PERMISSION_STATUS_ASK));
36 } 37 }
37 38
38 } // namespace 39 } // namespace
39 40
40 LayoutTestContentBrowserClient::LayoutTestContentBrowserClient() { 41 LayoutTestContentBrowserClient::LayoutTestContentBrowserClient() {
41 DCHECK(!g_layout_test_browser_client); 42 DCHECK(!g_layout_test_browser_client);
42 43
43 layout_test_notification_manager_.reset(new LayoutTestNotificationManager()); 44 layout_test_notification_manager_.reset(new LayoutTestNotificationManager());
44 45
45 g_layout_test_browser_client = this; 46 g_layout_test_browser_client = this;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 78
78 host->Send(new ShellViewMsg_SetWebKitSourceDir(GetWebKitRootDirFilePath())); 79 host->Send(new ShellViewMsg_SetWebKitSourceDir(GetWebKitRootDirFilePath()));
79 } 80 }
80 81
81 void LayoutTestContentBrowserClient::RequestPermission( 82 void LayoutTestContentBrowserClient::RequestPermission(
82 PermissionType permission, 83 PermissionType permission,
83 WebContents* web_contents, 84 WebContents* web_contents,
84 int bridge_id, 85 int bridge_id,
85 const GURL& requesting_frame, 86 const GURL& requesting_frame,
86 bool user_gesture, 87 bool user_gesture,
87 const base::Callback<void(bool)>& result_callback) { 88 const base::Callback<void(PermissionStatus)>& callback) {
88 DCHECK_CURRENTLY_ON(BrowserThread::UI); 89 DCHECK_CURRENTLY_ON(BrowserThread::UI);
89 if (permission == content::PERMISSION_NOTIFICATIONS) { 90 if (permission == content::PERMISSION_NOTIFICATIONS) {
90 BrowserThread::PostTask( 91 BrowserThread::PostTask(
91 BrowserThread::IO, 92 BrowserThread::IO,
92 FROM_HERE, 93 FROM_HERE,
93 base::Bind(&RequestDesktopNotificationPermissionOnIO, 94 base::Bind(&RequestDesktopNotificationPermissionOnIO,
94 requesting_frame, 95 requesting_frame,
95 result_callback)); 96 callback));
96 return; 97 return;
97 } 98 }
98 ShellContentBrowserClient::RequestPermission(permission, 99 ShellContentBrowserClient::RequestPermission(permission,
99 web_contents, 100 web_contents,
100 bridge_id, 101 bridge_id,
101 requesting_frame, 102 requesting_frame,
102 user_gesture, 103 user_gesture,
103 result_callback); 104 callback);
104 } 105 }
105 106
106 PlatformNotificationService* 107 PlatformNotificationService*
107 LayoutTestContentBrowserClient::GetPlatformNotificationService() { 108 LayoutTestContentBrowserClient::GetPlatformNotificationService() {
108 return layout_test_notification_manager_.get(); 109 return layout_test_notification_manager_.get();
109 } 110 }
110 111
111 } // namespace content 112 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698