Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Side by Side Diff: chrome/browser/policy/policy_notifier.cc

Issue 11946017: Remove old cloud policy code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/policy/policy_notifier.h"
6
7 namespace policy {
8
9 void PolicyNotifier::AddObserver(CloudPolicySubsystem::Observer* observer) {
10 observer_list_.AddObserver(observer);
11 }
12
13 void PolicyNotifier::RemoveObserver(CloudPolicySubsystem::Observer* observer) {
14 observer_list_.RemoveObserver(observer);
15 }
16
17 PolicyNotifier::PolicyNotifier()
18 : state_(CloudPolicySubsystem::UNENROLLED),
19 error_details_(CloudPolicySubsystem::NO_DETAILS) {
20 for (int i = 0; i < NUM_SOURCES; ++i) {
21 component_states_[i] = CloudPolicySubsystem::UNENROLLED;
22 component_error_details_[i] = CloudPolicySubsystem::NO_DETAILS;
23 }
24 }
25
26 PolicyNotifier::~PolicyNotifier() {
27 }
28
29 void PolicyNotifier::Inform(PolicySubsystemState state,
30 ErrorDetails error_details,
31 StatusSource source) {
32 component_states_[source] = state;
33 component_error_details_[source] = error_details;
34 RecomputeState();
35 }
36
37 void PolicyNotifier::RecomputeState() {
38 // Define shortcuts.
39 PolicySubsystemState* s = component_states_;
40 ErrorDetails* e = component_error_details_;
41
42 // Compute overall state. General idea: If any component knows we're
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'
45 // (which can also be read as 'undefined/unknown', ask the next component.
46 if (s[TOKEN_FETCHER] == CloudPolicySubsystem::UNMANAGED ||
47 s[POLICY_CONTROLLER] == CloudPolicySubsystem::UNMANAGED ||
48 s[POLICY_CACHE] == CloudPolicySubsystem::UNMANAGED) {
49 state_ = CloudPolicySubsystem::UNMANAGED;
50 error_details_ = CloudPolicySubsystem::NO_DETAILS;
51 } else if (s[TOKEN_FETCHER] == CloudPolicySubsystem::UNENROLLED &&
52 (e[TOKEN_FETCHER] == CloudPolicySubsystem::BAD_SERIAL_NUMBER ||
53 e[TOKEN_FETCHER] == CloudPolicySubsystem::BAD_ENROLLMENT_MODE ||
54 e[TOKEN_FETCHER] == CloudPolicySubsystem::MISSING_LICENSES)) {
55 state_ = s[TOKEN_FETCHER];
56 error_details_ = e[TOKEN_FETCHER];
57 } else if (s[TOKEN_FETCHER] == CloudPolicySubsystem::NETWORK_ERROR) {
58 state_ = s[TOKEN_FETCHER];
59 error_details_ = e[TOKEN_FETCHER];
60 } else if (s[TOKEN_FETCHER] == CloudPolicySubsystem::BAD_GAIA_TOKEN) {
61 state_ = s[TOKEN_FETCHER];
62 error_details_ = e[TOKEN_FETCHER];
63 } else if (s[POLICY_CONTROLLER] == CloudPolicySubsystem::NETWORK_ERROR) {
64 state_ = s[POLICY_CONTROLLER];
65 error_details_ = e[POLICY_CONTROLLER];
66 } else if (s[TOKEN_FETCHER] == CloudPolicySubsystem::SUCCESS &&
67 s[POLICY_CONTROLLER] != CloudPolicySubsystem::SUCCESS) {
68 // We need to be able to differentiate between token fetch success or
69 // policy fetch success.
70 state_ = CloudPolicySubsystem::TOKEN_FETCHED;
71 error_details_ = CloudPolicySubsystem::NO_DETAILS;
72 } else {
73 state_ = s[POLICY_CACHE];
74 error_details_ = e[POLICY_CACHE];
75 }
76
77 FOR_EACH_OBSERVER(CloudPolicySubsystem::Observer, observer_list_,
78 OnPolicyStateChanged(state_, error_details_));
79 }
80
81 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_notifier.h ('k') | chrome/browser/policy/proto/old_generic_format.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698