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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_
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"
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
{
27 virtual ~Delegate() {}
29 // Called when OS version label should be updated.
30 virtual void OnOSVersionLabelTextUpdated(
31 const std::string
& os_version_label_text
) = 0;
33 // Called when the enterprise info notice should be updated.
34 virtual void OnEnterpriseInfoUpdated(
35 const std::string
& enterprise_info
) = 0;
38 explicit VersionInfoUpdater(Delegate
* delegate
);
39 virtual ~VersionInfoUpdater();
42 void set_delegate(Delegate
* delegate
) { delegate_
= delegate
; }
44 // Starts fetching version info. The delegate will be notified when update
46 void StartUpdate(bool is_official_build
);
49 // policy::CloudPolicyStore::Observer interface:
50 virtual void OnStoreLoaded(policy::CloudPolicyStore
* store
) OVERRIDE
;
51 virtual void OnStoreError(policy::CloudPolicyStore
* store
) OVERRIDE
;
53 // Update the version label.
54 void UpdateVersionLabel();
56 // Check and update enterprise domain.
57 void UpdateEnterpriseInfo();
59 // Set enterprise domain name.
60 void SetEnterpriseInfo(const std::string
& domain_name
);
62 // Callback from chromeos::VersionLoader giving the version.
63 void OnVersion(const std::string
& version
);
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 CancelableTaskTracker tracker_
;
72 // Information pieces for version label.
73 std::string version_text_
;
75 // Full text for the OS version label.
76 std::string os_version_label_text_
;
78 ScopedVector
<CrosSettings::ObserverSubscription
> subscriptions_
;
80 chromeos::CrosSettings
* cros_settings_
;
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_
;
89 DISALLOW_COPY_AND_ASSIGN(VersionInfoUpdater
);
92 } // namespace chromeos
94 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_