OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shell_content_browser_client.h" | 5 #include "content/shell/browser/shell_content_browser_client.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
14 #include "content/public/browser/resource_dispatcher_host.h" | 14 #include "content/public/browser/resource_dispatcher_host.h" |
15 #include "content/public/browser/storage_partition.h" | 15 #include "content/public/browser/storage_partition.h" |
16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
17 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
18 #include "content/public/common/web_preferences.h" | 18 #include "content/public/common/web_preferences.h" |
19 #include "content/shell/browser/shell.h" | 19 #include "content/shell/browser/shell.h" |
20 #include "content/shell/browser/shell_browser_context.h" | 20 #include "content/shell/browser/shell_browser_context.h" |
21 #include "content/shell/browser/shell_browser_main_parts.h" | 21 #include "content/shell/browser/shell_browser_main_parts.h" |
22 #include "content/shell/browser/shell_devtools_delegate.h" | 22 #include "content/shell/browser/shell_devtools_delegate.h" |
23 #include "content/shell/browser/shell_message_filter.h" | 23 #include "content/shell/browser/shell_message_filter.h" |
24 #include "content/shell/browser/shell_net_log.h" | 24 #include "content/shell/browser/shell_net_log.h" |
25 #include "content/shell/browser/shell_notification_manager.h" | |
25 #include "content/shell/browser/shell_quota_permission_context.h" | 26 #include "content/shell/browser/shell_quota_permission_context.h" |
26 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" | 27 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" |
27 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" | 28 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" |
28 #include "content/shell/browser/webkit_test_controller.h" | 29 #include "content/shell/browser/webkit_test_controller.h" |
29 #include "content/shell/common/shell_messages.h" | 30 #include "content/shell/common/shell_messages.h" |
30 #include "content/shell/common/shell_switches.h" | 31 #include "content/shell/common/shell_switches.h" |
31 #include "content/shell/common/webkit_test_helpers.h" | 32 #include "content/shell/common/webkit_test_helpers.h" |
32 #include "content/shell/geolocation/shell_access_token_store.h" | 33 #include "content/shell/geolocation/shell_access_token_store.h" |
33 #include "net/url_request/url_request_context_getter.h" | 34 #include "net/url_request/url_request_context_getter.h" |
34 #include "url/gurl.h" | 35 #include "url/gurl.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 g_browser_client = this; | 131 g_browser_client = this; |
131 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 132 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
132 return; | 133 return; |
133 webkit_source_dir_ = GetWebKitRootDirFilePath(); | 134 webkit_source_dir_ = GetWebKitRootDirFilePath(); |
134 } | 135 } |
135 | 136 |
136 ShellContentBrowserClient::~ShellContentBrowserClient() { | 137 ShellContentBrowserClient::~ShellContentBrowserClient() { |
137 g_browser_client = NULL; | 138 g_browser_client = NULL; |
138 } | 139 } |
139 | 140 |
141 ShellNotificationManager* | |
142 ShellContentBrowserClient::GetShellNotificationManager() { | |
jochen (gone - plz use gerrit)
2014/07/17 09:29:45
add a DCHECK() that we're on the IO thread?
Peter Beverloo
2014/07/17 12:22:52
Ugh, fantastic. CBC::RequestDesktopNotificationPer
| |
143 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | |
144 return NULL; | |
145 | |
146 if (!shell_notification_manager_) | |
147 shell_notification_manager_.reset(new ShellNotificationManager()); | |
148 | |
149 return shell_notification_manager_.get(); | |
150 } | |
151 | |
140 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( | 152 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( |
141 const MainFunctionParams& parameters) { | 153 const MainFunctionParams& parameters) { |
142 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters); | 154 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters); |
143 return shell_browser_main_parts_; | 155 return shell_browser_main_parts_; |
144 } | 156 } |
145 | 157 |
146 void ShellContentBrowserClient::RenderProcessWillLaunch( | 158 void ShellContentBrowserClient::RenderProcessWillLaunch( |
147 RenderProcessHost* host) { | 159 RenderProcessHost* host) { |
148 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 160 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
149 return; | 161 return; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 #else | 278 #else |
267 return NULL; | 279 return NULL; |
268 #endif | 280 #endif |
269 } | 281 } |
270 | 282 |
271 QuotaPermissionContext* | 283 QuotaPermissionContext* |
272 ShellContentBrowserClient::CreateQuotaPermissionContext() { | 284 ShellContentBrowserClient::CreateQuotaPermissionContext() { |
273 return new ShellQuotaPermissionContext(); | 285 return new ShellQuotaPermissionContext(); |
274 } | 286 } |
275 | 287 |
288 void ShellContentBrowserClient::RequestDesktopNotificationPermission( | |
289 const GURL& source_origin, | |
290 RenderFrameHost* render_frame_host, | |
291 const base::Closure& callback) { | |
292 ShellNotificationManager* manager = GetShellNotificationManager(); | |
293 if (manager) | |
294 manager->RequestPermission(source_origin, callback); | |
jochen (gone - plz use gerrit)
2014/07/17 09:29:45
invoke the callback with some default if no manage
Peter Beverloo
2014/07/17 12:22:52
Done.
| |
295 } | |
296 | |
297 blink::WebNotificationPresenter::Permission | |
298 ShellContentBrowserClient::CheckDesktopNotificationPermission( | |
299 const GURL& source_url, | |
300 ResourceContext* context, | |
301 int render_process_id) { | |
302 ShellNotificationManager* manager = GetShellNotificationManager(); | |
303 if (manager) | |
304 return manager->CheckPermission(source_url); | |
305 | |
306 return blink::WebNotificationPresenter::PermissionAllowed; | |
307 } | |
308 | |
276 SpeechRecognitionManagerDelegate* | 309 SpeechRecognitionManagerDelegate* |
277 ShellContentBrowserClient::GetSpeechRecognitionManagerDelegate() { | 310 ShellContentBrowserClient::GetSpeechRecognitionManagerDelegate() { |
278 return new ShellSpeechRecognitionManagerDelegate(); | 311 return new ShellSpeechRecognitionManagerDelegate(); |
279 } | 312 } |
280 | 313 |
281 net::NetLog* ShellContentBrowserClient::GetNetLog() { | 314 net::NetLog* ShellContentBrowserClient::GetNetLog() { |
282 return shell_browser_main_parts_->net_log(); | 315 return shell_browser_main_parts_->net_log(); |
283 } | 316 } |
284 | 317 |
285 bool ShellContentBrowserClient::ShouldSwapProcessesForRedirect( | 318 bool ShellContentBrowserClient::ShouldSwapProcessesForRedirect( |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 ShellBrowserContext* | 397 ShellBrowserContext* |
365 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 398 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
366 BrowserContext* content_browser_context) { | 399 BrowserContext* content_browser_context) { |
367 if (content_browser_context == browser_context()) | 400 if (content_browser_context == browser_context()) |
368 return browser_context(); | 401 return browser_context(); |
369 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 402 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
370 return off_the_record_browser_context(); | 403 return off_the_record_browser_context(); |
371 } | 404 } |
372 | 405 |
373 } // namespace content | 406 } // namespace content |
OLD | NEW |