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
3 // found in the LICENSE file.
5 #include "chrome/browser/chrome_content_browser_client.h"
11 #include "base/bind.h"
12 #include "base/command_line.h"
13 #include "base/lazy_instance.h"
14 #include "base/path_service.h"
15 #include "base/prefs/pref_service.h"
16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/utf_string_conversions.h"
18 #include "base/threading/sequenced_worker_pool.h"
19 #include "chrome/app/breakpad_mac.h"
20 #include "chrome/browser/app_mode/app_mode_utils.h"
21 #include "chrome/browser/browser_about_handler.h"
22 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/browsing_data/browsing_data_helper.h"
24 #include "chrome/browser/browsing_data/browsing_data_remover.h"
25 #include "chrome/browser/character_encoding.h"
26 #include "chrome/browser/chrome_net_benchmarking_message_filter.h"
27 #include "chrome/browser/chrome_quota_permission_context.h"
28 #include "chrome/browser/content_settings/content_settings_utils.h"
29 #include "chrome/browser/content_settings/cookie_settings.h"
30 #include "chrome/browser/content_settings/host_content_settings_map.h"
31 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
32 #include "chrome/browser/defaults.h"
33 #include "chrome/browser/download/download_util.h"
34 #include "chrome/browser/extensions/activity_log/activity_log.h"
35 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
36 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h"
37 #include "chrome/browser/extensions/extension_host.h"
38 #include "chrome/browser/extensions/extension_info_map.h"
39 #include "chrome/browser/extensions/extension_process_manager.h"
40 #include "chrome/browser/extensions/extension_service.h"
41 #include "chrome/browser/extensions/extension_system.h"
42 #include "chrome/browser/extensions/extension_web_ui.h"
43 #include "chrome/browser/extensions/extension_webkit_preferences.h"
44 #include "chrome/browser/extensions/suggest_permission_util.h"
45 #include "chrome/browser/geolocation/chrome_access_token_store.h"
46 #include "chrome/browser/google/google_util.h"
47 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
48 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
49 #include "chrome/browser/nacl_host/nacl_host_message_filter.h"
50 #include "chrome/browser/nacl_host/nacl_process_host.h"
51 #include "chrome/browser/net/chrome_net_log.h"
52 #include "chrome/browser/notifications/desktop_notification_service.h"
53 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
54 #include "chrome/browser/platform_util.h"
55 #include "chrome/browser/plugins/plugin_info_message_filter.h"
56 #include "chrome/browser/prefs/scoped_user_pref_update.h"
57 #include "chrome/browser/prerender/prerender_manager.h"
58 #include "chrome/browser/prerender/prerender_manager_factory.h"
59 #include "chrome/browser/prerender/prerender_message_filter.h"
60 #include "chrome/browser/prerender/prerender_tracker.h"
61 #include "chrome/browser/printing/printing_message_filter.h"
62 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h"
63 #include "chrome/browser/profiles/profile.h"
64 #include "chrome/browser/profiles/profile_io_data.h"
65 #include "chrome/browser/profiles/profile_manager.h"
66 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
67 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
68 #include "chrome/browser/search/instant_service.h"
69 #include "chrome/browser/search/instant_service_factory.h"
70 #include "chrome/browser/search/search.h"
71 #include "chrome/browser/search_engines/search_provider_install_state_message_filter.h"
72 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h"
73 #include "chrome/browser/speech/tts_message_filter.h"
74 #include "chrome/browser/spellchecker/spellcheck_message_filter.h"
75 #include "chrome/browser/ssl/ssl_add_certificate.h"
76 #include "chrome/browser/ssl/ssl_blocking_page.h"
77 #include "chrome/browser/ssl/ssl_tab_helper.h"
78 #include "chrome/browser/tab_contents/tab_util.h"
79 #include "chrome/browser/toolkit_extra_parts.h"
80 #include "chrome/browser/ui/chrome_select_file_policy.h"
81 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h"
82 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
83 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
84 #include "chrome/browser/user_style_sheet_watcher.h"
85 #include "chrome/browser/user_style_sheet_watcher_factory.h"
86 #include "chrome/browser/validation_message_message_filter.h"
87 #include "chrome/browser/webview/webview_guest.h"
88 #include "chrome/common/child_process_logging.h"
89 #include "chrome/common/chrome_constants.h"
90 #include "chrome/common/chrome_paths.h"
91 #include "chrome/common/chrome_process_type.h"
92 #include "chrome/common/chrome_switches.h"
93 #include "chrome/common/extensions/background_info.h"
94 #include "chrome/common/extensions/extension.h"
95 #include "chrome/common/extensions/extension_process_policy.h"
96 #include "chrome/common/extensions/extension_set.h"
97 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
98 #include "chrome/common/extensions/manifest_handlers/shared_module_info.h"
99 #include "chrome/common/extensions/permissions/permissions_data.h"
100 #include "chrome/common/extensions/permissions/socket_permission.h"
101 #include "chrome/common/logging_chrome.h"
102 #include "chrome/common/pepper_permission_util.h"
103 #include "chrome/common/pref_names.h"
104 #include "chrome/common/render_messages.h"
105 #include "chrome/common/url_constants.h"
106 #include "chromeos/chromeos_constants.h"
107 #include "components/user_prefs/pref_registry_syncable.h"
108 #include "content/public/browser/browser_child_process_host.h"
109 #include "content/public/browser/browser_main_parts.h"
110 #include "content/public/browser/browser_ppapi_host.h"
111 #include "content/public/browser/browser_thread.h"
112 #include "content/public/browser/browser_url_handler.h"
113 #include "content/public/browser/child_process_data.h"
114 #include "content/public/browser/child_process_security_policy.h"
115 #include "content/public/browser/compositor_util.h"
116 #include "content/public/browser/render_process_host.h"
117 #include "content/public/browser/render_view_host.h"
118 #include "content/public/browser/resource_context.h"
119 #include "content/public/browser/site_instance.h"
120 #include "content/public/browser/web_contents.h"
121 #include "content/public/browser/web_contents_view.h"
122 #include "content/public/common/child_process_host.h"
123 #include "content/public/common/content_descriptors.h"
124 #include "extensions/browser/view_type_utils.h"
125 #include "extensions/common/constants.h"
126 #include "grit/generated_resources.h"
127 #include "grit/ui_resources.h"
128 #include "net/base/escape.h"
129 #include "net/base/mime_util.h"
130 #include "net/cookies/canonical_cookie.h"
131 #include "net/cookies/cookie_options.h"
132 #include "net/ssl/ssl_cert_request_info.h"
133 #include "ppapi/host/ppapi_host.h"
134 #include "ui/base/l10n/l10n_util.h"
135 #include "ui/base/resource/resource_bundle.h"
136 #include "ui/message_center/message_center_util.h"
137 #include "webkit/common/webpreferences.h"
138 #include "webkit/plugins/plugin_switches.h"
141 #include "chrome/browser/chrome_browser_main_win.h"
142 #include "sandbox/win/src/sandbox_policy.h"
143 #elif defined(OS_MACOSX)
144 #include "chrome/browser/chrome_browser_main_mac.h"
145 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
146 #elif defined(OS_CHROMEOS)
147 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
148 #include "chrome/browser/chromeos/login/startup_utils.h"
149 #include "chrome/browser/chromeos/login/user_manager.h"
150 #include "chrome/browser/chromeos/system/statistics_provider.h"
151 #include "chromeos/chromeos_switches.h"
152 #elif defined(OS_LINUX)
153 #include "chrome/browser/chrome_browser_main_linux.h"
154 #elif defined(OS_ANDROID)
155 #include "chrome/browser/android/crash_dump_manager.h"
156 #include "chrome/browser/chrome_browser_main_android.h"
157 #include "chrome/common/descriptors_android.h"
158 #elif defined(OS_POSIX)
159 #include "chrome/browser/chrome_browser_main_posix.h"
162 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_ANDROID)
163 #include "base/linux_util.h"
164 #include "chrome/browser/crash_handler_host_linux.h"
167 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
168 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h"
171 #if defined(OS_ANDROID)
172 #include "ui/base/ui_base_paths.h"
176 #include "chrome/browser/ui/crypto_module_password_dialog.h"
179 #if !defined(OS_CHROMEOS)
180 #include "chrome/browser/signin/signin_manager.h"
181 #include "chrome/browser/signin/signin_manager_factory.h"
184 #if !defined(OS_ANDROID)
185 #include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_provider.h"
188 #if defined(ENABLE_WEBRTC)
189 #include "chrome/browser/media/webrtc_logging_handler_host.h"
192 #if defined(FILE_MANAGER_EXTENSION)
193 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h"
196 using base::FileDescriptor
;
197 using content::AccessTokenStore
;
198 using content::BrowserChildProcessHostIterator
;
199 using content::BrowserThread
;
200 using content::BrowserURLHandler
;
201 using content::ChildProcessSecurityPolicy
;
202 using content::FileDescriptorInfo
;
203 using content::QuotaPermissionContext
;
204 using content::RenderViewHost
;
205 using content::SiteInstance
;
206 using content::WebContents
;
207 using extensions::APIPermission
;
208 using extensions::Extension
;
209 using extensions::Manifest
;
213 // Cached version of the locale so we can return the locale on the I/O
215 base::LazyInstance
<std::string
> g_io_thread_application_locale
;
217 #if defined(ENABLE_PLUGINS)
218 const char* kPredefinedAllowedSocketOrigins
[] = {
219 "okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client
220 "pnhechapfaindjhompbnflcldabbghjo", // HTerm App (SSH Client)
221 "bglhmjfplikpjnfoegeomebmfnkjomhe", // see crbug.com/122126
222 "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop
223 "kgngmbheleoaphbjbaiobfdepmghbfah", // Pre-release Chrome Remote Desktop
224 "odkaodonbgfohohmklejpjiejmcipmib", // Dogfood Chrome Remote Desktop
225 "ojoimpklfciegopdfgeenehpalipignm", // Chromoting canary
226 "cbkkbcmdlboombapidmoeolnmdacpkch", // see crbug.com/129089
227 "hhnbmknkdabfoieppbbljkhkfjcmcbjh", // see crbug.com/134099
228 "mablfbjkhmhkmefkjjacnbaikjkipphg", // see crbug.com/134099
229 "pdeelgamlgannhelgoegilelnnojegoh", // see crbug.com/134099
230 "cabapfdbkniadpollkckdnedaanlciaj", // see crbug.com/134099
231 "mapljbgnjledlpdmlchihnmeclmefbba", // see crbug.com/134099
232 "ghbfeebgmiidnnmeobbbaiamklmpbpii", // see crbug.com/134099
233 "jdfhpkjeckflbbleddjlpimecpbjdeep", // see crbug.com/142514
234 "iabmpiboiopbgfabjmgeedhcmjenhbla", // see crbug.com/165080
235 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see crbug.com/234789
236 "7525AF4F66763A70A883C4700529F647B470E4D2", // see crbug.com/238084
237 "0B549507088E1564D672F7942EB87CA4DAD73972", // see crbug.com/238084
238 "864288364E239573E777D3E0E36864E590E95C74" // see crbug.com/238084
242 // Returns a copy of the given url with its host set to given host and path set
243 // to given path. Other parts of the url will be the same.
244 GURL
ReplaceURLHostAndPath(const GURL
& url
,
245 const std::string
& host
,
246 const std::string
& path
) {
247 url_canon::Replacements
<char> replacements
;
248 replacements
.SetHost(host
.c_str(),
249 url_parse::Component(0, host
.length()));
250 replacements
.SetPath(path
.c_str(),
251 url_parse::Component(0, path
.length()));
252 return url
.ReplaceComponents(replacements
);
255 // Maps "foo://bar/baz/" to "foo://chrome/bar/baz/".
256 GURL
AddUberHost(const GURL
& url
) {
257 const std::string uber_host
= chrome::kChromeUIUberHost
;
258 const std::string new_path
= url
.host() + url
.path();
260 return ReplaceURLHostAndPath(url
, uber_host
, new_path
);
263 // If url->host() is "chrome" and url->path() has characters other than the
264 // first slash, changes the url from "foo://chrome/bar/" to "foo://bar/" and
265 // returns true. Otherwise returns false.
266 bool RemoveUberHost(GURL
* url
) {
267 if (url
->host() != chrome::kChromeUIUberHost
)
270 if (url
->path().empty() || url
->path() == "/")
273 const std::string old_path
= url
->path();
275 const std::string::size_type separator
= old_path
.find('/', 1);
276 std::string new_host
;
277 std::string new_path
;
278 if (separator
== std::string::npos
) {
279 new_host
= old_path
.substr(1);
281 new_host
= old_path
.substr(1, separator
- 1);
282 new_path
= old_path
.substr(separator
);
285 // Do not allow URLs with paths empty before the first slash since we can't
286 // have an empty host. (e.g "foo://chrome//")
287 if (new_host
.empty())
290 *url
= ReplaceURLHostAndPath(*url
, new_host
, new_path
);
292 DCHECK(url
->is_valid());
297 // Handles rewriting Web UI URLs.
298 bool HandleWebUI(GURL
* url
, content::BrowserContext
* browser_context
) {
299 // Do not handle special URLs such as "about:foo"
300 if (!url
->host().empty()) {
301 const GURL chrome_url
= AddUberHost(*url
);
303 // Handle valid "chrome://chrome/foo" URLs so the reverse handler will
305 if (ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
306 browser_context
, chrome_url
))
310 if (!ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
311 browser_context
, *url
))
314 #if defined(OS_CHROMEOS)
315 // Special case : in ChromeOS in Guest mode bookmarks and history are
316 // disabled for security reasons. New tab page explains the reasons, so
317 // we redirect user to new tab page.
318 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) {
319 if (url
->SchemeIs(chrome::kChromeUIScheme
) &&
320 (url
->DomainIs(chrome::kChromeUIBookmarksHost
) ||
321 url
->DomainIs(chrome::kChromeUIHistoryHost
))) {
322 // Rewrite with new tab URL
323 *url
= GURL(chrome::kChromeUINewTabURL
);
328 // Special case the new tab page. In older versions of Chrome, the new tab
329 // page was hosted at chrome-internal:<blah>. This might be in people's saved
330 // sessions or bookmarks, so we say any URL with that scheme triggers the new
332 if (url
->SchemeIs(chrome::kChromeInternalScheme
)) {
333 // Rewrite it with the proper new tab URL.
334 *url
= GURL(chrome::kChromeUINewTabURL
);
340 // Reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to
342 bool HandleWebUIReverse(GURL
* url
, content::BrowserContext
* browser_context
) {
343 if (!url
->is_valid() || !url
->SchemeIs(chrome::kChromeUIScheme
))
346 return RemoveUberHost(url
);
349 // Used by the GetPrivilegeRequiredByUrl() and GetProcessPrivilege() functions
350 // below. Extension, and isolated apps require different privileges to be
351 // granted to their RenderProcessHosts. This classification allows us to make
352 // sure URLs are served by hosts with the right set of privileges.
353 enum RenderProcessHostPrivilege
{
360 RenderProcessHostPrivilege
GetPrivilegeRequiredByUrl(
362 ExtensionService
* service
) {
363 // Default to a normal renderer cause it is lower privileged. This should only
364 // occur if the URL on a site instance is either malformed, or uninitialized.
365 // If it is malformed, then there is no need for better privileges anyways.
366 // If it is uninitialized, but eventually settles on being an a scheme other
367 // than normal webrenderer, the navigation logic will correct us out of band
372 if (url
.SchemeIs(extensions::kExtensionScheme
)) {
373 const Extension
* extension
=
374 service
->extensions()->GetByID(url
.host());
376 extensions::AppIsolationInfo::HasIsolatedStorage(extension
))
377 return PRIV_ISOLATED
;
378 if (extension
&& extension
->is_hosted_app())
381 return PRIV_EXTENSION
;
387 RenderProcessHostPrivilege
GetProcessPrivilege(
388 content::RenderProcessHost
* process_host
,
389 extensions::ProcessMap
* process_map
,
390 ExtensionService
* service
) {
391 std::set
<std::string
> extension_ids
=
392 process_map
->GetExtensionsInProcess(process_host
->GetID());
393 if (extension_ids
.empty())
396 for (std::set
<std::string
>::iterator iter
= extension_ids
.begin();
397 iter
!= extension_ids
.end(); ++iter
) {
398 const Extension
* extension
= service
->GetExtensionById(*iter
, false);
400 extensions::AppIsolationInfo::HasIsolatedStorage(extension
))
401 return PRIV_ISOLATED
;
402 if (extension
&& extension
->is_hosted_app())
406 return PRIV_EXTENSION
;
409 bool CertMatchesFilter(const net::X509Certificate
& cert
,
410 const base::DictionaryValue
& filter
) {
411 // TODO(markusheintz): This is the minimal required filter implementation.
412 // Implement a better matcher.
414 // An empty filter matches any client certificate since no requirements are
419 std::string common_name
;
420 if (filter
.GetString("ISSUER.CN", &common_name
) &&
421 (cert
.issuer().common_name
== common_name
)) {
427 // Fills |map| with the per-script font prefs under path |map_name|.
428 void FillFontFamilyMap(const PrefService
* prefs
,
429 const char* map_name
,
430 webkit_glue::ScriptFontFamilyMap
* map
) {
431 for (size_t i
= 0; i
< prefs::kWebKitScriptsForFontFamilyMapsLength
; ++i
) {
432 const char* script
= prefs::kWebKitScriptsForFontFamilyMaps
[i
];
433 std::string pref_name
= base::StringPrintf("%s.%s", map_name
, script
);
434 std::string font_family
= prefs
->GetString(pref_name
.c_str());
435 if (!font_family
.empty())
436 (*map
)[script
] = UTF8ToUTF16(font_family
);
440 #if defined(OS_POSIX) && !defined(OS_MACOSX)
441 int GetCrashSignalFD(const CommandLine
& command_line
) {
442 if (command_line
.HasSwitch(switches::kExtensionProcess
)) {
443 ExtensionCrashHandlerHostLinux
* crash_handler
=
444 ExtensionCrashHandlerHostLinux::GetInstance();
445 return crash_handler
->GetDeathSignalSocket();
448 std::string process_type
=
449 command_line
.GetSwitchValueASCII(switches::kProcessType
);
451 if (process_type
== switches::kRendererProcess
)
452 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
454 if (process_type
== switches::kPluginProcess
)
455 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
457 if (process_type
== switches::kPpapiPluginProcess
)
458 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
460 if (process_type
== switches::kGpuProcess
)
461 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
465 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
467 #if !defined(OS_CHROMEOS)
468 GURL
GetEffectiveURLForSignin(const GURL
& url
) {
469 CHECK(SigninManager::IsWebBasedSigninFlowURL(url
));
471 GURL
effective_url(SigninManager::kChromeSigninEffectiveSite
);
472 // Copy the path because the argument to SetPathStr must outlive
473 // the Replacements object.
474 const std::string
path_copy(url
.path());
475 GURL::Replacements replacements
;
476 replacements
.SetPathStr(path_copy
);
477 effective_url
= effective_url
.ReplaceComponents(replacements
);
478 return effective_url
;
482 void SetApplicationLocaleOnIOThread(const std::string
& locale
) {
483 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
484 g_io_thread_application_locale
.Get() = locale
;
491 ChromeContentBrowserClient::ChromeContentBrowserClient() {
492 #if defined(ENABLE_PLUGINS)
493 for (size_t i
= 0; i
< arraysize(kPredefinedAllowedSocketOrigins
); ++i
)
494 allowed_socket_origins_
.insert(kPredefinedAllowedSocketOrigins
[i
]);
497 permissions_policy_delegate_
.reset(
498 new extensions::BrowserPermissionsPolicyDelegate());
501 ChromeContentBrowserClient::~ChromeContentBrowserClient() {
505 void ChromeContentBrowserClient::RegisterUserPrefs(
506 user_prefs::PrefRegistrySyncable
* registry
) {
507 registry
->RegisterBooleanPref(
508 prefs::kDisable3DAPIs
,
510 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
511 registry
->RegisterBooleanPref(
512 prefs::kEnableHyperlinkAuditing
,
514 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
515 registry
->RegisterBooleanPref(
516 prefs::kEnableMemoryInfo
,
518 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF
);
522 void ChromeContentBrowserClient::SetApplicationLocale(
523 const std::string
& locale
) {
524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI
));
526 // This object is guaranteed to outlive all threads so we don't have to
527 // worry about the lack of refcounting and can just post as Unretained.
529 // The common case is that this function is called early in Chrome startup
530 // before any threads are created (it will also be called later if the user
531 // changes the pref). In this case, there will be no threads created and
532 // posting will fail. When there are no threads, we can just set the string
533 // without worrying about threadsafety.
534 if (!BrowserThread::PostTask(BrowserThread::IO
, FROM_HERE
,
535 base::Bind(&SetApplicationLocaleOnIOThread
, locale
))) {
536 g_io_thread_application_locale
.Get() = locale
;
540 content::BrowserMainParts
* ChromeContentBrowserClient::CreateBrowserMainParts(
541 const content::MainFunctionParams
& parameters
) {
542 ChromeBrowserMainParts
* main_parts
;
543 // Construct the Main browser parts based on the OS type.
545 main_parts
= new ChromeBrowserMainPartsWin(parameters
);
546 #elif defined(OS_MACOSX)
547 main_parts
= new ChromeBrowserMainPartsMac(parameters
);
548 #elif defined(OS_CHROMEOS)
549 main_parts
= new chromeos::ChromeBrowserMainPartsChromeos(parameters
);
550 #elif defined(OS_LINUX)
551 main_parts
= new ChromeBrowserMainPartsLinux(parameters
);
552 #elif defined(OS_ANDROID)
553 main_parts
= new ChromeBrowserMainPartsAndroid(parameters
);
554 #elif defined(OS_POSIX)
555 main_parts
= new ChromeBrowserMainPartsPosix(parameters
);
558 main_parts
= new ChromeBrowserMainParts(parameters
);
561 chrome::AddProfilesExtraParts(main_parts
);
563 // Construct additional browser parts. Stages are called in the order in
564 // which they are added.
565 #if defined(TOOLKIT_GTK)
566 chrome::AddGtkToolkitExtraParts(main_parts
);
569 #if defined(TOOLKIT_VIEWS)
570 chrome::AddViewsToolkitExtraParts(main_parts
);
574 chrome::AddAshToolkitExtraParts(main_parts
);
577 #if defined(USE_AURA)
578 chrome::AddAuraToolkitExtraParts(main_parts
);
581 chrome::AddMetricsExtraParts(main_parts
);
586 std::string
ChromeContentBrowserClient::GetStoragePartitionIdForSite(
587 content::BrowserContext
* browser_context
,
589 std::string partition_id
;
591 // The partition ID for webview guest processes is the string value of its
592 // SiteInstance URL - "chrome-guest://app_id/persist?partition".
593 if (site
.SchemeIs(chrome::kGuestScheme
))
594 partition_id
= site
.spec();
596 DCHECK(IsValidStoragePartitionId(browser_context
, partition_id
));
600 bool ChromeContentBrowserClient::IsValidStoragePartitionId(
601 content::BrowserContext
* browser_context
,
602 const std::string
& partition_id
) {
603 // The default ID is empty and is always valid.
604 if (partition_id
.empty())
607 return GURL(partition_id
).is_valid();
610 void ChromeContentBrowserClient::GetStoragePartitionConfigForSite(
611 content::BrowserContext
* browser_context
,
614 std::string
* partition_domain
,
615 std::string
* partition_name
,
617 // Default to the browser-wide storage partition and override based on |site|
619 partition_domain
->clear();
620 partition_name
->clear();
623 // For the webview tag, we create special guest processes, which host the
624 // tag content separately from the main application that embeds the tag.
625 // A webview tag can specify both the partition name and whether the storage
626 // for that partition should be persisted. Each tag gets a SiteInstance with
627 // a specially formatted URL, based on the application it is hosted by and
628 // the partition requested by it. The format for that URL is:
629 // chrome-guest://partition_domain/persist?partition_name
630 if (site
.SchemeIs(chrome::kGuestScheme
)) {
631 // Since guest URLs are only used for packaged apps, there must be an app
633 CHECK(site
.has_host());
634 *partition_domain
= site
.host();
635 // Since persistence is optional, the path must either be empty or the
637 *in_memory
= (site
.path() != "/persist");
638 // The partition name is user supplied value, which we have encoded when the
639 // URL was created, so it needs to be decoded.
640 *partition_name
= net::UnescapeURLComponent(site
.query(),
641 net::UnescapeRule::NORMAL
);
642 } else if (site
.SchemeIs(extensions::kExtensionScheme
)) {
643 // If |can_be_default| is false, the caller is stating that the |site|
644 // should be parsed as if it had isolated storage. In particular it is
645 // important to NOT check ExtensionService for the is_storage_isolated()
646 // attribute because this code path is run during Extension uninstall
647 // to do cleanup after the Extension has already been unloaded from the
649 bool is_isolated
= !can_be_default
;
650 if (can_be_default
) {
651 const Extension
* extension
= NULL
;
652 Profile
* profile
= Profile::FromBrowserContext(browser_context
);
653 ExtensionService
* extension_service
=
654 extensions::ExtensionSystem::Get(profile
)->extension_service();
655 if (extension_service
) {
656 extension
= extension_service
->extensions()->
657 GetExtensionOrAppByURL(ExtensionURLInfo(site
));
659 extensions::AppIsolationInfo::HasIsolatedStorage(extension
)) {
666 CHECK(site
.has_host());
667 // For extensions with isolated storage, the the host of the |site| is
668 // the |partition_domain|. The |in_memory| and |partition_name| are only
669 // used in guest schemes so they are cleared here.
670 *partition_domain
= site
.host();
672 partition_name
->clear();
676 // Assert that if |can_be_default| is false, the code above must have found a
677 // non-default partition. If this fails, the caller has a serious logic
678 // error about which StoragePartition they expect to be in and it is not
680 CHECK(can_be_default
|| !partition_domain
->empty());
683 content::WebContentsViewDelegate
*
684 ChromeContentBrowserClient::GetWebContentsViewDelegate(
685 content::WebContents
* web_contents
) {
686 return chrome::CreateWebContentsViewDelegate(web_contents
);
689 // Check if the extension activity log is enabled for the profile.
690 static bool IsExtensionActivityLogEnabledForProfile(Profile
* profile
) {
691 // crbug.com/247908 - This should be IsLogEnabled except for an issue
692 // in chrome_frame_net_tests
693 return extensions::ActivityLog::IsLogEnabledOnAnyProfile();
696 void ChromeContentBrowserClient::GuestWebContentsAttached(
697 WebContents
* guest_web_contents
,
698 WebContents
* embedder_web_contents
,
699 int browser_plugin_instance_id
) {
700 Profile
* profile
= Profile::FromBrowserContext(
701 embedder_web_contents
->GetBrowserContext());
702 ExtensionService
* service
=
703 extensions::ExtensionSystem::Get(profile
)->extension_service();
706 const GURL
& url
= embedder_web_contents
->GetSiteInstance()->GetSiteURL();
707 const Extension
* extension
= service
->extensions()->
708 GetExtensionOrAppByURL(ExtensionURLInfo(url
));
711 std::vector
<ExtensionMsg_Loaded_Params
> extensions
;
712 extensions
.push_back(ExtensionMsg_Loaded_Params(extension
));
713 guest_web_contents
->Send(new ExtensionMsg_Loaded(extensions
));
714 new WebViewGuest(guest_web_contents
,
715 embedder_web_contents
,
717 browser_plugin_instance_id
);
720 void ChromeContentBrowserClient::RenderProcessHostCreated(
721 content::RenderProcessHost
* host
) {
722 int id
= host
->GetID();
723 Profile
* profile
= Profile::FromBrowserContext(host
->GetBrowserContext());
724 net::URLRequestContextGetter
* context
=
725 profile
->GetRequestContextForRenderProcess(id
);
727 host
->GetChannel()->AddFilter(new ChromeRenderMessageFilter(
728 id
, profile
, context
));
729 #if defined(ENABLE_PLUGINS)
730 host
->GetChannel()->AddFilter(new PluginInfoMessageFilter(id
, profile
));
732 #if defined(ENABLE_PRINTING)
733 host
->GetChannel()->AddFilter(new PrintingMessageFilter(id
, profile
));
735 host
->GetChannel()->AddFilter(
736 new SearchProviderInstallStateMessageFilter(id
, profile
));
737 host
->GetChannel()->AddFilter(new SpellCheckMessageFilter(id
));
738 #if defined(OS_MACOSX)
739 host
->GetChannel()->AddFilter(new SpellCheckMessageFilterMac(id
));
741 host
->GetChannel()->AddFilter(new ChromeNetBenchmarkingMessageFilter(
742 id
, profile
, context
));
743 host
->GetChannel()->AddFilter(
744 new prerender::PrerenderMessageFilter(id
, profile
));
745 host
->GetChannel()->AddFilter(new ValidationMessageMessageFilter(id
));
746 host
->GetChannel()->AddFilter(new TtsMessageFilter(id
, profile
));
747 #if defined(ENABLE_WEBRTC)
748 host
->GetChannel()->AddFilter(new WebRtcLoggingHandlerHost());
750 #if !defined(DISABLE_NACL)
751 host
->GetChannel()->AddFilter(new NaClHostMessageFilter(id
, profile
,
755 host
->Send(new ChromeViewMsg_SetIsIncognitoProcess(
756 profile
->IsOffTheRecord()));
758 host
->Send(new ChromeViewMsg_SetExtensionActivityLogEnabled(
759 IsExtensionActivityLogEnabledForProfile(profile
)));
761 SendExtensionWebRequestStatusToHost(host
);
763 RendererContentSettingRules rules
;
764 GetRendererContentSettingRules(profile
->GetHostContentSettingsMap(), &rules
);
765 host
->Send(new ChromeViewMsg_SetContentSettingRules(rules
));
768 GURL
ChromeContentBrowserClient::GetPossiblyPrivilegedURL(
769 content::BrowserContext
* browser_context
,
771 bool is_renderer_initiated
,
772 content::SiteInstance
* current_instance
) {
773 Profile
* profile
= Profile::FromBrowserContext(browser_context
);
777 // Only return the privileged instant URL if we are entering from a browser-
778 // initiated navigation or if we are already in the instant process.
779 bool is_instant_process
= false;
780 int process_id
= current_instance
->GetProcess()->GetID();
781 InstantService
* instant_service
=
782 InstantServiceFactory::GetForProfile(profile
);
784 is_instant_process
= instant_service
->IsInstantProcess(process_id
);
786 DCHECK_EQ(is_instant_process
,
787 chrome::IsPrivilegedURLForInstant(current_instance
->GetSiteURL()));
788 if (!is_renderer_initiated
|| is_instant_process
) {
789 // If the input |url| should be assigned to the Instant renderer, make its
790 // privileged URL distinct from other URLs on the search provider's domain.
791 if (chrome::ShouldAssignURLToInstantRenderer(url
, profile
))
792 return chrome::GetPrivilegedURLForInstant(url
, profile
);
798 GURL
ChromeContentBrowserClient::GetEffectiveURL(
799 content::BrowserContext
* browser_context
, const GURL
& url
) {
800 Profile
* profile
= Profile::FromBrowserContext(browser_context
);
804 #if !defined(OS_CHROMEOS)
805 // If the input |url| should be assigned to the Signin renderer, make its
806 // effective URL distinct from other URLs on the signin service's domain.
807 // Note that the signin renderer will be allowed to sign the user in to
809 if (SigninManager::IsWebBasedSigninFlowURL(url
))
810 return GetEffectiveURLForSignin(url
);
813 // If the input |url| is part of an installed app, the effective URL is an
814 // extension URL with the ID of that extension as the host. This has the
815 // effect of grouping apps together in a common SiteInstance.
816 ExtensionService
* extension_service
=
817 extensions::ExtensionSystem::Get(profile
)->extension_service();
818 if (!extension_service
)
821 const Extension
* extension
= extension_service
->extensions()->
822 GetHostedAppByURL(ExtensionURLInfo(url
));
826 // Bookmark apps do not use the hosted app process model, and should be
827 // treated as normal URLs.
828 if (extension
->from_bookmark())
831 // If the URL is part of an extension's web extent, convert it to an
833 return extension
->GetResourceURL(url
.path());
836 bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
837 content::BrowserContext
* browser_context
, const GURL
& effective_url
) {
838 // Non-extension, non-Instant URLs should generally use
839 // process-per-site-instance. Because we expect to use the effective URL,
840 // URLs for hosted apps (apart from bookmark apps) should have an extension
843 Profile
* profile
= Profile::FromBrowserContext(browser_context
);
847 if (chrome::ShouldAssignURLToInstantRenderer(effective_url
, profile
))
850 #if !defined(OS_CHROMEOS)
851 if (SigninManager::IsWebBasedSigninFlowURL(effective_url
))
855 if (!effective_url
.SchemeIs(extensions::kExtensionScheme
))
858 ExtensionService
* extension_service
=
859 extensions::ExtensionSystem::Get(profile
)->extension_service();
860 if (!extension_service
)
863 const Extension
* extension
= extension_service
->extensions()->
864 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url
));
868 // If the URL is part of a hosted app that does not have the background
869 // permission, or that does not allow JavaScript access to the background
870 // page, we want to give each instance its own process to improve
872 if (extension
->GetType() == Manifest::TYPE_HOSTED_APP
) {
873 if (!extension
->HasAPIPermission(APIPermission::kBackground
) ||
874 !extensions::BackgroundInfo::AllowJSAccess(extension
)) {
879 // Hosted apps that have script access to their background page must use
880 // process per site, since all instances can make synchronous calls to the
881 // background window. Other extensions should use process per site as well.
885 // These are treated as WebUI schemes but do not get WebUI bindings.
886 void ChromeContentBrowserClient::GetAdditionalWebUISchemes(
887 std::vector
<std::string
>* additional_schemes
) {
888 additional_schemes
->push_back(chrome::kChromeSearchScheme
);
891 net::URLRequestContextGetter
*
892 ChromeContentBrowserClient::CreateRequestContext(
893 content::BrowserContext
* browser_context
,
894 content::ProtocolHandlerMap
* protocol_handlers
) {
895 Profile
* profile
= Profile::FromBrowserContext(browser_context
);
896 return profile
->CreateRequestContext(protocol_handlers
);
899 net::URLRequestContextGetter
*
900 ChromeContentBrowserClient::CreateRequestContextForStoragePartition(
901 content::BrowserContext
* browser_context
,
902 const base::FilePath
& partition_path
,
904 content::ProtocolHandlerMap
* protocol_handlers
) {
905 Profile
* profile
= Profile::FromBrowserContext(browser_context
);
906 return profile
->CreateRequestContextForStoragePartition(
907 partition_path
, in_memory
, protocol_handlers
);
910 bool ChromeContentBrowserClient::IsHandledURL(const GURL
& url
) {
911 return ProfileIOData::IsHandledURL(url
);
914 bool ChromeContentBrowserClient::CanCommitURL(
915 content::RenderProcessHost
* process_host
,
917 // We need to let most extension URLs commit in any process, since this can
918 // be allowed due to web_accessible_resources. Most hosted app URLs may also
919 // load in any process (e.g., in an iframe). However, the Chrome Web Store
920 // cannot be loaded in iframes and should never be requested outside its
923 Profile::FromBrowserContext(process_host
->GetBrowserContext());
924 ExtensionService
* service
=
925 extensions::ExtensionSystem::Get(profile
)->extension_service();
928 const Extension
* new_extension
=
929 service
->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url
));
931 new_extension
->is_hosted_app() &&
932 new_extension
->id() == extension_misc::kWebStoreAppId
&&
933 !service
->process_map()->Contains(new_extension
->id(),
934 process_host
->GetID())) {
941 bool ChromeContentBrowserClient::IsSuitableHost(
942 content::RenderProcessHost
* process_host
,
943 const GURL
& site_url
) {
945 Profile::FromBrowserContext(process_host
->GetBrowserContext());
946 // This may be NULL during tests. In that case, just assume any site can
951 // Instant URLs should only be in the instant process and instant process
952 // should only have Instant URLs.
953 InstantService
* instant_service
=
954 InstantServiceFactory::GetForProfile(profile
);
955 if (instant_service
) {
956 bool is_instant_process
= instant_service
->IsInstantProcess(
957 process_host
->GetID());
958 bool should_be_in_instant_process
=
959 chrome::ShouldAssignURLToInstantRenderer(site_url
, profile
);
960 if (is_instant_process
|| should_be_in_instant_process
)
961 return is_instant_process
&& should_be_in_instant_process
;
964 #if !defined(OS_CHROMEOS)
965 SigninManager
* signin_manager
= SigninManagerFactory::GetForProfile(profile
);
966 if (signin_manager
&& signin_manager
->IsSigninProcess(process_host
->GetID()))
967 return SigninManager::IsWebBasedSigninFlowURL(site_url
);
970 ExtensionService
* service
=
971 extensions::ExtensionSystem::Get(profile
)->extension_service();
972 extensions::ProcessMap
* process_map
= service
->process_map();
974 // Don't allow the Task Manager to share a process with anything else.
975 // Otherwise it can affect the renderers it is observing.
976 // Note: we could create another RenderProcessHostPrivilege bucket for
977 // this to allow multiple chrome://tasks instances to share, but that's
978 // a very unlikely case without serious consequences.
979 if (site_url
.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL
).GetOrigin())
982 // These may be NULL during tests. In that case, just assume any site can
984 if (!service
|| !process_map
)
987 // Otherwise, just make sure the process privilege matches the privilege
988 // required by the site.
989 RenderProcessHostPrivilege privilege_required
=
990 GetPrivilegeRequiredByUrl(site_url
, service
);
991 return GetProcessPrivilege(process_host
, process_map
, service
) ==
995 // This function is trying to limit the amount of processes used by extensions
996 // with background pages. It uses a globally set percentage of processes to
997 // run such extensions and if the limit is exceeded, it returns true, to
998 // indicate to the content module to group extensions together.
999 bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost(
1000 content::BrowserContext
* browser_context
, const GURL
& url
) {
1001 // It has to be a valid URL for us to check for an extension.
1002 if (!url
.is_valid())
1005 Profile
* profile
= Profile::FromBrowserContext(browser_context
);
1006 ExtensionService
* service
= !profile
? NULL
:
1007 extensions::ExtensionSystem::Get(profile
)->extension_service();
1011 // We have to have a valid extension with background page to proceed.
1012 const Extension
* extension
=
1013 service
->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url
));
1016 if (!extensions::BackgroundInfo::HasBackgroundPage(extension
))
1019 std::set
<int> process_ids
;
1020 size_t max_process_count
=
1021 content::RenderProcessHost::GetMaxRendererProcessCount();
1023 // Go through all profiles to ensure we have total count of extension
1024 // processes containing background pages, otherwise one profile can
1025 // starve the other.
1026 std::vector
<Profile
*> profiles
= g_browser_process
->profile_manager()->
1027 GetLoadedProfiles();
1028 for (size_t i
= 0; i
< profiles
.size(); ++i
) {
1029 ExtensionProcessManager
* epm
=
1030 extensions::ExtensionSystem::Get(profiles
[i
])->process_manager();
1031 for (ExtensionProcessManager::const_iterator iter
=
1032 epm
->background_hosts().begin();
1033 iter
!= epm
->background_hosts().end(); ++iter
) {
1034 const extensions::ExtensionHost
* host
= *iter
;
1035 process_ids
.insert(host
->render_process_host()->GetID());
1039 if (process_ids
.size() >
1040 (max_process_count
* chrome::kMaxShareOfExtensionProcesses
)) {
1047 void ChromeContentBrowserClient::SiteInstanceGotProcess(
1048 SiteInstance
* site_instance
) {
1049 CHECK(site_instance
->HasProcess());
1051 Profile
* profile
= Profile::FromBrowserContext(
1052 site_instance
->GetBrowserContext());
1056 // Remember the ID of the Instant process to signal the renderer process
1057 // on startup in |AppendExtraCommandLineSwitches| below.
1058 if (chrome::ShouldAssignURLToInstantRenderer(
1059 site_instance
->GetSiteURL(), profile
)) {
1060 InstantService
* instant_service
=
1061 InstantServiceFactory::GetForProfile(profile
);
1062 if (instant_service
)
1063 instant_service
->AddInstantProcess(site_instance
->GetProcess()->GetID());
1066 #if !defined(OS_CHROMEOS)
1067 // We only expect there to be one signin process as we use process-per-site
1068 // for signin URLs. The signin process will be cleared from SigninManager
1069 // when the renderer is destroyed.
1070 if (SigninManager::IsWebBasedSigninFlowURL(site_instance
->GetSiteURL())) {
1071 SigninManager
* signin_manager
=
1072 SigninManagerFactory::GetForProfile(profile
);
1074 signin_manager
->SetSigninProcess(site_instance
->GetProcess()->GetID());
1075 BrowserThread::PostTask(
1076 BrowserThread::IO
, FROM_HERE
,
1077 base::Bind(&ExtensionInfoMap::SetSigninProcess
,
1078 extensions::ExtensionSystem::Get(profile
)->info_map(),
1079 site_instance
->GetProcess()->GetID()));
1083 ExtensionService
* service
=
1084 extensions::ExtensionSystem::Get(profile
)->extension_service();
1088 const Extension
* extension
=
1089 service
->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(
1090 site_instance
->GetSiteURL()));
1094 service
->process_map()->Insert(extension
->id(),
1095 site_instance
->GetProcess()->GetID(),
1096 site_instance
->GetId());
1097 BrowserThread::PostTask(
1098 BrowserThread::IO
, FROM_HERE
,
1099 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess
,
1100 extensions::ExtensionSystem::Get(profile
)->info_map(),
1102 site_instance
->GetProcess()->GetID(),
1103 site_instance
->GetId()));
1106 void ChromeContentBrowserClient::SiteInstanceDeleting(
1107 SiteInstance
* site_instance
) {
1108 if (!site_instance
->HasProcess())
1111 Profile
* profile
= Profile::FromBrowserContext(
1112 site_instance
->GetBrowserContext());
1113 ExtensionService
* service
=
1114 extensions::ExtensionSystem::Get(profile
)->extension_service();
1118 const Extension
* extension
=
1119 service
->extensions()->GetExtensionOrAppByURL(
1120 ExtensionURLInfo(site_instance
->GetSiteURL()));
1124 service
->process_map()->Remove(extension
->id(),
1125 site_instance
->GetProcess()->GetID(),
1126 site_instance
->GetId());
1127 BrowserThread::PostTask(
1128 BrowserThread::IO
, FROM_HERE
,
1129 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess
,
1130 extensions::ExtensionSystem::Get(profile
)->info_map(),
1132 site_instance
->GetProcess()->GetID(),
1133 site_instance
->GetId()));
1136 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
1137 SiteInstance
* site_instance
,
1138 const GURL
& current_url
,
1139 const GURL
& new_url
) {
1140 if (current_url
.is_empty()) {
1141 // Always choose a new process when navigating to extension URLs. The
1142 // process grouping logic will combine all of a given extension's pages
1143 // into the same process.
1144 if (new_url
.SchemeIs(extensions::kExtensionScheme
))
1150 // Also, we must switch if one is an extension and the other is not the exact
1152 if (current_url
.SchemeIs(extensions::kExtensionScheme
) ||
1153 new_url
.SchemeIs(extensions::kExtensionScheme
)) {
1154 if (current_url
.GetOrigin() != new_url
.GetOrigin())
1158 // The checks below only matter if we can retrieve which extensions are
1161 Profile::FromBrowserContext(site_instance
->GetBrowserContext());
1162 ExtensionService
* service
=
1163 extensions::ExtensionSystem::Get(profile
)->extension_service();
1167 // We must swap if the URL is for an extension and we are not using an
1168 // extension process.
1169 const Extension
* new_extension
=
1170 service
->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(new_url
));
1171 // Ignore all hosted apps except the Chrome Web Store, since they do not
1172 // require their own BrowsingInstance (e.g., postMessage is ok).
1173 if (new_extension
&&
1174 new_extension
->is_hosted_app() &&
1175 new_extension
->id() != extension_misc::kWebStoreAppId
)
1176 new_extension
= NULL
;
1177 if (new_extension
&&
1178 site_instance
->HasProcess() &&
1179 !service
->process_map()->Contains(new_extension
->id(),
1180 site_instance
->GetProcess()->GetID()))
1186 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect(
1187 content::ResourceContext
* resource_context
, const GURL
& current_url
,
1188 const GURL
& new_url
) {
1189 ProfileIOData
* io_data
= ProfileIOData::FromResourceContext(resource_context
);
1190 return extensions::CrossesExtensionProcessBoundary(
1191 io_data
->GetExtensionInfoMap()->extensions(),
1192 ExtensionURLInfo(current_url
), ExtensionURLInfo(new_url
), false);
1195 std::string
ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName(
1196 const std::string
& alias_name
) {
1197 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name
);
1200 void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
1201 CommandLine
* command_line
, int child_process_id
) {
1202 #if defined(USE_LINUX_BREAKPAD)
1203 if (IsCrashReporterEnabled()) {
1204 command_line
->AppendSwitchASCII(switches::kEnableCrashReporter
,
1205 child_process_logging::GetClientId() + "," + base::GetLinuxDistro());
1207 #elif defined(OS_MACOSX)
1208 if (IsCrashReporterEnabled()) {
1209 command_line
->AppendSwitchASCII(switches::kEnableCrashReporter
,
1210 child_process_logging::GetClientId());
1214 if (logging::DialogsAreSuppressed())
1215 command_line
->AppendSwitch(switches::kNoErrorDialogs
);
1217 std::string process_type
=
1218 command_line
->GetSwitchValueASCII(switches::kProcessType
);
1219 const CommandLine
& browser_command_line
= *CommandLine::ForCurrentProcess();
1221 if (browser_command_line
.HasSwitch(switches::kChromeFrame
))
1222 command_line
->AppendSwitch(switches::kChromeFrame
);
1224 if (process_type
== switches::kRendererProcess
) {
1225 base::FilePath user_data_dir
=
1226 browser_command_line
.GetSwitchValuePath(switches::kUserDataDir
);
1227 if (!user_data_dir
.empty())
1228 command_line
->AppendSwitchPath(switches::kUserDataDir
, user_data_dir
);
1229 #if defined(OS_CHROMEOS)
1230 const std::string
& login_profile
=
1231 browser_command_line
.GetSwitchValueASCII(
1232 chromeos::switches::kLoginProfile
);
1233 if (!login_profile
.empty())
1234 command_line
->AppendSwitchASCII(
1235 chromeos::switches::kLoginProfile
, login_profile
);
1238 content::RenderProcessHost
* process
=
1239 content::RenderProcessHost::FromID(child_process_id
);
1241 Profile
* profile
= Profile::FromBrowserContext(
1242 process
->GetBrowserContext());
1243 ExtensionService
* extension_service
=
1244 extensions::ExtensionSystem::Get(profile
)->extension_service();
1245 if (extension_service
) {
1246 extensions::ProcessMap
* process_map
= extension_service
->process_map();
1247 if (process_map
&& process_map
->Contains(process
->GetID()))
1248 command_line
->AppendSwitch(switches::kExtensionProcess
);
1251 PrefService
* prefs
= profile
->GetPrefs();
1252 // Currently this pref is only registered if applied via a policy.
1253 if (prefs
->HasPrefPath(prefs::kDisable3DAPIs
) &&
1254 prefs
->GetBoolean(prefs::kDisable3DAPIs
)) {
1255 // Turn this policy into a command line switch.
1256 command_line
->AppendSwitch(switches::kDisable3DAPIs
);
1259 // Disable client-side phishing detection in the renderer if it is
1260 // disabled in the Profile preferences or the browser process.
1261 if (!prefs
->GetBoolean(prefs::kSafeBrowsingEnabled
) ||
1262 !g_browser_process
->safe_browsing_detection_service()) {
1263 command_line
->AppendSwitch(
1264 switches::kDisableClientSidePhishingDetection
);
1267 if (!prefs
->GetBoolean(prefs::kPrintPreviewDisabled
))
1268 command_line
->AppendSwitch(switches::kRendererPrintPreview
);
1270 InstantService
* instant_service
=
1271 InstantServiceFactory::GetForProfile(profile
);
1272 if (instant_service
&&
1273 instant_service
->IsInstantProcess(process
->GetID()))
1274 command_line
->AppendSwitch(switches::kInstantProcess
);
1276 #if !defined(OS_CHROMEOS)
1277 SigninManager
* signin_manager
=
1278 SigninManagerFactory::GetForProfile(profile
);
1279 if (signin_manager
&& signin_manager
->IsSigninProcess(process
->GetID()))
1280 command_line
->AppendSwitch(switches::kSigninProcess
);
1284 if (content::IsThreadedCompositingEnabled())
1285 command_line
->AppendSwitch(switches::kEnableThreadedCompositing
);
1287 if (message_center::IsRichNotificationEnabled())
1288 command_line
->AppendSwitch(switches::kDisableHTMLNotifications
);
1290 // Please keep this in alphabetical order.
1291 static const char* const kSwitchNames
[] = {
1292 autofill::switches::kDisableInteractiveAutocomplete
,
1293 autofill::switches::kEnableExperimentalFormFilling
,
1294 autofill::switches::kEnableInteractiveAutocomplete
,
1295 switches::kAllowHTTPBackgroundPage
,
1296 switches::kAllowLegacyExtensionManifests
,
1297 // TODO(victorhsieh): remove the following flag once we move PPAPI FileIO
1299 switches::kAllowNaClFileHandleAPI
,
1300 switches::kAllowScriptingGallery
,
1301 switches::kAppsCheckoutURL
,
1302 switches::kAppsGalleryURL
,
1303 switches::kCloudPrintServiceURL
,
1304 switches::kDebugPrint
,
1305 switches::kDisableBundledPpapiFlash
,
1306 switches::kDisableExtensionsResourceWhitelist
,
1307 switches::kDisableScriptedPrintThrottling
,
1308 switches::kEnableAdview
,
1309 switches::kEnableAdviewSrcAttribute
,
1310 switches::kEnableBenchmarking
,
1311 switches::kEnableExperimentalExtensionApis
,
1312 switches::kEnableIPCFuzzing
,
1313 switches::kEnableNaCl
,
1314 switches::kEnableNetBenchmarking
,
1315 switches::kEnablePasswordGeneration
,
1316 switches::kEnablePnacl
,
1317 switches::kEnableWatchdog
,
1318 switches::kExtensionsOnChromeURLs
,
1319 switches::kMemoryProfiling
,
1320 switches::kMessageLoopHistogrammer
,
1321 switches::kNoJsRandomness
,
1322 switches::kPlaybackMode
,
1323 switches::kPpapiFlashArgs
,
1324 switches::kPpapiFlashInProcess
,
1325 switches::kPpapiFlashPath
,
1326 switches::kPpapiFlashVersion
,
1327 switches::kProfilingAtStart
,
1328 switches::kProfilingFile
,
1329 switches::kProfilingFlush
,
1330 switches::kRecordMode
,
1331 switches::kSilentDumpOnDCHECK
,
1332 switches::kSpdyProxyAuthOrigin
,
1333 switches::kWhitelistedExtensionID
,
1336 command_line
->CopySwitchesFrom(browser_command_line
, kSwitchNames
,
1337 arraysize(kSwitchNames
));
1338 } else if (process_type
== switches::kUtilityProcess
) {
1339 static const char* const kSwitchNames
[] = {
1340 switches::kAllowHTTPBackgroundPage
,
1341 switches::kEnableExperimentalExtensionApis
,
1342 switches::kWhitelistedExtensionID
,
1345 command_line
->CopySwitchesFrom(browser_command_line
, kSwitchNames
,
1346 arraysize(kSwitchNames
));
1347 } else if (process_type
== switches::kPluginProcess
) {
1348 static const char* const kSwitchNames
[] = {
1349 #if defined(OS_CHROMEOS)
1350 chromeos::switches::kLoginProfile
,
1352 switches::kMemoryProfiling
,
1353 switches::kSilentDumpOnDCHECK
,
1354 switches::kUserDataDir
,
1357 command_line
->CopySwitchesFrom(browser_command_line
, kSwitchNames
,
1358 arraysize(kSwitchNames
));
1359 } else if (process_type
== switches::kZygoteProcess
) {
1360 static const char* const kSwitchNames
[] = {
1361 switches::kUserDataDir
, // Make logs go to the right file.
1362 // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox.
1363 switches::kDisableBundledPpapiFlash
,
1364 switches::kPpapiFlashInProcess
,
1365 switches::kPpapiFlashPath
,
1366 switches::kPpapiFlashVersion
,
1369 command_line
->CopySwitchesFrom(browser_command_line
, kSwitchNames
,
1370 arraysize(kSwitchNames
));
1371 } else if (process_type
== switches::kGpuProcess
) {
1372 base::FilePath user_data_dir
=
1373 browser_command_line
.GetSwitchValuePath(switches::kUserDataDir
);
1374 if (!user_data_dir
.empty())
1375 command_line
->AppendSwitchPath(switches::kUserDataDir
, user_data_dir
);
1376 // If --ignore-gpu-blacklist is passed in, don't send in crash reports
1377 // because GPU is expected to be unreliable.
1378 if (browser_command_line
.HasSwitch(switches::kIgnoreGpuBlacklist
) &&
1379 !command_line
->HasSwitch(switches::kDisableBreakpad
))
1380 command_line
->AppendSwitch(switches::kDisableBreakpad
);
1383 // The command line switch kEnableBenchmarking needs to be specified along
1384 // with the kEnableStatsTable switch to ensure that the stats table global
1385 // is initialized correctly.
1386 if (command_line
->HasSwitch(switches::kEnableBenchmarking
))
1387 DCHECK(command_line
->HasSwitch(switches::kEnableStatsTable
));
1390 std::string
ChromeContentBrowserClient::GetApplicationLocale() {
1391 if (BrowserThread::CurrentlyOn(BrowserThread::IO
))
1392 return g_io_thread_application_locale
.Get();
1393 return g_browser_process
->GetApplicationLocale();
1396 std::string
ChromeContentBrowserClient::GetAcceptLangs(
1397 content::BrowserContext
* context
) {
1398 Profile
* profile
= Profile::FromBrowserContext(context
);
1399 return profile
->GetPrefs()->GetString(prefs::kAcceptLanguages
);
1402 gfx::ImageSkia
* ChromeContentBrowserClient::GetDefaultFavicon() {
1403 ResourceBundle
& rb
= ResourceBundle::GetSharedInstance();
1404 return rb
.GetImageSkiaNamed(IDR_DEFAULT_FAVICON
);
1407 bool ChromeContentBrowserClient::AllowAppCache(
1408 const GURL
& manifest_url
,
1409 const GURL
& first_party
,
1410 content::ResourceContext
* context
) {
1411 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
1412 ProfileIOData
* io_data
= ProfileIOData::FromResourceContext(context
);
1413 return io_data
->GetCookieSettings()->
1414 IsSettingCookieAllowed(manifest_url
, first_party
);
1417 bool ChromeContentBrowserClient::AllowGetCookie(
1419 const GURL
& first_party
,
1420 const net::CookieList
& cookie_list
,
1421 content::ResourceContext
* context
,
1422 int render_process_id
,
1423 int render_view_id
) {
1424 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
1425 ProfileIOData
* io_data
= ProfileIOData::FromResourceContext(context
);
1426 bool allow
= io_data
->GetCookieSettings()->
1427 IsReadingCookieAllowed(url
, first_party
);
1429 BrowserThread::PostTask(
1430 BrowserThread::UI
, FROM_HERE
,
1431 base::Bind(&TabSpecificContentSettings::CookiesRead
, render_process_id
,
1432 render_view_id
, url
, first_party
, cookie_list
, !allow
));
1436 bool ChromeContentBrowserClient::AllowSetCookie(
1438 const GURL
& first_party
,
1439 const std::string
& cookie_line
,
1440 content::ResourceContext
* context
,
1441 int render_process_id
,
1443 net::CookieOptions
* options
) {
1444 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
1445 ProfileIOData
* io_data
= ProfileIOData::FromResourceContext(context
);
1446 CookieSettings
* cookie_settings
= io_data
->GetCookieSettings();
1447 bool allow
= cookie_settings
->IsSettingCookieAllowed(url
, first_party
);
1449 BrowserThread::PostTask(
1450 BrowserThread::UI
, FROM_HERE
,
1451 base::Bind(&TabSpecificContentSettings::CookieChanged
, render_process_id
,
1452 render_view_id
, url
, first_party
, cookie_line
, *options
,
1457 bool ChromeContentBrowserClient::AllowSaveLocalState(
1458 content::ResourceContext
* context
) {
1459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
1460 ProfileIOData
* io_data
= ProfileIOData::FromResourceContext(context
);
1461 CookieSettings
* cookie_settings
= io_data
->GetCookieSettings();
1462 ContentSetting setting
= cookie_settings
->GetDefaultCookieSetting(NULL
);
1464 // TODO(bauerb): Should we also disallow local state if the default is BLOCK?
1465 // Could we even support per-origin settings?
1466 return setting
!= CONTENT_SETTING_SESSION_ONLY
;
1469 bool ChromeContentBrowserClient::AllowWorkerDatabase(
1471 const string16
& name
,
1472 const string16
& display_name
,
1473 unsigned long estimated_size
,
1474 content::ResourceContext
* context
,
1475 const std::vector
<std::pair
<int, int> >& render_views
) {
1476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
1477 ProfileIOData
* io_data
= ProfileIOData::FromResourceContext(context
);
1478 CookieSettings
* cookie_settings
= io_data
->GetCookieSettings();
1479 bool allow
= cookie_settings
->IsSettingCookieAllowed(url
, url
);
1481 // Record access to database for potential display in UI.
1482 std::vector
<std::pair
<int, int> >::const_iterator i
;
1483 for (i
= render_views
.begin(); i
!= render_views
.end(); ++i
) {
1484 BrowserThread::PostTask(
1485 BrowserThread::UI
, FROM_HERE
,
1486 base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed
,
1487 i
->first
, i
->second
, url
, name
, display_name
, !allow
));
1493 bool ChromeContentBrowserClient::AllowWorkerFileSystem(
1495 content::ResourceContext
* context
,
1496 const std::vector
<std::pair
<int, int> >& render_views
) {
1497 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
1498 ProfileIOData
* io_data
= ProfileIOData::FromResourceContext(context
);
1499 CookieSettings
* cookie_settings
= io_data
->GetCookieSettings();
1500 bool allow
= cookie_settings
->IsSettingCookieAllowed(url
, url
);
1502 // Record access to file system for potential display in UI.
1503 std::vector
<std::pair
<int, int> >::const_iterator i
;
1504 for (i
= render_views
.begin(); i
!= render_views
.end(); ++i
) {
1505 BrowserThread::PostTask(
1506 BrowserThread::UI
, FROM_HERE
,
1507 base::Bind(&TabSpecificContentSettings::FileSystemAccessed
,
1508 i
->first
, i
->second
, url
, !allow
));
1514 bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
1516 const string16
& name
,
1517 content::ResourceContext
* context
,
1518 const std::vector
<std::pair
<int, int> >& render_views
) {
1519 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
1520 ProfileIOData
* io_data
= ProfileIOData::FromResourceContext(context
);
1521 CookieSettings
* cookie_settings
= io_data
->GetCookieSettings();
1522 bool allow
= cookie_settings
->IsSettingCookieAllowed(url
, url
);
1524 // Record access to IndexedDB for potential display in UI.
1525 std::vector
<std::pair
<int, int> >::const_iterator i
;
1526 for (i
= render_views
.begin(); i
!= render_views
.end(); ++i
) {
1527 BrowserThread::PostTask(
1528 BrowserThread::UI
, FROM_HERE
,
1529 base::Bind(&TabSpecificContentSettings::IndexedDBAccessed
,
1530 i
->first
, i
->second
, url
, name
, !allow
));
1536 net::URLRequestContext
*
1537 ChromeContentBrowserClient::OverrideRequestContextForURL(
1538 const GURL
& url
, content::ResourceContext
* context
) {
1539 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
1540 if (url
.SchemeIs(extensions::kExtensionScheme
)) {
1541 ProfileIOData
* io_data
= ProfileIOData::FromResourceContext(context
);
1542 return io_data
->extensions_request_context();
1548 QuotaPermissionContext
*
1549 ChromeContentBrowserClient::CreateQuotaPermissionContext() {
1550 return new ChromeQuotaPermissionContext();
1553 void ChromeContentBrowserClient::AllowCertificateError(
1554 int render_process_id
,
1557 const net::SSLInfo
& ssl_info
,
1558 const GURL
& request_url
,
1559 ResourceType::Type resource_type
,
1561 bool strict_enforcement
,
1562 const base::Callback
<void(bool)>& callback
,
1563 content::CertificateRequestResultType
* result
) {
1564 if (resource_type
!= ResourceType::MAIN_FRAME
) {
1565 // A sub-resource has a certificate error. The user doesn't really
1566 // have a context for making the right decision, so block the
1567 // request hard, without an info bar to allow showing the insecure
1569 *result
= content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY
;
1573 // If the tab is being prerendered, cancel the prerender and the request.
1574 WebContents
* tab
= tab_util::GetWebContentsByID(
1575 render_process_id
, render_view_id
);
1580 prerender::PrerenderManager
* prerender_manager
=
1581 prerender::PrerenderManagerFactory::GetForProfile(
1582 Profile::FromBrowserContext(tab
->GetBrowserContext()));
1583 if (prerender_manager
&& prerender_manager
->IsWebContentsPrerendering(tab
,
1585 if (prerender_manager
->prerender_tracker()->TryCancel(
1586 render_process_id
, render_view_id
,
1587 prerender::FINAL_STATUS_SSL_ERROR
)) {
1588 *result
= content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL
;
1593 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
1594 captive_portal::CaptivePortalTabHelper
* captive_portal_tab_helper
=
1595 captive_portal::CaptivePortalTabHelper::FromWebContents(tab
);
1596 if (captive_portal_tab_helper
)
1597 captive_portal_tab_helper
->OnSSLCertError(ssl_info
);
1600 // Otherwise, display an SSL blocking page.
1601 new SSLBlockingPage(tab
, cert_error
, ssl_info
, request_url
, overridable
,
1602 strict_enforcement
, callback
);
1605 void ChromeContentBrowserClient::SelectClientCertificate(
1606 int render_process_id
,
1608 const net::HttpNetworkSession
* network_session
,
1609 net::SSLCertRequestInfo
* cert_request_info
,
1610 const base::Callback
<void(net::X509Certificate
*)>& callback
) {
1611 WebContents
* tab
= tab_util::GetWebContentsByID(
1612 render_process_id
, render_view_id
);
1618 GURL
requesting_url("https://" + cert_request_info
->host_and_port
);
1619 DCHECK(requesting_url
.is_valid()) << "Invalid URL string: https://"
1620 << cert_request_info
->host_and_port
;
1622 Profile
* profile
= Profile::FromBrowserContext(tab
->GetBrowserContext());
1623 scoped_ptr
<Value
> filter(
1624 profile
->GetHostContentSettingsMap()->GetWebsiteSetting(
1627 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE
,
1628 std::string(), NULL
));
1631 // Try to automatically select a client certificate.
1632 if (filter
->IsType(Value::TYPE_DICTIONARY
)) {
1633 DictionaryValue
* filter_dict
=
1634 static_cast<DictionaryValue
*>(filter
.get());
1636 const std::vector
<scoped_refptr
<net::X509Certificate
> >&
1637 all_client_certs
= cert_request_info
->client_certs
;
1638 for (size_t i
= 0; i
< all_client_certs
.size(); ++i
) {
1639 if (CertMatchesFilter(*all_client_certs
[i
].get(), *filter_dict
)) {
1640 // Use the first certificate that is matched by the filter.
1641 callback
.Run(all_client_certs
[i
].get());
1650 SSLTabHelper
* ssl_tab_helper
= SSLTabHelper::FromWebContents(tab
);
1651 if (!ssl_tab_helper
) {
1652 // If there is no SSLTabHelper for the given WebContents then we can't
1653 // show the user a dialog to select a client certificate. So we simply
1654 // proceed with no client certificate.
1658 ssl_tab_helper
->ShowClientCertificateRequestDialog(
1659 network_session
, cert_request_info
, callback
);
1662 void ChromeContentBrowserClient::AddCertificate(
1663 net::URLRequest
* request
,
1664 net::CertificateMimeType cert_type
,
1665 const void* cert_data
,
1667 int render_process_id
,
1668 int render_view_id
) {
1669 chrome::SSLAddCertificate(request
, cert_type
, cert_data
, cert_size
,
1670 render_process_id
, render_view_id
);
1673 content::MediaObserver
* ChromeContentBrowserClient::GetMediaObserver() {
1674 return MediaCaptureDevicesDispatcher::GetInstance();
1677 void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
1678 const GURL
& source_origin
,
1679 int callback_context
,
1680 int render_process_id
,
1681 int render_view_id
) {
1682 #if defined(ENABLE_NOTIFICATIONS)
1683 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI
));
1684 WebContents
* contents
=
1685 tab_util::GetWebContentsByID(render_process_id
, render_view_id
);
1691 // Skip showing the infobar if the request comes from an extension, and that
1692 // extension has the 'notify' permission. (If the extension does not have the
1693 // permission, the user will still be prompted.)
1694 Profile
* profile
= Profile::FromBrowserContext(contents
->GetBrowserContext());
1695 ExtensionInfoMap
* extension_info_map
=
1696 extensions::ExtensionSystem::Get(profile
)->info_map();
1697 DesktopNotificationService
* notification_service
=
1698 DesktopNotificationServiceFactory::GetForProfile(profile
);
1699 const Extension
* extension
= NULL
;
1700 if (extension_info_map
) {
1701 ExtensionSet extensions
;
1702 extension_info_map
->GetExtensionsWithAPIPermissionForSecurityOrigin(
1703 source_origin
, render_process_id
,
1704 extensions::APIPermission::kNotification
, &extensions
);
1705 for (ExtensionSet::const_iterator iter
= extensions
.begin();
1706 iter
!= extensions
.end(); ++iter
) {
1707 if (notification_service
->IsExtensionEnabled((*iter
)->id())) {
1708 extension
= iter
->get();
1713 RenderViewHost
* rvh
=
1714 RenderViewHost::FromID(render_process_id
, render_view_id
);
1715 if (IsExtensionWithPermissionOrSuggestInConsole(
1716 APIPermission::kNotification
, extension
, rvh
)) {
1718 rvh
->DesktopNotificationPermissionRequestDone(callback_context
);
1722 notification_service
->RequestPermission(source_origin
, render_process_id
,
1723 render_view_id
, callback_context
, contents
);
1729 WebKit::WebNotificationPresenter::Permission
1730 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
1731 const GURL
& source_origin
,
1732 content::ResourceContext
* context
,
1733 int render_process_id
) {
1734 #if defined(ENABLE_NOTIFICATIONS)
1735 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
1736 ProfileIOData
* io_data
= ProfileIOData::FromResourceContext(context
);
1738 DesktopNotificationService
* notification_service
=
1739 io_data
->GetNotificationService();
1740 if (notification_service
) {
1741 ExtensionInfoMap
* extension_info_map
= io_data
->GetExtensionInfoMap();
1742 ExtensionSet extensions
;
1743 extension_info_map
->GetExtensionsWithAPIPermissionForSecurityOrigin(
1744 source_origin
, render_process_id
,
1745 extensions::APIPermission::kNotification
, &extensions
);
1746 for (ExtensionSet::const_iterator iter
= extensions
.begin();
1747 iter
!= extensions
.end(); ++iter
) {
1748 if (notification_service
->IsExtensionEnabled((*iter
)->id()))
1749 return WebKit::WebNotificationPresenter::PermissionAllowed
;
1752 return notification_service
->HasPermission(source_origin
);
1755 return WebKit::WebNotificationPresenter::PermissionNotAllowed
;
1757 return WebKit::WebNotificationPresenter::PermissionAllowed
;
1761 void ChromeContentBrowserClient::ShowDesktopNotification(
1762 const content::ShowDesktopNotificationHostMsgParams
& params
,
1763 int render_process_id
,
1766 #if defined(ENABLE_NOTIFICATIONS)
1767 RenderViewHost
* rvh
= RenderViewHost::FromID(
1768 render_process_id
, render_view_id
);
1774 content::RenderProcessHost
* process
= rvh
->GetProcess();
1775 Profile
* profile
= Profile::FromBrowserContext(process
->GetBrowserContext());
1776 DesktopNotificationService
* service
=
1777 DesktopNotificationServiceFactory::GetForProfile(profile
);
1778 service
->ShowDesktopNotification(
1779 params
, render_process_id
, render_view_id
,
1780 worker
? DesktopNotificationService::WorkerNotification
:
1781 DesktopNotificationService::PageNotification
);
1787 void ChromeContentBrowserClient::CancelDesktopNotification(
1788 int render_process_id
,
1790 int notification_id
) {
1791 #if defined(ENABLE_NOTIFICATIONS)
1792 RenderViewHost
* rvh
= RenderViewHost::FromID(
1793 render_process_id
, render_view_id
);
1799 content::RenderProcessHost
* process
= rvh
->GetProcess();
1800 Profile
* profile
= Profile::FromBrowserContext(process
->GetBrowserContext());
1801 DesktopNotificationService
* service
=
1802 DesktopNotificationServiceFactory::GetForProfile(profile
);
1803 service
->CancelDesktopNotification(
1804 render_process_id
, render_view_id
, notification_id
);
1810 bool ChromeContentBrowserClient::CanCreateWindow(
1811 const GURL
& opener_url
,
1812 const GURL
& source_origin
,
1813 WindowContainerType container_type
,
1814 content::ResourceContext
* context
,
1815 int render_process_id
,
1816 bool* no_javascript_access
) {
1817 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
1819 *no_javascript_access
= false;
1821 // If the opener is trying to create a background window but doesn't have
1822 // the appropriate permission, fail the attempt.
1823 if (container_type
== WINDOW_CONTAINER_TYPE_BACKGROUND
) {
1824 ProfileIOData
* io_data
= ProfileIOData::FromResourceContext(context
);
1825 ExtensionInfoMap
* map
= io_data
->GetExtensionInfoMap();
1827 if (!map
->SecurityOriginHasAPIPermission(
1830 APIPermission::kBackground
)) {
1834 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may
1835 // return a recently installed Extension even if this CanCreateWindow call
1836 // was made by an old copy of the page in a normal web process. That's ok,
1837 // because the permission check above would have caused an early return
1838 // already. We must use the full URL to find hosted apps, though, and not
1840 const Extension
* extension
= map
->extensions().GetExtensionOrAppByURL(
1841 ExtensionURLInfo(opener_url
));
1842 if (extension
&& !extensions::BackgroundInfo::AllowJSAccess(extension
))
1843 *no_javascript_access
= true;
1846 // No new browser window (popup or tab) in app mode.
1847 if (container_type
== WINDOW_CONTAINER_TYPE_NORMAL
&&
1848 chrome::IsRunningInForcedAppMode()) {
1855 std::string
ChromeContentBrowserClient::GetWorkerProcessTitle(
1856 const GURL
& url
, content::ResourceContext
* context
) {
1857 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
1858 // Check if it's an extension-created worker, in which case we want to use
1859 // the name of the extension.
1860 ProfileIOData
* io_data
= ProfileIOData::FromResourceContext(context
);
1861 const Extension
* extension
=
1862 io_data
->GetExtensionInfoMap()->extensions().GetByID(url
.host());
1863 return extension
? extension
->name() : std::string();
1866 void ChromeContentBrowserClient::ResourceDispatcherHostCreated() {
1867 return g_browser_process
->ResourceDispatcherHostCreated();
1870 // TODO(tommi): Rename from Get to Create.
1871 content::SpeechRecognitionManagerDelegate
*
1872 ChromeContentBrowserClient::GetSpeechRecognitionManagerDelegate() {
1873 #if !defined(OS_ANDROID)
1874 return new speech::ChromeSpeechRecognitionManagerDelegate();
1876 // TODO(janx): Implement speech::AndroidSpeechRecognitionManagerDelegate
1877 // (see crbug.com/222352).
1882 net::NetLog
* ChromeContentBrowserClient::GetNetLog() {
1883 return g_browser_process
->net_log();
1886 AccessTokenStore
* ChromeContentBrowserClient::CreateAccessTokenStore() {
1887 return new ChromeAccessTokenStore();
1890 bool ChromeContentBrowserClient::IsFastShutdownPossible() {
1894 void ChromeContentBrowserClient::OverrideWebkitPrefs(
1895 RenderViewHost
* rvh
, const GURL
& url
, WebPreferences
* web_prefs
) {
1896 Profile
* profile
= Profile::FromBrowserContext(
1897 rvh
->GetProcess()->GetBrowserContext());
1898 PrefService
* prefs
= profile
->GetPrefs();
1900 FillFontFamilyMap(prefs
, prefs::kWebKitStandardFontFamilyMap
,
1901 &web_prefs
->standard_font_family_map
);
1902 FillFontFamilyMap(prefs
, prefs::kWebKitFixedFontFamilyMap
,
1903 &web_prefs
->fixed_font_family_map
);
1904 FillFontFamilyMap(prefs
, prefs::kWebKitSerifFontFamilyMap
,
1905 &web_prefs
->serif_font_family_map
);
1906 FillFontFamilyMap(prefs
, prefs::kWebKitSansSerifFontFamilyMap
,
1907 &web_prefs
->sans_serif_font_family_map
);
1908 FillFontFamilyMap(prefs
, prefs::kWebKitCursiveFontFamilyMap
,
1909 &web_prefs
->cursive_font_family_map
);
1910 FillFontFamilyMap(prefs
, prefs::kWebKitFantasyFontFamilyMap
,
1911 &web_prefs
->fantasy_font_family_map
);
1912 FillFontFamilyMap(prefs
, prefs::kWebKitPictographFontFamilyMap
,
1913 &web_prefs
->pictograph_font_family_map
);
1915 web_prefs
->default_font_size
=
1916 prefs
->GetInteger(prefs::kWebKitDefaultFontSize
);
1917 web_prefs
->default_fixed_font_size
=
1918 prefs
->GetInteger(prefs::kWebKitDefaultFixedFontSize
);
1919 web_prefs
->minimum_font_size
=
1920 prefs
->GetInteger(prefs::kWebKitMinimumFontSize
);
1921 web_prefs
->minimum_logical_font_size
=
1922 prefs
->GetInteger(prefs::kWebKitMinimumLogicalFontSize
);
1924 web_prefs
->default_encoding
= prefs
->GetString(prefs::kDefaultCharset
);
1926 web_prefs
->javascript_can_open_windows_automatically
=
1927 prefs
->GetBoolean(prefs::kWebKitJavascriptCanOpenWindowsAutomatically
);
1928 web_prefs
->dom_paste_enabled
=
1929 prefs
->GetBoolean(prefs::kWebKitDomPasteEnabled
);
1930 web_prefs
->shrinks_standalone_images_to_fit
=
1931 prefs
->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit
);
1932 const DictionaryValue
* inspector_settings
=
1933 prefs
->GetDictionary(prefs::kWebKitInspectorSettings
);
1934 if (inspector_settings
) {
1935 for (DictionaryValue::Iterator
iter(*inspector_settings
); !iter
.IsAtEnd();
1938 if (iter
.value().GetAsString(&value
)) {
1939 web_prefs
->inspector_settings
.push_back(
1940 std::make_pair(iter
.key(), value
));
1944 web_prefs
->tabs_to_links
= prefs
->GetBoolean(prefs::kWebkitTabsToLinks
);
1946 if (!prefs
->GetBoolean(prefs::kWebKitJavascriptEnabled
))
1947 web_prefs
->javascript_enabled
= false;
1948 if (!prefs
->GetBoolean(prefs::kWebKitWebSecurityEnabled
))
1949 web_prefs
->web_security_enabled
= false;
1950 if (!prefs
->GetBoolean(prefs::kWebKitPluginsEnabled
))
1951 web_prefs
->plugins_enabled
= false;
1952 if (!prefs
->GetBoolean(prefs::kWebKitJavaEnabled
))
1953 web_prefs
->java_enabled
= false;
1954 web_prefs
->loads_images_automatically
=
1955 prefs
->GetBoolean(prefs::kWebKitLoadsImagesAutomatically
);
1957 if (prefs
->GetBoolean(prefs::kDisable3DAPIs
))
1958 web_prefs
->experimental_webgl_enabled
= false;
1960 web_prefs
->memory_info_enabled
=
1961 prefs
->GetBoolean(prefs::kEnableMemoryInfo
);
1962 web_prefs
->allow_displaying_insecure_content
=
1963 prefs
->GetBoolean(prefs::kWebKitAllowDisplayingInsecureContent
);
1964 web_prefs
->allow_running_insecure_content
=
1965 prefs
->GetBoolean(prefs::kWebKitAllowRunningInsecureContent
);
1966 #if defined(OS_ANDROID)
1967 web_prefs
->font_scale_factor
=
1968 static_cast<float>(prefs
->GetDouble(prefs::kWebKitFontScaleFactor
));
1969 web_prefs
->force_enable_zoom
=
1970 prefs
->GetBoolean(prefs::kWebKitForceEnableZoom
);
1971 #if defined(GOOGLE_TV)
1972 web_prefs
->user_gesture_required_for_media_playback
= false;
1976 #if defined(OS_ANDROID)
1977 web_prefs
->password_echo_enabled
=
1978 prefs
->GetBoolean(prefs::kWebKitPasswordEchoEnabled
);
1980 web_prefs
->password_echo_enabled
= browser_defaults::kPasswordEchoEnabled
;
1983 #if defined(OS_CHROMEOS)
1984 // Enable password echo during OOBE when keyboard driven flag is set.
1985 if (chromeos::UserManager::IsInitialized() &&
1986 !chromeos::UserManager::Get()->IsUserLoggedIn() &&
1987 !chromeos::StartupUtils::IsOobeCompleted()) {
1988 bool keyboard_driven_oobe
= false;
1989 chromeos::system::StatisticsProvider::GetInstance()->GetMachineFlag(
1990 chromeos::system::kOemKeyboardDrivenOobeKey
, &keyboard_driven_oobe
);
1991 if (keyboard_driven_oobe
)
1992 web_prefs
->password_echo_enabled
= true;
1996 #if defined(OS_ANDROID)
1997 web_prefs
->user_style_sheet_enabled
= false;
1999 // The user stylesheet watcher may not exist in a testing profile.
2000 UserStyleSheetWatcher
* user_style_sheet_watcher
=
2001 UserStyleSheetWatcherFactory::GetForProfile(profile
).get();
2002 if (user_style_sheet_watcher
) {
2003 web_prefs
->user_style_sheet_enabled
= true;
2004 web_prefs
->user_style_sheet_location
=
2005 user_style_sheet_watcher
->user_style_sheet();
2007 web_prefs
->user_style_sheet_enabled
= false;
2011 web_prefs
->asynchronous_spell_checking_enabled
= true;
2012 web_prefs
->unified_textchecker_enabled
= true;
2014 web_prefs
->uses_universal_detector
=
2015 prefs
->GetBoolean(prefs::kWebKitUsesUniversalDetector
);
2016 web_prefs
->text_areas_are_resizable
=
2017 prefs
->GetBoolean(prefs::kWebKitTextAreasAreResizable
);
2018 web_prefs
->hyperlink_auditing_enabled
=
2019 prefs
->GetBoolean(prefs::kEnableHyperlinkAuditing
);
2021 // Make sure we will set the default_encoding with canonical encoding name.
2022 web_prefs
->default_encoding
=
2023 CharacterEncoding::GetCanonicalEncodingNameByAliasName(
2024 web_prefs
->default_encoding
);
2025 if (web_prefs
->default_encoding
.empty()) {
2026 prefs
->ClearPref(prefs::kDefaultCharset
);
2027 web_prefs
->default_encoding
= prefs
->GetString(prefs::kDefaultCharset
);
2029 DCHECK(!web_prefs
->default_encoding
.empty());
2031 if (content::IsForceCompositingModeEnabled())
2032 web_prefs
->force_compositing_mode
= true;
2034 WebContents
* web_contents
= WebContents::FromRenderViewHost(rvh
);
2035 extensions::ViewType view_type
= extensions::GetViewType(web_contents
);
2036 ExtensionService
* service
=
2037 extensions::ExtensionSystem::Get(profile
)->extension_service();
2039 const GURL
& url
= rvh
->GetSiteInstance()->GetSiteURL();
2040 const Extension
* extension
= service
->extensions()->GetByID(url
.host());
2041 // Ensure that we are only granting extension preferences to URLs with
2042 // the correct scheme. Without this check, chrome-guest:// schemes used by
2043 // webview tags as well as hosts that happen to match the id of an
2044 // installed extension would get the wrong preferences.
2045 if (url
.SchemeIs(extensions::kExtensionScheme
)) {
2046 extension_webkit_preferences::SetPreferences(
2047 extension
, view_type
, web_prefs
);
2051 if (view_type
== extensions::VIEW_TYPE_NOTIFICATION
) {
2052 web_prefs
->allow_scripts_to_close_windows
= true;
2053 } else if (view_type
== extensions::VIEW_TYPE_BACKGROUND_CONTENTS
) {
2054 // Disable all kinds of acceleration for background pages.
2055 // See http://crbug.com/96005 and http://crbug.com/96006
2056 web_prefs
->force_compositing_mode
= false;
2057 web_prefs
->accelerated_compositing_enabled
= false;
2060 #if defined(FILE_MANAGER_EXTENSION)
2061 // Override the default of suppressing HW compositing for WebUI pages for the
2062 // file manager, which is implemented using WebUI but wants HW acceleration
2063 // for video decode & render.
2064 if (url
.SchemeIs(extensions::kExtensionScheme
) &&
2065 url
.host() == kFileBrowserDomain
) {
2066 web_prefs
->accelerated_compositing_enabled
= true;
2067 web_prefs
->accelerated_2d_canvas_enabled
= true;
2072 void ChromeContentBrowserClient::UpdateInspectorSetting(
2073 RenderViewHost
* rvh
, const std::string
& key
, const std::string
& value
) {
2074 content::BrowserContext
* browser_context
=
2075 rvh
->GetProcess()->GetBrowserContext();
2076 DictionaryPrefUpdate
update(
2077 Profile::FromBrowserContext(browser_context
)->GetPrefs(),
2078 prefs::kWebKitInspectorSettings
);
2079 DictionaryValue
* inspector_settings
= update
.Get();
2080 inspector_settings
->SetWithoutPathExpansion(key
,
2081 Value::CreateStringValue(value
));
2084 void ChromeContentBrowserClient::BrowserURLHandlerCreated(
2085 BrowserURLHandler
* handler
) {
2086 // Add the default URL handlers.
2087 handler
->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride
,
2088 BrowserURLHandler::null_handler());
2089 handler
->AddHandlerPair(BrowserURLHandler::null_handler(),
2090 &ExtensionWebUI::HandleChromeURLOverrideReverse
);
2092 // about: handler. Must come before chrome: handler, since it will
2093 // rewrite about: urls to chrome: URLs and then expect chrome: to
2094 // actually handle them.
2095 handler
->AddHandlerPair(&WillHandleBrowserAboutURL
,
2096 BrowserURLHandler::null_handler());
2097 // chrome: & friends.
2098 handler
->AddHandlerPair(&HandleWebUI
, &HandleWebUIReverse
);
2101 void ChromeContentBrowserClient::ClearCache(RenderViewHost
* rvh
) {
2102 Profile
* profile
= Profile::FromBrowserContext(
2103 rvh
->GetSiteInstance()->GetProcess()->GetBrowserContext());
2104 BrowsingDataRemover
* remover
=
2105 BrowsingDataRemover::CreateForUnboundedRange(profile
);
2106 remover
->Remove(BrowsingDataRemover::REMOVE_CACHE
,
2107 BrowsingDataHelper::UNPROTECTED_WEB
);
2108 // BrowsingDataRemover takes care of deleting itself when done.
2111 void ChromeContentBrowserClient::ClearCookies(RenderViewHost
* rvh
) {
2112 Profile
* profile
= Profile::FromBrowserContext(
2113 rvh
->GetSiteInstance()->GetProcess()->GetBrowserContext());
2114 BrowsingDataRemover
* remover
=
2115 BrowsingDataRemover::CreateForUnboundedRange(profile
);
2116 int remove_mask
= BrowsingDataRemover::REMOVE_SITE_DATA
;
2117 remover
->Remove(remove_mask
, BrowsingDataHelper::UNPROTECTED_WEB
);
2118 // BrowsingDataRemover takes care of deleting itself when done.
2121 base::FilePath
ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
2122 return download_util::GetDefaultDownloadDirectory();
2125 std::string
ChromeContentBrowserClient::GetDefaultDownloadName() {
2126 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME
);
2129 void ChromeContentBrowserClient::DidCreatePpapiPlugin(
2130 content::BrowserPpapiHost
* browser_host
) {
2131 #if defined(ENABLE_PLUGINS)
2132 browser_host
->GetPpapiHost()->AddHostFactoryFilter(
2133 scoped_ptr
<ppapi::host::HostFactory
>(
2134 new ChromeBrowserPepperHostFactory(browser_host
)));
2138 content::BrowserPpapiHost
*
2139 ChromeContentBrowserClient::GetExternalBrowserPpapiHost(
2140 int plugin_process_id
) {
2141 BrowserChildProcessHostIterator
iter(PROCESS_TYPE_NACL_LOADER
);
2142 while (!iter
.Done()) {
2143 NaClProcessHost
* host
= static_cast<NaClProcessHost
*>(iter
.GetDelegate());
2144 if (host
->process() &&
2145 host
->process()->GetData().id
== plugin_process_id
) {
2146 // Found the plugin.
2147 return host
->browser_ppapi_host();
2154 bool ChromeContentBrowserClient::SupportsBrowserPlugin(
2155 content::BrowserContext
* browser_context
, const GURL
& site_url
) {
2156 if (CommandLine::ForCurrentProcess()->HasSwitch(
2157 switches::kEnableBrowserPluginForAllViewTypes
))
2160 Profile
* profile
= Profile::FromBrowserContext(browser_context
);
2161 ExtensionService
* service
=
2162 extensions::ExtensionSystem::Get(profile
)->extension_service();
2166 const Extension
* extension
= service
->extensions()->
2167 GetExtensionOrAppByURL(ExtensionURLInfo(site_url
));
2171 return extension
->HasAPIPermission(APIPermission::kWebView
) ||
2172 extension
->HasAPIPermission(APIPermission::kAdView
);
2175 bool ChromeContentBrowserClient::AllowPepperSocketAPI(
2176 content::BrowserContext
* browser_context
,
2179 const content::SocketPermissionRequest
& params
) {
2180 #if defined(ENABLE_PLUGINS)
2181 Profile
* profile
= Profile::FromBrowserContext(browser_context
);
2182 const ExtensionSet
* extension_set
= NULL
;
2184 extension_set
= extensions::ExtensionSystem::Get(profile
)->
2185 extension_service()->extensions();
2189 // Access to private socket APIs is controlled by the whitelist.
2190 if (IsExtensionOrSharedModuleWhitelisted(url
, extension_set
,
2191 allowed_socket_origins_
)) {
2195 // Access to public socket APIs is controlled by extension permissions.
2196 if (url
.is_valid() && url
.SchemeIs(extensions::kExtensionScheme
) &&
2198 const Extension
* extension
= extension_set
->GetByID(url
.host());
2200 extensions::SocketPermission::CheckParam
check_params(
2201 params
.type
, params
.host
, params
.port
);
2202 if (extensions::PermissionsData::CheckAPIPermissionWithParam(
2203 extension
, extensions::APIPermission::kSocket
, &check_params
)) {
2210 // Allow both public and private APIs if the command line says so.
2211 return IsHostAllowedByCommandLine(url
, extension_set
,
2212 switches::kAllowNaClSocketAPI
);
2218 base::FilePath
ChromeContentBrowserClient::GetHyphenDictionaryDirectory() {
2219 base::FilePath directory
;
2220 PathService::Get(chrome::DIR_APP_DICTIONARIES
, &directory
);
2221 return directory
.Append(FILE_PATH_LITERAL("Hyphen"));
2224 ui::SelectFilePolicy
* ChromeContentBrowserClient::CreateSelectFilePolicy(
2225 WebContents
* web_contents
) {
2226 return new ChromeSelectFilePolicy(web_contents
);
2229 void ChromeContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
2230 std::vector
<std::string
>* additional_allowed_schemes
) {
2231 ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
2232 additional_allowed_schemes
);
2233 additional_allowed_schemes
->push_back(kChromeUIScheme
);
2234 additional_allowed_schemes
->push_back(extensions::kExtensionScheme
);
2237 void ChromeContentBrowserClient::GetAdditionalFileSystemMountPointProviders(
2238 const base::FilePath
& storage_partition_path
,
2239 ScopedVector
<fileapi::FileSystemMountPointProvider
>* additional_providers
) {
2240 #if !defined(OS_ANDROID)
2241 base::SequencedWorkerPool
* pool
= content::BrowserThread::GetBlockingPool();
2242 additional_providers
->push_back(new MediaFileSystemMountPointProvider(
2243 storage_partition_path
,
2244 pool
->GetSequencedTaskRunner(pool
->GetNamedSequenceToken(
2245 MediaFileSystemMountPointProvider::kMediaTaskRunnerName
)).get()));
2249 #if defined(OS_POSIX) && !defined(OS_MACOSX)
2250 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
2251 const CommandLine
& command_line
,
2252 int child_process_id
,
2253 std::vector
<FileDescriptorInfo
>* mappings
) {
2254 #if defined(OS_ANDROID)
2255 base::FilePath data_path
;
2256 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID
, &data_path
);
2257 DCHECK(!data_path
.empty());
2259 int flags
= base::PLATFORM_FILE_OPEN
| base::PLATFORM_FILE_READ
;
2260 base::FilePath chrome_pak
= data_path
.AppendASCII("chrome.pak");
2261 base::PlatformFile f
=
2262 base::CreatePlatformFile(chrome_pak
, flags
, NULL
, NULL
);
2263 DCHECK(f
!= base::kInvalidPlatformFileValue
);
2264 mappings
->push_back(FileDescriptorInfo(kAndroidChromePakDescriptor
,
2265 FileDescriptor(f
, true)));
2267 base::FilePath chrome_resources_pak
=
2268 data_path
.AppendASCII("chrome_100_percent.pak");
2269 f
= base::CreatePlatformFile(chrome_resources_pak
, flags
, NULL
, NULL
);
2270 DCHECK(f
!= base::kInvalidPlatformFileValue
);
2271 mappings
->push_back(FileDescriptorInfo(kAndroidChrome100PercentPakDescriptor
,
2272 FileDescriptor(f
, true)));
2274 const std::string locale
= GetApplicationLocale();
2275 base::FilePath locale_pak
= ResourceBundle::GetSharedInstance().
2276 GetLocaleFilePath(locale
, false);
2277 f
= base::CreatePlatformFile(locale_pak
, flags
, NULL
, NULL
);
2278 DCHECK(f
!= base::kInvalidPlatformFileValue
);
2279 mappings
->push_back(FileDescriptorInfo(kAndroidLocalePakDescriptor
,
2280 FileDescriptor(f
, true)));
2282 base::FilePath resources_pack_path
;
2283 PathService::Get(chrome::FILE_RESOURCES_PACK
, &resources_pack_path
);
2284 f
= base::CreatePlatformFile(resources_pack_path
, flags
, NULL
, NULL
);
2285 DCHECK(f
!= base::kInvalidPlatformFileValue
);
2286 mappings
->push_back(FileDescriptorInfo(kAndroidUIResourcesPakDescriptor
,
2287 FileDescriptor(f
, true)));
2289 #if defined(USE_LINUX_BREAKPAD)
2290 if (IsCrashReporterEnabled()) {
2291 f
= CrashDumpManager::GetInstance()->CreateMinidumpFile(child_process_id
);
2292 if (f
== base::kInvalidPlatformFileValue
) {
2293 LOG(ERROR
) << "Failed to create file for minidump, crash reporting will "
2294 "be disabled for this process.";
2296 mappings
->push_back(FileDescriptorInfo(kAndroidMinidumpDescriptor
,
2297 FileDescriptor(f
, true)));
2300 #endif // defined(USE_LINUX_BREAKPAD)
2303 int crash_signal_fd
= GetCrashSignalFD(command_line
);
2304 if (crash_signal_fd
>= 0) {
2305 mappings
->push_back(FileDescriptorInfo(kCrashDumpSignal
,
2306 FileDescriptor(crash_signal_fd
,
2309 #endif // defined(OS_ANDROID)
2311 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
2314 const wchar_t* ChromeContentBrowserClient::GetResourceDllName() {
2315 return chrome::kBrowserResourcesDll
;
2318 void ChromeContentBrowserClient::PreSpawnRenderer(
2319 sandbox::TargetPolicy
* policy
,
2321 // This code is duplicated in nacl_exe_win_64.cc.
2322 // Allow the server side of a pipe restricted to the "chrome.nacl."
2323 // namespace so that it cannot impersonate other system or other chrome
2325 sandbox::ResultCode result
= policy
->AddRule(
2326 sandbox::TargetPolicy::SUBSYS_NAMED_PIPES
,
2327 sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY
,
2328 L
"\\\\.\\pipe\\chrome.nacl.*");
2329 if (result
!= sandbox::SBOX_ALL_OK
) {
2334 // Renderers need to send named pipe handles and shared memory
2335 // segment handles to NaCl loader processes.
2336 result
= policy
->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES
,
2337 sandbox::TargetPolicy::HANDLES_DUP_ANY
,
2339 if (result
!= sandbox::SBOX_ALL_OK
) {
2346 #if defined(USE_NSS)
2347 crypto::CryptoModuleBlockingPasswordDelegate
*
2348 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
2350 return chrome::NewCryptoModuleBlockingDialogDelegate(
2351 chrome::kCryptoModulePasswordKeygen
, url
.host());
2355 } // namespace chrome