Chromium Code Reviews| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 &tracker_); | 66 &tracker_); |
| 67 boot_times_loader_.GetBootTimes( | 67 boot_times_loader_.GetBootTimes( |
| 68 base::Bind(is_official_build ? &VersionInfoUpdater::OnBootTimesNoop | 68 base::Bind(is_official_build ? &VersionInfoUpdater::OnBootTimesNoop |
| 69 : &VersionInfoUpdater::OnBootTimes, | 69 : &VersionInfoUpdater::OnBootTimes, |
| 70 base::Unretained(this)), | 70 base::Unretained(this)), |
| 71 &tracker_); | 71 &tracker_); |
| 72 } else { | 72 } else { |
| 73 UpdateVersionLabel(); | 73 UpdateVersionLabel(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 policy::CloudPolicySubsystem* cloud_policy = | |
| 77 g_browser_process->browser_policy_connector()-> | |
| 78 device_cloud_policy_subsystem(); | |
| 79 if (cloud_policy) { | |
| 80 // Two-step reset because we want to construct new ObserverRegistrar after | |
| 81 // destruction of old ObserverRegistrar to avoid DCHECK violation because | |
| 82 // of adding existing observer. | |
| 83 cloud_policy_registrar_.reset(); | |
| 84 cloud_policy_registrar_.reset( | |
| 85 new policy::CloudPolicySubsystem::ObserverRegistrar( | |
| 86 cloud_policy, this)); | |
| 87 | |
| 88 // Ensure that we have up-to-date enterprise info in case enterprise policy | |
| 89 // is already fetched and has finished initialization. | |
| 90 UpdateEnterpriseInfo(); | |
| 91 } | |
| 92 | |
| 93 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 76 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
| 94 g_browser_process->browser_policy_connector()-> | 77 g_browser_process->browser_policy_connector()-> |
| 95 GetDeviceCloudPolicyManager(); | 78 GetDeviceCloudPolicyManager(); |
| 96 if (policy_manager) { | 79 if (policy_manager) { |
| 97 policy_manager->core()->store()->AddObserver(this); | 80 policy_manager->core()->store()->AddObserver(this); |
| 98 | 81 |
| 99 // Ensure that we have up-to-date enterprise info in case enterprise policy | 82 // Ensure that we have up-to-date enterprise info in case enterprise policy |
| 100 // is already fetched and has finished initialization. | 83 // is already fetched and has finished initialization. |
| 101 UpdateEnterpriseInfo(); | 84 UpdateEnterpriseInfo(); |
| 102 } | 85 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 126 } | 109 } |
| 127 | 110 |
| 128 void VersionInfoUpdater::UpdateEnterpriseInfo() { | 111 void VersionInfoUpdater::UpdateEnterpriseInfo() { |
| 129 SetEnterpriseInfo( | 112 SetEnterpriseInfo( |
| 130 g_browser_process->browser_policy_connector()->GetEnterpriseDomain()); | 113 g_browser_process->browser_policy_connector()->GetEnterpriseDomain()); |
| 131 } | 114 } |
| 132 | 115 |
| 133 void VersionInfoUpdater::SetEnterpriseInfo(const std::string& domain_name) { | 116 void VersionInfoUpdater::SetEnterpriseInfo(const std::string& domain_name) { |
| 134 if (domain_name != enterprise_domain_text_) { | 117 if (domain_name != enterprise_domain_text_) { |
| 135 enterprise_domain_text_ = domain_name; | 118 enterprise_domain_text_ = domain_name; |
| 136 UpdateVersionLabel(); | 119 UpdateVersionLabel(); |
|
Joao da Silva
2013/01/17 09:38:05
FWIW, UpdateVersionLabel() doesn't use enterprise_
Mattias Nissler (ping if slow)
2013/01/22 10:31:39
Done.
| |
| 137 | 120 |
| 138 // Update the notification about device status reporting. | 121 // Update the notification about device status reporting. |
| 139 if (delegate_) { | 122 if (delegate_) { |
| 140 std::string enterprise_info; | 123 std::string enterprise_info; |
| 141 if (!domain_name.empty()) { | 124 if (!domain_name.empty()) { |
| 142 enterprise_info = l10n_util::GetStringFUTF8( | 125 enterprise_info = l10n_util::GetStringFUTF8( |
| 143 IDS_DEVICE_OWNED_BY_NOTICE, | 126 IDS_DEVICE_OWNED_BY_NOTICE, |
| 144 UTF8ToUTF16(domain_name)); | 127 UTF8ToUTF16(domain_name)); |
| 145 delegate_->OnEnterpriseInfoUpdated(enterprise_info); | 128 delegate_->OnEnterpriseInfoUpdated(enterprise_info); |
| 146 } | 129 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 kBootTimesNoChromeExec, | 162 kBootTimesNoChromeExec, |
| 180 boot_times.total, | 163 boot_times.total, |
| 181 boot_times.pre_startup, | 164 boot_times.pre_startup, |
| 182 boot_times.system); | 165 boot_times.system); |
| 183 } | 166 } |
| 184 // Use UTF8ToWide once this string is localized. | 167 // Use UTF8ToWide once this string is localized. |
| 185 if (delegate_) | 168 if (delegate_) |
| 186 delegate_->OnBootTimesLabelTextUpdated(boot_times_text); | 169 delegate_->OnBootTimesLabelTextUpdated(boot_times_text); |
| 187 } | 170 } |
| 188 | 171 |
| 189 void VersionInfoUpdater::OnPolicyStateChanged( | |
| 190 policy::CloudPolicySubsystem::PolicySubsystemState state, | |
| 191 policy::CloudPolicySubsystem::ErrorDetails error_details) { | |
| 192 UpdateEnterpriseInfo(); | |
| 193 } | |
| 194 | |
| 195 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) { | 172 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) { |
| 196 UpdateEnterpriseInfo(); | 173 UpdateEnterpriseInfo(); |
| 197 } | 174 } |
| 198 | 175 |
| 199 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) { | 176 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) { |
| 200 UpdateEnterpriseInfo(); | 177 UpdateEnterpriseInfo(); |
| 201 } | 178 } |
| 202 | 179 |
| 203 void VersionInfoUpdater::Observe( | 180 void VersionInfoUpdater::Observe( |
| 204 int type, | 181 int type, |
| 205 const content::NotificationSource& source, | 182 const content::NotificationSource& source, |
| 206 const content::NotificationDetails& details) { | 183 const content::NotificationDetails& details) { |
| 207 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) | 184 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) |
| 208 UpdateEnterpriseInfo(); | 185 UpdateEnterpriseInfo(); |
| 209 else | 186 else |
| 210 NOTREACHED(); | 187 NOTREACHED(); |
| 211 } | 188 } |
| 212 | 189 |
| 213 } // namespace chromeos | 190 } // namespace chromeos |
| OLD | NEW |