OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/settings/device_oauth2_token_service.h" | 5 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 14 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
15 #include "chrome/browser/chromeos/settings/token_encryptor.h" | 15 #include "chrome/browser/chromeos/settings/token_encryptor.h" |
16 #include "chrome/browser/policy/browser_policy_connector.h" | 16 #include "chrome/browser/policy/browser_policy_connector.h" |
17 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" | |
18 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
20 #include "google_apis/gaia/gaia_urls.h" | 19 #include "google_apis/gaia/gaia_urls.h" |
21 #include "google_apis/gaia/google_service_auth_error.h" | 20 #include "google_apis/gaia/google_service_auth_error.h" |
| 21 #include "policy/proto/device_management_backend.pb.h" |
22 | 22 |
23 namespace { | 23 namespace { |
24 const char kServiceScopeGetUserInfo[] = | 24 const char kServiceScopeGetUserInfo[] = |
25 "https://www.googleapis.com/auth/userinfo.email"; | 25 "https://www.googleapis.com/auth/userinfo.email"; |
26 } | 26 } |
27 | 27 |
28 namespace chromeos { | 28 namespace chromeos { |
29 | 29 |
30 // A wrapper for the consumer passed to StartRequest, which doesn't call | 30 // A wrapper for the consumer passed to StartRequest, which doesn't call |
31 // through to the target Consumer unless the refresh token validation is | 31 // through to the target Consumer unless the refresh token validation is |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 token_info->GetString("email", &gaia_robot_id); | 132 token_info->GetString("email", &gaia_robot_id); |
133 | 133 |
134 std::string policy_robot_id = token_service_->GetRobotAccountId(); | 134 std::string policy_robot_id = token_service_->GetRobotAccountId(); |
135 | 135 |
136 if (policy_robot_id == gaia_robot_id) { | 136 if (policy_robot_id == gaia_robot_id) { |
137 RefreshTokenIsValid(true); | 137 RefreshTokenIsValid(true); |
138 } else { | 138 } else { |
139 if (gaia_robot_id.empty()) { | 139 if (gaia_robot_id.empty()) { |
140 LOG(WARNING) << "Device service account owner in policy is empty."; | 140 LOG(WARNING) << "Device service account owner in policy is empty."; |
141 } else { | 141 } else { |
142 LOG(INFO) << "Device service account owner in policy does not match " | 142 LOG(WARNING) << "Device service account owner in policy does not match " |
143 << "refresh token owner \"" << gaia_robot_id << "\"."; | 143 << "refresh token owner \"" << gaia_robot_id << "\"."; |
144 } | 144 } |
145 RefreshTokenIsValid(false); | 145 RefreshTokenIsValid(false); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 void DeviceOAuth2TokenService::ValidatingConsumer::OnOAuthError() { | 149 void DeviceOAuth2TokenService::ValidatingConsumer::OnOAuthError() { |
150 RefreshTokenIsValid(false); | 150 RefreshTokenIsValid(false); |
151 } | 151 } |
152 | 152 |
153 void DeviceOAuth2TokenService::ValidatingConsumer::OnNetworkError( | 153 void DeviceOAuth2TokenService::ValidatingConsumer::OnNetworkError( |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 return OAuth2TokenService::CreateRequest(account_id, consumer); | 284 return OAuth2TokenService::CreateRequest(account_id, consumer); |
285 | 285 |
286 // Substitute our own consumer to wait for refresh token validation. | 286 // Substitute our own consumer to wait for refresh token validation. |
287 scoped_ptr<ValidatingConsumer> validating_consumer( | 287 scoped_ptr<ValidatingConsumer> validating_consumer( |
288 new ValidatingConsumer(this, account_id, consumer)); | 288 new ValidatingConsumer(this, account_id, consumer)); |
289 validating_consumer->StartValidation(); | 289 validating_consumer->StartValidation(); |
290 return validating_consumer.PassAs<RequestImpl>(); | 290 return validating_consumer.PassAs<RequestImpl>(); |
291 } | 291 } |
292 | 292 |
293 } // namespace chromeos | 293 } // namespace chromeos |
OLD | NEW |