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_vector.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/settings/cros_settings.h"
13 #include "chromeos/system/version_loader.h"
14 #include "components/policy/core/common/cloud/cloud_policy_store.h"
20 // Fetches all info we want to show on OOBE/Login screens about system
21 // version, boot times and cloud policy.
22 class VersionInfoUpdater
: public policy::CloudPolicyStore::Observer
{
26 virtual ~Delegate() {}
28 // Called when OS version label should be updated.
29 virtual void OnOSVersionLabelTextUpdated(
30 const std::string
& os_version_label_text
) = 0;
32 // Called when the enterprise info notice should be updated.
33 virtual void OnEnterpriseInfoUpdated(
34 const std::string
& enterprise_info
) = 0;
37 explicit VersionInfoUpdater(Delegate
* delegate
);
38 ~VersionInfoUpdater() override
;
41 void set_delegate(Delegate
* delegate
) { delegate_
= delegate
; }
43 // Starts fetching version info. The delegate will be notified when update
45 void StartUpdate(bool is_official_build
);
48 // policy::CloudPolicyStore::Observer interface:
49 void OnStoreLoaded(policy::CloudPolicyStore
* store
) override
;
50 void OnStoreError(policy::CloudPolicyStore
* store
) override
;
52 // Update the version label.
53 void UpdateVersionLabel();
55 // Check and update enterprise domain.
56 void UpdateEnterpriseInfo();
58 // Set enterprise domain name.
59 void SetEnterpriseInfo(const std::string
& domain_name
);
61 // Creates a serial number string.
62 void UpdateSerialNumberInfo();
64 // Callback from chromeos::VersionLoader giving the version.
65 void OnVersion(const std::string
& version
);
67 // Information pieces for version label.
68 std::string version_text_
;
69 std::string serial_number_text_
;
71 // Full text for the OS version label.
72 std::string os_version_label_text_
;
74 ScopedVector
<CrosSettings::ObserverSubscription
> subscriptions_
;
76 chromeos::CrosSettings
* cros_settings_
;
80 // Weak pointer factory so we can give our callbacks for invocation
81 // at a later time without worrying that they will actually try to
82 // happen after the lifetime of this object.
83 base::WeakPtrFactory
<VersionInfoUpdater
> weak_pointer_factory_
;
85 DISALLOW_COPY_AND_ASSIGN(VersionInfoUpdater
);
88 } // namespace chromeos
90 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_