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/browser_main.h" | 5 #include "chrome/browser/browser_main.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "chrome/browser/metrics/metrics_log.h" | 50 #include "chrome/browser/metrics/metrics_log.h" |
51 #include "chrome/browser/metrics/metrics_service.h" | 51 #include "chrome/browser/metrics/metrics_service.h" |
52 #include "chrome/browser/metrics/thread_watcher.h" | 52 #include "chrome/browser/metrics/thread_watcher.h" |
53 #include "chrome/browser/net/chrome_dns_cert_provenance_checker.h" | 53 #include "chrome/browser/net/chrome_dns_cert_provenance_checker.h" |
54 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" | 54 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" |
55 #include "chrome/browser/net/chrome_net_log.h" | 55 #include "chrome/browser/net/chrome_net_log.h" |
56 #include "chrome/browser/net/predictor_api.h" | 56 #include "chrome/browser/net/predictor_api.h" |
57 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 57 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
58 #include "chrome/browser/net/websocket_experiment/websocket_experiment_runner.h" | 58 #include "chrome/browser/net/websocket_experiment/websocket_experiment_runner.h" |
59 #include "chrome/browser/plugin_updater.h" | 59 #include "chrome/browser/plugin_updater.h" |
| 60 #include "chrome/browser/policy/browser_policy_connector.h" |
60 #include "chrome/browser/prefs/pref_service.h" | 61 #include "chrome/browser/prefs/pref_service.h" |
61 #include "chrome/browser/prefs/pref_value_store.h" | 62 #include "chrome/browser/prefs/pref_value_store.h" |
62 #include "chrome/browser/prerender/prerender_field_trial.h" | 63 #include "chrome/browser/prerender/prerender_field_trial.h" |
63 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 64 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
64 #include "chrome/browser/process_singleton.h" | 65 #include "chrome/browser/process_singleton.h" |
65 #include "chrome/browser/profiles/profile.h" | 66 #include "chrome/browser/profiles/profile.h" |
66 #include "chrome/browser/profiles/profile_manager.h" | 67 #include "chrome/browser/profiles/profile_manager.h" |
67 #include "chrome/browser/search_engines/search_engine_type.h" | 68 #include "chrome/browser/search_engines/search_engine_type.h" |
68 #include "chrome/browser/search_engines/template_url.h" | 69 #include "chrome/browser/search_engines/template_url.h" |
69 #include "chrome/browser/search_engines/template_url_service.h" | 70 #include "chrome/browser/search_engines/template_url_service.h" |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 // Checking that the local state file for the current profile doesn't exist | 843 // Checking that the local state file for the current profile doesn't exist |
843 // is the most robust way to determine whether we need to inherit or not | 844 // is the most robust way to determine whether we need to inherit or not |
844 // since the parent profile command line flag can be present even when the | 845 // since the parent profile command line flag can be present even when the |
845 // current profile is not a new one, and in that case we do not want to | 846 // current profile is not a new one, and in that case we do not want to |
846 // inherit and reset the user's setting. | 847 // inherit and reset the user's setting. |
847 if (!local_state_file_exists && | 848 if (!local_state_file_exists && |
848 parsed_command_line.HasSwitch(switches::kParentProfile)) { | 849 parsed_command_line.HasSwitch(switches::kParentProfile)) { |
849 FilePath parent_profile = | 850 FilePath parent_profile = |
850 parsed_command_line.GetSwitchValuePath(switches::kParentProfile); | 851 parsed_command_line.GetSwitchValuePath(switches::kParentProfile); |
851 scoped_ptr<PrefService> parent_local_state( | 852 scoped_ptr<PrefService> parent_local_state( |
852 PrefService::CreatePrefService(parent_profile, NULL, NULL, false)); | 853 PrefService::CreatePrefService(parent_profile, NULL, false)); |
853 parent_local_state->RegisterStringPref(prefs::kApplicationLocale, | 854 parent_local_state->RegisterStringPref(prefs::kApplicationLocale, |
854 std::string()); | 855 std::string()); |
855 // Right now, we only inherit the locale setting from the parent profile. | 856 // Right now, we only inherit the locale setting from the parent profile. |
856 local_state->SetString( | 857 local_state->SetString( |
857 prefs::kApplicationLocale, | 858 prefs::kApplicationLocale, |
858 parent_local_state->GetString(prefs::kApplicationLocale)); | 859 parent_local_state->GetString(prefs::kApplicationLocale)); |
859 } | 860 } |
860 | 861 |
861 #if defined(OS_CHROMEOS) | 862 #if defined(OS_CHROMEOS) |
862 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { | 863 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 logging::RedirectChromeLogging(parsed_command_line); | 1640 logging::RedirectChromeLogging(parsed_command_line); |
1640 } | 1641 } |
1641 #endif | 1642 #endif |
1642 | 1643 |
1643 Profile* profile = CreateProfile(parameters, user_data_dir); | 1644 Profile* profile = CreateProfile(parameters, user_data_dir); |
1644 if (!profile) | 1645 if (!profile) |
1645 return ResultCodes::NORMAL_EXIT; | 1646 return ResultCodes::NORMAL_EXIT; |
1646 | 1647 |
1647 // Post-profile init --------------------------------------------------------- | 1648 // Post-profile init --------------------------------------------------------- |
1648 | 1649 |
| 1650 #if defined(OS_CHROMEOS) |
| 1651 // Handling the user cloud policy initialization for case 2 mentioned above. |
| 1652 // We do this after the profile creation since we need the TokenService. |
| 1653 if (parsed_command_line.HasSwitch(switches::kLoginUser) && |
| 1654 !parsed_command_line.HasSwitch(switches::kLoginPassword)) { |
| 1655 std::string username = |
| 1656 parsed_command_line.GetSwitchValueASCII(switches::kLoginUser); |
| 1657 policy::BrowserPolicyConnector* browser_policy_connector = |
| 1658 g_browser_process->browser_policy_connector(); |
| 1659 browser_policy_connector->InitializeUserPolicy(username, |
| 1660 profile->GetPath(), |
| 1661 profile->GetTokenService()); |
| 1662 } |
| 1663 #endif |
| 1664 |
1649 PrefService* user_prefs = profile->GetPrefs(); | 1665 PrefService* user_prefs = profile->GetPrefs(); |
1650 DCHECK(user_prefs); | 1666 DCHECK(user_prefs); |
1651 | 1667 |
1652 // Tests should be able to tune login manager before showing it. | 1668 // Tests should be able to tune login manager before showing it. |
1653 // Thus only show login manager in normal (non-testing) mode. | 1669 // Thus only show login manager in normal (non-testing) mode. |
1654 if (!parameters.ui_task) { | 1670 if (!parameters.ui_task) { |
1655 OptionallyRunChromeOSLoginManager(parsed_command_line); | 1671 OptionallyRunChromeOSLoginManager(parsed_command_line); |
1656 } | 1672 } |
1657 | 1673 |
1658 #if !defined(OS_MACOSX) | 1674 #if !defined(OS_MACOSX) |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2056 #if defined(OS_CHROMEOS) | 2072 #if defined(OS_CHROMEOS) |
2057 // To be precise, logout (browser shutdown) is not yet done, but the | 2073 // To be precise, logout (browser shutdown) is not yet done, but the |
2058 // remaining work is negligible, hence we say LogoutDone here. | 2074 // remaining work is negligible, hence we say LogoutDone here. |
2059 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 2075 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
2060 false); | 2076 false); |
2061 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 2077 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
2062 #endif | 2078 #endif |
2063 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | 2079 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); |
2064 return result_code; | 2080 return result_code; |
2065 } | 2081 } |
OLD | NEW |