Chromium Code Reviews| 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" |
|
joth
2010/12/09 15:06:40
remove, fwd declare traits
| |
| 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" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 void RespectLocalePreference(PrefService* pref); | 136 void RespectLocalePreference(PrefService* pref); |
| 137 | 137 |
| 138 // Indicates if DoBrowserLaunch will actually launch the browser or not. | 138 // Indicates if DoBrowserLaunch will actually launch the browser or not. |
| 139 bool browser_launch_enabled_; | 139 bool browser_launch_enabled_; |
| 140 | 140 |
| 141 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl); | 141 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl); |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 class LoginUtilsWrapper { | 144 class LoginUtilsWrapper { |
| 145 public: | 145 public: |
| 146 LoginUtilsWrapper() {} | 146 static LoginUtilsWrapper* GetInstance() { |
| 147 return Singleton<LoginUtilsWrapper>::get(); | |
| 148 } | |
| 147 | 149 |
| 148 LoginUtils* get() { | 150 LoginUtils* get() { |
| 149 AutoLock create(create_lock_); | 151 AutoLock create(create_lock_); |
| 150 if (!ptr_.get()) | 152 if (!ptr_.get()) |
| 151 reset(new LoginUtilsImpl); | 153 reset(new LoginUtilsImpl); |
| 152 return ptr_.get(); | 154 return ptr_.get(); |
| 153 } | 155 } |
| 154 | 156 |
| 155 void reset(LoginUtils* ptr) { | 157 void reset(LoginUtils* ptr) { |
| 156 ptr_.reset(ptr); | 158 ptr_.reset(ptr); |
| 157 } | 159 } |
| 158 | 160 |
| 159 private: | 161 private: |
| 162 friend struct DefaultSingletonTraits<LoginUtilsWrapper>; | |
| 163 | |
| 164 LoginUtilsWrapper() {} | |
| 165 | |
| 160 Lock create_lock_; | 166 Lock create_lock_; |
| 161 scoped_ptr<LoginUtils> ptr_; | 167 scoped_ptr<LoginUtils> ptr_; |
| 162 | 168 |
| 163 DISALLOW_COPY_AND_ASSIGN(LoginUtilsWrapper); | 169 DISALLOW_COPY_AND_ASSIGN(LoginUtilsWrapper); |
| 164 }; | 170 }; |
| 165 | 171 |
| 166 void LoginUtilsImpl::CompleteLogin( | 172 void LoginUtilsImpl::CompleteLogin( |
| 167 const std::string& username, | 173 const std::string& username, |
| 168 const std::string& password, | 174 const std::string& password, |
| 169 const GaiaAuthConsumer::ClientLoginResult& credentials) { | 175 const GaiaAuthConsumer::ClientLoginResult& credentials) { |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 GURL(GaiaAuthFetcher::kClientLoginUrl), | 453 GURL(GaiaAuthFetcher::kClientLoginUrl), |
| 448 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, | 454 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, |
| 449 kConnectionsNeeded); | 455 kConnectionsNeeded); |
| 450 } else { | 456 } else { |
| 451 new WarmingObserver(); | 457 new WarmingObserver(); |
| 452 } | 458 } |
| 453 } | 459 } |
| 454 } | 460 } |
| 455 | 461 |
| 456 LoginUtils* LoginUtils::Get() { | 462 LoginUtils* LoginUtils::Get() { |
| 457 return Singleton<LoginUtilsWrapper>::get()->get(); | 463 return LoginUtilsWrapper::GetInstance()->get(); |
| 458 } | 464 } |
| 459 | 465 |
| 460 void LoginUtils::Set(LoginUtils* mock) { | 466 void LoginUtils::Set(LoginUtils* mock) { |
| 461 Singleton<LoginUtilsWrapper>::get()->reset(mock); | 467 LoginUtilsWrapper::GetInstance()->reset(mock); |
| 462 } | 468 } |
| 463 | 469 |
| 464 void LoginUtils::DoBrowserLaunch(Profile* profile) { | 470 void LoginUtils::DoBrowserLaunch(Profile* profile) { |
| 465 BootTimesLoader::Get()->AddLoginTimeMarker("BrowserLaunched", false); | 471 BootTimesLoader::Get()->AddLoginTimeMarker("BrowserLaunched", false); |
| 466 // Browser launch was disabled due to some post login screen. | 472 // Browser launch was disabled due to some post login screen. |
| 467 if (!LoginUtils::Get()->IsBrowserLaunchEnabled()) | 473 if (!LoginUtils::Get()->IsBrowserLaunchEnabled()) |
| 468 return; | 474 return; |
| 469 | 475 |
| 470 // Update command line in case loose values were added. | 476 // Update command line in case loose values were added. |
| 471 CommandLine::ForCurrentProcess()->InitFromArgv( | 477 CommandLine::ForCurrentProcess()->InitFromArgv( |
| 472 CommandLine::ForCurrentProcess()->argv()); | 478 CommandLine::ForCurrentProcess()->argv()); |
| 473 | 479 |
| 474 VLOG(1) << "Launching browser..."; | 480 VLOG(1) << "Launching browser..."; |
| 475 BrowserInit browser_init; | 481 BrowserInit browser_init; |
| 476 int return_code; | 482 int return_code; |
| 477 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), | 483 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), |
| 478 profile, | 484 profile, |
| 479 FilePath(), | 485 FilePath(), |
| 480 true, | 486 true, |
| 481 &return_code); | 487 &return_code); |
| 482 } | 488 } |
| 483 | 489 |
| 484 } // namespace chromeos | 490 } // namespace chromeos |
| OLD | NEW |