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
106
107
108
ash / webui / diagnostics_ui / diagnostics_ui.h [blame]
// Copyright 2020 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_DIAGNOSTICS_UI_DIAGNOSTICS_UI_H_
#define ASH_WEBUI_DIAGNOSTICS_UI_DIAGNOSTICS_UI_H_
#include "ash/webui/common/backend/plural_string_handler.h"
#include "ash/webui/common/chrome_os_webui_config.h"
#include "ash/webui/diagnostics_ui/backend/input/input_data_provider.h"
#include "ash/webui/diagnostics_ui/backend/session_log_handler.h"
#include "ash/webui/diagnostics_ui/diagnostics_metrics.h"
#include "ash/webui/diagnostics_ui/diagnostics_metrics_message_handler.h"
#include "ash/webui/diagnostics_ui/mojom/input_data_provider.mojom-forward.h"
#include "ash/webui/diagnostics_ui/mojom/network_health_provider.mojom-forward.h"
#include "ash/webui/diagnostics_ui/mojom/system_data_provider.mojom-forward.h"
#include "ash/webui/diagnostics_ui/mojom/system_routine_controller.mojom-forward.h"
#include "ash/webui/diagnostics_ui/url_constants.h"
#include "base/time/time.h"
#include "content/public/common/url_constants.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "ui/web_dialogs/web_dialog_ui.h"
#include "ui/webui/resources/cr_components/color_change_listener/color_change_listener.mojom.h"
namespace base {
class FilePath;
} // namespace base
namespace ui {
class ColorChangeHandler;
} // namespace ui
namespace ash {
class HoldingSpaceClient;
class DiagnosticsDialogUI;
namespace diagnostics {
class DiagnosticsManager;
class InputDataProvider;
} // namespace diagnostics
// The WebDialogUIConfig for chrome://diagnostics.
class DiagnosticsDialogUIConfig
: public ChromeOSWebUIConfig<DiagnosticsDialogUI> {
public:
explicit DiagnosticsDialogUIConfig(
CreateWebUIControllerFunc create_controller_func)
: ChromeOSWebUIConfig(content::kChromeUIScheme,
ash::kChromeUIDiagnosticsAppHost,
create_controller_func) {}
};
// The WebDialogUI for chrome://diagnostics.
class DiagnosticsDialogUI : public ui::MojoWebDialogUI {
public:
explicit DiagnosticsDialogUI(
content::WebUI* web_ui,
const diagnostics::SessionLogHandler::SelectFilePolicyCreator&
select_file_policy_creator,
HoldingSpaceClient* holding_space_client,
const base::FilePath& log_directory_path);
~DiagnosticsDialogUI() override;
DiagnosticsDialogUI(const DiagnosticsDialogUI&) = delete;
DiagnosticsDialogUI& operator=(const DiagnosticsDialogUI&) = delete;
static bool ShouldCloseDialogOnEscape() {
return diagnostics::InputDataProvider::ShouldCloseDialogOnEscape();
}
void BindInterface(
mojo::PendingReceiver<diagnostics::mojom::NetworkHealthProvider>
receiver);
void BindInterface(
mojo::PendingReceiver<diagnostics::mojom::SystemDataProvider> receiver);
void BindInterface(
mojo::PendingReceiver<diagnostics::mojom::SystemRoutineController>
receiver);
void BindInterface(
mojo::PendingReceiver<diagnostics::mojom::InputDataProvider> receiver);
void BindInterface(
mojo::PendingReceiver<color_change_listener::mojom::PageHandler>
receiver);
private:
WEB_UI_CONTROLLER_TYPE_DECL();
// Timestamp of when the app was opened. Used to calculate a duration for
// metrics.
base::Time open_timestamp_;
std::unique_ptr<diagnostics::DiagnosticsManager> diagnostics_manager_;
std::unique_ptr<diagnostics::metrics::DiagnosticsMetrics>
diagnostics_metrics_;
std::unique_ptr<diagnostics::InputDataProvider> input_data_provider_;
// The color change handler notifies the WebUI when the color provider
// changes.
std::unique_ptr<ui::ColorChangeHandler> color_provider_handler_;
};
} // namespace ash
#endif // ASH_WEBUI_DIAGNOSTICS_UI_DIAGNOSTICS_UI_H_