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

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

Issue 23494053: Remove NOTIFICATION_SYSTEM_SETTING_CHANGED, switch CrosSettings to base::CallbackRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: trailing space Created 7 years, 3 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"
11 #include "base/chromeos/chromeos_version.h" 11 #include "base/chromeos/chromeos_version.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 16 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
18 #include "chrome/browser/chromeos/settings/cros_settings.h" 17 #include "chrome/browser/chromeos/settings/cros_settings.h"
19 #include "chrome/browser/chromeos/settings/cros_settings_names.h" 18 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
20 #include "chrome/browser/policy/browser_policy_connector.h" 19 #include "chrome/browser/policy/browser_policy_connector.h"
21 #include "chrome/common/chrome_version_info.h" 20 #include "chrome/common/chrome_version_info.h"
22 #include "grit/chromium_strings.h" 21 #include "grit/chromium_strings.h"
23 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
24 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
25 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
(...skipping 19 matching lines...) Expand all
46 delegate_(delegate), 45 delegate_(delegate),
47 weak_pointer_factory_(this) { 46 weak_pointer_factory_(this) {
48 } 47 }
49 48
50 VersionInfoUpdater::~VersionInfoUpdater() { 49 VersionInfoUpdater::~VersionInfoUpdater() {
51 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 50 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
52 g_browser_process->browser_policy_connector()-> 51 g_browser_process->browser_policy_connector()->
53 GetDeviceCloudPolicyManager(); 52 GetDeviceCloudPolicyManager();
54 if (policy_manager) 53 if (policy_manager)
55 policy_manager->core()->store()->RemoveObserver(this); 54 policy_manager->core()->store()->RemoveObserver(this);
56
57 for (unsigned int i = 0; i < arraysize(kReportingFlags); ++i)
58 cros_settings_->RemoveSettingsObserver(kReportingFlags[i], this);
59 } 55 }
60 56
61 void VersionInfoUpdater::StartUpdate(bool is_official_build) { 57 void VersionInfoUpdater::StartUpdate(bool is_official_build) {
62 if (base::chromeos::IsRunningOnChromeOS()) { 58 if (base::chromeos::IsRunningOnChromeOS()) {
63 version_loader_.GetVersion( 59 version_loader_.GetVersion(
64 is_official_build ? VersionLoader::VERSION_SHORT_WITH_DATE 60 is_official_build ? VersionLoader::VERSION_SHORT_WITH_DATE
65 : VersionLoader::VERSION_FULL, 61 : VersionLoader::VERSION_FULL,
66 base::Bind(&VersionInfoUpdater::OnVersion, 62 base::Bind(&VersionInfoUpdater::OnVersion,
67 weak_pointer_factory_.GetWeakPtr()), 63 weak_pointer_factory_.GetWeakPtr()),
68 &tracker_); 64 &tracker_);
69 } else { 65 } else {
70 UpdateVersionLabel(); 66 UpdateVersionLabel();
71 } 67 }
72 68
73 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 69 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
74 g_browser_process->browser_policy_connector()-> 70 g_browser_process->browser_policy_connector()->
75 GetDeviceCloudPolicyManager(); 71 GetDeviceCloudPolicyManager();
76 if (policy_manager) { 72 if (policy_manager) {
77 policy_manager->core()->store()->AddObserver(this); 73 policy_manager->core()->store()->AddObserver(this);
78 74
79 // Ensure that we have up-to-date enterprise info in case enterprise policy 75 // Ensure that we have up-to-date enterprise info in case enterprise policy
80 // is already fetched and has finished initialization. 76 // is already fetched and has finished initialization.
81 UpdateEnterpriseInfo(); 77 UpdateEnterpriseInfo();
82 } 78 }
83 79
84 // Watch for changes to the reporting flags. 80 // Watch for changes to the reporting flags.
85 for (unsigned int i = 0; i < arraysize(kReportingFlags); ++i) 81 base::Closure callback =
86 cros_settings_->AddSettingsObserver(kReportingFlags[i], this); 82 base::Bind(&VersionInfoUpdater::UpdateEnterpriseInfo,
83 base::Unretained(this));
84 for (unsigned int i = 0; i < arraysize(kReportingFlags); ++i) {
85 subscriptions_.push_back(
86 cros_settings_->AddSettingsObserver(kReportingFlags[i],
87 callback).release());
88 }
87 } 89 }
88 90
89 void VersionInfoUpdater::UpdateVersionLabel() { 91 void VersionInfoUpdater::UpdateVersionLabel() {
90 if (version_text_.empty()) 92 if (version_text_.empty())
91 return; 93 return;
92 94
93 chrome::VersionInfo version_info; 95 chrome::VersionInfo version_info;
94 std::string label_text = l10n_util::GetStringFUTF8( 96 std::string label_text = l10n_util::GetStringFUTF8(
95 IDS_LOGIN_VERSION_LABEL_FORMAT, 97 IDS_LOGIN_VERSION_LABEL_FORMAT,
96 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), 98 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
(...skipping 30 matching lines...) Expand all
127 } 129 }
128 130
129 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) { 131 void VersionInfoUpdater::OnStoreLoaded(policy::CloudPolicyStore* store) {
130 UpdateEnterpriseInfo(); 132 UpdateEnterpriseInfo();
131 } 133 }
132 134
133 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) { 135 void VersionInfoUpdater::OnStoreError(policy::CloudPolicyStore* store) {
134 UpdateEnterpriseInfo(); 136 UpdateEnterpriseInfo();
135 } 137 }
136 138
137 void VersionInfoUpdater::Observe(
138 int type,
139 const content::NotificationSource& source,
140 const content::NotificationDetails& details) {
141 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED)
142 UpdateEnterpriseInfo();
143 else
144 NOTREACHED();
145 }
146
147 } // namespace chromeos 139 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/version_info_updater.h ('k') | chrome/browser/chromeos/login/wallpaper_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698