| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "chrome/browser/chromeos/boot_times_loader.h" | 11 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 12 #include "chrome/browser/chromeos/version_loader.h" | 12 #include "chrome/browser/chromeos/version_loader.h" |
| 13 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 13 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| 14 #include "content/public/browser/notification_observer.h" |
| 14 | 15 |
| 15 namespace chromeos { | 16 namespace chromeos { |
| 16 | 17 |
| 18 class CrosSettings; |
| 19 |
| 17 // Fetches all info we want to show on OOBE/Login screens about system | 20 // Fetches all info we want to show on OOBE/Login screens about system |
| 18 // version, boot times and cloud policy. | 21 // version, boot times and cloud policy. |
| 19 class VersionInfoUpdater : policy::CloudPolicySubsystem::Observer { | 22 class VersionInfoUpdater : public policy::CloudPolicySubsystem::Observer, |
| 23 public content::NotificationObserver { |
| 20 public: | 24 public: |
| 21 class Delegate { | 25 class Delegate { |
| 22 public: | 26 public: |
| 23 virtual ~Delegate() {} | 27 virtual ~Delegate() {} |
| 24 | 28 |
| 25 // Called when OS version label should be updated. | 29 // Called when OS version label should be updated. |
| 26 virtual void OnOSVersionLabelTextUpdated( | 30 virtual void OnOSVersionLabelTextUpdated( |
| 27 const std::string& os_version_label_text) = 0; | 31 const std::string& os_version_label_text) = 0; |
| 28 | 32 |
| 29 // Called when boot times label should be updated. | 33 // Called when boot times label should be updated. |
| 30 virtual void OnBootTimesLabelTextUpdated( | 34 virtual void OnBootTimesLabelTextUpdated( |
| 31 const std::string& boot_times_label_text) = 0; | 35 const std::string& boot_times_label_text) = 0; |
| 32 | 36 |
| 33 // Called when the enterprise info notice should be updated. | 37 // Called when the enterprise info notice should be updated. |
| 34 virtual void OnEnterpriseInfoUpdated( | 38 virtual void OnEnterpriseInfoUpdated( |
| 35 const std::string& enterprise_info) = 0; | 39 const std::string& enterprise_info, |
| 40 bool reporting_hint) = 0; |
| 36 }; | 41 }; |
| 37 | 42 |
| 38 explicit VersionInfoUpdater(Delegate* delegate); | 43 explicit VersionInfoUpdater(Delegate* delegate); |
| 39 virtual ~VersionInfoUpdater(); | 44 virtual ~VersionInfoUpdater(); |
| 40 | 45 |
| 41 // Sets delegate. | 46 // Sets delegate. |
| 42 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | 47 void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
| 43 | 48 |
| 44 // Starts fetching version info. The delegate will be notified when update | 49 // Starts fetching version info. The delegate will be notified when update |
| 45 // is received. | 50 // is received. |
| 46 void StartUpdate(bool is_official_build); | 51 void StartUpdate(bool is_official_build); |
| 47 | 52 |
| 48 private: | 53 private: |
| 49 // policy::CloudPolicySubsystem::Observer methods: | 54 // policy::CloudPolicySubsystem::Observer methods: |
| 50 virtual void OnPolicyStateChanged( | 55 virtual void OnPolicyStateChanged( |
| 51 policy::CloudPolicySubsystem::PolicySubsystemState state, | 56 policy::CloudPolicySubsystem::PolicySubsystemState state, |
| 52 policy::CloudPolicySubsystem::ErrorDetails error_details) OVERRIDE; | 57 policy::CloudPolicySubsystem::ErrorDetails error_details) OVERRIDE; |
| 53 | 58 |
| 59 // content::NotificationObserver interface. |
| 60 virtual void Observe( |
| 61 int type, |
| 62 const content::NotificationSource& source, |
| 63 const content::NotificationDetails& details) OVERRIDE; |
| 64 |
| 54 // Update the version label. | 65 // Update the version label. |
| 55 void UpdateVersionLabel(); | 66 void UpdateVersionLabel(); |
| 56 | 67 |
| 57 // Check and update enterprise domain. | 68 // Check and update enterprise domain. |
| 58 void UpdateEnterpriseInfo(); | 69 void UpdateEnterpriseInfo(); |
| 59 | 70 |
| 60 // Set enterprise domain name. | 71 // Set enterprise domain name. |
| 61 void SetEnterpriseInfo(const std::string& domain_name, | 72 void SetEnterpriseInfo(const std::string& domain_name, |
| 62 const std::string& status_text); | 73 const std::string& status_text, |
| 74 bool reporting_hint); |
| 63 | 75 |
| 64 // Callback from chromeos::VersionLoader giving the version. | 76 // Callback from chromeos::VersionLoader giving the version. |
| 65 void OnVersion(VersionLoader::Handle handle, std::string version); | 77 void OnVersion(VersionLoader::Handle handle, std::string version); |
| 66 // Callback from chromeos::InfoLoader giving the boot times. | 78 // Callback from chromeos::InfoLoader giving the boot times. |
| 67 void OnBootTimes( | 79 void OnBootTimes( |
| 68 BootTimesLoader::Handle handle, BootTimesLoader::BootTimes boot_times); | 80 BootTimesLoader::Handle handle, BootTimesLoader::BootTimes boot_times); |
| 69 // Null callback from chromeos::InfoLoader. | 81 // Null callback from chromeos::InfoLoader. |
| 70 void OnBootTimesNoop( | 82 void OnBootTimesNoop( |
| 71 BootTimesLoader::Handle handle, BootTimesLoader::BootTimes boot_times); | 83 BootTimesLoader::Handle handle, BootTimesLoader::BootTimes boot_times); |
| 72 | 84 |
| 73 // Handles asynchronously loading the version. | 85 // Handles asynchronously loading the version. |
| 74 VersionLoader version_loader_; | 86 VersionLoader version_loader_; |
| 75 // Used to request the version. | 87 // Used to request the version. |
| 76 CancelableRequestConsumer version_consumer_; | 88 CancelableRequestConsumer version_consumer_; |
| 77 | 89 |
| 78 // Handles asynchronously loading the boot times. | 90 // Handles asynchronously loading the boot times. |
| 79 BootTimesLoader boot_times_loader_; | 91 BootTimesLoader boot_times_loader_; |
| 80 // Used to request the boot times. | 92 // Used to request the boot times. |
| 81 CancelableRequestConsumer boot_times_consumer_; | 93 CancelableRequestConsumer boot_times_consumer_; |
| 82 | 94 |
| 83 // Information pieces for version label. | 95 // Information pieces for version label. |
| 84 std::string version_text_; | 96 std::string version_text_; |
| 85 std::string enterprise_domain_text_; | 97 std::string enterprise_domain_text_; |
| 86 std::string enterprise_status_text_; | 98 std::string enterprise_status_text_; |
| 99 bool enterprise_reporting_hint_; |
| 87 | 100 |
| 88 // Full text for the OS version label. | 101 // Full text for the OS version label. |
| 89 std::string os_version_label_text_; | 102 std::string os_version_label_text_; |
| 90 | 103 |
| 91 // CloudPolicySubsysterm observer registrar | 104 // CloudPolicySubsysterm observer registrar |
| 92 scoped_ptr<policy::CloudPolicySubsystem::ObserverRegistrar> | 105 scoped_ptr<policy::CloudPolicySubsystem::ObserverRegistrar> |
| 93 cloud_policy_registrar_; | 106 cloud_policy_registrar_; |
| 94 | 107 |
| 108 chromeos::CrosSettings* cros_settings_; |
| 109 |
| 95 Delegate* delegate_; | 110 Delegate* delegate_; |
| 96 | 111 |
| 97 DISALLOW_COPY_AND_ASSIGN(VersionInfoUpdater); | 112 DISALLOW_COPY_AND_ASSIGN(VersionInfoUpdater); |
| 98 }; | 113 }; |
| 99 | 114 |
| 100 } // namespace chromeos | 115 } // namespace chromeos |
| 101 | 116 |
| 102 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_ | 117 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_ |
| OLD | NEW |