forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
google_account_access_token_fetch_delegate.h
50 lines (40 loc) · 2.01 KB
/
google_account_access_token_fetch_delegate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBLAYER_PUBLIC_GOOGLE_ACCOUNT_ACCESS_TOKEN_FETCH_DELEGATE_H_
#define WEBLAYER_PUBLIC_GOOGLE_ACCOUNT_ACCESS_TOKEN_FETCH_DELEGATE_H_
#include <set>
#include <string>
#include "base/callback_forward.h"
namespace weblayer {
using OnTokenFetchedCallback =
base::OnceCallback<void(const std::string& token)>;
// An interface that allows clients to handle access token requests for Google
// accounts originating in the browser.
class GoogleAccountAccessTokenFetchDelegate {
public:
// Called when the WebLayer implementation wants to fetch an access token for
// the embedder's current GAIA account (if any) and the given scopes. The
// client should invoke |onTokenFetchedCallback| when its internal token fetch
// is complete, passing either the fetched access token or the empty string in
// the case of failure (e.g., if there is no current GAIA account or there was
// an error in the token fetch).
//
// NOTE: WebLayer will not perform any caching of the returned token but will
// instead make a new request each time that it needs to use an access token.
// The expectation is that the client will use caching internally to minimize
// latency of these requests.
virtual void FetchAccessToken(const std::set<std::string>& scopes,
OnTokenFetchedCallback callback) = 0;
// Called when a token previously obtained via a call to
// FetchAccessToken(|scopes|) is identified as invalid, so the embedder can
// take appropriate action (e.g., dropping the token from its cache and/or
// force-fetching a new token).
virtual void OnAccessTokenIdentifiedAsInvalid(
const std::set<std::string>& scopes,
const std::string& token) = 0;
protected:
virtual ~GoogleAccountAccessTokenFetchDelegate() {}
};
} // namespace weblayer
#endif // WEBLAYER_PUBLIC_GOOGLE_ACCOUNT_ACCESS_TOKEN_FETCH_DELEGATE_H_