blob: 264782e6c236aeb2039855e575ae8ff4321253b9 [file] [log] [blame]
Alex Gough4b5d0f92019-10-02 05:58:161// Copyright 2019 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.
4
5#ifndef CHROME_BROWSER_UI_WEBUI_SANDBOX_SANDBOX_HANDLER_H_
6#define CHROME_BROWSER_UI_WEBUI_SANDBOX_SANDBOX_HANDLER_H_
7
8#include "base/macros.h"
9#include "base/memory/weak_ptr.h"
10#include "content/public/browser/web_ui_message_handler.h"
11
12namespace base {
13class Value;
14class ListValue;
15} // namespace base
16
17namespace sandbox_handler {
18// This class takes care of sending the list of processes and their sandboxing
19// status to the chrome://sandbox WebUI page when it is requested.
20class SandboxHandler : public content::WebUIMessageHandler {
21 public:
22 SandboxHandler();
Peter Boström53c6c5952021-09-17 09:41:2623
24 SandboxHandler(const SandboxHandler&) = delete;
25 SandboxHandler& operator=(const SandboxHandler&) = delete;
26
Alex Gough4b5d0f92019-10-02 05:58:1627 ~SandboxHandler() override;
28
29 private:
30 // content::WebUIMessageHandler:
31 void RegisterMessages() override;
32
33 // Callback for the "requestSandboxDiagnostics" message.
34 void HandleRequestSandboxDiagnostics(const base::ListValue* args);
35
36 void OnSandboxDataFetched(base::Value results);
37
38 void FetchBrowserChildProcessesCompleted(base::Value browser_processes);
39 void FetchSandboxDiagnosticsCompleted(base::Value sandbox_policies);
40 void GetRendererProcessesAndFinish();
41
42 // The ID of the callback that will get invoked with the sandbox list.
43 base::Value sandbox_diagnostics_callback_id_;
44 base::Value browser_processes_;
45 base::Value sandbox_policies_;
46
47 // Always keep this the last member of this class to make sure it's the
48 // first thing to be destructed.
49 base::WeakPtrFactory<SandboxHandler> weak_ptr_factory_{this};
Alex Gough4b5d0f92019-10-02 05:58:1650};
51
52} // namespace sandbox_handler
53
54#endif // CHROME_BROWSER_UI_WEBUI_SANDBOX_SANDBOX_HANDLER_H_