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> | 7 #include <string> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "chrome/browser/chromeos/login/signin/oauth2_token_fetcher.h" | 10 #include "chrome/browser/chromeos/login/signin/oauth2_token_fetcher.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 ~InlineLoginUIOAuth2Delegate() override {} | 37 ~InlineLoginUIOAuth2Delegate() override {} |
38 | 38 |
39 // OAuth2TokenFetcher::Delegate overrides: | 39 // OAuth2TokenFetcher::Delegate overrides: |
40 void OnOAuth2TokensAvailable( | 40 void OnOAuth2TokensAvailable( |
41 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) override { | 41 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) override { |
42 // Closes sign-in dialog before update token service. Token service update | 42 // Closes sign-in dialog before update token service. Token service update |
43 // might trigger a permission dialog and if this dialog does not close, | 43 // might trigger a permission dialog and if this dialog does not close, |
44 // a DCHECK would be triggered because attempting to activate a window | 44 // a DCHECK would be triggered because attempting to activate a window |
45 // while there is a modal dialog. | 45 // while there is a modal dialog. |
46 web_ui_->CallJavascriptFunction("inline.login.closeDialog"); | 46 web_ui_->CallJavascriptFunctionUnsafe("inline.login.closeDialog"); |
47 | 47 |
48 Profile* profile = Profile::FromWebUI(web_ui_); | 48 Profile* profile = Profile::FromWebUI(web_ui_); |
49 ProfileOAuth2TokenService* token_service = | 49 ProfileOAuth2TokenService* token_service = |
50 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 50 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
51 token_service->UpdateCredentials(account_id_, oauth2_tokens.refresh_token); | 51 token_service->UpdateCredentials(account_id_, oauth2_tokens.refresh_token); |
52 } | 52 } |
53 | 53 |
54 void OnOAuth2TokensFetchFailed() override { | 54 void OnOAuth2TokensFetchFailed() override { |
55 LOG(ERROR) << "Failed to fetch oauth2 token with inline login."; | 55 LOG(ERROR) << "Failed to fetch oauth2 token with inline login."; |
56 web_ui_->CallJavascriptFunction("inline.login.handleOAuth2TokenFailure"); | 56 web_ui_->CallJavascriptFunctionUnsafe( |
| 57 "inline.login.handleOAuth2TokenFailure"); |
57 } | 58 } |
58 | 59 |
59 private: | 60 private: |
60 content::WebUI* web_ui_; | 61 content::WebUI* web_ui_; |
61 std::string account_id_; | 62 std::string account_id_; |
62 | 63 |
63 DISALLOW_COPY_AND_ASSIGN(InlineLoginUIOAuth2Delegate); | 64 DISALLOW_COPY_AND_ASSIGN(InlineLoginUIOAuth2Delegate); |
64 }; | 65 }; |
65 | 66 |
66 InlineLoginHandlerChromeOS::InlineLoginHandlerChromeOS() {} | 67 InlineLoginHandlerChromeOS::InlineLoginHandlerChromeOS() {} |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 new OAuth2TokenFetcher(oauth2_delegate_.get(), request_context)); | 101 new OAuth2TokenFetcher(oauth2_delegate_.get(), request_context)); |
101 SigninClient* signin_client = | 102 SigninClient* signin_client = |
102 ChromeSigninClientFactory::GetForProfile(profile); | 103 ChromeSigninClientFactory::GetForProfile(profile); |
103 std::string signin_scoped_device_id = | 104 std::string signin_scoped_device_id = |
104 signin_client->GetSigninScopedDeviceId(); | 105 signin_client->GetSigninScopedDeviceId(); |
105 oauth2_token_fetcher_->StartExchangeFromCookies(session_index, | 106 oauth2_token_fetcher_->StartExchangeFromCookies(session_index, |
106 signin_scoped_device_id); | 107 signin_scoped_device_id); |
107 } | 108 } |
108 | 109 |
109 } // namespace chromeos | 110 } // namespace chromeos |
OLD | NEW |