Index: chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.cc |
diff --git a/chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.cc b/chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.cc |
index 9fa4efce7e6bdf386abf7cf41a34f16d3e163b81..3e14d22a62994033e0540df95543f6e0c981afa4 100644 |
--- a/chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.cc |
+++ b/chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.cc |
@@ -4,21 +4,29 @@ |
#include "chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.h" |
+#include "base/strings/utf_string_conversions.h" |
xiyuan
2014/04/24 21:22:10
Is this used?
dzhioev (left Google)
2014/04/24 22:06:20
No, removed it.
|
#include "chrome/browser/chromeos/login/oauth2_token_fetcher.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
#include "chrome/browser/signin/signin_manager_factory.h" |
+#include "chrome/common/url_constants.h" |
#include "components/signin/core/browser/profile_oauth2_token_service.h" |
#include "components/signin/core/browser/signin_manager.h" |
+#include "content/public/browser/storage_partition.h" |
+#include "content/public/browser/web_contents.h" |
#include "content/public/browser/web_ui.h" |
+#include "google_apis/gaia/gaia_urls.h" |
+#include "net/base/url_util.h" |
namespace chromeos { |
class InlineLoginHandlerChromeOS::InlineLoginUIOAuth2Delegate |
: public OAuth2TokenFetcher::Delegate { |
public: |
- explicit InlineLoginUIOAuth2Delegate(content::WebUI* web_ui) |
- : web_ui_(web_ui) {} |
+ explicit InlineLoginUIOAuth2Delegate(content::WebUI* web_ui, |
+ const std::string& account_id) |
+ : web_ui_(web_ui), account_id_(account_id) {} |
+ |
virtual ~InlineLoginUIOAuth2Delegate() {} |
// OAuth2TokenFetcher::Delegate overrides: |
@@ -33,11 +41,7 @@ class InlineLoginHandlerChromeOS::InlineLoginUIOAuth2Delegate |
Profile* profile = Profile::FromWebUI(web_ui_); |
ProfileOAuth2TokenService* token_service = |
ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
- SigninManagerBase* signin_manager = |
- SigninManagerFactory::GetForProfile(profile); |
- token_service->UpdateCredentials( |
- signin_manager->GetAuthenticatedAccountId(), |
- oauth2_tokens.refresh_token); |
+ token_service->UpdateCredentials(account_id_, oauth2_tokens.refresh_token); |
} |
virtual void OnOAuth2TokensFetchFailed() OVERRIDE { |
@@ -47,19 +51,58 @@ class InlineLoginHandlerChromeOS::InlineLoginUIOAuth2Delegate |
private: |
content::WebUI* web_ui_; |
+ std::string account_id_; |
}; |
xiyuan
2014/04/24 21:22:10
nit: DISALLOW_COPY_AND_ASSIGN since you are here.
dzhioev (left Google)
2014/04/24 22:06:20
Done.
|
InlineLoginHandlerChromeOS::InlineLoginHandlerChromeOS() {} |
InlineLoginHandlerChromeOS::~InlineLoginHandlerChromeOS() {} |
+void InlineLoginHandlerChromeOS::SetExtraInitParams( |
+ base::DictionaryValue& params) { |
+ const GURL& current_url = web_ui()->GetWebContents()->GetURL(); |
+ params.SetInteger("authMode", InlineLoginHandler::kDesktopAuthMode); |
+ |
+ std::string frame_url; |
+ net::GetValueForKeyInQuery(current_url, "frameUrl", &frame_url); |
+ if (!frame_url.empty()) |
+ params.SetString("frameUrl", frame_url); |
+ |
+ std::string is_constrained; |
+ net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained); |
+ if (!is_constrained.empty()) |
+ params.SetString("constrained", is_constrained); |
+ |
+ params.SetString( |
+ "gaiaPath", |
+ GaiaUrls::GetInstance()->embedded_signin_url().path().substr(1)); |
+ params.SetString( |
+ "continueUrl", |
+ "https://www.google.com/intl/en-US/chrome/blank.html?source=10"); |
xiyuan
2014/04/24 21:22:10
Should we get the url from GetLandingURL() in sign
dzhioev (left Google)
2014/04/24 22:06:20
Yes, sorry I forgot about it. Could you please exp
xiyuan
2014/04/24 22:31:51
It's the enum here:
https://code.google.com/p/chro
dzhioev (left Google)
2014/04/24 23:05:47
Roger, should I add the new field?
dzhioev (left Google)
2014/04/29 12:23:58
Replaced with GetLandingURL. Roger said that it is
|
+} |
+ |
void InlineLoginHandlerChromeOS::CompleteLogin(const base::ListValue* args) { |
Profile* profile = Profile::FromWebUI(web_ui()); |
- oauth2_delegate_.reset(new InlineLoginUIOAuth2Delegate(web_ui())); |
- oauth2_token_fetcher_.reset(new OAuth2TokenFetcher( |
- oauth2_delegate_.get(), profile->GetRequestContext())); |
- oauth2_token_fetcher_->StartExchangeFromCookies(); |
+ const base::DictionaryValue* dict = NULL; |
+ args->GetDictionary(0, &dict); |
+ |
+ std::string session_index; |
+ dict->GetString("sessionIndex", &session_index); |
+ CHECK(!session_index.empty()) << "Session index is empty."; |
+ |
+ std::string account_id; |
+ dict->GetString("email", &account_id); |
+ CHECK(!account_id.empty()) << "Account ID is empty."; |
+ |
+ oauth2_delegate_.reset(new InlineLoginUIOAuth2Delegate(web_ui(), account_id)); |
+ net::URLRequestContextGetter* request_context = |
+ content::BrowserContext::GetStoragePartitionForSite( |
+ profile, GURL(chrome::kChromeUIChromeSigninURL)) |
+ ->GetURLRequestContext(); |
+ oauth2_token_fetcher_.reset( |
+ new OAuth2TokenFetcher(oauth2_delegate_.get(), request_context)); |
+ oauth2_token_fetcher_->StartExchangeFromCookies(session_index); |
} |
} // namespace chromeos |