Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: chrome/browser/ui/app_list/speech_auth_helper.h

Issue 778393002: Add OAuth2 authentication for some voice transcription requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit test on Chrome. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_APP_LIST_SPEECH_AUTH_HELPER_H_
6 #define CHROME_BROWSER_UI_APP_LIST_SPEECH_AUTH_HELPER_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "components/signin/core/browser/profile_oauth2_token_service.h"
13
14 class Profile;
15
16 namespace app_list {
17
18 // SpeechAuthHelper is a helper class to generate oauth tokens for audio
19 // history. This encalsulates generating and refreshing the auth token for a
20 // given profile. All functions should be called on the UI thread.
21 class SpeechAuthHelper : public OAuth2TokenService::Consumer,
22 public OAuth2TokenService::Observer {
23 public:
24 explicit SpeechAuthHelper(Profile* profile);
25 ~SpeechAuthHelper();
26
27 // Overridden from OAuth2TokenService::Consumer:
28 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
29 const std::string& access_token,
30 const base::Time& expiration_time) override;
31 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
32 const GoogleServiceAuthError& error) override;
33
34 // Overridden from OAuth2TokenService::Observer:
35 void OnRefreshTokenAvailable(const std::string& account_id) override;
36
37 // Returns the current auth token. If the auth service is not available, or
38 // there was a failure in obtaining a token, return the empty string.
39 std::string GetToken();
40
41 // Returns the OAuth scope associated with the auth token.
42 std::string GetScope();
43
44 private:
45 void ScheduleTokenFetch(const base::TimeDelta& fetch_delay);
46 void FetchAuthToken();
47
48 Profile* profile_;
49 std::string auth_token_;
50 scoped_ptr<OAuth2TokenService::Request> auth_token_request_;
51
52 base::WeakPtrFactory<SpeechAuthHelper> weak_factory_;
53
54 DISALLOW_COPY_AND_ASSIGN(SpeechAuthHelper);
55 };
56
57 } // namespace app_list
58
59 #endif // CHROME_BROWSER_UI_APP_LIST_SPEECH_AUTH_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/speech_auth_helper.cc » ('j') | chrome/browser/ui/app_list/speech_auth_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698