| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/webui/chromeos/login/inline_login_handler_chromeos.h
" | 5 #include "chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.h
" |
| 6 | 6 |
| 7 #include <string> | |
| 8 | |
| 9 #include "chrome/browser/chromeos/login/signin/oauth2_token_fetcher.h" | 7 #include "chrome/browser/chromeos/login/signin/oauth2_token_fetcher.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/signin/account_tracker_service_factory.h" | |
| 12 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 9 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 14 #include "chrome/browser/signin/signin_manager_factory.h" | 11 #include "chrome/browser/signin/signin_manager_factory.h" |
| 15 #include "chrome/browser/signin/signin_promo.h" | 12 #include "chrome/browser/signin/signin_promo.h" |
| 16 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 17 #include "components/signin/core/browser/account_tracker_service.h" | |
| 18 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 14 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 19 #include "components/signin/core/browser/signin_client.h" | 15 #include "components/signin/core/browser/signin_client.h" |
| 20 #include "components/signin/core/browser/signin_manager.h" | 16 #include "components/signin/core/browser/signin_manager.h" |
| 21 #include "content/public/browser/storage_partition.h" | 17 #include "content/public/browser/storage_partition.h" |
| 22 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_ui.h" | 19 #include "content/public/browser/web_ui.h" |
| 24 #include "google_apis/gaia/gaia_urls.h" | 20 #include "google_apis/gaia/gaia_urls.h" |
| 25 #include "net/base/url_util.h" | 21 #include "net/base/url_util.h" |
| 26 | 22 |
| 27 namespace chromeos { | 23 namespace chromeos { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 void InlineLoginHandlerChromeOS::CompleteLogin(const base::ListValue* args) { | 65 void InlineLoginHandlerChromeOS::CompleteLogin(const base::ListValue* args) { |
| 70 Profile* profile = Profile::FromWebUI(web_ui()); | 66 Profile* profile = Profile::FromWebUI(web_ui()); |
| 71 | 67 |
| 72 const base::DictionaryValue* dict = NULL; | 68 const base::DictionaryValue* dict = NULL; |
| 73 args->GetDictionary(0, &dict); | 69 args->GetDictionary(0, &dict); |
| 74 | 70 |
| 75 std::string session_index; | 71 std::string session_index; |
| 76 dict->GetString("sessionIndex", &session_index); | 72 dict->GetString("sessionIndex", &session_index); |
| 77 CHECK(!session_index.empty()) << "Session index is empty."; | 73 CHECK(!session_index.empty()) << "Session index is empty."; |
| 78 | 74 |
| 79 std::string email; | 75 std::string account_id; |
| 80 dict->GetString("email", &email); | 76 dict->GetString("email", &account_id); |
| 81 CHECK(!email.empty()) << "Email is empty."; | 77 CHECK(!account_id.empty()) << "Account ID is empty."; |
| 82 | 78 |
| 83 std::string gaia_id; | |
| 84 dict->GetString("gaiaId", &gaia_id); | |
| 85 CHECK(!gaia_id.empty()) << "Gaia ID is empty."; | |
| 86 | |
| 87 AccountTrackerService* account_tracker = | |
| 88 AccountTrackerServiceFactory::GetForProfile(profile); | |
| 89 account_tracker->SeedAccountInfo(gaia_id, email); | |
| 90 | |
| 91 const std::string account_id = | |
| 92 account_tracker->PickAccountIdForAccount(gaia_id, email); | |
| 93 oauth2_delegate_.reset(new InlineLoginUIOAuth2Delegate(web_ui(), account_id)); | 79 oauth2_delegate_.reset(new InlineLoginUIOAuth2Delegate(web_ui(), account_id)); |
| 94 net::URLRequestContextGetter* request_context = | 80 net::URLRequestContextGetter* request_context = |
| 95 content::BrowserContext::GetStoragePartitionForSite( | 81 content::BrowserContext::GetStoragePartitionForSite( |
| 96 profile, GURL(chrome::kChromeUIChromeSigninURL)) | 82 profile, GURL(chrome::kChromeUIChromeSigninURL)) |
| 97 ->GetURLRequestContext(); | 83 ->GetURLRequestContext(); |
| 98 oauth2_token_fetcher_.reset( | 84 oauth2_token_fetcher_.reset( |
| 99 new OAuth2TokenFetcher(oauth2_delegate_.get(), request_context)); | 85 new OAuth2TokenFetcher(oauth2_delegate_.get(), request_context)); |
| 100 SigninClient* signin_client = | 86 SigninClient* signin_client = |
| 101 ChromeSigninClientFactory::GetForProfile(profile); | 87 ChromeSigninClientFactory::GetForProfile(profile); |
| 102 std::string signin_scoped_device_id = | 88 std::string signin_scoped_device_id = |
| 103 signin_client->GetSigninScopedDeviceId(); | 89 signin_client->GetSigninScopedDeviceId(); |
| 104 oauth2_token_fetcher_->StartExchangeFromCookies(session_index, | 90 oauth2_token_fetcher_->StartExchangeFromCookies(session_index, |
| 105 signin_scoped_device_id); | 91 signin_scoped_device_id); |
| 106 } | 92 } |
| 107 | 93 |
| 108 } // namespace chromeos | 94 } // namespace chromeos |
| OLD | NEW |