| 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 #include "chrome/browser/chromeos/login/policy_oauth_fetcher.h" | 5 #include "chrome/browser/chromeos/login/policy_oauth_fetcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/policy/browser_policy_connector.h" | 9 #include "chrome/browser/policy/browser_policy_connector.h" |
| 10 #include "chrome/browser/policy/user_cloud_policy_manager_chromeos.h" | 10 #include "chrome/browser/policy/user_cloud_policy_manager_chromeos.h" |
| 11 #include "chrome/browser/profiles/profile.h" | |
| 12 #include "chrome/browser/profiles/profile_manager.h" | |
| 13 #include "google_apis/gaia/gaia_constants.h" | 11 #include "google_apis/gaia/gaia_constants.h" |
| 14 #include "google_apis/gaia/google_service_auth_error.h" | 12 #include "google_apis/gaia/google_service_auth_error.h" |
| 15 | 13 |
| 16 namespace chromeos { | 14 namespace chromeos { |
| 17 | 15 |
| 18 namespace { | 16 namespace { |
| 19 const char kServiceScopeChromeOSDeviceManagement[] = | 17 const char kServiceScopeChromeOSDeviceManagement[] = |
| 20 "https://www.googleapis.com/auth/chromeosdevicemanagement"; | 18 "https://www.googleapis.com/auth/chromeosdevicemanagement"; |
| 21 } // namespace | 19 } // namespace |
| 22 | 20 |
| 23 PolicyOAuthFetcher::PolicyOAuthFetcher(Profile* profile, | 21 PolicyOAuthFetcher::PolicyOAuthFetcher( |
| 24 const std::string& oauth1_token, | 22 net::URLRequestContextGetter* context_getter, |
| 25 const std::string& oauth1_secret) | 23 const std::string& oauth1_token, |
| 24 const std::string& oauth1_secret) |
| 26 : oauth_fetcher_(this, | 25 : oauth_fetcher_(this, |
| 27 profile->GetRequestContext(), | 26 context_getter, |
| 28 kServiceScopeChromeOSDeviceManagement), | 27 kServiceScopeChromeOSDeviceManagement), |
| 29 oauth1_token_(oauth1_token), | 28 oauth1_token_(oauth1_token), |
| 30 oauth1_secret_(oauth1_secret) { | 29 oauth1_secret_(oauth1_secret) { |
| 31 } | 30 } |
| 32 | 31 |
| 33 PolicyOAuthFetcher::PolicyOAuthFetcher(Profile* profile) | 32 PolicyOAuthFetcher::PolicyOAuthFetcher( |
| 33 net::URLRequestContextGetter* context_getter) |
| 34 : oauth_fetcher_(this, | 34 : oauth_fetcher_(this, |
| 35 profile->GetRequestContext(), | 35 context_getter, |
| 36 kServiceScopeChromeOSDeviceManagement) { | 36 kServiceScopeChromeOSDeviceManagement) { |
| 37 } | 37 } |
| 38 | 38 |
| 39 PolicyOAuthFetcher::~PolicyOAuthFetcher() { | 39 PolicyOAuthFetcher::~PolicyOAuthFetcher() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 void PolicyOAuthFetcher::Start() { | 42 void PolicyOAuthFetcher::Start() { |
| 43 oauth_fetcher_.SetAutoFetchLimit( | 43 oauth_fetcher_.SetAutoFetchLimit( |
| 44 GaiaOAuthFetcher::OAUTH2_SERVICE_ACCESS_TOKEN); | 44 GaiaOAuthFetcher::OAUTH2_SERVICE_ACCESS_TOKEN); |
| 45 | 45 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 browser_policy_connector->GetUserCloudPolicyManager(); | 104 browser_policy_connector->GetUserCloudPolicyManager(); |
| 105 if (cloud_policy_manager) { | 105 if (cloud_policy_manager) { |
| 106 if (token.empty()) | 106 if (token.empty()) |
| 107 cloud_policy_manager->CancelWaitForPolicyFetch(); | 107 cloud_policy_manager->CancelWaitForPolicyFetch(); |
| 108 else | 108 else |
| 109 cloud_policy_manager->RegisterClient(token); | 109 cloud_policy_manager->RegisterClient(token); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace chromeos | 113 } // namespace chromeos |
| OLD | NEW |