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/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.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/ipc_echo_message_filter.h" | 19 #include "content/shell/browser/ipc_echo_message_filter.h" |
20 #include "content/shell/browser/layout_test/layout_test_browser_main_parts.h" | 20 #include "content/shell/browser/layout_test/layout_test_browser_main_parts.h" |
21 #include "content/shell/browser/layout_test/layout_test_resource_dispatcher_host
_delegate.h" | 21 #include "content/shell/browser/layout_test/layout_test_resource_dispatcher_host
_delegate.h" |
22 #include "content/shell/browser/shell.h" | 22 #include "content/shell/browser/shell.h" |
23 #include "content/shell/browser/shell_browser_context.h" | 23 #include "content/shell/browser/shell_browser_context.h" |
24 #include "content/shell/browser/shell_browser_main_parts.h" | 24 #include "content/shell/browser/shell_browser_main_parts.h" |
25 #include "content/shell/browser/shell_devtools_delegate.h" | 25 #include "content/shell/browser/shell_devtools_delegate.h" |
26 #include "content/shell/browser/shell_message_filter.h" | 26 #include "content/shell/browser/shell_message_filter.h" |
27 #include "content/shell/browser/shell_net_log.h" | 27 #include "content/shell/browser/shell_net_log.h" |
28 #include "content/shell/browser/shell_notification_manager.h" | |
29 #include "content/shell/browser/shell_quota_permission_context.h" | 28 #include "content/shell/browser/shell_quota_permission_context.h" |
30 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" | 29 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" |
31 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" | 30 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" |
32 #include "content/shell/browser/webkit_test_controller.h" | 31 #include "content/shell/browser/webkit_test_controller.h" |
33 #include "content/shell/common/shell_messages.h" | 32 #include "content/shell/common/shell_messages.h" |
34 #include "content/shell/common/shell_switches.h" | 33 #include "content/shell/common/shell_switches.h" |
35 #include "content/shell/common/webkit_test_helpers.h" | 34 #include "content/shell/common/webkit_test_helpers.h" |
36 #include "content/shell/geolocation/shell_access_token_store.h" | 35 #include "content/shell/geolocation/shell_access_token_store.h" |
37 #include "net/url_request/url_request_context_getter.h" | 36 #include "net/url_request/url_request_context_getter.h" |
38 #include "url/gurl.h" | 37 #include "url/gurl.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 static breakpad::CrashHandlerHostLinux* crash_handler = NULL; | 109 static breakpad::CrashHandlerHostLinux* crash_handler = NULL; |
111 if (!crash_handler) | 110 if (!crash_handler) |
112 crash_handler = CreateCrashHandlerHost(process_type); | 111 crash_handler = CreateCrashHandlerHost(process_type); |
113 return crash_handler->GetDeathSignalSocket(); | 112 return crash_handler->GetDeathSignalSocket(); |
114 } | 113 } |
115 | 114 |
116 return -1; | 115 return -1; |
117 } | 116 } |
118 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 117 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
119 | 118 |
120 void RequestDesktopNotificationPermissionOnIO( | |
121 const GURL& source_origin, | |
122 RenderFrameHost* render_frame_host, | |
123 const base::Callback<void(blink::WebNotificationPermission)>& callback) { | |
124 ShellNotificationManager* manager = | |
125 ShellContentBrowserClient::Get()->GetShellNotificationManager(); | |
126 if (manager) | |
127 manager->RequestPermission(source_origin, callback); | |
128 else | |
129 callback.Run(blink::WebNotificationPermissionAllowed); | |
130 } | |
131 | |
132 } // namespace | 119 } // namespace |
133 | 120 |
134 ShellContentBrowserClient* ShellContentBrowserClient::Get() { | 121 ShellContentBrowserClient* ShellContentBrowserClient::Get() { |
135 return g_browser_client; | 122 return g_browser_client; |
136 } | 123 } |
137 | 124 |
138 void ShellContentBrowserClient::SetSwapProcessesForRedirect(bool swap) { | 125 void ShellContentBrowserClient::SetSwapProcessesForRedirect(bool swap) { |
139 g_swap_processes_for_redirect = swap; | 126 g_swap_processes_for_redirect = swap; |
140 } | 127 } |
141 | 128 |
142 ShellContentBrowserClient::ShellContentBrowserClient() | 129 ShellContentBrowserClient::ShellContentBrowserClient() |
143 : shell_browser_main_parts_(NULL) { | 130 : shell_browser_main_parts_(NULL) { |
144 DCHECK(!g_browser_client); | 131 DCHECK(!g_browser_client); |
145 g_browser_client = this; | 132 g_browser_client = this; |
146 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 133 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
147 return; | 134 return; |
148 webkit_source_dir_ = GetWebKitRootDirFilePath(); | 135 webkit_source_dir_ = GetWebKitRootDirFilePath(); |
149 } | 136 } |
150 | 137 |
151 ShellContentBrowserClient::~ShellContentBrowserClient() { | 138 ShellContentBrowserClient::~ShellContentBrowserClient() { |
152 g_browser_client = NULL; | 139 g_browser_client = NULL; |
153 } | 140 } |
154 | 141 |
155 ShellNotificationManager* | |
156 ShellContentBrowserClient::GetShellNotificationManager() { | |
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
158 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | |
159 return NULL; | |
160 | |
161 if (!shell_notification_manager_) | |
162 shell_notification_manager_.reset(new ShellNotificationManager()); | |
163 | |
164 return shell_notification_manager_.get(); | |
165 } | |
166 | |
167 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( | 142 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( |
168 const MainFunctionParams& parameters) { | 143 const MainFunctionParams& parameters) { |
169 shell_browser_main_parts_ = | 144 shell_browser_main_parts_ = |
170 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree) | 145 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree) |
171 ? new LayoutTestBrowserMainParts(parameters) | 146 ? new LayoutTestBrowserMainParts(parameters) |
172 : new ShellBrowserMainParts(parameters); | 147 : new ShellBrowserMainParts(parameters); |
173 return shell_browser_main_parts_; | 148 return shell_browser_main_parts_; |
174 } | 149 } |
175 | 150 |
176 void ShellContentBrowserClient::RenderProcessWillLaunch( | 151 void ShellContentBrowserClient::RenderProcessWillLaunch( |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 #else | 282 #else |
308 return NULL; | 283 return NULL; |
309 #endif | 284 #endif |
310 } | 285 } |
311 | 286 |
312 QuotaPermissionContext* | 287 QuotaPermissionContext* |
313 ShellContentBrowserClient::CreateQuotaPermissionContext() { | 288 ShellContentBrowserClient::CreateQuotaPermissionContext() { |
314 return new ShellQuotaPermissionContext(); | 289 return new ShellQuotaPermissionContext(); |
315 } | 290 } |
316 | 291 |
317 void ShellContentBrowserClient::RequestDesktopNotificationPermission( | |
318 const GURL& source_origin, | |
319 RenderFrameHost* render_frame_host, | |
320 const base::Callback<void(blink::WebNotificationPermission)>& callback) { | |
321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
322 BrowserThread::PostTask(BrowserThread::IO, | |
323 FROM_HERE, | |
324 base::Bind(&RequestDesktopNotificationPermissionOnIO, | |
325 source_origin, | |
326 render_frame_host, | |
327 callback)); | |
328 } | |
329 | |
330 blink::WebNotificationPermission | |
331 ShellContentBrowserClient::CheckDesktopNotificationPermission( | |
332 const GURL& source_url, | |
333 ResourceContext* context, | |
334 int render_process_id) { | |
335 ShellNotificationManager* manager = GetShellNotificationManager(); | |
336 if (manager) | |
337 return manager->CheckPermission(source_url); | |
338 | |
339 return blink::WebNotificationPermissionAllowed; | |
340 } | |
341 | |
342 SpeechRecognitionManagerDelegate* | 292 SpeechRecognitionManagerDelegate* |
343 ShellContentBrowserClient::GetSpeechRecognitionManagerDelegate() { | 293 ShellContentBrowserClient::GetSpeechRecognitionManagerDelegate() { |
344 return new ShellSpeechRecognitionManagerDelegate(); | 294 return new ShellSpeechRecognitionManagerDelegate(); |
345 } | 295 } |
346 | 296 |
347 net::NetLog* ShellContentBrowserClient::GetNetLog() { | 297 net::NetLog* ShellContentBrowserClient::GetNetLog() { |
348 return shell_browser_main_parts_->net_log(); | 298 return shell_browser_main_parts_->net_log(); |
349 } | 299 } |
350 | 300 |
351 bool ShellContentBrowserClient::ShouldSwapProcessesForRedirect( | 301 bool ShellContentBrowserClient::ShouldSwapProcessesForRedirect( |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 ShellBrowserContext* | 383 ShellBrowserContext* |
434 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 384 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
435 BrowserContext* content_browser_context) { | 385 BrowserContext* content_browser_context) { |
436 if (content_browser_context == browser_context()) | 386 if (content_browser_context == browser_context()) |
437 return browser_context(); | 387 return browser_context(); |
438 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 388 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
439 return off_the_record_browser_context(); | 389 return off_the_record_browser_context(); |
440 } | 390 } |
441 | 391 |
442 } // namespace content | 392 } // namespace content |
OLD | NEW |