OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/app/breakpad_mac.h" | 8 #include "chrome/app/breakpad_mac.h" |
9 #include "chrome/browser/browser_about_handler.h" | 9 #include "chrome/browser/browser_about_handler.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 Profile* profile = | 259 Profile* profile = |
260 Profile::FromBrowserContext(process_host->browser_context()); | 260 Profile::FromBrowserContext(process_host->browser_context()); |
261 ExtensionProcessManager* extension_process_manager = | 261 ExtensionProcessManager* extension_process_manager = |
262 profile->GetExtensionProcessManager(); | 262 profile->GetExtensionProcessManager(); |
263 | 263 |
264 // Maybe NULL during tests. | 264 // Maybe NULL during tests. |
265 if (!extension_process_manager) | 265 if (!extension_process_manager) |
266 return true; | 266 return true; |
267 | 267 |
268 bool is_extension_host = | 268 bool is_extension_host = |
269 process_host->is_extension_process() || | 269 extension_process_manager->IsExtensionProcess(process_host->id()); |
270 extension_process_manager->AreBindingsEnabledForProcess( | |
271 process_host->id()); | |
272 return site_url.SchemeIs(chrome::kExtensionScheme) == is_extension_host; | 270 return site_url.SchemeIs(chrome::kExtensionScheme) == is_extension_host; |
273 } | 271 } |
274 | 272 |
275 std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( | 273 std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( |
276 const std::string& alias_name) { | 274 const std::string& alias_name) { |
277 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name); | 275 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name); |
278 } | 276 } |
279 | 277 |
280 void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( | 278 void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( |
281 CommandLine* command_line, int child_process_id) { | 279 CommandLine* command_line, int child_process_id) { |
282 #if defined(USE_LINUX_BREAKPAD) | 280 #if defined(USE_LINUX_BREAKPAD) |
283 if (IsCrashReporterEnabled()) { | 281 if (IsCrashReporterEnabled()) { |
284 command_line->AppendSwitchASCII(switches::kEnableCrashReporter, | 282 command_line->AppendSwitchASCII(switches::kEnableCrashReporter, |
285 child_process_logging::GetClientId() + "," + base::GetLinuxDistro()); | 283 child_process_logging::GetClientId() + "," + base::GetLinuxDistro()); |
286 } | 284 } |
287 #elif defined(OS_MACOSX) | 285 #elif defined(OS_MACOSX) |
288 if (IsCrashReporterEnabled()) { | 286 if (IsCrashReporterEnabled()) { |
289 command_line->AppendSwitchASCII(switches::kEnableCrashReporter, | 287 command_line->AppendSwitchASCII(switches::kEnableCrashReporter, |
290 child_process_logging::GetClientId()); | 288 child_process_logging::GetClientId()); |
291 } | 289 } |
292 #endif // OS_MACOSX | 290 #endif // OS_MACOSX |
293 | 291 |
294 if (logging::DialogsAreSuppressed()) | 292 if (logging::DialogsAreSuppressed()) |
295 command_line->AppendSwitch(switches::kNoErrorDialogs); | 293 command_line->AppendSwitch(switches::kNoErrorDialogs); |
296 | 294 |
297 std::string process_type = | 295 std::string process_type = |
298 command_line->GetSwitchValueASCII(switches::kProcessType); | 296 command_line->GetSwitchValueASCII(switches::kProcessType); |
299 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 297 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
300 if (process_type == switches::kExtensionProcess || | 298 if (process_type == switches::kRendererProcess) { |
301 process_type == switches::kRendererProcess) { | |
302 FilePath user_data_dir = | 299 FilePath user_data_dir = |
303 browser_command_line.GetSwitchValuePath(switches::kUserDataDir); | 300 browser_command_line.GetSwitchValuePath(switches::kUserDataDir); |
304 if (!user_data_dir.empty()) | 301 if (!user_data_dir.empty()) |
305 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); | 302 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
306 #if defined(OS_CHROMEOS) | 303 #if defined(OS_CHROMEOS) |
307 const std::string& login_profile = | 304 const std::string& login_profile = |
308 browser_command_line.GetSwitchValueASCII(switches::kLoginProfile); | 305 browser_command_line.GetSwitchValueASCII(switches::kLoginProfile); |
309 if (!login_profile.empty()) | 306 if (!login_profile.empty()) |
310 command_line->AppendSwitchASCII(switches::kLoginProfile, login_profile); | 307 command_line->AppendSwitchASCII(switches::kLoginProfile, login_profile); |
311 #endif | 308 #endif |
312 | 309 |
313 RenderProcessHost* process = RenderProcessHost::FromID(child_process_id); | 310 RenderProcessHost* process = RenderProcessHost::FromID(child_process_id); |
314 | 311 |
315 Profile* profile = Profile::FromBrowserContext(process->browser_context()); | 312 Profile* profile = Profile::FromBrowserContext(process->browser_context()); |
313 | |
314 ExtensionProcessManager* extension_process_manager = | |
315 profile->GetExtensionProcessManager(); | |
316 if (extension_process_manager->IsExtensionProcess( | |
317 process->id())) { | |
318 command_line->AppendSwitch(switches::kExtensionProcess); | |
319 } | |
320 | |
316 PrefService* prefs = profile->GetPrefs(); | 321 PrefService* prefs = profile->GetPrefs(); |
317 // Currently this pref is only registered if applied via a policy. | 322 // Currently this pref is only registered if applied via a policy. |
318 if (prefs->HasPrefPath(prefs::kDisable3DAPIs) && | 323 if (prefs->HasPrefPath(prefs::kDisable3DAPIs) && |
319 prefs->GetBoolean(prefs::kDisable3DAPIs)) { | 324 prefs->GetBoolean(prefs::kDisable3DAPIs)) { |
320 // Turn this policy into a command line switch. | 325 // Turn this policy into a command line switch. |
321 command_line->AppendSwitch(switches::kDisable3DAPIs); | 326 command_line->AppendSwitch(switches::kDisable3DAPIs); |
322 } | 327 } |
323 | 328 |
324 // Disable client-side phishing detection in the renderer if it is disabled | 329 // Disable client-side phishing detection in the renderer if it is disabled |
325 // in the Profile preferences or the browser process. | 330 // in the Profile preferences or the browser process. |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
788 remover->Remove(remove_mask); | 793 remover->Remove(remove_mask); |
789 // BrowsingDataRemover takes care of deleting itself when done. | 794 // BrowsingDataRemover takes care of deleting itself when done. |
790 } | 795 } |
791 | 796 |
792 FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { | 797 FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { |
793 return download_util::GetDefaultDownloadDirectory(); | 798 return download_util::GetDefaultDownloadDirectory(); |
794 } | 799 } |
795 | 800 |
796 #if defined(OS_LINUX) | 801 #if defined(OS_LINUX) |
797 int ChromeContentBrowserClient::GetCrashSignalFD( | 802 int ChromeContentBrowserClient::GetCrashSignalFD( |
798 const std::string& process_type) { | 803 const CommandLine* command_line) { |
799 if (process_type == switches::kRendererProcess) | 804 if (command_line->HasSwitch(switches::kExtensionProcess)) { |
800 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); | |
801 | |
802 if (process_type == switches::kExtensionProcess) { | |
803 ExtensionCrashHandlerHostLinux* crash_handler = | 805 ExtensionCrashHandlerHostLinux* crash_handler = |
804 ExtensionCrashHandlerHostLinux::GetInstance(); | 806 ExtensionCrashHandlerHostLinux::GetInstance(); |
805 return crash_handler->GetDeathSignalSocket(); | 807 return crash_handler->GetDeathSignalSocket(); |
806 } | 808 } |
807 | 809 |
810 std::string process_type = | |
811 command_line->GetSwitchValueASCII(switches::kProcessType); | |
812 | |
813 if (process_type == switches::kRendererProcess) | |
814 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); | |
815 | |
816 | |
jam
2011/10/04 16:59:22
nit: extra line
jochen (gone - plz use gerrit)
2011/10/04 18:50:19
Done.
| |
808 if (process_type == switches::kPluginProcess) | 817 if (process_type == switches::kPluginProcess) |
809 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); | 818 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
810 | 819 |
811 if (process_type == switches::kPpapiPluginProcess) | 820 if (process_type == switches::kPpapiPluginProcess) |
812 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); | 821 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
813 | 822 |
814 if (process_type == switches::kGpuProcess) | 823 if (process_type == switches::kGpuProcess) |
815 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); | 824 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
816 | 825 |
817 return -1; | 826 return -1; |
818 } | 827 } |
819 #endif // defined(OS_LINUX) | 828 #endif // defined(OS_LINUX) |
820 | 829 |
821 #if defined(OS_WIN) | 830 #if defined(OS_WIN) |
822 const wchar_t* ChromeContentBrowserClient::GetResourceDllName() { | 831 const wchar_t* ChromeContentBrowserClient::GetResourceDllName() { |
823 return chrome::kBrowserResourcesDll; | 832 return chrome::kBrowserResourcesDll; |
824 } | 833 } |
825 #endif | 834 #endif |
826 | 835 |
827 #if defined(USE_NSS) | 836 #if defined(USE_NSS) |
828 crypto::CryptoModuleBlockingPasswordDelegate* | 837 crypto::CryptoModuleBlockingPasswordDelegate* |
829 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 838 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
830 const GURL& url) { | 839 const GURL& url) { |
831 return browser::NewCryptoModuleBlockingDialogDelegate( | 840 return browser::NewCryptoModuleBlockingDialogDelegate( |
832 browser::kCryptoModulePasswordKeygen, url.host()); | 841 browser::kCryptoModulePasswordKeygen, url.host()); |
833 } | 842 } |
834 #endif | 843 #endif |
835 | 844 |
836 } // namespace chrome | 845 } // namespace chrome |
OLD | NEW |