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

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

Issue 1011953003: Refactor Permissions related method out of ContentBrowserClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission_type_enum_class
Patch Set: fix cros Created 5 years, 8 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/navigator_connect_context.h" 9 #include "content/public/browser/navigator_connect_context.h"
10 #include "content/public/browser/permission_type.h"
11 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
12 #include "content/public/browser/storage_partition.h" 11 #include "content/public/browser/storage_partition.h"
13 #include "content/shell/browser/layout_test/layout_test_browser_context.h" 12 #include "content/shell/browser/layout_test/layout_test_browser_context.h"
14 #include "content/shell/browser/layout_test/layout_test_message_filter.h" 13 #include "content/shell/browser/layout_test/layout_test_message_filter.h"
15 #include "content/shell/browser/layout_test/layout_test_navigator_connect_servic e_factory.h" 14 #include "content/shell/browser/layout_test/layout_test_navigator_connect_servic e_factory.h"
16 #include "content/shell/browser/layout_test/layout_test_notification_manager.h" 15 #include "content/shell/browser/layout_test/layout_test_notification_manager.h"
17 #include "content/shell/browser/shell_browser_context.h" 16 #include "content/shell/browser/shell_browser_context.h"
18 #include "content/shell/common/shell_messages.h" 17 #include "content/shell/common/shell_messages.h"
19 #include "content/shell/common/webkit_test_helpers.h" 18 #include "content/shell/common/webkit_test_helpers.h"
20 19
21 namespace content { 20 namespace content {
22 namespace { 21 namespace {
23 22
24 LayoutTestContentBrowserClient* g_layout_test_browser_client; 23 LayoutTestContentBrowserClient* g_layout_test_browser_client;
25 24
26 void RequestDesktopNotificationPermissionOnIO(
27 const GURL& source_origin,
28 const base::Callback<void(PermissionStatus)>& callback) {
29 LayoutTestNotificationManager* manager =
30 LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager();
31 PermissionStatus result = manager ? manager->RequestPermission(source_origin)
32 : PERMISSION_STATUS_GRANTED;
33
34 // The callback came from the UI thread, we need to run it from there again.
35 BrowserThread::PostTask(
36 BrowserThread::UI,
37 FROM_HERE,
38 base::Bind(callback, result));
39 }
40
41 } // namespace 25 } // namespace
42 26
43 LayoutTestContentBrowserClient::LayoutTestContentBrowserClient() { 27 LayoutTestContentBrowserClient::LayoutTestContentBrowserClient() {
44 DCHECK(!g_layout_test_browser_client); 28 DCHECK(!g_layout_test_browser_client);
45 29
46 layout_test_notification_manager_.reset(new LayoutTestNotificationManager()); 30 layout_test_notification_manager_.reset(new LayoutTestNotificationManager());
47 31
48 g_layout_test_browser_client = this; 32 g_layout_test_browser_client = this;
49 } 33 }
50 34
(...skipping 23 matching lines...) Expand all
74 BrowserContext::GetDefaultStoragePartition(browser_context()); 58 BrowserContext::GetDefaultStoragePartition(browser_context());
75 host->AddFilter(new LayoutTestMessageFilter( 59 host->AddFilter(new LayoutTestMessageFilter(
76 host->GetID(), 60 host->GetID(),
77 partition->GetDatabaseTracker(), 61 partition->GetDatabaseTracker(),
78 partition->GetQuotaManager(), 62 partition->GetQuotaManager(),
79 partition->GetURLRequestContext())); 63 partition->GetURLRequestContext()));
80 64
81 host->Send(new ShellViewMsg_SetWebKitSourceDir(GetWebKitRootDirFilePath())); 65 host->Send(new ShellViewMsg_SetWebKitSourceDir(GetWebKitRootDirFilePath()));
82 } 66 }
83 67
84 void LayoutTestContentBrowserClient::RequestPermission(
85 PermissionType permission,
86 WebContents* web_contents,
87 int bridge_id,
88 const GURL& requesting_frame,
89 bool user_gesture,
90 const base::Callback<void(PermissionStatus)>& callback) {
91 DCHECK_CURRENTLY_ON(BrowserThread::UI);
92 if (permission == PermissionType::NOTIFICATIONS) {
93 BrowserThread::PostTask(
94 BrowserThread::IO,
95 FROM_HERE,
96 base::Bind(&RequestDesktopNotificationPermissionOnIO,
97 requesting_frame,
98 callback));
99 return;
100 }
101 ShellContentBrowserClient::RequestPermission(permission,
102 web_contents,
103 bridge_id,
104 requesting_frame,
105 user_gesture,
106 callback);
107 }
108
109 PlatformNotificationService* 68 PlatformNotificationService*
110 LayoutTestContentBrowserClient::GetPlatformNotificationService() { 69 LayoutTestContentBrowserClient::GetPlatformNotificationService() {
111 return layout_test_notification_manager_.get(); 70 return layout_test_notification_manager_.get();
112 } 71 }
113 72
114 void LayoutTestContentBrowserClient::GetAdditionalNavigatorConnectServices( 73 void LayoutTestContentBrowserClient::GetAdditionalNavigatorConnectServices(
115 const scoped_refptr<NavigatorConnectContext>& context) { 74 const scoped_refptr<NavigatorConnectContext>& context) {
116 context->AddFactory( 75 context->AddFactory(
117 make_scoped_ptr(new LayoutTestNavigatorConnectServiceFactory)); 76 make_scoped_ptr(new LayoutTestNavigatorConnectServiceFactory));
118 } 77 }
119 78
120 } // namespace content 79 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698