| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/app_list/speech_auth_helper.h" | 5 #include "chrome/browser/ui/app_list/speech_auth_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/time/clock.h" | 10 #include "base/time/clock.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 76 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 77 auth_token_ = ""; | 77 auth_token_ = ""; |
| 78 auth_token_request_.reset(); | 78 auth_token_request_.reset(); |
| 79 | 79 |
| 80 // Try again later. | 80 // Try again later. |
| 81 // TODO(amistry): Implement backoff. | 81 // TODO(amistry): Implement backoff. |
| 82 ScheduleTokenFetch( | 82 ScheduleTokenFetch( |
| 83 base::TimeDelta::FromSeconds(kMinTokenRefreshDelaySeconds)); | 83 base::TimeDelta::FromSeconds(kMinTokenRefreshDelaySeconds)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void SpeechAuthHelper::OnRefreshTokenAvailable(const std::string& account_id) { | 86 void SpeechAuthHelper::OnRefreshTokenAvailable(const std::string& user_id) { |
| 87 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 87 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 88 if (authenticated_account_id_ == account_id) | 88 if (authenticated_account_id_ == user_id) |
| 89 FetchAuthToken(); | 89 FetchAuthToken(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void SpeechAuthHelper::ScheduleTokenFetch(const base::TimeDelta& fetch_delay) { | 92 void SpeechAuthHelper::ScheduleTokenFetch(const base::TimeDelta& fetch_delay) { |
| 93 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 93 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 94 content::BrowserThread::PostDelayedTask( | 94 content::BrowserThread::PostDelayedTask( |
| 95 content::BrowserThread::UI, | 95 content::BrowserThread::UI, |
| 96 FROM_HERE, | 96 FROM_HERE, |
| 97 base::Bind(&SpeechAuthHelper::FetchAuthToken, | 97 base::Bind(&SpeechAuthHelper::FetchAuthToken, |
| 98 weak_factory_.GetWeakPtr()), | 98 weak_factory_.GetWeakPtr()), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 116 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 116 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 117 return auth_token_; | 117 return auth_token_; |
| 118 } | 118 } |
| 119 | 119 |
| 120 std::string SpeechAuthHelper::GetScope() const { | 120 std::string SpeechAuthHelper::GetScope() const { |
| 121 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 121 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 122 return kAuthScope; | 122 return kAuthScope; |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace app_list | 125 } // namespace app_list |
| OLD | NEW |