OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_POLICY_OAUTH_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_POLICY_OAUTH_FETCHER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_POLICY_OAUTH_FETCHER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_POLICY_OAUTH_FETCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" | 12 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" |
13 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" | 13 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" |
14 | 14 |
15 class Profile; | 15 namespace net { |
| 16 class URLRequestContextGetter; |
| 17 } |
16 | 18 |
17 namespace chromeos { | 19 namespace chromeos { |
18 | 20 |
19 // Fetches the oauth token for the device management service. Since Profile | 21 // Fetches the oauth token for the device management service. Since Profile |
20 // creation might be blocking on a user policy fetch, this fetcher must always | 22 // creation might be blocking on a user policy fetch, this fetcher must always |
21 // send a (possibly empty) token to the BrowserPolicyConnector, which will then | 23 // send a (possibly empty) token to the BrowserPolicyConnector, which will then |
22 // let the policy subsystem proceed and resume Profile creation. | 24 // let the policy subsystem proceed and resume Profile creation. |
23 // Sending the token even when no Profile is pending is also OK. | 25 // Sending the token even when no Profile is pending is also OK. |
24 class PolicyOAuthFetcher : public GaiaOAuthConsumer { | 26 class PolicyOAuthFetcher : public GaiaOAuthConsumer { |
25 public: | 27 public: |
26 // Fetches the device management service's oauth token using |oauth1_token| | 28 // Fetches the device management service's oauth token using |oauth1_token| |
27 // and |oauth1_secret| as access tokens. | 29 // and |oauth1_secret| as access tokens. |
28 PolicyOAuthFetcher(Profile* profile, | 30 PolicyOAuthFetcher(net::URLRequestContextGetter* context_getter, |
29 const std::string& oauth1_token, | 31 const std::string& oauth1_token, |
30 const std::string& oauth1_secret); | 32 const std::string& oauth1_secret); |
31 // Fetches the device management service's oauth token, after also retrieving | 33 // Fetches the device management service's oauth token, after also retrieving |
32 // the access tokens. | 34 // the access tokens. |
33 explicit PolicyOAuthFetcher(Profile* profile); | 35 explicit PolicyOAuthFetcher(net::URLRequestContextGetter* context_getter); |
34 virtual ~PolicyOAuthFetcher(); | 36 virtual ~PolicyOAuthFetcher(); |
35 | 37 |
36 void Start(); | 38 void Start(); |
37 | 39 |
38 const std::string& oauth1_token() const { return oauth1_token_; } | 40 const std::string& oauth1_token() const { return oauth1_token_; } |
39 const std::string& oauth1_secret() const { return oauth1_secret_; } | 41 const std::string& oauth1_secret() const { return oauth1_secret_; } |
40 bool failed() const { | 42 bool failed() const { |
41 return !oauth_fetcher_.HasPendingFetch() && policy_token_.empty(); | 43 return !oauth_fetcher_.HasPendingFetch() && policy_token_.empty(); |
42 } | 44 } |
43 | 45 |
(...skipping 21 matching lines...) Expand all Loading... |
65 std::string oauth1_token_; | 67 std::string oauth1_token_; |
66 std::string oauth1_secret_; | 68 std::string oauth1_secret_; |
67 std::string policy_token_; | 69 std::string policy_token_; |
68 | 70 |
69 DISALLOW_COPY_AND_ASSIGN(PolicyOAuthFetcher); | 71 DISALLOW_COPY_AND_ASSIGN(PolicyOAuthFetcher); |
70 }; | 72 }; |
71 | 73 |
72 } // namespace chromeos | 74 } // namespace chromeos |
73 | 75 |
74 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_POLICY_OAUTH_FETCHER_H_ | 76 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_POLICY_OAUTH_FETCHER_H_ |
OLD | NEW |