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
ash / webui / help_app_ui / help_app_ui.h [blame]
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WEBUI_HELP_APP_UI_HELP_APP_UI_H_
#define ASH_WEBUI_HELP_APP_UI_HELP_APP_UI_H_
#include <memory>
#include "ash/webui/help_app_ui/help_app_ui.mojom.h"
#include "ash/webui/help_app_ui/help_app_ui_delegate.h"
#include "ash/webui/help_app_ui/search/search.mojom.h"
#include "ash/webui/help_app_ui/url_constants.h"
#include "ash/webui/system_apps/public/system_web_app_ui_config.h"
#include "base/memory/raw_ref.h"
#include "chromeos/ash/components/local_search_service/public/mojom/index.mojom.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "ui/webui/mojo_web_ui_controller.h"
class PrefService;
namespace ash {
class HelpAppPageHandler;
class HelpAppUI;
// The WebUIConfig for chrome://help-app.
class HelpAppUIConfig : public SystemWebAppUIConfig<HelpAppUI> {
public:
explicit HelpAppUIConfig(
SystemWebAppUIConfig::CreateWebUIControllerFunc create_controller_func)
: SystemWebAppUIConfig(ash::kChromeUIHelpAppHost,
SystemWebAppType::HELP,
create_controller_func) {}
};
// The WebUI controller for chrome://help-app.
class HelpAppUI : public ui::MojoWebUIController,
public help_app::mojom::PageHandlerFactory {
public:
HelpAppUI(content::WebUI* web_ui,
std::unique_ptr<HelpAppUIDelegate> delegate,
PrefService* pref_service);
~HelpAppUI() override;
HelpAppUI(const HelpAppUI&) = delete;
HelpAppUI& operator=(const HelpAppUI&) = delete;
void BindInterface(
mojo::PendingReceiver<help_app::mojom::PageHandlerFactory> receiver);
void BindInterface(
mojo::PendingReceiver<local_search_service::mojom::Index> index_receiver);
// The search handler is used to update the search index for launcher search.
void BindInterface(
mojo::PendingReceiver<help_app::mojom::SearchHandler> receiver);
HelpAppUIDelegate* delegate() { return delegate_.get(); }
bool IsJavascriptErrorReportingEnabled() override;
private:
// help_app::mojom::PageHandlerFactory:
void CreatePageHandler(
mojo::PendingReceiver<help_app::mojom::PageHandler> receiver) override;
std::unique_ptr<HelpAppPageHandler> page_handler_;
mojo::Receiver<help_app::mojom::PageHandlerFactory> page_factory_receiver_{
this};
std::unique_ptr<HelpAppUIDelegate> delegate_;
// Safe because PrefService is owned by the profile, which indirectly owns
// this class.
raw_ref<PrefService> pref_service_;
WEB_UI_CONTROLLER_TYPE_DECL();
};
} // namespace ash
#endif // ASH_WEBUI_HELP_APP_UI_HELP_APP_UI_H_