OLD | NEW |
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 Loading... |
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 Loading... |
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_ && !domain_name.empty()) { |
138 UpdateVersionLabel(); | 121 std::string enterprise_info; |
139 | 122 enterprise_info = l10n_util::GetStringFUTF8( |
140 // Update the notification about device status reporting. | 123 IDS_DEVICE_OWNED_BY_NOTICE, |
141 if (delegate_) { | 124 UTF8ToUTF16(domain_name)); |
142 std::string enterprise_info; | 125 delegate_->OnEnterpriseInfoUpdated(enterprise_info); |
143 if (!domain_name.empty()) { | |
144 enterprise_info = l10n_util::GetStringFUTF8( | |
145 IDS_DEVICE_OWNED_BY_NOTICE, | |
146 UTF8ToUTF16(domain_name)); | |
147 delegate_->OnEnterpriseInfoUpdated(enterprise_info); | |
148 } | |
149 } | |
150 } | 126 } |
151 } | 127 } |
152 | 128 |
153 void VersionInfoUpdater::OnVersion(const std::string& version) { | 129 void VersionInfoUpdater::OnVersion(const std::string& version) { |
154 version_text_ = version; | 130 version_text_ = version; |
155 UpdateVersionLabel(); | 131 UpdateVersionLabel(); |
156 } | 132 } |
157 | 133 |
158 void VersionInfoUpdater::OnBootTimesNoop( | 134 void VersionInfoUpdater::OnBootTimesNoop( |
159 const BootTimesLoader::BootTimes& boot_times) {} | 135 const BootTimesLoader::BootTimes& boot_times) {} |
(...skipping 21 matching lines...) Expand all Loading... |
181 kBootTimesNoChromeExec, | 157 kBootTimesNoChromeExec, |
182 boot_times.total, | 158 boot_times.total, |
183 boot_times.pre_startup, | 159 boot_times.pre_startup, |
184 boot_times.system); | 160 boot_times.system); |
185 } | 161 } |
186 // Use UTF8ToWide once this string is localized. | 162 // Use UTF8ToWide once this string is localized. |
187 if (delegate_) | 163 if (delegate_) |
188 delegate_->OnBootTimesLabelTextUpdated(boot_times_text); | 164 delegate_->OnBootTimesLabelTextUpdated(boot_times_text); |
189 } | 165 } |
190 | 166 |
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) { | 167 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) { |
198 UpdateEnterpriseInfo(); | 168 UpdateEnterpriseInfo(); |
199 } | 169 } |
200 | 170 |
201 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) { | 171 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) { |
202 UpdateEnterpriseInfo(); | 172 UpdateEnterpriseInfo(); |
203 } | 173 } |
204 | 174 |
205 void VersionInfoUpdater::Observe( | 175 void VersionInfoUpdater::Observe( |
206 int type, | 176 int type, |
207 const content::NotificationSource& source, | 177 const content::NotificationSource& source, |
208 const content::NotificationDetails& details) { | 178 const content::NotificationDetails& details) { |
209 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) | 179 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) |
210 UpdateEnterpriseInfo(); | 180 UpdateEnterpriseInfo(); |
211 else | 181 else |
212 NOTREACHED(); | 182 NOTREACHED(); |
213 } | 183 } |
214 | 184 |
215 } // namespace chromeos | 185 } // namespace chromeos |
OLD | NEW |