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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 static breakpad::CrashHandlerHostLinux* crash_handler = NULL; | 108 static breakpad::CrashHandlerHostLinux* crash_handler = NULL; |
108 if (!crash_handler) | 109 if (!crash_handler) |
109 crash_handler = CreateCrashHandlerHost(process_type); | 110 crash_handler = CreateCrashHandlerHost(process_type); |
110 return crash_handler->GetDeathSignalSocket(); | 111 return crash_handler->GetDeathSignalSocket(); |
111 } | 112 } |
112 | 113 |
113 return -1; | 114 return -1; |
114 } | 115 } |
115 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 116 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
116 | 117 |
| 118 void RequestDesktopNotificationPermissionOnIO( |
| 119 const GURL& source_origin, |
| 120 RenderFrameHost* render_frame_host, |
| 121 const base::Callback<void(blink::WebNotificationPermission)>& callback) { |
| 122 ShellNotificationManager* manager = |
| 123 ShellContentBrowserClient::Get()->GetShellNotificationManager(); |
| 124 if (manager) |
| 125 manager->RequestPermission(source_origin, callback); |
| 126 else |
| 127 callback.Run(blink::WebNotificationPermissionAllowed); |
| 128 } |
| 129 |
117 } // namespace | 130 } // namespace |
118 | 131 |
119 ShellContentBrowserClient* ShellContentBrowserClient::Get() { | 132 ShellContentBrowserClient* ShellContentBrowserClient::Get() { |
120 return g_browser_client; | 133 return g_browser_client; |
121 } | 134 } |
122 | 135 |
123 void ShellContentBrowserClient::SetSwapProcessesForRedirect(bool swap) { | 136 void ShellContentBrowserClient::SetSwapProcessesForRedirect(bool swap) { |
124 g_swap_processes_for_redirect = swap; | 137 g_swap_processes_for_redirect = swap; |
125 } | 138 } |
126 | 139 |
127 ShellContentBrowserClient::ShellContentBrowserClient() | 140 ShellContentBrowserClient::ShellContentBrowserClient() |
128 : shell_browser_main_parts_(NULL) { | 141 : shell_browser_main_parts_(NULL) { |
129 DCHECK(!g_browser_client); | 142 DCHECK(!g_browser_client); |
130 g_browser_client = this; | 143 g_browser_client = this; |
131 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 144 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
132 return; | 145 return; |
133 webkit_source_dir_ = GetWebKitRootDirFilePath(); | 146 webkit_source_dir_ = GetWebKitRootDirFilePath(); |
134 } | 147 } |
135 | 148 |
136 ShellContentBrowserClient::~ShellContentBrowserClient() { | 149 ShellContentBrowserClient::~ShellContentBrowserClient() { |
137 g_browser_client = NULL; | 150 g_browser_client = NULL; |
138 } | 151 } |
139 | 152 |
| 153 ShellNotificationManager* |
| 154 ShellContentBrowserClient::GetShellNotificationManager() { |
| 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 156 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
| 157 return NULL; |
| 158 |
| 159 if (!shell_notification_manager_) |
| 160 shell_notification_manager_.reset(new ShellNotificationManager()); |
| 161 |
| 162 return shell_notification_manager_.get(); |
| 163 } |
| 164 |
140 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( | 165 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( |
141 const MainFunctionParams& parameters) { | 166 const MainFunctionParams& parameters) { |
142 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters); | 167 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters); |
143 return shell_browser_main_parts_; | 168 return shell_browser_main_parts_; |
144 } | 169 } |
145 | 170 |
146 void ShellContentBrowserClient::RenderProcessWillLaunch( | 171 void ShellContentBrowserClient::RenderProcessWillLaunch( |
147 RenderProcessHost* host) { | 172 RenderProcessHost* host) { |
148 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 173 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
149 return; | 174 return; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 #else | 295 #else |
271 return NULL; | 296 return NULL; |
272 #endif | 297 #endif |
273 } | 298 } |
274 | 299 |
275 QuotaPermissionContext* | 300 QuotaPermissionContext* |
276 ShellContentBrowserClient::CreateQuotaPermissionContext() { | 301 ShellContentBrowserClient::CreateQuotaPermissionContext() { |
277 return new ShellQuotaPermissionContext(); | 302 return new ShellQuotaPermissionContext(); |
278 } | 303 } |
279 | 304 |
| 305 void ShellContentBrowserClient::RequestDesktopNotificationPermission( |
| 306 const GURL& source_origin, |
| 307 RenderFrameHost* render_frame_host, |
| 308 const base::Callback<void(blink::WebNotificationPermission)>& callback) { |
| 309 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 310 BrowserThread::PostTask(BrowserThread::IO, |
| 311 FROM_HERE, |
| 312 base::Bind(&RequestDesktopNotificationPermissionOnIO, |
| 313 source_origin, |
| 314 render_frame_host, |
| 315 callback)); |
| 316 } |
| 317 |
| 318 blink::WebNotificationPermission |
| 319 ShellContentBrowserClient::CheckDesktopNotificationPermission( |
| 320 const GURL& source_url, |
| 321 ResourceContext* context, |
| 322 int render_process_id) { |
| 323 ShellNotificationManager* manager = GetShellNotificationManager(); |
| 324 if (manager) |
| 325 return manager->CheckPermission(source_url); |
| 326 |
| 327 return blink::WebNotificationPermissionAllowed; |
| 328 } |
| 329 |
280 SpeechRecognitionManagerDelegate* | 330 SpeechRecognitionManagerDelegate* |
281 ShellContentBrowserClient::GetSpeechRecognitionManagerDelegate() { | 331 ShellContentBrowserClient::GetSpeechRecognitionManagerDelegate() { |
282 return new ShellSpeechRecognitionManagerDelegate(); | 332 return new ShellSpeechRecognitionManagerDelegate(); |
283 } | 333 } |
284 | 334 |
285 net::NetLog* ShellContentBrowserClient::GetNetLog() { | 335 net::NetLog* ShellContentBrowserClient::GetNetLog() { |
286 return shell_browser_main_parts_->net_log(); | 336 return shell_browser_main_parts_->net_log(); |
287 } | 337 } |
288 | 338 |
289 bool ShellContentBrowserClient::ShouldSwapProcessesForRedirect( | 339 bool ShellContentBrowserClient::ShouldSwapProcessesForRedirect( |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 ShellBrowserContext* | 418 ShellBrowserContext* |
369 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 419 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
370 BrowserContext* content_browser_context) { | 420 BrowserContext* content_browser_context) { |
371 if (content_browser_context == browser_context()) | 421 if (content_browser_context == browser_context()) |
372 return browser_context(); | 422 return browser_context(); |
373 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 423 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
374 return off_the_record_browser_context(); | 424 return off_the_record_browser_context(); |
375 } | 425 } |
376 | 426 |
377 } // namespace content | 427 } // namespace content |
OLD | NEW |