blob: 397c02343d6138cd08418b6ebe544499393fd6c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_
#include <string>
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/help/version_updater.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_ui_message_handler.h"
#if defined(OS_CHROMEOS)
#include "base/platform_file.h"
#include "chrome/browser/chromeos/version_loader.h"
#endif // defined(OS_CHROMEOS)
namespace content {
class WebUIDataSource;
}
// WebUI message handler for the help page.
class HelpHandler : public content::WebUIMessageHandler,
public content::NotificationObserver {
public:
HelpHandler();
virtual ~HelpHandler();
// WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE;
// Fills |source| with string values for the UI.
void GetLocalizedValues(content::WebUIDataSource* source);
// NotificationObserver implementation.
virtual void Observe(int type, const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
private:
// Initializes querying values for the page.
void OnPageLoaded(const base::ListValue* args);
#if defined(OS_MACOSX)
// Promotes the updater for all users.
void PromoteUpdater(const base::ListValue* args);
#endif
// Relaunches the browser. |args| must be empty.
void RelaunchNow(const base::ListValue* args);
// Opens the feedback dialog. |args| must be empty.
void OpenFeedbackDialog(const base::ListValue* args);
// Opens the help page. |args| must be empty.
void OpenHelpPage(const base::ListValue* args);
#if defined(OS_CHROMEOS)
// Sets the release track version.
void SetReleaseTrack(const base::ListValue* args);
#endif
// Callback method which forwards status updates to the page.
void SetUpdateStatus(VersionUpdater::Status status, int progress,
const string16& fail_message);
#if defined(OS_MACOSX)
// Callback method which forwards promotion state to the page.
void SetPromotionState(VersionUpdater::PromotionState state);
#endif
#if defined(OS_CHROMEOS)
// Callbacks from VersionLoader.
void OnOSVersion(const std::string& version);
void OnOSFirmware(const std::string& firmware);
void OnReleaseChannel(const std::string& channel);
void ProcessLsbFileInfo(
base::PlatformFileError rv, const base::PlatformFileInfo& file_info);
#endif
// Specialized instance of the VersionUpdater used to update the browser.
scoped_ptr<VersionUpdater> version_updater_;
// Used for callbacks.
base::WeakPtrFactory<HelpHandler> weak_factory_;
// Used to observe notifications.
content::NotificationRegistrar registrar_;
#if defined(OS_CHROMEOS)
// Handles asynchronously loading the CrOS version info.
chromeos::VersionLoader loader_;
// Used to request the version.
CancelableTaskTracker tracker_;
#endif // defined(OS_CHROMEOS)
DISALLOW_COPY_AND_ASSIGN(HelpHandler);
};
#endif // CHROME_BROWSER_UI_WEBUI_HELP_HELP_HANDLER_H_
|