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