OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/login/login_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/lock.h" | 12 #include "base/lock.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
15 #include "base/singleton.h" | 15 #include "base/singleton.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/browser_init.h" | 20 #include "chrome/browser/browser_init.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/browser_thread.h" | 22 #include "chrome/browser/browser_thread.h" |
23 #include "chrome/browser/chromeos/boot_times_loader.h" | 23 #include "chrome/browser/chromeos/boot_times_loader.h" |
24 #include "chrome/browser/chromeos/cros/login_library.h" | 24 #include "chrome/browser/chromeos/cros/login_library.h" |
25 #include "chrome/browser/chromeos/cros/network_library.h" | 25 #include "chrome/browser/chromeos/cros/network_library.h" |
26 #include "chrome/browser/chromeos/external_cookie_handler.h" | 26 #include "chrome/browser/chromeos/external_cookie_handler.h" |
27 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 27 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
28 #include "chrome/browser/chromeos/login/cookie_fetcher.h" | 28 #include "chrome/browser/chromeos/login/cookie_fetcher.h" |
29 #include "chrome/browser/chromeos/login/google_authenticator.h" | 29 #include "chrome/browser/chromeos/login/google_authenticator.h" |
30 #include "chrome/browser/chromeos/login/language_switch_menu.h" | |
30 #include "chrome/browser/chromeos/login/ownership_service.h" | 31 #include "chrome/browser/chromeos/login/ownership_service.h" |
31 #include "chrome/browser/chromeos/login/parallel_authenticator.h" | 32 #include "chrome/browser/chromeos/login/parallel_authenticator.h" |
32 #include "chrome/browser/chromeos/login/user_image_downloader.h" | 33 #include "chrome/browser/chromeos/login/user_image_downloader.h" |
33 #include "chrome/browser/chromeos/login/user_manager.h" | 34 #include "chrome/browser/chromeos/login/user_manager.h" |
34 #include "chrome/browser/extensions/extensions_service.h" | 35 #include "chrome/browser/extensions/extensions_service.h" |
35 #include "chrome/browser/net/gaia/token_service.h" | 36 #include "chrome/browser/net/gaia/token_service.h" |
36 #include "chrome/browser/net/preconnect.h" | 37 #include "chrome/browser/net/preconnect.h" |
37 #include "chrome/browser/prefs/pref_member.h" | 38 #include "chrome/browser/prefs/pref_member.h" |
38 #include "chrome/browser/profile.h" | 39 #include "chrome/browser/profile.h" |
39 #include "chrome/browser/profile_manager.h" | 40 #include "chrome/browser/profile_manager.h" |
40 #include "chrome/browser/sync/profile_sync_service.h" | 41 #include "chrome/browser/sync/profile_sync_service.h" |
41 #include "chrome/common/chrome_paths.h" | 42 #include "chrome/common/chrome_paths.h" |
42 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
43 #include "chrome/common/logging_chrome.h" | 44 #include "chrome/common/logging_chrome.h" |
44 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" | 45 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
45 #include "chrome/common/net/gaia/gaia_constants.h" | 46 #include "chrome/common/net/gaia/gaia_constants.h" |
46 #include "chrome/common/net/url_request_context_getter.h" | 47 #include "chrome/common/net/url_request_context_getter.h" |
47 #include "chrome/common/pref_names.h" | 48 #include "chrome/common/pref_names.h" |
48 #include "googleurl/src/gurl.h" | 49 #include "googleurl/src/gurl.h" |
49 #include "net/base/cookie_store.h" | 50 #include "net/base/cookie_store.h" |
50 #include "net/url_request/url_request_context.h" | 51 #include "net/url_request/url_request_context.h" |
51 #include "views/widget/widget_gtk.h" | 52 #include "views/widget/widget_gtk.h" |
52 | 53 |
53 namespace chromeos { | 54 namespace chromeos { |
54 | 55 |
55 namespace { | 56 namespace { |
56 | 57 |
57 // Prefix for Auth token received from ClientLogin request. | 58 // Affixes for Auth token received from ClientLogin request. |
58 const char kAuthPrefix[] = "Auth="; | 59 const char kAuthPrefix[] = "Auth="; |
59 // Suffix for Auth token received from ClientLogin request. | |
60 const char kAuthSuffix[] = "\n"; | 60 const char kAuthSuffix[] = "\n"; |
61 | 61 |
62 // Increase logging level for Guest mode to avoid LOG(INFO) messages in logs. | 62 // Increase logging level for Guest mode to avoid LOG(INFO) messages in logs. |
63 const char kGuestModeLoggingLevel[] = "1"; | 63 const char kGuestModeLoggingLevel[] = "1"; |
64 | 64 |
65 // Format of command line switch. | 65 // Format of command line switch. |
66 const char kSwitchFormatString[] = "--%s=\"%s\""; | 66 const char kSwitchFormatString[] = "--%s=\"%s\""; |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
(...skipping 22 matching lines...) Expand all Loading... | |
92 // login screen is to be shown. | 92 // login screen is to be shown. |
93 virtual void EnableBrowserLaunch(bool enable); | 93 virtual void EnableBrowserLaunch(bool enable); |
94 | 94 |
95 // Returns if browser launch enabled now or not. | 95 // Returns if browser launch enabled now or not. |
96 virtual bool IsBrowserLaunchEnabled() const; | 96 virtual bool IsBrowserLaunchEnabled() const; |
97 | 97 |
98 // Warms the url used by authentication. | 98 // Warms the url used by authentication. |
99 virtual void PrewarmAuthentication(); | 99 virtual void PrewarmAuthentication(); |
100 | 100 |
101 private: | 101 private: |
102 // Check user's profile for kApplicationLocale setting. | |
103 void RespectLocalePreference(PrefService* pref); | |
104 | |
102 // Indicates if DoBrowserLaunch will actually launch the browser or not. | 105 // Indicates if DoBrowserLaunch will actually launch the browser or not. |
103 bool browser_launch_enabled_; | 106 bool browser_launch_enabled_; |
104 | 107 |
105 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl); | 108 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl); |
106 }; | 109 }; |
107 | 110 |
108 class LoginUtilsWrapper { | 111 class LoginUtilsWrapper { |
109 public: | 112 public: |
110 LoginUtilsWrapper() {} | 113 LoginUtilsWrapper() {} |
111 | 114 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 if (cryptohome->TpmIsEnabled() && !cryptohome->TpmIsBeingOwned()) { | 207 if (cryptohome->TpmIsEnabled() && !cryptohome->TpmIsBeingOwned()) { |
205 if (cryptohome->TpmIsOwned()) { | 208 if (cryptohome->TpmIsOwned()) { |
206 cryptohome->TpmClearStoredPassword(); | 209 cryptohome->TpmClearStoredPassword(); |
207 } else { | 210 } else { |
208 cryptohome->TpmCanAttemptOwnership(); | 211 cryptohome->TpmCanAttemptOwnership(); |
209 } | 212 } |
210 } | 213 } |
211 } | 214 } |
212 btl->AddLoginTimeMarker("TPMOwned", false); | 215 btl->AddLoginTimeMarker("TPMOwned", false); |
213 | 216 |
217 RespectLocalePreference(profile->GetPrefs()); | |
218 | |
214 static const char kFallbackInputMethodLocale[] = "en-US"; | 219 static const char kFallbackInputMethodLocale[] = "en-US"; |
215 if (first_login) { | 220 if (first_login) { |
216 std::string locale(g_browser_process->GetApplicationLocale()); | 221 std::string locale(g_browser_process->GetApplicationLocale()); |
217 // Add input methods based on the application locale when the user first | 222 // Add input methods based on the application locale when the user first |
218 // logs in. For instance, if the user chooses Japanese as the UI | 223 // logs in. For instance, if the user chooses Japanese as the UI |
219 // language at the first login, we'll add input methods associated with | 224 // language at the first login, we'll add input methods associated with |
220 // Japanese, such as mozc. | 225 // Japanese, such as mozc. |
221 if (locale != kFallbackInputMethodLocale) { | 226 if (locale != kFallbackInputMethodLocale) { |
222 StringPrefMember language_preload_engines; | 227 StringPrefMember language_preload_engines; |
223 language_preload_engines.Init(prefs::kLanguagePreloadEngines, | 228 language_preload_engines.Init(prefs::kLanguagePreloadEngines, |
(...skipping 27 matching lines...) Expand all Loading... | |
251 // out when we get that done properly. | 256 // out when we get that done properly. |
252 // TODO(xiyuan): Remove this once enterprise feature is ready. | 257 // TODO(xiyuan): Remove this once enterprise feature is ready. |
253 if (EndsWith(username, "@google.com", true)) { | 258 if (EndsWith(username, "@google.com", true)) { |
254 PrefService* pref_service = profile->GetPrefs(); | 259 PrefService* pref_service = profile->GetPrefs(); |
255 pref_service->SetBoolean(prefs::kEnableScreenLock, true); | 260 pref_service->SetBoolean(prefs::kEnableScreenLock, true); |
256 } | 261 } |
257 | 262 |
258 DoBrowserLaunch(profile); | 263 DoBrowserLaunch(profile); |
259 } | 264 } |
260 | 265 |
266 void LoginUtilsImpl::RespectLocalePreference(PrefService* pref) { | |
267 std::string pref_locale = pref->GetString(prefs::kApplicationLocale); | |
268 if (pref_locale.empty()) { | |
269 // TODO(dilmah): current code will clobber existing setting in case | |
270 // language preference was set via another device | |
271 // but still not synced yet. | |
Nikita (slow)
2010/11/15 07:54:41
That would be always the case because profile is n
Denis Lagno
2010/11/15 11:50:05
Done.
| |
272 pref->SetString(prefs::kApplicationLocale, | |
273 g_browser_process->GetApplicationLocale()); | |
274 } else { | |
275 LanguageSwitchMenu::SwitchLanguage(pref_locale); | |
276 } | |
277 } | |
278 | |
261 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { | 279 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { |
262 VLOG(1) << "Completing off the record login"; | 280 VLOG(1) << "Completing off the record login"; |
263 | 281 |
264 UserManager::Get()->OffTheRecordUserLoggedIn(); | 282 UserManager::Get()->OffTheRecordUserLoggedIn(); |
265 | 283 |
266 if (CrosLibrary::Get()->EnsureLoaded()) { | 284 if (CrosLibrary::Get()->EnsureLoaded()) { |
267 // For guest session we ask session manager to restart Chrome with --bwsi | 285 // For guest session we ask session manager to restart Chrome with --bwsi |
268 // flag. We keep only some of the arguments of this process. | 286 // flag. We keep only some of the arguments of this process. |
269 static const char* kForwardSwitches[] = { | 287 static const char* kForwardSwitches[] = { |
270 switches::kEnableLogging, | 288 switches::kEnableLogging, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 BrowserInit browser_init; | 403 BrowserInit browser_init; |
386 int return_code; | 404 int return_code; |
387 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), | 405 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), |
388 profile, | 406 profile, |
389 FilePath(), | 407 FilePath(), |
390 true, | 408 true, |
391 &return_code); | 409 &return_code); |
392 } | 410 } |
393 | 411 |
394 } // namespace chromeos | 412 } // namespace chromeos |
OLD | NEW |