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
ash / webui / demo_mode_app_ui / demo_mode_app_untrusted_ui.h [blame]
// Copyright 2021 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_DEMO_MODE_APP_UI_DEMO_MODE_APP_UNTRUSTED_UI_H_
#define ASH_WEBUI_DEMO_MODE_APP_UI_DEMO_MODE_APP_UNTRUSTED_UI_H_
#include "ash/webui/common/chrome_os_webui_config.h"
#include "ash/webui/demo_mode_app_ui/demo_mode_app_delegate.h"
#include "ash/webui/demo_mode_app_ui/mojom/demo_mode_app_untrusted_ui.mojom.h"
#include "base/files/file_path.h"
#include "content/public/browser/web_ui_data_source.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "ui/webui/untrusted_web_ui_controller.h"
namespace ash {
class DemoModeAppUntrustedUI;
class DemoModeAppUntrustedUIConfig
: public ChromeOSWebUIConfig<DemoModeAppUntrustedUI> {
public:
explicit DemoModeAppUntrustedUIConfig(
CreateWebUIControllerFunc create_controller_func);
~DemoModeAppUntrustedUIConfig() override;
bool IsWebUIEnabled(content::BrowserContext* browser_context) override;
};
// The WebUI for chrome-untrusted://demo-mode-app
class DemoModeAppUntrustedUI
: public ui::UntrustedWebUIController,
public mojom::demo_mode::UntrustedPageHandlerFactory {
public:
explicit DemoModeAppUntrustedUI(
content::WebUI* web_ui,
base::FilePath component_base_path,
std::unique_ptr<DemoModeAppDelegate> delegate);
~DemoModeAppUntrustedUI() override;
DemoModeAppUntrustedUI(const DemoModeAppUntrustedUI&) = delete;
DemoModeAppUntrustedUI& operator=(const DemoModeAppUntrustedUI&) = delete;
void BindInterface(
mojo::PendingReceiver<mojom::demo_mode::UntrustedPageHandlerFactory>
factory);
// Visible for testing
static void SourceDataFromComponent(
const base::FilePath& component_path,
const std::string& resource_path,
content::WebUIDataSource::GotDataCallback callback);
DemoModeAppDelegate& delegate() { return *delegate_; }
private:
// mojom::DemoModePageHandlerFactory
void CreatePageHandler(
mojo::PendingReceiver<mojom::demo_mode::UntrustedPageHandler> handler)
override;
std::unique_ptr<DemoModeAppDelegate> delegate_;
mojo::Receiver<mojom::demo_mode::UntrustedPageHandlerFactory>
demo_mode_page_factory_{this};
std::unique_ptr<mojom::demo_mode::UntrustedPageHandler>
demo_mode_page_handler_;
WEB_UI_CONTROLLER_TYPE_DECL();
};
} // namespace ash
#endif // ASH_WEBUI_DEMO_MODE_APP_UI_DEMO_MODE_APP_UNTRUSTED_UI_H_