| 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/chrome_signin_client_factory.h" | 9 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 : public OAuth2TokenFetcher::Delegate { | 26 : public OAuth2TokenFetcher::Delegate { |
| 27 public: | 27 public: |
| 28 explicit InlineLoginUIOAuth2Delegate(content::WebUI* web_ui, | 28 explicit InlineLoginUIOAuth2Delegate(content::WebUI* web_ui, |
| 29 const std::string& account_id) | 29 const std::string& account_id) |
| 30 : web_ui_(web_ui), account_id_(account_id) {} | 30 : web_ui_(web_ui), account_id_(account_id) {} |
| 31 | 31 |
| 32 virtual ~InlineLoginUIOAuth2Delegate() {} | 32 virtual ~InlineLoginUIOAuth2Delegate() {} |
| 33 | 33 |
| 34 // OAuth2TokenFetcher::Delegate overrides: | 34 // OAuth2TokenFetcher::Delegate overrides: |
| 35 virtual void OnOAuth2TokensAvailable( | 35 virtual void OnOAuth2TokensAvailable( |
| 36 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) OVERRIDE { | 36 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) override { |
| 37 // Closes sign-in dialog before update token service. Token service update | 37 // Closes sign-in dialog before update token service. Token service update |
| 38 // might trigger a permission dialog and if this dialog does not close, | 38 // might trigger a permission dialog and if this dialog does not close, |
| 39 // a DCHECK would be triggered because attempting to activate a window | 39 // a DCHECK would be triggered because attempting to activate a window |
| 40 // while there is a modal dialog. | 40 // while there is a modal dialog. |
| 41 web_ui_->CallJavascriptFunction("inline.login.closeDialog"); | 41 web_ui_->CallJavascriptFunction("inline.login.closeDialog"); |
| 42 | 42 |
| 43 Profile* profile = Profile::FromWebUI(web_ui_); | 43 Profile* profile = Profile::FromWebUI(web_ui_); |
| 44 ProfileOAuth2TokenService* token_service = | 44 ProfileOAuth2TokenService* token_service = |
| 45 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 45 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 46 token_service->UpdateCredentials(account_id_, oauth2_tokens.refresh_token); | 46 token_service->UpdateCredentials(account_id_, oauth2_tokens.refresh_token); |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual void OnOAuth2TokensFetchFailed() OVERRIDE { | 49 virtual void OnOAuth2TokensFetchFailed() override { |
| 50 LOG(ERROR) << "Failed to fetch oauth2 token with inline login."; | 50 LOG(ERROR) << "Failed to fetch oauth2 token with inline login."; |
| 51 web_ui_->CallJavascriptFunction("inline.login.handleOAuth2TokenFailure"); | 51 web_ui_->CallJavascriptFunction("inline.login.handleOAuth2TokenFailure"); |
| 52 } | 52 } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 content::WebUI* web_ui_; | 55 content::WebUI* web_ui_; |
| 56 std::string account_id_; | 56 std::string account_id_; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(InlineLoginUIOAuth2Delegate); | 58 DISALLOW_COPY_AND_ASSIGN(InlineLoginUIOAuth2Delegate); |
| 59 }; | 59 }; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 85 new OAuth2TokenFetcher(oauth2_delegate_.get(), request_context)); | 85 new OAuth2TokenFetcher(oauth2_delegate_.get(), request_context)); |
| 86 SigninClient* signin_client = | 86 SigninClient* signin_client = |
| 87 ChromeSigninClientFactory::GetForProfile(profile); | 87 ChromeSigninClientFactory::GetForProfile(profile); |
| 88 std::string signin_scoped_device_id = | 88 std::string signin_scoped_device_id = |
| 89 signin_client->GetSigninScopedDeviceId(); | 89 signin_client->GetSigninScopedDeviceId(); |
| 90 oauth2_token_fetcher_->StartExchangeFromCookies(session_index, | 90 oauth2_token_fetcher_->StartExchangeFromCookies(session_index, |
| 91 signin_scoped_device_id); | 91 signin_scoped_device_id); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace chromeos | 94 } // namespace chromeos |
| OLD | NEW |