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(const std::string
& enterprise_info
,
34 const std::string
& asset_id
) = 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 and device asset ID.
59 void SetEnterpriseInfo(const std::string
& domain_name
,
60 const std::string
& asset_id
);
62 // Creates a serial number string.
63 void UpdateSerialNumberInfo();
65 // Callback from chromeos::VersionLoader giving the version.
66 void OnVersion(const std::string
& version
);
68 // Information pieces for version label.
69 std::string version_text_
;
70 std::string serial_number_text_
;
72 // Full text for the OS version label.
73 std::string os_version_label_text_
;
75 ScopedVector
<CrosSettings::ObserverSubscription
> subscriptions_
;
77 chromeos::CrosSettings
* cros_settings_
;
81 // Weak pointer factory so we can give our callbacks for invocation
82 // at a later time without worrying that they will actually try to
83 // happen after the lifetime of this object.
84 base::WeakPtrFactory
<VersionInfoUpdater
> weak_pointer_factory_
;
86 DISALLOW_COPY_AND_ASSIGN(VersionInfoUpdater
);
89 } // namespace chromeos
91 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_