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