OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/app/chrome_main_delegate.h" | 5 #include "chrome/app/chrome_main_delegate.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "chrome/browser/chrome_content_browser_client.h" | 17 #include "chrome/browser/chrome_content_browser_client.h" |
18 #include "chrome/browser/defaults.h" | 18 #include "chrome/browser/defaults.h" |
19 #include "chrome/browser/diagnostics/diagnostics_main.h" | 19 #include "chrome/browser/diagnostics/diagnostics_main.h" |
20 #include "chrome/browser/first_run/first_run.h" | |
20 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
21 #include "chrome/common/chrome_content_client.h" | 22 #include "chrome/common/chrome_content_client.h" |
22 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
23 #include "chrome/common/chrome_paths_internal.h" | 24 #include "chrome/common/chrome_paths_internal.h" |
24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/chrome_version_info.h" | 26 #include "chrome/common/chrome_version_info.h" |
26 #include "chrome/common/logging_chrome.h" | 27 #include "chrome/common/logging_chrome.h" |
27 #include "chrome/common/profiling.h" | 28 #include "chrome/common/profiling.h" |
28 #include "chrome/common/startup_metric_utils.h" | 29 #include "chrome/common/startup_metric_utils.h" |
29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 // some apps fail to properly escape arguments. | 119 // some apps fail to properly escape arguments. |
119 bool HasDeprecatedArguments(const std::wstring& command_line) { | 120 bool HasDeprecatedArguments(const std::wstring& command_line) { |
120 const wchar_t kChromeHtml[] = L"chromehtml:"; | 121 const wchar_t kChromeHtml[] = L"chromehtml:"; |
121 std::wstring command_line_lower = command_line; | 122 std::wstring command_line_lower = command_line; |
122 // We are only searching for ASCII characters so this is OK. | 123 // We are only searching for ASCII characters so this is OK. |
123 StringToLowerASCII(&command_line_lower); | 124 StringToLowerASCII(&command_line_lower); |
124 std::wstring::size_type pos = command_line_lower.find(kChromeHtml); | 125 std::wstring::size_type pos = command_line_lower.find(kChromeHtml); |
125 return (pos != std::wstring::npos); | 126 return (pos != std::wstring::npos); |
126 } | 127 } |
127 | 128 |
129 // Handles command line switches to extract information from Chrome, which | |
130 // can be passed via |exit_code| or by stdout. | |
131 bool HandleInfoQuery(const CommandLine& command_line, int* exit_code) { | |
132 if (command_line.HasSwitch(switches::kQueryEULAAcceptance)) { | |
133 *exit_code = first_run::IsEULAAccepted() ? 1 : 0; | |
134 return true; | |
135 } | |
136 | |
137 return false; | |
138 } | |
139 | |
128 // Checks if the registry key exists in the given hive and expands any | 140 // Checks if the registry key exists in the given hive and expands any |
129 // variables in the string. | 141 // variables in the string. |
130 bool LoadUserDataDirPolicyFromRegistry(HKEY hive, | 142 bool LoadUserDataDirPolicyFromRegistry(HKEY hive, |
131 const std::wstring& key_name, | 143 const std::wstring& key_name, |
132 FilePath* user_data_dir) { | 144 FilePath* user_data_dir) { |
133 std::wstring value; | 145 std::wstring value; |
134 | 146 |
135 base::win::RegKey policy_key(hive, | 147 base::win::RegKey policy_key(hive, |
136 policy::kRegistryMandatorySubKey, | 148 policy::kRegistryMandatorySubKey, |
137 KEY_READ); | 149 KEY_READ); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 return true; | 428 return true; |
417 } | 429 } |
418 #endif | 430 #endif |
419 | 431 |
420 #if defined(OS_WIN) | 432 #if defined(OS_WIN) |
421 // Must do this before any other usage of command line! | 433 // Must do this before any other usage of command line! |
422 if (HasDeprecatedArguments(command_line.GetCommandLineString())) { | 434 if (HasDeprecatedArguments(command_line.GetCommandLineString())) { |
423 *exit_code = 1; | 435 *exit_code = 1; |
424 return true; | 436 return true; |
425 } | 437 } |
438 | |
439 if (HandleInfoQuery(command_line, exit_code)) { | |
grt (UTC plus 2)
2013/01/23 19:02:29
nit: no braces
huangs
2013/01/24 00:08:08
Done.
| |
440 return true; | |
441 } | |
426 #endif | 442 #endif |
427 | 443 |
428 if (!command_line.HasSwitch(switches::kProcessType) && | 444 if (!command_line.HasSwitch(switches::kProcessType) && |
429 command_line.HasSwitch(switches::kEnableBenchmarking)) { | 445 command_line.HasSwitch(switches::kEnableBenchmarking)) { |
430 base::FieldTrial::EnableBenchmarking(); | 446 base::FieldTrial::EnableBenchmarking(); |
431 } | 447 } |
432 | 448 |
433 content::SetContentClient(&chrome_content_client_); | 449 content::SetContentClient(&chrome_content_client_); |
434 | 450 |
435 return false; | 451 return false; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
774 | 790 |
775 content::ContentRendererClient* | 791 content::ContentRendererClient* |
776 ChromeMainDelegate::CreateContentRendererClient() { | 792 ChromeMainDelegate::CreateContentRendererClient() { |
777 return &g_chrome_content_renderer_client.Get(); | 793 return &g_chrome_content_renderer_client.Get(); |
778 } | 794 } |
779 | 795 |
780 content::ContentUtilityClient* | 796 content::ContentUtilityClient* |
781 ChromeMainDelegate::CreateContentUtilityClient() { | 797 ChromeMainDelegate::CreateContentUtilityClient() { |
782 return &g_chrome_content_utility_client.Get(); | 798 return &g_chrome_content_utility_client.Get(); |
783 } | 799 } |
OLD | NEW |