| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/policy/cloud_policy_identity_strategy.h" | 5 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" |
| 6 #include "chrome/common/guid.h" |
| 6 | 7 |
| 7 namespace policy { | 8 namespace policy { |
| 8 | 9 |
| 9 CloudPolicyIdentityStrategy::CloudPolicyIdentityStrategy() {} | 10 CloudPolicyIdentityStrategy::CloudPolicyIdentityStrategy(CloudPolicyData* data) |
| 10 | 11 : data_(data) { |
| 11 CloudPolicyIdentityStrategy::~CloudPolicyIdentityStrategy() {} | 12 data->AddObserver(this); |
| 12 | |
| 13 void CloudPolicyIdentityStrategy::AddObserver(Observer* obs) { | |
| 14 observer_list_.AddObserver(obs); | |
| 15 } | 13 } |
| 16 | 14 |
| 17 void CloudPolicyIdentityStrategy::RemoveObserver(Observer* obs) { | 15 CloudPolicyIdentityStrategy::~CloudPolicyIdentityStrategy() { |
| 18 observer_list_.RemoveObserver(obs); | 16 data()->RemoveObserver(this); |
| 19 } | 17 } |
| 20 | 18 |
| 21 void CloudPolicyIdentityStrategy::NotifyDeviceTokenChanged() { | 19 CloudPolicyData* CloudPolicyIdentityStrategy::data() { |
| 22 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceTokenChanged()); | 20 return data_; |
| 23 } | 21 } |
| 24 | 22 |
| 25 void CloudPolicyIdentityStrategy::NotifyAuthChanged() { | 23 void CloudPolicyIdentityStrategy::OnDeviceTokenChanged() { |
| 26 FOR_EACH_OBSERVER(Observer, observer_list_, OnCredentialsChanged()); | 24 } |
| 25 |
| 26 void CloudPolicyIdentityStrategy::OnCredentialsChanged() { |
| 27 if (data()->token_cache_loaded() && |
| 28 !data()->user_name().empty() && |
| 29 !data()->gaia_token().empty() && |
| 30 data()->device_id().empty()) { |
| 31 data()->set_device_id(guid::GenerateGUID()); |
| 32 } |
| 27 } | 33 } |
| 28 | 34 |
| 29 } // namespace policy | 35 } // namespace policy |
| OLD | NEW |