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/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_process.h" | 20 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/browser_thread.h" | 21 #include "chrome/browser/browser_thread.h" |
22 #include "chrome/browser/chromeos/boot_times_loader.h" | 22 #include "chrome/browser/chromeos/boot_times_loader.h" |
23 #include "chrome/browser/chromeos/cros/login_library.h" | 23 #include "chrome/browser/chromeos/cros/login_library.h" |
24 #include "chrome/browser/chromeos/cros/network_library.h" | 24 #include "chrome/browser/chromeos/cros/network_library.h" |
25 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 25 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 26 #include "chrome/browser/chromeos/login/background_view.h" |
26 #include "chrome/browser/chromeos/login/cookie_fetcher.h" | 27 #include "chrome/browser/chromeos/login/cookie_fetcher.h" |
27 #include "chrome/browser/chromeos/login/google_authenticator.h" | 28 #include "chrome/browser/chromeos/login/google_authenticator.h" |
28 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 29 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
29 #include "chrome/browser/chromeos/login/ownership_service.h" | 30 #include "chrome/browser/chromeos/login/ownership_service.h" |
30 #include "chrome/browser/chromeos/login/parallel_authenticator.h" | 31 #include "chrome/browser/chromeos/login/parallel_authenticator.h" |
31 #include "chrome/browser/chromeos/login/user_image_downloader.h" | 32 #include "chrome/browser/chromeos/login/user_image_downloader.h" |
32 #include "chrome/browser/chromeos/login/user_manager.h" | 33 #include "chrome/browser/chromeos/login/user_manager.h" |
33 #include "chrome/browser/chromeos/proxy_config_service.h" | 34 #include "chrome/browser/chromeos/proxy_config_service.h" |
34 #include "chrome/browser/extensions/extension_service.h" | 35 #include "chrome/browser/extensions/extension_service.h" |
35 #include "chrome/browser/net/chrome_url_request_context.h" | 36 #include "chrome/browser/net/chrome_url_request_context.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 scoped_ptr<net::ProxyConfigService> proxy_config_service_; | 93 scoped_ptr<net::ProxyConfigService> proxy_config_service_; |
93 | 94 |
94 DISALLOW_COPY_AND_ASSIGN(ResetDefaultProxyConfigServiceTask); | 95 DISALLOW_COPY_AND_ASSIGN(ResetDefaultProxyConfigServiceTask); |
95 }; | 96 }; |
96 | 97 |
97 } // namespace | 98 } // namespace |
98 | 99 |
99 class LoginUtilsImpl : public LoginUtils { | 100 class LoginUtilsImpl : public LoginUtils { |
100 public: | 101 public: |
101 LoginUtilsImpl() | 102 LoginUtilsImpl() |
102 : browser_launch_enabled_(true) { | 103 : browser_launch_enabled_(true), |
| 104 background_view_(NULL) { |
103 } | 105 } |
104 | 106 |
105 // Invoked after the user has successfully logged in. This launches a browser | 107 // Invoked after the user has successfully logged in. This launches a browser |
106 // and does other bookkeeping after logging in. | 108 // and does other bookkeeping after logging in. |
107 virtual void CompleteLogin( | 109 virtual void CompleteLogin( |
108 const std::string& username, | 110 const std::string& username, |
109 const std::string& password, | 111 const std::string& password, |
110 const GaiaAuthConsumer::ClientLoginResult& credentials, | 112 const GaiaAuthConsumer::ClientLoginResult& credentials, |
111 bool pending_requests); | 113 bool pending_requests); |
112 | 114 |
(...skipping 23 matching lines...) Expand all Loading... |
136 // full-fledged Google authentication cookies. | 138 // full-fledged Google authentication cookies. |
137 virtual void FetchCookies( | 139 virtual void FetchCookies( |
138 Profile* profile, | 140 Profile* profile, |
139 const GaiaAuthConsumer::ClientLoginResult& credentials); | 141 const GaiaAuthConsumer::ClientLoginResult& credentials); |
140 | 142 |
141 // Supply credentials for sync and others to use. | 143 // Supply credentials for sync and others to use. |
142 virtual void FetchTokens( | 144 virtual void FetchTokens( |
143 Profile* profile, | 145 Profile* profile, |
144 const GaiaAuthConsumer::ClientLoginResult& credentials); | 146 const GaiaAuthConsumer::ClientLoginResult& credentials); |
145 | 147 |
| 148 // Sets the current background view. |
| 149 virtual void SetBackgroundView(chromeos::BackgroundView* background_view); |
| 150 |
| 151 // Gets the current background view. |
| 152 virtual chromeos::BackgroundView* GetBackgroundView(); |
| 153 |
146 private: | 154 private: |
147 // Check user's profile for kApplicationLocale setting. | 155 // Check user's profile for kApplicationLocale setting. |
148 void RespectLocalePreference(PrefService* pref); | 156 void RespectLocalePreference(PrefService* pref); |
149 | 157 |
150 // Indicates if DoBrowserLaunch will actually launch the browser or not. | 158 // Indicates if DoBrowserLaunch will actually launch the browser or not. |
151 bool browser_launch_enabled_; | 159 bool browser_launch_enabled_; |
152 | 160 |
| 161 // The current background view. |
| 162 chromeos::BackgroundView* background_view_; |
| 163 |
153 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl); | 164 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl); |
154 }; | 165 }; |
155 | 166 |
156 class LoginUtilsWrapper { | 167 class LoginUtilsWrapper { |
157 public: | 168 public: |
158 static LoginUtilsWrapper* GetInstance() { | 169 static LoginUtilsWrapper* GetInstance() { |
159 return Singleton<LoginUtilsWrapper>::get(); | 170 return Singleton<LoginUtilsWrapper>::get(); |
160 } | 171 } |
161 | 172 |
162 LoginUtils* get() { | 173 LoginUtils* get() { |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 chrome_browser_net::Preconnect::PreconnectOnUIThread( | 535 chrome_browser_net::Preconnect::PreconnectOnUIThread( |
525 GURL(GaiaAuthFetcher::kClientLoginUrl), | 536 GURL(GaiaAuthFetcher::kClientLoginUrl), |
526 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, | 537 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, |
527 kConnectionsNeeded); | 538 kConnectionsNeeded); |
528 } else { | 539 } else { |
529 new WarmingObserver(); | 540 new WarmingObserver(); |
530 } | 541 } |
531 } | 542 } |
532 } | 543 } |
533 | 544 |
| 545 void LoginUtilsImpl::SetBackgroundView(BackgroundView* background_view) { |
| 546 background_view_ = background_view; |
| 547 } |
| 548 |
| 549 BackgroundView* LoginUtilsImpl::GetBackgroundView() { |
| 550 return background_view_; |
| 551 } |
| 552 |
534 LoginUtils* LoginUtils::Get() { | 553 LoginUtils* LoginUtils::Get() { |
535 return LoginUtilsWrapper::GetInstance()->get(); | 554 return LoginUtilsWrapper::GetInstance()->get(); |
536 } | 555 } |
537 | 556 |
538 void LoginUtils::Set(LoginUtils* mock) { | 557 void LoginUtils::Set(LoginUtils* mock) { |
539 LoginUtilsWrapper::GetInstance()->reset(mock); | 558 LoginUtilsWrapper::GetInstance()->reset(mock); |
540 } | 559 } |
541 | 560 |
542 void LoginUtils::DoBrowserLaunch(Profile* profile) { | 561 void LoginUtils::DoBrowserLaunch(Profile* profile) { |
543 BootTimesLoader::Get()->AddLoginTimeMarker("BrowserLaunched", false); | 562 BootTimesLoader::Get()->AddLoginTimeMarker("BrowserLaunched", false); |
544 // Browser launch was disabled due to some post login screen. | 563 // Browser launch was disabled due to some post login screen. |
545 if (!LoginUtils::Get()->IsBrowserLaunchEnabled()) | 564 if (!LoginUtils::Get()->IsBrowserLaunchEnabled()) |
546 return; | 565 return; |
547 | 566 |
548 // Update command line in case loose values were added. | 567 // Update command line in case loose values were added. |
549 CommandLine::ForCurrentProcess()->InitFromArgv( | 568 CommandLine::ForCurrentProcess()->InitFromArgv( |
550 CommandLine::ForCurrentProcess()->argv()); | 569 CommandLine::ForCurrentProcess()->argv()); |
551 | 570 |
552 VLOG(1) << "Launching browser..."; | 571 VLOG(1) << "Launching browser..."; |
553 BrowserInit browser_init; | 572 BrowserInit browser_init; |
554 int return_code; | 573 int return_code; |
555 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), | 574 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), |
556 profile, | 575 profile, |
557 FilePath(), | 576 FilePath(), |
558 true, | 577 true, |
559 &return_code); | 578 &return_code); |
560 } | 579 } |
561 | 580 |
562 } // namespace chromeos | 581 } // namespace chromeos |
OLD | NEW |