Chromium Code Reviews| Index: chrome/browser/chromeos/login/version_info_updater.cc |
| diff --git a/chrome/browser/chromeos/login/version_info_updater.cc b/chrome/browser/chromeos/login/version_info_updater.cc |
| index 72c068ba0bcfa19e51d0ad1a0f055ed525596bb1..bd0a25bbf6831e0d471d627fef473757a6cd7539 100644 |
| --- a/chrome/browser/chromeos/login/version_info_updater.cc |
| +++ b/chrome/browser/chromeos/login/version_info_updater.cc |
| @@ -16,8 +16,11 @@ |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/chromeos/cros/cros_library.h" |
| +#include "chrome/browser/chromeos/cros_settings.h" |
| +#include "chrome/browser/chromeos/cros_settings_names.h" |
| #include "chrome/browser/policy/browser_policy_connector.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| +#include "chrome/common/chrome_notification_types.h" |
| #include "chrome/common/chrome_version_info.h" |
| #include "googleurl/src/gurl.h" |
| #include "grit/chromium_strings.h" |
| @@ -29,11 +32,27 @@ |
| namespace chromeos { |
| +namespace { |
| + |
| +const char* kReportingFlags[] = { |
| + chromeos::kReportDeviceVersionInfo, |
| + chromeos::kReportDeviceActivityTimes, |
| + chromeos::kReportDeviceBootMode, |
| +}; |
| + |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////// |
| // VersionInfoUpdater public: |
| VersionInfoUpdater::VersionInfoUpdater(Delegate* delegate) |
| - : delegate_(delegate) { |
| + : enterprise_reporting_hint_(false), |
| + delegate_(delegate) { |
| + cros_settings_ = chromeos::CrosSettings::Get(); |
| + |
| + // Watch for changes to the reporting flags. |
| + for (unsigned int i = 0; i < arraysize(kReportingFlags); ++i) |
| + cros_settings_->AddSettingsObserver(kReportingFlags[i], this); |
| } |
| VersionInfoUpdater::~VersionInfoUpdater() { |
| @@ -144,15 +163,27 @@ void VersionInfoUpdater::UpdateEnterpriseInfo() { |
| } |
| } |
| - SetEnterpriseInfo(policy_connector->GetEnterpriseDomain(), status_text); |
| + bool reporting_hint = false; |
| + for (unsigned int i = 0; i < arraysize(kReportingFlags); ++i) { |
| + bool enabled = false; |
| + if (cros_settings_->GetBoolean(kReportingFlags[i], &enabled)) |
|
Patrick Dubroy
2012/03/26 08:28:20
Why not just "="? Using bitwise OR on a boolean se
Mattias Nissler (ping if slow)
2012/03/26 13:08:26
Done.
|
| + reporting_hint |= enabled; |
| + } |
| + |
| + SetEnterpriseInfo(policy_connector->GetEnterpriseDomain(), |
| + status_text, |
| + reporting_hint); |
| } |
| void VersionInfoUpdater::SetEnterpriseInfo(const std::string& domain_name, |
| - const std::string& status_text) { |
| + const std::string& status_text, |
| + bool reporting_hint) { |
| if (domain_name != enterprise_domain_text_ || |
| - status_text != enterprise_status_text_) { |
| + status_text != enterprise_status_text_ || |
| + reporting_hint != enterprise_reporting_hint_) { |
| enterprise_domain_text_ = domain_name; |
| enterprise_status_text_ = status_text; |
| + enterprise_reporting_hint_ = enterprise_reporting_hint_; |
| UpdateVersionLabel(); |
| // Update the notification about device status reporting. |
| @@ -162,7 +193,7 @@ void VersionInfoUpdater::SetEnterpriseInfo(const std::string& domain_name, |
| enterprise_info = l10n_util::GetStringFUTF8( |
| IDS_LOGIN_MANAGED_BY_NOTICE, |
| UTF8ToUTF16(enterprise_domain_text_)); |
| - delegate_->OnEnterpriseInfoUpdated(enterprise_info); |
| + delegate_->OnEnterpriseInfoUpdated(enterprise_info, reporting_hint); |
| } |
| } |
| } |
| @@ -214,4 +245,14 @@ void VersionInfoUpdater::OnPolicyStateChanged( |
| UpdateEnterpriseInfo(); |
| } |
| +void VersionInfoUpdater::Observe( |
| + int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) { |
| + if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) |
| + UpdateEnterpriseInfo(); |
| + else |
| + NOTREACHED(); |
| +} |
| + |
| } // namespace chromeos |