Removed affiliation from chrome and tests.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / version_info_updater.h
blobf1ee1c540b57d6ccdb0f6f54a9266a613c7b11af
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_
8 #include <string>
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"
16 namespace chromeos {
18 class CrosSettings;
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 {
23 public:
24 class Delegate {
25 public:
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;
40 // Sets delegate.
41 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
43 // Starts fetching version info. The delegate will be notified when update
44 // is received.
45 void StartUpdate(bool is_official_build);
47 private:
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_;
79 Delegate* delegate_;
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_