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_UI_WEBUI_HELP_VERSION_UPDATER_CHROMEOS_H_
6 #define CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_CHROMEOS_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/ui/webui/help/version_updater.h"
11 #include "chromeos/dbus/update_engine_client.h"
18 class VersionUpdaterCros
: public VersionUpdater
,
19 public chromeos::UpdateEngineClient::Observer
{
21 // VersionUpdater implementation.
22 void CheckForUpdate(const StatusCallback
& callback
) override
;
23 void RelaunchBrowser() const override
;
24 void SetChannel(const std::string
& channel
,
25 bool is_powerwash_allowed
) override
;
26 void GetChannel(bool get_current_channel
,
27 const ChannelCallback
& callback
) override
;
29 // Gets the last update status, without triggering a new check or download.
30 void GetUpdateStatus(const StatusCallback
& callback
);
33 friend class VersionUpdater
;
35 // Clients must use VersionUpdater::Create().
36 explicit VersionUpdaterCros(content::WebContents
* web_contents
);
37 ~VersionUpdaterCros() override
;
40 // UpdateEngineClient::Observer implementation.
41 void UpdateStatusChanged(
42 const chromeos::UpdateEngineClient::Status
& status
) override
;
44 // Callback from UpdateEngineClient::RequestUpdateCheck().
45 void OnUpdateCheck(chromeos::UpdateEngineClient::UpdateCheckResult result
);
47 // BrowserContext in which the class was instantiated.
48 content::BrowserContext
* context_
;
50 // Callback used to communicate update status to the client.
51 StatusCallback callback_
;
53 // Last state received via UpdateStatusChanged().
54 chromeos::UpdateEngineClient::UpdateStatusOperation last_operation_
;
56 // True if an update check should be scheduled when the update engine is idle.
57 bool check_for_update_when_idle_
;
59 base::WeakPtrFactory
<VersionUpdaterCros
> weak_ptr_factory_
;
61 DISALLOW_COPY_AND_ASSIGN(VersionUpdaterCros
);
64 #endif // CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_CHROMEOS_H_