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