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

Side by Side Diff: chrome/browser/chromeos/login/version_info_updater.cc

Issue 11946017: Remove old cloud policy code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit tests. 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
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/version_info_updater.h" 5 #include "chrome/browser/chromeos/login/version_info_updater.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 &tracker_); 68 &tracker_);
69 boot_times_loader_.GetBootTimes( 69 boot_times_loader_.GetBootTimes(
70 base::Bind(is_official_build ? &VersionInfoUpdater::OnBootTimesNoop 70 base::Bind(is_official_build ? &VersionInfoUpdater::OnBootTimesNoop
71 : &VersionInfoUpdater::OnBootTimes, 71 : &VersionInfoUpdater::OnBootTimes,
72 weak_pointer_factory_.GetWeakPtr()), 72 weak_pointer_factory_.GetWeakPtr()),
73 &tracker_); 73 &tracker_);
74 } else { 74 } else {
75 UpdateVersionLabel(); 75 UpdateVersionLabel();
76 } 76 }
77 77
78 policy::CloudPolicySubsystem* cloud_policy =
79 g_browser_process->browser_policy_connector()->
80 device_cloud_policy_subsystem();
81 if (cloud_policy) {
82 // Two-step reset because we want to construct new ObserverRegistrar after
83 // destruction of old ObserverRegistrar to avoid DCHECK violation because
84 // of adding existing observer.
85 cloud_policy_registrar_.reset();
86 cloud_policy_registrar_.reset(
87 new policy::CloudPolicySubsystem::ObserverRegistrar(
88 cloud_policy, this));
89
90 // Ensure that we have up-to-date enterprise info in case enterprise policy
91 // is already fetched and has finished initialization.
92 UpdateEnterpriseInfo();
93 }
94
95 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 78 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
96 g_browser_process->browser_policy_connector()-> 79 g_browser_process->browser_policy_connector()->
97 GetDeviceCloudPolicyManager(); 80 GetDeviceCloudPolicyManager();
98 if (policy_manager) { 81 if (policy_manager) {
99 policy_manager->core()->store()->AddObserver(this); 82 policy_manager->core()->store()->AddObserver(this);
100 83
101 // Ensure that we have up-to-date enterprise info in case enterprise policy 84 // Ensure that we have up-to-date enterprise info in case enterprise policy
102 // is already fetched and has finished initialization. 85 // is already fetched and has finished initialization.
103 UpdateEnterpriseInfo(); 86 UpdateEnterpriseInfo();
104 } 87 }
(...skipping 21 matching lines...) Expand all
126 if (delegate_) 109 if (delegate_)
127 delegate_->OnOSVersionLabelTextUpdated(label_text); 110 delegate_->OnOSVersionLabelTextUpdated(label_text);
128 } 111 }
129 112
130 void VersionInfoUpdater::UpdateEnterpriseInfo() { 113 void VersionInfoUpdater::UpdateEnterpriseInfo() {
131 SetEnterpriseInfo( 114 SetEnterpriseInfo(
132 g_browser_process->browser_policy_connector()->GetEnterpriseDomain()); 115 g_browser_process->browser_policy_connector()->GetEnterpriseDomain());
133 } 116 }
134 117
135 void VersionInfoUpdater::SetEnterpriseInfo(const std::string& domain_name) { 118 void VersionInfoUpdater::SetEnterpriseInfo(const std::string& domain_name) {
136 if (domain_name != enterprise_domain_text_) { 119 // Update the notification about device status reporting.
137 enterprise_domain_text_ = domain_name; 120 if (delegate_) {
Joao da Silva 2013/01/22 12:39:03 if (delegate_ && !domain_name.empty()) { ... }
Mattias Nissler (ping if slow) 2013/01/22 14:14:52 Done.
138 UpdateVersionLabel(); 121 std::string enterprise_info;
139 122 if (!domain_name.empty()) {
140 // Update the notification about device status reporting. 123 enterprise_info = l10n_util::GetStringFUTF8(
141 if (delegate_) { 124 IDS_DEVICE_OWNED_BY_NOTICE,
142 std::string enterprise_info; 125 UTF8ToUTF16(domain_name));
143 if (!domain_name.empty()) { 126 delegate_->OnEnterpriseInfoUpdated(enterprise_info);
144 enterprise_info = l10n_util::GetStringFUTF8(
145 IDS_DEVICE_OWNED_BY_NOTICE,
146 UTF8ToUTF16(domain_name));
147 delegate_->OnEnterpriseInfoUpdated(enterprise_info);
148 }
149 } 127 }
150 } 128 }
151 } 129 }
152 130
153 void VersionInfoUpdater::OnVersion(const std::string& version) { 131 void VersionInfoUpdater::OnVersion(const std::string& version) {
154 version_text_ = version; 132 version_text_ = version;
155 UpdateVersionLabel(); 133 UpdateVersionLabel();
156 } 134 }
157 135
158 void VersionInfoUpdater::OnBootTimesNoop( 136 void VersionInfoUpdater::OnBootTimesNoop(
(...skipping 22 matching lines...) Expand all
181 kBootTimesNoChromeExec, 159 kBootTimesNoChromeExec,
182 boot_times.total, 160 boot_times.total,
183 boot_times.pre_startup, 161 boot_times.pre_startup,
184 boot_times.system); 162 boot_times.system);
185 } 163 }
186 // Use UTF8ToWide once this string is localized. 164 // Use UTF8ToWide once this string is localized.
187 if (delegate_) 165 if (delegate_)
188 delegate_->OnBootTimesLabelTextUpdated(boot_times_text); 166 delegate_->OnBootTimesLabelTextUpdated(boot_times_text);
189 } 167 }
190 168
191 void VersionInfoUpdater::OnPolicyStateChanged(
192 policy::CloudPolicySubsystem::PolicySubsystemState state,
193 policy::CloudPolicySubsystem::ErrorDetails error_details) {
194 UpdateEnterpriseInfo();
195 }
196
197 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) { 169 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) {
198 UpdateEnterpriseInfo(); 170 UpdateEnterpriseInfo();
199 } 171 }
200 172
201 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) { 173 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) {
202 UpdateEnterpriseInfo(); 174 UpdateEnterpriseInfo();
203 } 175 }
204 176
205 void VersionInfoUpdater::Observe( 177 void VersionInfoUpdater::Observe(
206 int type, 178 int type,
207 const content::NotificationSource& source, 179 const content::NotificationSource& source,
208 const content::NotificationDetails& details) { 180 const content::NotificationDetails& details) {
209 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) 181 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED)
210 UpdateEnterpriseInfo(); 182 UpdateEnterpriseInfo();
211 else 183 else
212 NOTREACHED(); 184 NOTREACHED();
213 } 185 }
214 186
215 } // namespace chromeos 187 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698