OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/browser/chrome_net_benchmarking_message_filter.h" | 26 #include "chrome/browser/chrome_net_benchmarking_message_filter.h" |
27 #include "chrome/browser/chrome_quota_permission_context.h" | 27 #include "chrome/browser/chrome_quota_permission_context.h" |
28 #include "chrome/browser/content_settings/content_settings_utils.h" | 28 #include "chrome/browser/content_settings/content_settings_utils.h" |
29 #include "chrome/browser/content_settings/cookie_settings.h" | 29 #include "chrome/browser/content_settings/cookie_settings.h" |
30 #include "chrome/browser/content_settings/host_content_settings_map.h" | 30 #include "chrome/browser/content_settings/host_content_settings_map.h" |
31 #include "chrome/browser/content_settings/permission_request_id.h" | 31 #include "chrome/browser/content_settings/permission_request_id.h" |
32 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 32 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
33 #include "chrome/browser/defaults.h" | 33 #include "chrome/browser/defaults.h" |
34 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h" | 34 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h" |
35 #include "chrome/browser/download/download_prefs.h" | 35 #include "chrome/browser/download/download_prefs.h" |
36 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h" | |
37 #include "chrome/browser/extensions/chrome_content_browser_client_extensions_par
t.h" | 36 #include "chrome/browser/extensions/chrome_content_browser_client_extensions_par
t.h" |
38 #include "chrome/browser/extensions/extension_service.h" | |
39 #include "chrome/browser/extensions/extension_util.h" | |
40 #include "chrome/browser/extensions/suggest_permission_util.h" | |
41 #include "chrome/browser/geolocation/chrome_access_token_store.h" | 37 #include "chrome/browser/geolocation/chrome_access_token_store.h" |
42 #include "chrome/browser/geolocation/geolocation_permission_context.h" | 38 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
43 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" | 39 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" |
44 #include "chrome/browser/media/cast_transport_host_filter.h" | 40 #include "chrome/browser/media/cast_transport_host_filter.h" |
45 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 41 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
46 #include "chrome/browser/media/midi_permission_context.h" | 42 #include "chrome/browser/media/midi_permission_context.h" |
47 #include "chrome/browser/media/midi_permission_context_factory.h" | 43 #include "chrome/browser/media/midi_permission_context_factory.h" |
48 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" | 44 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" |
49 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" | 45 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" |
50 #include "chrome/browser/net/chrome_net_log.h" | 46 #include "chrome/browser/net/chrome_net_log.h" |
51 #include "chrome/browser/notifications/desktop_notification_service.h" | 47 #include "chrome/browser/notifications/desktop_notification_service.h" |
52 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 48 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
53 #include "chrome/browser/platform_util.h" | 49 #include "chrome/browser/platform_util.h" |
54 #include "chrome/browser/plugins/plugin_info_message_filter.h" | 50 #include "chrome/browser/plugins/plugin_info_message_filter.h" |
55 #include "chrome/browser/prerender/prerender_final_status.h" | 51 #include "chrome/browser/prerender/prerender_final_status.h" |
56 #include "chrome/browser/prerender/prerender_manager.h" | 52 #include "chrome/browser/prerender/prerender_manager.h" |
57 #include "chrome/browser/prerender/prerender_manager_factory.h" | 53 #include "chrome/browser/prerender/prerender_manager_factory.h" |
58 #include "chrome/browser/prerender/prerender_message_filter.h" | 54 #include "chrome/browser/prerender/prerender_message_filter.h" |
59 #include "chrome/browser/prerender/prerender_tracker.h" | 55 #include "chrome/browser/prerender/prerender_tracker.h" |
60 #include "chrome/browser/printing/printing_message_filter.h" | 56 #include "chrome/browser/printing/printing_message_filter.h" |
61 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" | 57 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" |
62 #include "chrome/browser/profiles/profile.h" | 58 #include "chrome/browser/profiles/profile.h" |
63 #include "chrome/browser/profiles/profile_io_data.h" | 59 #include "chrome/browser/profiles/profile_io_data.h" |
64 #include "chrome/browser/profiles/profile_manager.h" | |
65 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 60 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
66 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory
.h" | 61 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory
.h" |
67 #include "chrome/browser/search/instant_service.h" | 62 #include "chrome/browser/search/instant_service.h" |
68 #include "chrome/browser/search/instant_service_factory.h" | 63 #include "chrome/browser/search/instant_service_factory.h" |
69 #include "chrome/browser/search/search.h" | 64 #include "chrome/browser/search/search.h" |
70 #include "chrome/browser/search_engines/search_provider_install_state_message_fi
lter.h" | 65 #include "chrome/browser/search_engines/search_provider_install_state_message_fi
lter.h" |
71 #include "chrome/browser/signin/principals_message_filter.h" | 66 #include "chrome/browser/signin/principals_message_filter.h" |
72 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" | 67 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h" |
73 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" | 68 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" |
74 #include "chrome/browser/speech/tts_controller.h" | 69 #include "chrome/browser/speech/tts_controller.h" |
75 #include "chrome/browser/speech/tts_message_filter.h" | 70 #include "chrome/browser/speech/tts_message_filter.h" |
76 #include "chrome/browser/ssl/ssl_add_certificate.h" | 71 #include "chrome/browser/ssl/ssl_add_certificate.h" |
77 #include "chrome/browser/ssl/ssl_blocking_page.h" | 72 #include "chrome/browser/ssl/ssl_blocking_page.h" |
78 #include "chrome/browser/ssl/ssl_client_certificate_selector.h" | 73 #include "chrome/browser/ssl/ssl_client_certificate_selector.h" |
79 #include "chrome/browser/tab_contents/tab_util.h" | 74 #include "chrome/browser/tab_contents/tab_util.h" |
80 #include "chrome/browser/ui/blocked_content/blocked_window_params.h" | 75 #include "chrome/browser/ui/blocked_content/blocked_window_params.h" |
81 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 76 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
82 #include "chrome/browser/ui/chrome_select_file_policy.h" | 77 #include "chrome/browser/ui/chrome_select_file_policy.h" |
83 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 78 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
84 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" | 79 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" |
85 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 80 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
86 #include "chrome/common/chrome_constants.h" | 81 #include "chrome/common/chrome_constants.h" |
87 #include "chrome/common/chrome_paths.h" | 82 #include "chrome/common/chrome_paths.h" |
88 #include "chrome/common/chrome_switches.h" | 83 #include "chrome/common/chrome_switches.h" |
89 #include "chrome/common/env_vars.h" | 84 #include "chrome/common/env_vars.h" |
90 #include "chrome/common/extensions/extension_constants.h" | |
91 #include "chrome/common/extensions/extension_process_policy.h" | |
92 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" | |
93 #include "chrome/common/logging_chrome.h" | 85 #include "chrome/common/logging_chrome.h" |
94 #include "chrome/common/pepper_permission_util.h" | 86 #include "chrome/common/pepper_permission_util.h" |
95 #include "chrome/common/pref_names.h" | 87 #include "chrome/common/pref_names.h" |
96 #include "chrome/common/render_messages.h" | 88 #include "chrome/common/render_messages.h" |
97 #include "chrome/common/url_constants.h" | 89 #include "chrome/common/url_constants.h" |
98 #include "chrome/installer/util/google_update_settings.h" | 90 #include "chrome/installer/util/google_update_settings.h" |
99 #include "chromeos/chromeos_constants.h" | 91 #include "chromeos/chromeos_constants.h" |
100 #include "components/cdm/browser/cdm_message_filter_android.h" | 92 #include "components/cdm/browser/cdm_message_filter_android.h" |
101 #include "components/cloud_devices/common/cloud_devices_switches.h" | 93 #include "components/cloud_devices/common/cloud_devices_switches.h" |
102 #include "components/dom_distiller/core/url_constants.h" | 94 #include "components/dom_distiller/core/url_constants.h" |
(...skipping 13 matching lines...) Expand all Loading... |
116 #include "content/public/browser/render_process_host.h" | 108 #include "content/public/browser/render_process_host.h" |
117 #include "content/public/browser/render_view_host.h" | 109 #include "content/public/browser/render_view_host.h" |
118 #include "content/public/browser/resource_context.h" | 110 #include "content/public/browser/resource_context.h" |
119 #include "content/public/browser/site_instance.h" | 111 #include "content/public/browser/site_instance.h" |
120 #include "content/public/browser/web_contents.h" | 112 #include "content/public/browser/web_contents.h" |
121 #include "content/public/common/child_process_host.h" | 113 #include "content/public/common/child_process_host.h" |
122 #include "content/public/common/content_descriptors.h" | 114 #include "content/public/common/content_descriptors.h" |
123 #include "content/public/common/show_desktop_notification_params.h" | 115 #include "content/public/common/show_desktop_notification_params.h" |
124 #include "content/public/common/url_utils.h" | 116 #include "content/public/common/url_utils.h" |
125 #include "content/public/common/web_preferences.h" | 117 #include "content/public/common/web_preferences.h" |
126 #include "extensions/browser/extension_host.h" | |
127 #include "extensions/browser/extension_system.h" | 118 #include "extensions/browser/extension_system.h" |
128 #include "extensions/browser/info_map.h" | |
129 #include "extensions/browser/process_manager.h" | |
130 #include "extensions/browser/process_map.h" | |
131 #include "extensions/browser/view_type_utils.h" | |
132 #include "extensions/common/constants.h" | 119 #include "extensions/common/constants.h" |
133 #include "extensions/common/extension.h" | 120 #include "extensions/common/extension.h" |
134 #include "extensions/common/extension_set.h" | 121 #include "extensions/common/extension_set.h" |
135 #include "extensions/common/manifest_handlers/background_info.h" | |
136 #include "extensions/common/manifest_handlers/shared_module_info.h" | 122 #include "extensions/common/manifest_handlers/shared_module_info.h" |
137 #include "extensions/common/manifest_handlers/web_accessible_resources_info.h" | |
138 #include "extensions/common/permissions/permissions_data.h" | 123 #include "extensions/common/permissions/permissions_data.h" |
139 #include "extensions/common/permissions/socket_permission.h" | 124 #include "extensions/common/permissions/socket_permission.h" |
140 #include "extensions/common/switches.h" | 125 #include "extensions/common/switches.h" |
141 #include "grit/generated_resources.h" | 126 #include "grit/generated_resources.h" |
142 #include "grit/ui_resources.h" | 127 #include "grit/ui_resources.h" |
143 #include "net/base/mime_util.h" | 128 #include "net/base/mime_util.h" |
144 #include "net/cookies/canonical_cookie.h" | 129 #include "net/cookies/canonical_cookie.h" |
145 #include "net/cookies/cookie_options.h" | 130 #include "net/cookies/cookie_options.h" |
146 #include "net/ssl/ssl_cert_request_info.h" | 131 #include "net/ssl/ssl_cert_request_info.h" |
147 #include "ppapi/host/ppapi_host.h" | 132 #include "ppapi/host/ppapi_host.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 208 |
224 #if !defined(DISABLE_NACL) | 209 #if !defined(DISABLE_NACL) |
225 #include "components/nacl/browser/nacl_browser.h" | 210 #include "components/nacl/browser/nacl_browser.h" |
226 #include "components/nacl/browser/nacl_host_message_filter.h" | 211 #include "components/nacl/browser/nacl_host_message_filter.h" |
227 #include "components/nacl/browser/nacl_process_host.h" | 212 #include "components/nacl/browser/nacl_process_host.h" |
228 #include "components/nacl/common/nacl_process_type.h" | 213 #include "components/nacl/common/nacl_process_type.h" |
229 #include "components/nacl/common/nacl_switches.h" | 214 #include "components/nacl/common/nacl_switches.h" |
230 #endif | 215 #endif |
231 | 216 |
232 #if defined(ENABLE_EXTENSIONS) | 217 #if defined(ENABLE_EXTENSIONS) |
| 218 #include "chrome/browser/extensions/extension_service.h" |
| 219 #include "chrome/browser/extensions/extension_util.h" |
| 220 #include "chrome/browser/extensions/suggest_permission_util.h" |
233 #include "chrome/browser/guest_view/guest_view_base.h" | 221 #include "chrome/browser/guest_view/guest_view_base.h" |
234 #include "chrome/browser/guest_view/guest_view_constants.h" | 222 #include "chrome/browser/guest_view/guest_view_constants.h" |
235 #include "chrome/browser/guest_view/guest_view_manager.h" | 223 #include "chrome/browser/guest_view/guest_view_manager.h" |
236 #include "chrome/browser/guest_view/web_view/web_view_guest.h" | 224 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
237 #include "chrome/browser/guest_view/web_view/web_view_permission_helper.h" | 225 #include "chrome/browser/guest_view/web_view/web_view_permission_helper.h" |
238 #include "chrome/browser/guest_view/web_view/web_view_renderer_state.h" | 226 #include "chrome/browser/guest_view/web_view/web_view_renderer_state.h" |
| 227 #include "extensions/common/manifest_handlers/background_info.h" |
239 #endif | 228 #endif |
240 | 229 |
241 #if defined(ENABLE_SPELLCHECK) | 230 #if defined(ENABLE_SPELLCHECK) |
242 #include "chrome/browser/spellchecker/spellcheck_message_filter.h" | 231 #include "chrome/browser/spellchecker/spellcheck_message_filter.h" |
243 #endif | 232 #endif |
244 | 233 |
245 #if defined(ENABLE_SERVICE_DISCOVERY) | 234 #if defined(ENABLE_SERVICE_DISCOVERY) |
246 #include "chrome/browser/local_discovery/storage/privet_filesystem_backend.h" | 235 #include "chrome/browser/local_discovery/storage/privet_filesystem_backend.h" |
247 #endif | 236 #endif |
248 | 237 |
249 #if defined(ENABLE_WEBRTC) | 238 #if defined(ENABLE_WEBRTC) |
250 #include "chrome/browser/media/webrtc_logging_handler_host.h" | 239 #include "chrome/browser/media/webrtc_logging_handler_host.h" |
251 #endif | 240 #endif |
252 | 241 |
253 using base::FileDescriptor; | 242 using base::FileDescriptor; |
254 using blink::WebWindowFeatures; | 243 using blink::WebWindowFeatures; |
255 using content::AccessTokenStore; | 244 using content::AccessTokenStore; |
256 using content::BrowserThread; | 245 using content::BrowserThread; |
257 using content::BrowserURLHandler; | 246 using content::BrowserURLHandler; |
258 using content::ChildProcessSecurityPolicy; | 247 using content::ChildProcessSecurityPolicy; |
259 using content::QuotaPermissionContext; | 248 using content::QuotaPermissionContext; |
260 using content::RenderFrameHost; | 249 using content::RenderFrameHost; |
261 using content::RenderViewHost; | 250 using content::RenderViewHost; |
262 using content::ResourceType; | 251 using content::ResourceType; |
263 using content::SiteInstance; | 252 using content::SiteInstance; |
264 using content::WebContents; | 253 using content::WebContents; |
265 using content::WebPreferences; | 254 using content::WebPreferences; |
266 using extensions::APIPermission; | 255 using extensions::APIPermission; |
| 256 using extensions::ChromeContentBrowserClientExtensionsPart; |
267 using extensions::Extension; | 257 using extensions::Extension; |
268 using extensions::InfoMap; | 258 using extensions::InfoMap; |
269 using extensions::Manifest; | 259 using extensions::Manifest; |
270 using message_center::NotifierId; | 260 using message_center::NotifierId; |
271 | 261 |
272 #if defined(OS_POSIX) | 262 #if defined(OS_POSIX) |
273 using content::FileDescriptorInfo; | 263 using content::FileDescriptorInfo; |
274 #endif | 264 #endif |
275 | 265 |
276 namespace { | 266 namespace { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 | 398 |
409 // Reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to | 399 // Reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to |
410 // "chrome://foo/". | 400 // "chrome://foo/". |
411 bool HandleWebUIReverse(GURL* url, content::BrowserContext* browser_context) { | 401 bool HandleWebUIReverse(GURL* url, content::BrowserContext* browser_context) { |
412 if (!url->is_valid() || !url->SchemeIs(content::kChromeUIScheme)) | 402 if (!url->is_valid() || !url->SchemeIs(content::kChromeUIScheme)) |
413 return false; | 403 return false; |
414 | 404 |
415 return RemoveUberHost(url); | 405 return RemoveUberHost(url); |
416 } | 406 } |
417 | 407 |
418 // Used by the GetPrivilegeRequiredByUrl() and GetProcessPrivilege() functions | |
419 // below. Extension, and isolated apps require different privileges to be | |
420 // granted to their RenderProcessHosts. This classification allows us to make | |
421 // sure URLs are served by hosts with the right set of privileges. | |
422 enum RenderProcessHostPrivilege { | |
423 PRIV_NORMAL, | |
424 PRIV_HOSTED, | |
425 PRIV_ISOLATED, | |
426 PRIV_EXTENSION, | |
427 }; | |
428 | |
429 RenderProcessHostPrivilege GetPrivilegeRequiredByUrl( | |
430 const GURL& url, | |
431 ExtensionService* service) { | |
432 // Default to a normal renderer cause it is lower privileged. This should only | |
433 // occur if the URL on a site instance is either malformed, or uninitialized. | |
434 // If it is malformed, then there is no need for better privileges anyways. | |
435 // If it is uninitialized, but eventually settles on being an a scheme other | |
436 // than normal webrenderer, the navigation logic will correct us out of band | |
437 // anyways. | |
438 if (!url.is_valid()) | |
439 return PRIV_NORMAL; | |
440 | |
441 if (url.SchemeIs(extensions::kExtensionScheme)) { | |
442 const Extension* extension = | |
443 service->extensions()->GetByID(url.host()); | |
444 if (extension && | |
445 extensions::AppIsolationInfo::HasIsolatedStorage(extension)) | |
446 return PRIV_ISOLATED; | |
447 if (extension && extension->is_hosted_app()) | |
448 return PRIV_HOSTED; | |
449 | |
450 return PRIV_EXTENSION; | |
451 } | |
452 | |
453 return PRIV_NORMAL; | |
454 } | |
455 | |
456 RenderProcessHostPrivilege GetProcessPrivilege( | |
457 content::RenderProcessHost* process_host, | |
458 extensions::ProcessMap* process_map, | |
459 ExtensionService* service) { | |
460 std::set<std::string> extension_ids = | |
461 process_map->GetExtensionsInProcess(process_host->GetID()); | |
462 if (extension_ids.empty()) | |
463 return PRIV_NORMAL; | |
464 | |
465 for (std::set<std::string>::iterator iter = extension_ids.begin(); | |
466 iter != extension_ids.end(); ++iter) { | |
467 const Extension* extension = service->GetExtensionById(*iter, false); | |
468 if (extension && | |
469 extensions::AppIsolationInfo::HasIsolatedStorage(extension)) | |
470 return PRIV_ISOLATED; | |
471 if (extension && extension->is_hosted_app()) | |
472 return PRIV_HOSTED; | |
473 } | |
474 | |
475 return PRIV_EXTENSION; | |
476 } | |
477 | |
478 bool CertMatchesFilter(const net::X509Certificate& cert, | 408 bool CertMatchesFilter(const net::X509Certificate& cert, |
479 const base::DictionaryValue& filter) { | 409 const base::DictionaryValue& filter) { |
480 // TODO(markusheintz): This is the minimal required filter implementation. | 410 // TODO(markusheintz): This is the minimal required filter implementation. |
481 // Implement a better matcher. | 411 // Implement a better matcher. |
482 | 412 |
483 // An empty filter matches any client certificate since no requirements are | 413 // An empty filter matches any client certificate since no requirements are |
484 // specified at all. | 414 // specified at all. |
485 if (filter.empty()) | 415 if (filter.empty()) |
486 return true; | 416 return true; |
487 | 417 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 weak_factory_(this) { | 582 weak_factory_(this) { |
653 #if defined(ENABLE_PLUGINS) | 583 #if defined(ENABLE_PLUGINS) |
654 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) | 584 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) |
655 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); | 585 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); |
656 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i) | 586 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i) |
657 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); | 587 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); |
658 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) | 588 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
659 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); | 589 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
660 #endif | 590 #endif |
661 | 591 |
662 permissions_policy_delegate_.reset( | |
663 new extensions::BrowserPermissionsPolicyDelegate()); | |
664 | |
665 #if !defined(OS_ANDROID) | 592 #if !defined(OS_ANDROID) |
666 TtsExtensionEngine* tts_extension_engine = TtsExtensionEngine::GetInstance(); | 593 TtsExtensionEngine* tts_extension_engine = TtsExtensionEngine::GetInstance(); |
667 TtsController::GetInstance()->SetTtsEngineDelegate(tts_extension_engine); | 594 TtsController::GetInstance()->SetTtsEngineDelegate(tts_extension_engine); |
668 #endif | 595 #endif |
669 | 596 |
670 extra_parts_.push_back( | 597 extra_parts_.push_back(new ChromeContentBrowserClientExtensionsPart); |
671 new extensions::ChromeContentBrowserClientExtensionsPart); | |
672 } | 598 } |
673 | 599 |
674 ChromeContentBrowserClient::~ChromeContentBrowserClient() { | 600 ChromeContentBrowserClient::~ChromeContentBrowserClient() { |
675 for (int i = static_cast<int>(extra_parts_.size()) - 1; i >= 0; --i) | 601 for (int i = static_cast<int>(extra_parts_.size()) - 1; i >= 0; --i) |
676 delete extra_parts_[i]; | 602 delete extra_parts_[i]; |
677 extra_parts_.clear(); | 603 extra_parts_.clear(); |
678 } | 604 } |
679 | 605 |
680 // static | 606 // static |
681 void ChromeContentBrowserClient::RegisterProfilePrefs( | 607 void ChromeContentBrowserClient::RegisterProfilePrefs( |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 | 856 |
931 #if !defined(OS_CHROMEOS) | 857 #if !defined(OS_CHROMEOS) |
932 // If the input |url| should be assigned to the Signin renderer, make its | 858 // If the input |url| should be assigned to the Signin renderer, make its |
933 // effective URL distinct from other URLs on the signin service's domain. | 859 // effective URL distinct from other URLs on the signin service's domain. |
934 // Note that the signin renderer will be allowed to sign the user in to | 860 // Note that the signin renderer will be allowed to sign the user in to |
935 // Chrome. | 861 // Chrome. |
936 if (SigninManager::IsWebBasedSigninFlowURL(url)) | 862 if (SigninManager::IsWebBasedSigninFlowURL(url)) |
937 return GetEffectiveURLForSignin(url); | 863 return GetEffectiveURLForSignin(url); |
938 #endif | 864 #endif |
939 | 865 |
940 // If the input |url| is part of an installed app, the effective URL is an | 866 return ChromeContentBrowserClientExtensionsPart::GetEffectiveURL( |
941 // extension URL with the ID of that extension as the host. This has the | 867 profile, url); |
942 // effect of grouping apps together in a common SiteInstance. | |
943 ExtensionService* extension_service = | |
944 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
945 if (!extension_service) | |
946 return url; | |
947 | |
948 const Extension* extension = extension_service->extensions()-> | |
949 GetHostedAppByURL(url); | |
950 if (!extension) | |
951 return url; | |
952 | |
953 // Bookmark apps do not use the hosted app process model, and should be | |
954 // treated as normal URLs. | |
955 if (extension->from_bookmark()) | |
956 return url; | |
957 | |
958 // If the URL is part of an extension's web extent, convert it to an | |
959 // extension URL. | |
960 return extension->GetResourceURL(url.path()); | |
961 } | 868 } |
962 | 869 |
963 bool ChromeContentBrowserClient::ShouldUseProcessPerSite( | 870 bool ChromeContentBrowserClient::ShouldUseProcessPerSite( |
964 content::BrowserContext* browser_context, const GURL& effective_url) { | 871 content::BrowserContext* browser_context, const GURL& effective_url) { |
965 // Non-extension, non-Instant URLs should generally use | 872 // Non-extension, non-Instant URLs should generally use |
966 // process-per-site-instance. Because we expect to use the effective URL, | 873 // process-per-site-instance. Because we expect to use the effective URL, |
967 // URLs for hosted apps (apart from bookmark apps) should have an extension | 874 // URLs for hosted apps (apart from bookmark apps) should have an extension |
968 // scheme by now. | 875 // scheme by now. |
969 | 876 |
970 Profile* profile = Profile::FromBrowserContext(browser_context); | 877 Profile* profile = Profile::FromBrowserContext(browser_context); |
971 if (!profile) | 878 if (!profile) |
972 return false; | 879 return false; |
973 | 880 |
974 if (chrome::ShouldUseProcessPerSiteForInstantURL(effective_url, profile)) | 881 if (chrome::ShouldUseProcessPerSiteForInstantURL(effective_url, profile)) |
975 return true; | 882 return true; |
976 | 883 |
977 #if !defined(OS_CHROMEOS) | 884 #if !defined(OS_CHROMEOS) |
978 if (SigninManager::IsWebBasedSigninFlowURL(effective_url)) | 885 if (SigninManager::IsWebBasedSigninFlowURL(effective_url)) |
979 return true; | 886 return true; |
980 #endif | 887 #endif |
981 | 888 |
982 if (!effective_url.SchemeIs(extensions::kExtensionScheme)) | 889 return ChromeContentBrowserClientExtensionsPart::ShouldUseProcessPerSite( |
983 return false; | 890 profile, effective_url); |
984 | |
985 ExtensionService* extension_service = | |
986 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
987 if (!extension_service) | |
988 return false; | |
989 | |
990 const Extension* extension = | |
991 extension_service->extensions()->GetExtensionOrAppByURL(effective_url); | |
992 if (!extension) | |
993 return false; | |
994 | |
995 // If the URL is part of a hosted app that does not have the background | |
996 // permission, or that does not allow JavaScript access to the background | |
997 // page, we want to give each instance its own process to improve | |
998 // responsiveness. | |
999 if (extension->GetType() == Manifest::TYPE_HOSTED_APP) { | |
1000 if (!extension->permissions_data()->HasAPIPermission( | |
1001 APIPermission::kBackground) || | |
1002 !extensions::BackgroundInfo::AllowJSAccess(extension)) { | |
1003 return false; | |
1004 } | |
1005 } | |
1006 | |
1007 // Hosted apps that have script access to their background page must use | |
1008 // process per site, since all instances can make synchronous calls to the | |
1009 // background window. Other extensions should use process per site as well. | |
1010 return true; | |
1011 } | 891 } |
1012 | 892 |
1013 // These are treated as WebUI schemes but do not get WebUI bindings. Also, | 893 // These are treated as WebUI schemes but do not get WebUI bindings. Also, |
1014 // view-source is allowed for these schemes. | 894 // view-source is allowed for these schemes. |
1015 void ChromeContentBrowserClient::GetAdditionalWebUISchemes( | 895 void ChromeContentBrowserClient::GetAdditionalWebUISchemes( |
1016 std::vector<std::string>* additional_schemes) { | 896 std::vector<std::string>* additional_schemes) { |
1017 additional_schemes->push_back(chrome::kChromeSearchScheme); | 897 additional_schemes->push_back(chrome::kChromeSearchScheme); |
1018 additional_schemes->push_back(dom_distiller::kDomDistillerScheme); | 898 additional_schemes->push_back(dom_distiller::kDomDistillerScheme); |
1019 } | 899 } |
1020 | 900 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 request_interceptors.Pass()); | 933 request_interceptors.Pass()); |
1054 } | 934 } |
1055 | 935 |
1056 bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) { | 936 bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) { |
1057 return ProfileIOData::IsHandledURL(url); | 937 return ProfileIOData::IsHandledURL(url); |
1058 } | 938 } |
1059 | 939 |
1060 bool ChromeContentBrowserClient::CanCommitURL( | 940 bool ChromeContentBrowserClient::CanCommitURL( |
1061 content::RenderProcessHost* process_host, | 941 content::RenderProcessHost* process_host, |
1062 const GURL& url) { | 942 const GURL& url) { |
1063 // We need to let most extension URLs commit in any process, since this can | 943 return ChromeContentBrowserClientExtensionsPart::CanCommitURL( |
1064 // be allowed due to web_accessible_resources. Most hosted app URLs may also | 944 process_host, url); |
1065 // load in any process (e.g., in an iframe). However, the Chrome Web Store | |
1066 // cannot be loaded in iframes and should never be requested outside its | |
1067 // process. | |
1068 Profile* profile = | |
1069 Profile::FromBrowserContext(process_host->GetBrowserContext()); | |
1070 ExtensionService* service = | |
1071 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
1072 if (!service) | |
1073 return true; | |
1074 const Extension* new_extension = | |
1075 service->extensions()->GetExtensionOrAppByURL(url); | |
1076 if (new_extension && | |
1077 new_extension->is_hosted_app() && | |
1078 new_extension->id() == extension_misc::kWebStoreAppId && | |
1079 !extensions::ProcessMap::Get(profile)-> | |
1080 Contains(new_extension->id(), process_host->GetID())) { | |
1081 return false; | |
1082 } | |
1083 | |
1084 return true; | |
1085 } | 945 } |
1086 | 946 |
1087 bool ChromeContentBrowserClient::ShouldAllowOpenURL( | 947 bool ChromeContentBrowserClient::ShouldAllowOpenURL( |
1088 content::SiteInstance* site_instance, const GURL& url) { | 948 content::SiteInstance* site_instance, const GURL& url) { |
1089 GURL from_url = site_instance->GetSiteURL(); | 949 GURL from_url = site_instance->GetSiteURL(); |
1090 // Do not allow pages from the web or other extensions navigate to | |
1091 // non-web-accessible extension resources. | |
1092 if (url.SchemeIs(extensions::kExtensionScheme) && | |
1093 (from_url.SchemeIsHTTPOrHTTPS() || | |
1094 from_url.SchemeIs(extensions::kExtensionScheme))) { | |
1095 Profile* profile = Profile::FromBrowserContext( | |
1096 site_instance->GetProcess()->GetBrowserContext()); | |
1097 ExtensionService* service = | |
1098 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
1099 if (!service) | |
1100 return true; | |
1101 const Extension* extension = | |
1102 service->extensions()->GetExtensionOrAppByURL(url); | |
1103 if (!extension) | |
1104 return true; | |
1105 const Extension* from_extension = | |
1106 service->extensions()->GetExtensionOrAppByURL( | |
1107 site_instance->GetSiteURL()); | |
1108 if (from_extension && from_extension->id() == extension->id()) | |
1109 return true; | |
1110 | 950 |
1111 if (!extensions::WebAccessibleResourcesInfo::IsResourceWebAccessible( | 951 bool result; |
1112 extension, url.path())) | 952 if (ChromeContentBrowserClientExtensionsPart::ShouldAllowOpenURL( |
1113 return false; | 953 site_instance, from_url, url, &result)) |
1114 } | 954 return result; |
1115 | 955 |
1116 // Do not allow chrome://chrome-signin navigate to other chrome:// URLs, since | 956 // Do not allow chrome://chrome-signin navigate to other chrome:// URLs, since |
1117 // the signin page may host untrusted web content. | 957 // the signin page may host untrusted web content. |
1118 if (from_url.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL && | 958 if (from_url.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL && |
1119 url.SchemeIs(content::kChromeUIScheme) && | 959 url.SchemeIs(content::kChromeUIScheme) && |
1120 url.host() != chrome::kChromeUIChromeSigninHost) { | 960 url.host() != chrome::kChromeUIChromeSigninHost) { |
1121 VLOG(1) << "Blocked navigation to " << url.spec() << " from " | 961 VLOG(1) << "Blocked navigation to " << url.spec() << " from " |
1122 << chrome::kChromeUIChromeSigninURL; | 962 << chrome::kChromeUIChromeSigninURL; |
1123 return false; | 963 return false; |
1124 } | 964 } |
(...skipping 24 matching lines...) Expand all Loading... |
1149 return is_instant_process && should_be_in_instant_process; | 989 return is_instant_process && should_be_in_instant_process; |
1150 } | 990 } |
1151 | 991 |
1152 #if !defined(OS_CHROMEOS) | 992 #if !defined(OS_CHROMEOS) |
1153 SigninClient* signin_client = | 993 SigninClient* signin_client = |
1154 ChromeSigninClientFactory::GetForProfile(profile); | 994 ChromeSigninClientFactory::GetForProfile(profile); |
1155 if (signin_client && signin_client->IsSigninProcess(process_host->GetID())) | 995 if (signin_client && signin_client->IsSigninProcess(process_host->GetID())) |
1156 return SigninManager::IsWebBasedSigninFlowURL(site_url); | 996 return SigninManager::IsWebBasedSigninFlowURL(site_url); |
1157 #endif | 997 #endif |
1158 | 998 |
1159 ExtensionService* service = | 999 return ChromeContentBrowserClientExtensionsPart::IsSuitableHost( |
1160 extensions::ExtensionSystem::Get(profile)->extension_service(); | 1000 profile, process_host, site_url); |
1161 extensions::ProcessMap* process_map = extensions::ProcessMap::Get(profile); | |
1162 | |
1163 // These may be NULL during tests. In that case, just assume any site can | |
1164 // share any host. | |
1165 if (!service || !process_map) | |
1166 return true; | |
1167 | |
1168 // Otherwise, just make sure the process privilege matches the privilege | |
1169 // required by the site. | |
1170 RenderProcessHostPrivilege privilege_required = | |
1171 GetPrivilegeRequiredByUrl(site_url, service); | |
1172 return GetProcessPrivilege(process_host, process_map, service) == | |
1173 privilege_required; | |
1174 } | 1001 } |
1175 | 1002 |
1176 bool ChromeContentBrowserClient::MayReuseHost( | 1003 bool ChromeContentBrowserClient::MayReuseHost( |
1177 content::RenderProcessHost* process_host) { | 1004 content::RenderProcessHost* process_host) { |
1178 // If there is currently a prerender in progress for the host provided, | 1005 // If there is currently a prerender in progress for the host provided, |
1179 // it may not be shared. We require prerenders to be by themselves in a | 1006 // it may not be shared. We require prerenders to be by themselves in a |
1180 // separate process, so that we can monitor their resource usage, and so that | 1007 // separate process, so that we can monitor their resource usage, and so that |
1181 // we can track the cookies that they change. | 1008 // we can track the cookies that they change. |
1182 Profile* profile = Profile::FromBrowserContext( | 1009 Profile* profile = Profile::FromBrowserContext( |
1183 process_host->GetBrowserContext()); | 1010 process_host->GetBrowserContext()); |
1184 prerender::PrerenderManager* prerender_manager = | 1011 prerender::PrerenderManager* prerender_manager = |
1185 prerender::PrerenderManagerFactory::GetForProfile(profile); | 1012 prerender::PrerenderManagerFactory::GetForProfile(profile); |
1186 if (prerender_manager && | 1013 if (prerender_manager && |
1187 !prerender_manager->MayReuseProcessHost(process_host)) { | 1014 !prerender_manager->MayReuseProcessHost(process_host)) { |
1188 return false; | 1015 return false; |
1189 } | 1016 } |
1190 | 1017 |
1191 return true; | 1018 return true; |
1192 } | 1019 } |
1193 | 1020 |
1194 // This function is trying to limit the amount of processes used by extensions | |
1195 // with background pages. It uses a globally set percentage of processes to | |
1196 // run such extensions and if the limit is exceeded, it returns true, to | |
1197 // indicate to the content module to group extensions together. | |
1198 bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost( | 1021 bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost( |
1199 content::BrowserContext* browser_context, const GURL& url) { | 1022 content::BrowserContext* browser_context, const GURL& url) { |
1200 // It has to be a valid URL for us to check for an extension. | 1023 // It has to be a valid URL for us to check for an extension. |
1201 if (!url.is_valid()) | 1024 if (!url.is_valid()) |
1202 return false; | 1025 return false; |
1203 | 1026 |
1204 Profile* profile = Profile::FromBrowserContext(browser_context); | 1027 Profile* profile = Profile::FromBrowserContext(browser_context); |
1205 ExtensionService* service = !profile ? NULL : | 1028 return ChromeContentBrowserClientExtensionsPart:: |
1206 extensions::ExtensionSystem::Get(profile)->extension_service(); | 1029 ShouldTryToUseExistingProcessHost( |
1207 if (!service) | 1030 profile, url); |
1208 return false; | |
1209 | |
1210 // We have to have a valid extension with background page to proceed. | |
1211 const Extension* extension = | |
1212 service->extensions()->GetExtensionOrAppByURL(url); | |
1213 if (!extension) | |
1214 return false; | |
1215 if (!extensions::BackgroundInfo::HasBackgroundPage(extension)) | |
1216 return false; | |
1217 | |
1218 std::set<int> process_ids; | |
1219 size_t max_process_count = | |
1220 content::RenderProcessHost::GetMaxRendererProcessCount(); | |
1221 | |
1222 // Go through all profiles to ensure we have total count of extension | |
1223 // processes containing background pages, otherwise one profile can | |
1224 // starve the other. | |
1225 std::vector<Profile*> profiles = g_browser_process->profile_manager()-> | |
1226 GetLoadedProfiles(); | |
1227 for (size_t i = 0; i < profiles.size(); ++i) { | |
1228 extensions::ProcessManager* epm = | |
1229 extensions::ExtensionSystem::Get(profiles[i])->process_manager(); | |
1230 for (extensions::ProcessManager::const_iterator iter = | |
1231 epm->background_hosts().begin(); | |
1232 iter != epm->background_hosts().end(); ++iter) { | |
1233 const extensions::ExtensionHost* host = *iter; | |
1234 process_ids.insert(host->render_process_host()->GetID()); | |
1235 } | |
1236 } | |
1237 | |
1238 if (process_ids.size() > | |
1239 (max_process_count * chrome::kMaxShareOfExtensionProcesses)) { | |
1240 return true; | |
1241 } | |
1242 | |
1243 return false; | |
1244 } | 1031 } |
1245 | 1032 |
1246 void ChromeContentBrowserClient::SiteInstanceGotProcess( | 1033 void ChromeContentBrowserClient::SiteInstanceGotProcess( |
1247 SiteInstance* site_instance) { | 1034 SiteInstance* site_instance) { |
1248 CHECK(site_instance->HasProcess()); | 1035 CHECK(site_instance->HasProcess()); |
1249 | 1036 |
1250 Profile* profile = Profile::FromBrowserContext( | 1037 Profile* profile = Profile::FromBrowserContext( |
1251 site_instance->GetBrowserContext()); | 1038 site_instance->GetBrowserContext()); |
1252 if (!profile) | 1039 if (!profile) |
1253 return; | 1040 return; |
(...skipping 10 matching lines...) Expand all Loading... |
1264 | 1051 |
1265 #if !defined(OS_CHROMEOS) | 1052 #if !defined(OS_CHROMEOS) |
1266 // We only expect there to be one signin process as we use process-per-site | 1053 // We only expect there to be one signin process as we use process-per-site |
1267 // for signin URLs. The signin process will be cleared from SigninManager | 1054 // for signin URLs. The signin process will be cleared from SigninManager |
1268 // when the renderer is destroyed. | 1055 // when the renderer is destroyed. |
1269 if (SigninManager::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) { | 1056 if (SigninManager::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) { |
1270 SigninClient* signin_client = | 1057 SigninClient* signin_client = |
1271 ChromeSigninClientFactory::GetForProfile(profile); | 1058 ChromeSigninClientFactory::GetForProfile(profile); |
1272 if (signin_client) | 1059 if (signin_client) |
1273 signin_client->SetSigninProcess(site_instance->GetProcess()->GetID()); | 1060 signin_client->SetSigninProcess(site_instance->GetProcess()->GetID()); |
1274 BrowserThread::PostTask( | 1061 ChromeContentBrowserClientExtensionsPart::SetSigninProcess(site_instance); |
1275 BrowserThread::IO, | |
1276 FROM_HERE, | |
1277 base::Bind(&InfoMap::SetSigninProcess, | |
1278 extensions::ExtensionSystem::Get(profile)->info_map(), | |
1279 site_instance->GetProcess()->GetID())); | |
1280 } | 1062 } |
1281 #endif | 1063 #endif |
1282 | 1064 |
1283 for (size_t i = 0; i < extra_parts_.size(); ++i) | 1065 for (size_t i = 0; i < extra_parts_.size(); ++i) |
1284 extra_parts_[i]->SiteInstanceGotProcess(site_instance); | 1066 extra_parts_[i]->SiteInstanceGotProcess(site_instance); |
1285 } | 1067 } |
1286 | 1068 |
1287 void ChromeContentBrowserClient::SiteInstanceDeleting( | 1069 void ChromeContentBrowserClient::SiteInstanceDeleting( |
1288 SiteInstance* site_instance) { | 1070 SiteInstance* site_instance) { |
1289 if (!site_instance->HasProcess()) | 1071 if (!site_instance->HasProcess()) |
(...skipping 14 matching lines...) Expand all Loading... |
1304 SiteInstance* site_instance, | 1086 SiteInstance* site_instance, |
1305 int worker_process_id) { | 1087 int worker_process_id) { |
1306 for (size_t i = 0; i < extra_parts_.size(); ++i) | 1088 for (size_t i = 0; i < extra_parts_.size(); ++i) |
1307 extra_parts_[i]->WorkerProcessTerminated(site_instance, worker_process_id); | 1089 extra_parts_[i]->WorkerProcessTerminated(site_instance, worker_process_id); |
1308 } | 1090 } |
1309 | 1091 |
1310 bool ChromeContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation( | 1092 bool ChromeContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation( |
1311 SiteInstance* site_instance, | 1093 SiteInstance* site_instance, |
1312 const GURL& current_url, | 1094 const GURL& current_url, |
1313 const GURL& new_url) { | 1095 const GURL& new_url) { |
1314 // If we don't have an ExtensionService, then rely on the SiteInstance logic | 1096 return ChromeContentBrowserClientExtensionsPart:: |
1315 // in RenderFrameHostManager to decide when to swap. | 1097 ShouldSwapBrowsingInstancesForNavigation( |
1316 Profile* profile = | 1098 site_instance, current_url, new_url); |
1317 Profile::FromBrowserContext(site_instance->GetBrowserContext()); | |
1318 ExtensionService* service = | |
1319 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
1320 if (!service) | |
1321 return false; | |
1322 | |
1323 // We must use a new BrowsingInstance (forcing a process swap and disabling | |
1324 // scripting by existing tabs) if one of the URLs is an extension and the | |
1325 // other is not the exact same extension. | |
1326 // | |
1327 // We ignore hosted apps here so that other tabs in their BrowsingInstance can | |
1328 // use postMessage with them. (The exception is the Chrome Web Store, which | |
1329 // is a hosted app that requires its own BrowsingInstance.) Navigations | |
1330 // to/from a hosted app will still trigger a SiteInstance swap in | |
1331 // RenderFrameHostManager. | |
1332 const Extension* current_extension = | |
1333 service->extensions()->GetExtensionOrAppByURL(current_url); | |
1334 if (current_extension && | |
1335 current_extension->is_hosted_app() && | |
1336 current_extension->id() != extension_misc::kWebStoreAppId) | |
1337 current_extension = NULL; | |
1338 | |
1339 const Extension* new_extension = | |
1340 service->extensions()->GetExtensionOrAppByURL(new_url); | |
1341 if (new_extension && | |
1342 new_extension->is_hosted_app() && | |
1343 new_extension->id() != extension_misc::kWebStoreAppId) | |
1344 new_extension = NULL; | |
1345 | |
1346 // First do a process check. We should force a BrowsingInstance swap if the | |
1347 // current process doesn't know about new_extension, even if current_extension | |
1348 // is somehow the same as new_extension. | |
1349 extensions::ProcessMap* process_map = extensions::ProcessMap::Get(profile); | |
1350 if (new_extension && | |
1351 site_instance->HasProcess() && | |
1352 !process_map->Contains( | |
1353 new_extension->id(), site_instance->GetProcess()->GetID())) | |
1354 return true; | |
1355 | |
1356 // Otherwise, swap BrowsingInstances if current_extension and new_extension | |
1357 // differ. | |
1358 return current_extension != new_extension; | |
1359 } | 1099 } |
1360 | 1100 |
1361 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( | 1101 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( |
1362 content::ResourceContext* resource_context, const GURL& current_url, | 1102 content::ResourceContext* resource_context, const GURL& current_url, |
1363 const GURL& new_url) { | 1103 const GURL& new_url) { |
1364 #if defined(ENABLE_EXTENSIONS) | 1104 #if defined(ENABLE_EXTENSIONS) |
1365 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 1105 return ChromeContentBrowserClientExtensionsPart:: |
1366 return extensions::CrossesExtensionProcessBoundary( | 1106 ShouldSwapProcessesForRedirect(resource_context, current_url, new_url); |
1367 io_data->GetExtensionInfoMap()->extensions(), | |
1368 current_url, new_url, false); | |
1369 #else | 1107 #else |
1370 return false; | 1108 return false; |
1371 #endif | 1109 #endif |
1372 } | 1110 } |
1373 | 1111 |
1374 bool ChromeContentBrowserClient::ShouldAssignSiteForURL(const GURL& url) { | 1112 bool ChromeContentBrowserClient::ShouldAssignSiteForURL(const GURL& url) { |
1375 return !url.SchemeIs(chrome::kChromeNativeScheme); | 1113 return !url.SchemeIs(chrome::kChromeNativeScheme); |
1376 } | 1114 } |
1377 | 1115 |
1378 std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( | 1116 std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( |
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2308 } | 2046 } |
2309 #endif | 2047 #endif |
2310 | 2048 |
2311 return true; | 2049 return true; |
2312 } | 2050 } |
2313 | 2051 |
2314 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( | 2052 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( |
2315 const GURL& url, content::ResourceContext* context) { | 2053 const GURL& url, content::ResourceContext* context) { |
2316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2054 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
2317 #if defined(ENABLE_EXTENSIONS) | 2055 #if defined(ENABLE_EXTENSIONS) |
2318 // Check if it's an extension-created worker, in which case we want to use | 2056 return ChromeContentBrowserClientExtensionsPart::GetWorkerProcessTitle( |
2319 // the name of the extension. | 2057 url, context); |
2320 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | |
2321 const Extension* extension = | |
2322 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host()); | |
2323 return extension ? extension->name() : std::string(); | |
2324 #else | 2058 #else |
2325 return std::string(); | 2059 return std::string(); |
2326 #endif | 2060 #endif |
2327 } | 2061 } |
2328 | 2062 |
2329 void ChromeContentBrowserClient::ResourceDispatcherHostCreated() { | 2063 void ChromeContentBrowserClient::ResourceDispatcherHostCreated() { |
2330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2064 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2331 prerender_tracker_ = g_browser_process->prerender_tracker(); | 2065 prerender_tracker_ = g_browser_process->prerender_tracker(); |
2332 return g_browser_process->ResourceDispatcherHostCreated(); | 2066 return g_browser_process->ResourceDispatcherHostCreated(); |
2333 } | 2067 } |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2861 switches::kDisableWebRtcEncryption, | 2595 switches::kDisableWebRtcEncryption, |
2862 }; | 2596 }; |
2863 to_command_line->CopySwitchesFrom(from_command_line, | 2597 to_command_line->CopySwitchesFrom(from_command_line, |
2864 kWebRtcDevSwitchNames, | 2598 kWebRtcDevSwitchNames, |
2865 arraysize(kWebRtcDevSwitchNames)); | 2599 arraysize(kWebRtcDevSwitchNames)); |
2866 } | 2600 } |
2867 } | 2601 } |
2868 #endif // defined(ENABLE_WEBRTC) | 2602 #endif // defined(ENABLE_WEBRTC) |
2869 | 2603 |
2870 } // namespace chrome | 2604 } // namespace chrome |
OLD | NEW |