| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/signin/signin_manager.h" | 5 #include "chrome/browser/signin/signin_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/content_settings/cookie_settings.h" | |
| 18 #include "chrome/browser/signin/about_signin_internals.h" | 17 #include "chrome/browser/signin/about_signin_internals.h" |
| 19 #include "chrome/browser/signin/about_signin_internals_factory.h" | 18 #include "chrome/browser/signin/about_signin_internals_factory.h" |
| 20 #include "chrome/browser/signin/signin_global_error.h" | 19 #include "chrome/browser/signin/signin_global_error.h" |
| 21 #include "chrome/browser/signin/signin_internals_util.h" | 20 #include "chrome/browser/signin/signin_internals_util.h" |
| 22 #include "chrome/browser/signin/signin_manager_cookie_helper.h" | 21 #include "chrome/browser/signin/signin_manager_cookie_helper.h" |
| 22 #include "chrome/browser/signin/signin_manager_delegate.h" |
| 23 #include "chrome/browser/signin/signin_manager_factory.h" | 23 #include "chrome/browser/signin/signin_manager_factory.h" |
| 24 #include "chrome/browser/signin/token_service.h" | 24 #include "chrome/browser/signin/token_service.h" |
| 25 #include "chrome/browser/signin/token_service_factory.h" | 25 #include "chrome/browser/signin/token_service_factory.h" |
| 26 #include "chrome/browser/ui/global_error/global_error_service.h" | 26 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 27 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 27 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 28 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
| 29 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 32 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 return false; | 72 return false; |
| 73 | 73 |
| 74 // Any login UI URLs with signin=chromiumsync should be considered a web | 74 // Any login UI URLs with signin=chromiumsync should be considered a web |
| 75 // URL (relies on GAIA keeping the "service=chromiumsync" query string | 75 // URL (relies on GAIA keeping the "service=chromiumsync" query string |
| 76 // fragment present even when embedding inside a "continue" parameter). | 76 // fragment present even when embedding inside a "continue" parameter). |
| 77 return net::UnescapeURLComponent( | 77 return net::UnescapeURLComponent( |
| 78 url.query(), net::UnescapeRule::URL_SPECIAL_CHARS) | 78 url.query(), net::UnescapeRule::URL_SPECIAL_CHARS) |
| 79 .find(kChromiumSyncService) != std::string::npos; | 79 .find(kChromiumSyncService) != std::string::npos; |
| 80 } | 80 } |
| 81 | 81 |
| 82 SigninManager::SigninManager() | 82 SigninManager::SigninManager(scoped_ptr<SigninManagerDelegate> delegate) |
| 83 : prohibit_signout_(false), | 83 : prohibit_signout_(false), |
| 84 had_two_factor_error_(false), | 84 had_two_factor_error_(false), |
| 85 type_(SIGNIN_TYPE_NONE), | 85 type_(SIGNIN_TYPE_NONE), |
| 86 weak_pointer_factory_(this), | 86 weak_pointer_factory_(this), |
| 87 signin_process_id_(kInvalidProcessId) { | 87 signin_process_id_(kInvalidProcessId), |
| 88 delegate_(delegate.Pass()) { |
| 88 } | 89 } |
| 89 | 90 |
| 90 void SigninManager::SetSigninProcess(int process_id) { | 91 void SigninManager::SetSigninProcess(int process_id) { |
| 91 if (process_id == signin_process_id_) | 92 if (process_id == signin_process_id_) |
| 92 return; | 93 return; |
| 93 DLOG_IF(WARNING, signin_process_id_ != kInvalidProcessId) << | 94 DLOG_IF(WARNING, signin_process_id_ != kInvalidProcessId) << |
| 94 "Replacing in-use signin process."; | 95 "Replacing in-use signin process."; |
| 95 signin_process_id_ = process_id; | 96 signin_process_id_ = process_id; |
| 96 const content::RenderProcessHost* process = | 97 const content::RenderProcessHost* process = |
| 97 content::RenderProcessHost::FromID(process_id); | 98 content::RenderProcessHost::FromID(process_id); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 193 |
| 193 client_login_->StartClientLogin(username, | 194 client_login_->StartClientLogin(username, |
| 194 password, | 195 password, |
| 195 "", | 196 "", |
| 196 login_token, | 197 login_token, |
| 197 login_captcha, | 198 login_captcha, |
| 198 GaiaAuthFetcher::HostedAccountsNotAllowed); | 199 GaiaAuthFetcher::HostedAccountsNotAllowed); |
| 199 | 200 |
| 200 // Register for token availability. The signin manager will pre-login the | 201 // Register for token availability. The signin manager will pre-login the |
| 201 // user when the GAIA service token is ready for use. | 202 // user when the GAIA service token is ready for use. |
| 202 if (AreSigninCookiesAllowed(profile_)) { | 203 if (delegate_->AreSigninCookiesAllowed()) { |
| 203 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 204 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
| 204 registrar_.Add(this, | 205 registrar_.Add(this, |
| 205 chrome::NOTIFICATION_TOKEN_AVAILABLE, | 206 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
| 206 content::Source<TokenService>(token_service)); | 207 content::Source<TokenService>(token_service)); |
| 207 } | 208 } |
| 208 } | 209 } |
| 209 | 210 |
| 210 void SigninManager::ProvideSecondFactorAccessCode( | 211 void SigninManager::ProvideSecondFactorAccessCode( |
| 211 const std::string& access_code) { | 212 const std::string& access_code) { |
| 212 DCHECK(!possibly_invalid_username_.empty() && !password_.empty() && | 213 DCHECK(!possibly_invalid_username_.empty() && !password_.empty() && |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 } | 588 } |
| 588 } | 589 } |
| 589 | 590 |
| 590 void SigninManager::ProhibitSignout(bool prohibit_signout) { | 591 void SigninManager::ProhibitSignout(bool prohibit_signout) { |
| 591 prohibit_signout_ = prohibit_signout; | 592 prohibit_signout_ = prohibit_signout; |
| 592 } | 593 } |
| 593 | 594 |
| 594 bool SigninManager::IsSignoutProhibited() const { | 595 bool SigninManager::IsSignoutProhibited() const { |
| 595 return prohibit_signout_; | 596 return prohibit_signout_; |
| 596 } | 597 } |
| OLD | NEW |