| 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/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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 26 #include "chrome/browser/chromeos/input_method/input_method_manager.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/background_view.h" | 28 #include "chrome/browser/chromeos/login/background_view.h" |
| 29 #include "chrome/browser/chromeos/login/cookie_fetcher.h" | 29 #include "chrome/browser/chromeos/login/cookie_fetcher.h" |
| 30 #include "chrome/browser/chromeos/login/google_authenticator.h" | 30 #include "chrome/browser/chromeos/login/google_authenticator.h" |
| 31 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 31 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
| 32 #include "chrome/browser/chromeos/login/login_display_host.h" | 32 #include "chrome/browser/chromeos/login/login_display_host.h" |
| 33 #include "chrome/browser/chromeos/login/ownership_service.h" | 33 #include "chrome/browser/chromeos/login/ownership_service.h" |
| 34 #include "chrome/browser/chromeos/login/parallel_authenticator.h" | 34 #include "chrome/browser/chromeos/login/parallel_authenticator.h" |
| 35 #include "chrome/browser/chromeos/login/user_manager.h" | 35 #include "chrome/browser/chromeos/login/user_manager.h" |
| 36 #include "chrome/browser/chromeos/proxy_config_service.h" | |
| 37 #include "chrome/browser/extensions/extension_service.h" | 36 #include "chrome/browser/extensions/extension_service.h" |
| 38 #include "chrome/browser/net/chrome_url_request_context.h" | 37 #include "chrome/browser/net/chrome_url_request_context.h" |
| 39 #include "chrome/browser/net/gaia/token_service.h" | 38 #include "chrome/browser/net/gaia/token_service.h" |
| 40 #include "chrome/browser/net/preconnect.h" | 39 #include "chrome/browser/net/preconnect.h" |
| 41 #include "chrome/browser/net/pref_proxy_config_service.h" | |
| 42 #include "chrome/browser/plugin_updater.h" | 40 #include "chrome/browser/plugin_updater.h" |
| 43 #include "chrome/browser/policy/browser_policy_connector.h" | 41 #include "chrome/browser/policy/browser_policy_connector.h" |
| 44 #include "chrome/browser/prefs/pref_member.h" | 42 #include "chrome/browser/prefs/pref_member.h" |
| 45 #include "chrome/browser/profiles/profile.h" | 43 #include "chrome/browser/profiles/profile.h" |
| 46 #include "chrome/browser/profiles/profile_manager.h" | 44 #include "chrome/browser/profiles/profile_manager.h" |
| 47 #include "chrome/browser/sync/profile_sync_service.h" | 45 #include "chrome/browser/sync/profile_sync_service.h" |
| 48 #include "chrome/browser/ui/browser_init.h" | 46 #include "chrome/browser/ui/browser_init.h" |
| 49 #include "chrome/common/chrome_paths.h" | 47 #include "chrome/common/chrome_paths.h" |
| 50 #include "chrome/common/chrome_switches.h" | 48 #include "chrome/common/chrome_switches.h" |
| 51 #include "chrome/common/logging_chrome.h" | 49 #include "chrome/common/logging_chrome.h" |
| 52 #include "chrome/common/net/gaia/gaia_constants.h" | 50 #include "chrome/common/net/gaia/gaia_constants.h" |
| 53 #include "chrome/common/net/gaia/gaia_urls.h" | 51 #include "chrome/common/net/gaia/gaia_urls.h" |
| 54 #include "chrome/common/pref_names.h" | 52 #include "chrome/common/pref_names.h" |
| 55 #include "chrome/common/url_constants.h" | 53 #include "chrome/common/url_constants.h" |
| 56 #include "content/browser/browser_thread.h" | 54 #include "content/browser/browser_thread.h" |
| 57 #include "googleurl/src/gurl.h" | 55 #include "googleurl/src/gurl.h" |
| 56 #include "net/base/cookie_monster.h" |
| 58 #include "net/base/cookie_store.h" | 57 #include "net/base/cookie_store.h" |
| 59 #include "net/base/cookie_monster.h" | |
| 60 #include "net/proxy/proxy_config_service.h" | |
| 61 #include "net/proxy/proxy_service.h" | |
| 62 #include "net/url_request/url_request_context.h" | 58 #include "net/url_request/url_request_context.h" |
| 63 #include "net/url_request/url_request_context_getter.h" | 59 #include "net/url_request/url_request_context_getter.h" |
| 64 #include "ui/gfx/gl/gl_switches.h" | 60 #include "ui/gfx/gl/gl_switches.h" |
| 65 | 61 |
| 66 namespace chromeos { | 62 namespace chromeos { |
| 67 | 63 |
| 68 namespace { | 64 namespace { |
| 69 | 65 |
| 70 // Affixes for Auth token received from ClientLogin request. | 66 // Affixes for Auth token received from ClientLogin request. |
| 71 const char kAuthPrefix[] = "Auth="; | 67 const char kAuthPrefix[] = "Auth="; |
| 72 const char kAuthSuffix[] = "\n"; | 68 const char kAuthSuffix[] = "\n"; |
| 73 | 69 |
| 74 // Increase logging level for Guest mode to avoid LOG(INFO) messages in logs. | 70 // Increase logging level for Guest mode to avoid LOG(INFO) messages in logs. |
| 75 const char kGuestModeLoggingLevel[] = "1"; | 71 const char kGuestModeLoggingLevel[] = "1"; |
| 76 | 72 |
| 77 // Format of command line switch. | 73 // Format of command line switch. |
| 78 const char kSwitchFormatString[] = " --%s=\"%s\""; | 74 const char kSwitchFormatString[] = " --%s=\"%s\""; |
| 79 | 75 |
| 80 // User name which is used in the Guest session. | 76 // User name which is used in the Guest session. |
| 81 const char kGuestUserName[] = ""; | 77 const char kGuestUserName[] = ""; |
| 82 | 78 |
| 83 } // namespace | 79 } // namespace |
| 84 | 80 |
| 85 // Resets the proxy configuration service for the default request context. | |
| 86 class ResetDefaultProxyConfigServiceTask : public Task { | |
| 87 public: | |
| 88 ResetDefaultProxyConfigServiceTask( | |
| 89 net::ProxyConfigService* proxy_config_service) | |
| 90 : proxy_config_service_(proxy_config_service) {} | |
| 91 virtual ~ResetDefaultProxyConfigServiceTask() {} | |
| 92 | |
| 93 // Task override. | |
| 94 virtual void Run() { | |
| 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 96 // TODO(willchan): Move this class back into the anonymous namespace after | |
| 97 // we stop using this deprecated API. | |
| 98 net::URLRequestContextGetter* getter = | |
| 99 Profile::Deprecated::GetDefaultRequestContext(); | |
| 100 DCHECK(getter); | |
| 101 if (getter) { | |
| 102 getter->GetURLRequestContext()->proxy_service()->ResetConfigService( | |
| 103 proxy_config_service_.release()); | |
| 104 } | |
| 105 } | |
| 106 | |
| 107 private: | |
| 108 scoped_ptr<net::ProxyConfigService> proxy_config_service_; | |
| 109 | |
| 110 DISALLOW_COPY_AND_ASSIGN(ResetDefaultProxyConfigServiceTask); | |
| 111 }; | |
| 112 | |
| 113 // Transfer the inital set of Profile cookies form the default profile. | 81 // Transfer the inital set of Profile cookies form the default profile. |
| 114 class TransferDefaultCookiesOnIOThreadTask : public Task { | 82 class TransferDefaultCookiesOnIOThreadTask : public Task { |
| 115 public: | 83 public: |
| 116 TransferDefaultCookiesOnIOThreadTask( | 84 TransferDefaultCookiesOnIOThreadTask( |
| 117 net::URLRequestContextGetter* default_context, | 85 net::URLRequestContextGetter* default_context, |
| 118 net::URLRequestContextGetter* new_context) | 86 net::URLRequestContextGetter* new_context) |
| 119 : default_context_(default_context), | 87 : default_context_(default_context), |
| 120 new_context_(new_context) {} | 88 new_context_(new_context) {} |
| 121 virtual ~TransferDefaultCookiesOnIOThreadTask() {} | 89 virtual ~TransferDefaultCookiesOnIOThreadTask() {} |
| 122 | 90 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // Initialize the user-policy backend. | 272 // Initialize the user-policy backend. |
| 305 policy::BrowserPolicyConnector* browser_policy_connector = | 273 policy::BrowserPolicyConnector* browser_policy_connector = |
| 306 g_browser_process->browser_policy_connector(); | 274 g_browser_process->browser_policy_connector(); |
| 307 browser_policy_connector->InitializeUserPolicy(username_, | 275 browser_policy_connector->InitializeUserPolicy(username_, |
| 308 profile->GetPath(), | 276 profile->GetPath(), |
| 309 profile->GetTokenService()); | 277 profile->GetTokenService()); |
| 310 | 278 |
| 311 BootTimesLoader* btl = BootTimesLoader::Get(); | 279 BootTimesLoader* btl = BootTimesLoader::Get(); |
| 312 btl->AddLoginTimeMarker("UserProfileGotten", false); | 280 btl->AddLoginTimeMarker("UserProfileGotten", false); |
| 313 | 281 |
| 314 // Change the proxy configuration service of the default request context to | |
| 315 // use the preference configuration from the logged-in profile. This ensures | |
| 316 // that requests done through the default context use the proxy configuration | |
| 317 // provided by configuration policy. | |
| 318 // | |
| 319 // Note: Many of the clients of the default request context should probably be | |
| 320 // fixed to use the request context of the profile they are associated with. | |
| 321 // This includes preconnect, autofill, metrics service to only name a few; | |
| 322 // see http://code.google.com/p/chromium/issues/detail?id=64339 for details. | |
| 323 // | |
| 324 // TODO(mnissler) Revisit when support for device-specific policy arrives, at | |
| 325 // which point the default request context can directly be managed through | |
| 326 // device policy. | |
| 327 net::ProxyConfigService* proxy_config_service = | |
| 328 new PrefProxyConfigService( | |
| 329 profile->GetProxyConfigTracker(), | |
| 330 new chromeos::ProxyConfigService( | |
| 331 g_browser_process->chromeos_proxy_config_service_impl())); | |
| 332 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | |
| 333 new ResetDefaultProxyConfigServiceTask( | |
| 334 proxy_config_service)); | |
| 335 | |
| 336 // Since we're doing parallel authentication, only new user sign in | 282 // Since we're doing parallel authentication, only new user sign in |
| 337 // would perform online auth before calling PrepareProfile. | 283 // would perform online auth before calling PrepareProfile. |
| 338 // For existing users there's usually a pending online auth request. | 284 // For existing users there's usually a pending online auth request. |
| 339 // Cookies will be fetched after it's is succeeded. | 285 // Cookies will be fetched after it's is succeeded. |
| 340 if (!pending_requests_) { | 286 if (!pending_requests_) { |
| 341 if (CommandLine::ForCurrentProcess()->HasSwitch( | 287 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 342 switches::kWebUIGaiaLogin)) { | 288 switches::kWebUIGaiaLogin)) { |
| 343 // Transfer cookies from the profile that was used for authentication. | 289 // Transfer cookies from the profile that was used for authentication. |
| 344 // This profile contains cookies that auth extension should have already | 290 // This profile contains cookies that auth extension should have already |
| 345 // put in place that will ensure that the newly created session is | 291 // put in place that will ensure that the newly created session is |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 // Mark login host for deletion after browser starts. This | 648 // Mark login host for deletion after browser starts. This |
| 703 // guarantees that the message loop will be referenced by the | 649 // guarantees that the message loop will be referenced by the |
| 704 // browser before it is dereferenced by the login host. | 650 // browser before it is dereferenced by the login host. |
| 705 if (login_host) { | 651 if (login_host) { |
| 706 login_host->OnSessionStart(); | 652 login_host->OnSessionStart(); |
| 707 login_host = NULL; | 653 login_host = NULL; |
| 708 } | 654 } |
| 709 } | 655 } |
| 710 | 656 |
| 711 } // namespace chromeos | 657 } // namespace chromeos |
| OLD | NEW |