| 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 11 #include "chrome/browser/chromeos/boot_times_loader.h" | 12 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 13 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 12 #include "chrome/browser/chromeos/version_loader.h" | 14 #include "chrome/browser/chromeos/version_loader.h" |
| 13 #include "chrome/browser/policy/cloud/cloud_policy_store.h" | 15 #include "chrome/browser/policy/cloud/cloud_policy_store.h" |
| 14 #include "content/public/browser/notification_observer.h" | |
| 15 | 16 |
| 16 namespace chromeos { | 17 namespace chromeos { |
| 17 | 18 |
| 18 class CrosSettings; | 19 class CrosSettings; |
| 19 | 20 |
| 20 // Fetches all info we want to show on OOBE/Login screens about system | 21 // Fetches all info we want to show on OOBE/Login screens about system |
| 21 // version, boot times and cloud policy. | 22 // version, boot times and cloud policy. |
| 22 class VersionInfoUpdater : public policy::CloudPolicyStore::Observer, | 23 class VersionInfoUpdater : public policy::CloudPolicyStore::Observer { |
| 23 public content::NotificationObserver { | |
| 24 public: | 24 public: |
| 25 class Delegate { | 25 class Delegate { |
| 26 public: | 26 public: |
| 27 virtual ~Delegate() {} | 27 virtual ~Delegate() {} |
| 28 | 28 |
| 29 // Called when OS version label should be updated. | 29 // Called when OS version label should be updated. |
| 30 virtual void OnOSVersionLabelTextUpdated( | 30 virtual void OnOSVersionLabelTextUpdated( |
| 31 const std::string& os_version_label_text) = 0; | 31 const std::string& os_version_label_text) = 0; |
| 32 | 32 |
| 33 // Called when the enterprise info notice should be updated. | 33 // Called when the enterprise info notice should be updated. |
| 34 virtual void OnEnterpriseInfoUpdated( | 34 virtual void OnEnterpriseInfoUpdated( |
| 35 const std::string& enterprise_info) = 0; | 35 const std::string& enterprise_info) = 0; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 explicit VersionInfoUpdater(Delegate* delegate); | 38 explicit VersionInfoUpdater(Delegate* delegate); |
| 39 virtual ~VersionInfoUpdater(); | 39 virtual ~VersionInfoUpdater(); |
| 40 | 40 |
| 41 // Sets delegate. | 41 // Sets delegate. |
| 42 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | 42 void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
| 43 | 43 |
| 44 // Starts fetching version info. The delegate will be notified when update | 44 // Starts fetching version info. The delegate will be notified when update |
| 45 // is received. | 45 // is received. |
| 46 void StartUpdate(bool is_official_build); | 46 void StartUpdate(bool is_official_build); |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 // policy::CloudPolicyStore::Observer interface: | 49 // policy::CloudPolicyStore::Observer interface: |
| 50 virtual void OnStoreLoaded(policy::CloudPolicyStore* store) OVERRIDE; | 50 virtual void OnStoreLoaded(policy::CloudPolicyStore* store) OVERRIDE; |
| 51 virtual void OnStoreError(policy::CloudPolicyStore* store) OVERRIDE; | 51 virtual void OnStoreError(policy::CloudPolicyStore* store) OVERRIDE; |
| 52 | 52 |
| 53 // content::NotificationObserver interface. | |
| 54 virtual void Observe( | |
| 55 int type, | |
| 56 const content::NotificationSource& source, | |
| 57 const content::NotificationDetails& details) OVERRIDE; | |
| 58 | |
| 59 // Update the version label. | 53 // Update the version label. |
| 60 void UpdateVersionLabel(); | 54 void UpdateVersionLabel(); |
| 61 | 55 |
| 62 // Check and update enterprise domain. | 56 // Check and update enterprise domain. |
| 63 void UpdateEnterpriseInfo(); | 57 void UpdateEnterpriseInfo(); |
| 64 | 58 |
| 65 // Set enterprise domain name. | 59 // Set enterprise domain name. |
| 66 void SetEnterpriseInfo(const std::string& domain_name); | 60 void SetEnterpriseInfo(const std::string& domain_name); |
| 67 | 61 |
| 68 // Callback from chromeos::VersionLoader giving the version. | 62 // Callback from chromeos::VersionLoader giving the version. |
| 69 void OnVersion(const std::string& version); | 63 void OnVersion(const std::string& version); |
| 70 | 64 |
| 71 // Handles asynchronously loading the version. | 65 // Handles asynchronously loading the version. |
| 72 VersionLoader version_loader_; | 66 VersionLoader version_loader_; |
| 73 // Handles asynchronously loading the boot times. | 67 // Handles asynchronously loading the boot times. |
| 74 BootTimesLoader boot_times_loader_; | 68 BootTimesLoader boot_times_loader_; |
| 75 // Used to request version and boot times. | 69 // Used to request version and boot times. |
| 76 CancelableTaskTracker tracker_; | 70 CancelableTaskTracker tracker_; |
| 77 | 71 |
| 78 // Information pieces for version label. | 72 // Information pieces for version label. |
| 79 std::string version_text_; | 73 std::string version_text_; |
| 80 | 74 |
| 81 // Full text for the OS version label. | 75 // Full text for the OS version label. |
| 82 std::string os_version_label_text_; | 76 std::string os_version_label_text_; |
| 83 | 77 |
| 78 scoped_ptr<CrosSettings::ObserverSubscription> version_info_subscription_; |
| 79 scoped_ptr<CrosSettings::ObserverSubscription> activity_times_subscription_; |
| 80 scoped_ptr<CrosSettings::ObserverSubscription> boot_mode_subscription_; |
| 81 scoped_ptr<CrosSettings::ObserverSubscription> location_subscription_; |
| 82 |
| 84 chromeos::CrosSettings* cros_settings_; | 83 chromeos::CrosSettings* cros_settings_; |
| 85 | 84 |
| 86 Delegate* delegate_; | 85 Delegate* delegate_; |
| 87 | 86 |
| 88 // Weak pointer factory so we can give our callbacks for invocation | 87 // Weak pointer factory so we can give our callbacks for invocation |
| 89 // at a later time without worrying that they will actually try to | 88 // at a later time without worrying that they will actually try to |
| 90 // happen after the lifetime of this object. | 89 // happen after the lifetime of this object. |
| 91 base::WeakPtrFactory<VersionInfoUpdater> weak_pointer_factory_; | 90 base::WeakPtrFactory<VersionInfoUpdater> weak_pointer_factory_; |
| 92 | 91 |
| 93 DISALLOW_COPY_AND_ASSIGN(VersionInfoUpdater); | 92 DISALLOW_COPY_AND_ASSIGN(VersionInfoUpdater); |
| 94 }; | 93 }; |
| 95 | 94 |
| 96 } // namespace chromeos | 95 } // namespace chromeos |
| 97 | 96 |
| 98 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_ | 97 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_ |
| OLD | NEW |