| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/signin/core/browser/signin_manager.h" | 5 #include "components/signin/core/browser/signin_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 16 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 17 #include "components/signin/core/browser/signin_account_id_helper.h" | 17 #include "components/signin/core/browser/signin_account_id_helper.h" |
| 18 #include "components/signin/core/browser/signin_client.h" | 18 #include "components/signin/core/browser/signin_client.h" |
| 19 #include "components/signin/core/browser/signin_internals_util.h" | 19 #include "components/signin/core/browser/signin_internals_util.h" |
| 20 #include "components/signin/core/browser/signin_manager_cookie_helper.h" | 20 #include "components/signin/core/browser/signin_manager_cookie_helper.h" |
| 21 #include "components/signin/core/browser/signin_metrics.h" | 21 #include "components/signin/core/browser/signin_metrics.h" |
| 22 #include "components/signin/core/common/signin_pref_names.h" | 22 #include "components/signin/core/common/signin_pref_names.h" |
| 23 #include "google_apis/gaia/gaia_auth_util.h" | 23 #include "google_apis/gaia/gaia_auth_util.h" |
| 24 #include "google_apis/gaia/gaia_constants.h" | 24 #include "google_apis/gaia/gaia_constants.h" |
| 25 #include "google_apis/gaia/gaia_urls.h" | 25 #include "google_apis/gaia/gaia_urls.h" |
| 26 #include "net/base/escape.h" | |
| 27 #include "third_party/icu/source/i18n/unicode/regex.h" | 26 #include "third_party/icu/source/i18n/unicode/regex.h" |
| 28 | 27 |
| 29 using namespace signin_internals_util; | 28 using namespace signin_internals_util; |
| 30 | 29 |
| 31 namespace { | |
| 32 | |
| 33 const char kChromiumSyncService[] = "service=chromiumsync"; | |
| 34 | |
| 35 } // namespace | |
| 36 | |
| 37 // Under the covers, we use a dummy chrome-extension ID to serve the purposes | |
| 38 // outlined in the .h file comment for this string. | |
| 39 const char SigninManager::kChromeSigninEffectiveSite[] = | |
| 40 "chrome-extension://acfccoigjajmmgbhpfbjnpckhjjegnih"; | |
| 41 | |
| 42 // static | |
| 43 bool SigninManager::IsWebBasedSigninFlowURL(const GURL& url) { | |
| 44 GURL effective(kChromeSigninEffectiveSite); | |
| 45 if (url.SchemeIs(effective.scheme().c_str()) && | |
| 46 url.host() == effective.host()) { | |
| 47 return true; | |
| 48 } | |
| 49 | |
| 50 GURL service_login(GaiaUrls::GetInstance()->service_login_url()); | |
| 51 if (url.GetOrigin() != service_login.GetOrigin()) | |
| 52 return false; | |
| 53 | |
| 54 // Any login UI URLs with signin=chromiumsync should be considered a web | |
| 55 // URL (relies on GAIA keeping the "service=chromiumsync" query string | |
| 56 // fragment present even when embedding inside a "continue" parameter). | |
| 57 return net::UnescapeURLComponent(url.query(), | |
| 58 net::UnescapeRule::URL_SPECIAL_CHARS) | |
| 59 .find(kChromiumSyncService) != std::string::npos; | |
| 60 } | |
| 61 | |
| 62 SigninManager::SigninManager(SigninClient* client, | 30 SigninManager::SigninManager(SigninClient* client, |
| 63 ProfileOAuth2TokenService* token_service, | 31 ProfileOAuth2TokenService* token_service, |
| 64 AccountTrackerService* account_tracker_service) | 32 AccountTrackerService* account_tracker_service) |
| 65 : SigninManagerBase(client), | 33 : SigninManagerBase(client), |
| 66 prohibit_signout_(false), | 34 prohibit_signout_(false), |
| 67 type_(SIGNIN_TYPE_NONE), | 35 type_(SIGNIN_TYPE_NONE), |
| 68 client_(client), | 36 client_(client), |
| 69 token_service_(token_service), | 37 token_service_(token_service), |
| 70 account_tracker_service_(account_tracker_service), | 38 account_tracker_service_(account_tracker_service), |
| 71 signin_manager_signed_in_(false), | 39 signin_manager_signed_in_(false), |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 void SigninManager::OnAccountUpdateFailed(const std::string& account_id) { | 415 void SigninManager::OnAccountUpdateFailed(const std::string& account_id) { |
| 448 user_info_fetched_by_account_tracker_ = true; | 416 user_info_fetched_by_account_tracker_ = true; |
| 449 PostSignedIn(); | 417 PostSignedIn(); |
| 450 } | 418 } |
| 451 | 419 |
| 452 void SigninManager::ProhibitSignout(bool prohibit_signout) { | 420 void SigninManager::ProhibitSignout(bool prohibit_signout) { |
| 453 prohibit_signout_ = prohibit_signout; | 421 prohibit_signout_ = prohibit_signout; |
| 454 } | 422 } |
| 455 | 423 |
| 456 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; } | 424 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; } |
| OLD | NEW |