| OLD | NEW |
| 1 // Copyright (c) 2011 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/policy/policy_notifier.h" | 5 #include "chrome/browser/policy/policy_notifier.h" |
| 6 | 6 |
| 7 namespace policy { | 7 namespace policy { |
| 8 | 8 |
| 9 void PolicyNotifier::AddObserver(CloudPolicySubsystem::Observer* observer) { | 9 void PolicyNotifier::AddObserver(CloudPolicySubsystem::Observer* observer) { |
| 10 observer_list_.AddObserver(observer); | 10 observer_list_.AddObserver(observer); |
| 11 } | 11 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 42 // Compute overall state. General idea: If any component knows we're | 42 // Compute overall state. General idea: If any component knows we're |
| 43 // unmanaged, set that as global state. Otherwise, ask components in the | 43 // unmanaged, set that as global state. Otherwise, ask components in the |
| 44 // order they normally do work in. If anyone reports 'SUCCESS' or 'UNENROLLED' | 44 // order they normally do work in. If anyone reports 'SUCCESS' or 'UNENROLLED' |
| 45 // (which can also be read as 'undefined/unknown', ask the next component. | 45 // (which can also be read as 'undefined/unknown', ask the next component. |
| 46 if (s[TOKEN_FETCHER] == CloudPolicySubsystem::UNMANAGED || | 46 if (s[TOKEN_FETCHER] == CloudPolicySubsystem::UNMANAGED || |
| 47 s[POLICY_CONTROLLER] == CloudPolicySubsystem::UNMANAGED || | 47 s[POLICY_CONTROLLER] == CloudPolicySubsystem::UNMANAGED || |
| 48 s[POLICY_CACHE] == CloudPolicySubsystem::UNMANAGED) { | 48 s[POLICY_CACHE] == CloudPolicySubsystem::UNMANAGED) { |
| 49 state_ = CloudPolicySubsystem::UNMANAGED; | 49 state_ = CloudPolicySubsystem::UNMANAGED; |
| 50 error_details_ = CloudPolicySubsystem::NO_DETAILS; | 50 error_details_ = CloudPolicySubsystem::NO_DETAILS; |
| 51 } else if (s[TOKEN_FETCHER] == CloudPolicySubsystem::UNENROLLED && | 51 } else if (s[TOKEN_FETCHER] == CloudPolicySubsystem::UNENROLLED && |
| 52 e[TOKEN_FETCHER] == CloudPolicySubsystem::BAD_SERIAL_NUMBER) { | 52 (e[TOKEN_FETCHER] == CloudPolicySubsystem::BAD_SERIAL_NUMBER || |
| 53 e[TOKEN_FETCHER] == CloudPolicySubsystem::BAD_ENROLLMENT_MODE)) { |
| 53 state_ = s[TOKEN_FETCHER]; | 54 state_ = s[TOKEN_FETCHER]; |
| 54 error_details_ = e[TOKEN_FETCHER]; | 55 error_details_ = e[TOKEN_FETCHER]; |
| 55 } else if (s[TOKEN_FETCHER] == CloudPolicySubsystem::NETWORK_ERROR) { | 56 } else if (s[TOKEN_FETCHER] == CloudPolicySubsystem::NETWORK_ERROR) { |
| 56 state_ = s[TOKEN_FETCHER]; | 57 state_ = s[TOKEN_FETCHER]; |
| 57 error_details_ = e[TOKEN_FETCHER]; | 58 error_details_ = e[TOKEN_FETCHER]; |
| 58 } else if (s[TOKEN_FETCHER] == CloudPolicySubsystem::BAD_GAIA_TOKEN) { | 59 } else if (s[TOKEN_FETCHER] == CloudPolicySubsystem::BAD_GAIA_TOKEN) { |
| 59 state_ = s[TOKEN_FETCHER]; | 60 state_ = s[TOKEN_FETCHER]; |
| 60 error_details_ = e[TOKEN_FETCHER]; | 61 error_details_ = e[TOKEN_FETCHER]; |
| 61 } else if (s[POLICY_CONTROLLER] == CloudPolicySubsystem::NETWORK_ERROR) { | 62 } else if (s[POLICY_CONTROLLER] == CloudPolicySubsystem::NETWORK_ERROR) { |
| 62 state_ = s[POLICY_CONTROLLER]; | 63 state_ = s[POLICY_CONTROLLER]; |
| 63 error_details_ = e[POLICY_CONTROLLER]; | 64 error_details_ = e[POLICY_CONTROLLER]; |
| 64 } else if (s[TOKEN_FETCHER] == CloudPolicySubsystem::SUCCESS && | 65 } else if (s[TOKEN_FETCHER] == CloudPolicySubsystem::SUCCESS && |
| 65 s[POLICY_CONTROLLER] != CloudPolicySubsystem::SUCCESS) { | 66 s[POLICY_CONTROLLER] != CloudPolicySubsystem::SUCCESS) { |
| 66 // We need to be able to differentiate between token fetch success or | 67 // We need to be able to differentiate between token fetch success or |
| 67 // policy fetch success. | 68 // policy fetch success. |
| 68 state_ = CloudPolicySubsystem::TOKEN_FETCHED; | 69 state_ = CloudPolicySubsystem::TOKEN_FETCHED; |
| 69 error_details_ = CloudPolicySubsystem::NO_DETAILS; | 70 error_details_ = CloudPolicySubsystem::NO_DETAILS; |
| 70 } else { | 71 } else { |
| 71 state_ = s[POLICY_CACHE]; | 72 state_ = s[POLICY_CACHE]; |
| 72 error_details_ = e[POLICY_CACHE]; | 73 error_details_ = e[POLICY_CACHE]; |
| 73 } | 74 } |
| 74 | 75 |
| 75 FOR_EACH_OBSERVER(CloudPolicySubsystem::Observer, observer_list_, | 76 FOR_EACH_OBSERVER(CloudPolicySubsystem::Observer, observer_list_, |
| 76 OnPolicyStateChanged(state_, error_details_)); | 77 OnPolicyStateChanged(state_, error_details_)); |
| 77 } | 78 } |
| 78 | 79 |
| 79 } // namespace policy | 80 } // namespace policy |
| OLD | NEW |