Alex Gough | 4b5d0f9 | 2019-10-02 05:58:16 | [diff] [blame] | 1 | // 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 | |
| 12 | namespace base { |
| 13 | class Value; |
| 14 | class ListValue; |
| 15 | } // namespace base |
| 16 | |
| 17 | namespace 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. |
| 20 | class SandboxHandler : public content::WebUIMessageHandler { |
| 21 | public: |
| 22 | SandboxHandler(); |
Peter Boström | 53c6c595 | 2021-09-17 09:41:26 | [diff] [blame^] | 23 | |
| 24 | SandboxHandler(const SandboxHandler&) = delete; |
| 25 | SandboxHandler& operator=(const SandboxHandler&) = delete; |
| 26 | |
Alex Gough | 4b5d0f9 | 2019-10-02 05:58:16 | [diff] [blame] | 27 | ~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 Gough | 4b5d0f9 | 2019-10-02 05:58:16 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | } // namespace sandbox_handler |
| 53 | |
| 54 | #endif // CHROME_BROWSER_UI_WEBUI_SANDBOX_SANDBOX_HANDLER_H_ |