• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 REMOTING_CLIENT_TOKEN_FETCHER_PROXY_H_
6 #define REMOTING_CLIENT_TOKEN_FETCHER_PROXY_H_
7 
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "remoting/protocol/third_party_client_authenticator.h"
11 
12 namespace remoting {
13 
14 class TokenFetcherProxy
15     : public protocol::ThirdPartyClientAuthenticator::TokenFetcher {
16  public:
17   typedef base::Callback<void(
18       const GURL& token_url,
19       const std::string& host_public_key,
20       const std::string& scope,
21       base::WeakPtr<TokenFetcherProxy>)> TokenFetcherCallback;
22 
23   TokenFetcherProxy(const TokenFetcherCallback& token_fetcher_impl,
24                     const std::string& host_public_key);
25   virtual ~TokenFetcherProxy();
26 
27   // protocol::TokenClientAuthenticator::TokenFetcher interface.
28   virtual void FetchThirdPartyToken(
29       const GURL& token_url,
30       const std::string& scope,
31       const TokenFetchedCallback& token_fetched_callback) OVERRIDE;
32 
33   // Called by the token fetching implementation when the token is fetched.
34   void OnTokenFetched(const std::string& token,
35                       const std::string& shared_secret);
36 
37  private:
38   std::string host_public_key_;
39   TokenFetcherCallback token_fetcher_impl_;
40   TokenFetchedCallback token_fetched_callback_;
41   base::WeakPtrFactory<TokenFetcherProxy> weak_factory_;
42 
43   DISALLOW_COPY_AND_ASSIGN(TokenFetcherProxy);
44 };
45 
46 }  // namespace remoting
47 
48 #endif  // REMOTING_CLIENT_TOKEN_FETCHER_PROXY_H_
49