OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_WEBUI_CLEANUP_TOOL_CLEANUP_ACTION_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CLEANUP_TOOL_CLEANUP_ACTION_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_CLEANUP_TOOL_CLEANUP_ACTION_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CLEANUP_TOOL_CLEANUP_ACTION_HANDLER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "components/component_updater/component_updater_service.h" |
10 #include "content/public/browser/web_ui_message_handler.h" | 12 #include "content/public/browser/web_ui_message_handler.h" |
11 | 13 |
12 // The handler for Javascript messages related to the "Chrome Cleanup" view. | 14 // The handler for Javascript messages related to the "Chrome Cleanup" view. |
13 class CleanupActionHandler : public content::WebUIMessageHandler { | 15 class CleanupActionHandler : public content::WebUIMessageHandler { |
14 public: | 16 public: |
15 CleanupActionHandler(); | 17 CleanupActionHandler(); |
16 ~CleanupActionHandler() override; | 18 ~CleanupActionHandler() override; |
17 | 19 |
18 // WebUIMessageHandler implementation. | 20 // WebUIMessageHandler implementation. |
19 void RegisterMessages() override; | 21 void RegisterMessages() override; |
20 | 22 |
21 private: | 23 private: |
| 24 // Invalidates the weak pointers in callbacks that are no longer safe to run. |
| 25 void OnJavascriptDisallowed() override; |
| 26 |
22 void HandleRequestLastScanResult(const base::ListValue* args); | 27 void HandleRequestLastScanResult(const base::ListValue* args); |
| 28 void HandleStartScan(const base::ListValue* args); |
| 29 |
| 30 // Returns the scan result initiated by HandleStartScan() to the Javascript |
| 31 // caller refererenced by |callback_id|. |
| 32 void ReportScanResults(const std::string& callback_id); |
| 33 |
| 34 // Used to cancel callbacks when JavaScript becomes disallowed. |
| 35 base::WeakPtrFactory<CleanupActionHandler> callback_weak_ptr_factory_; |
23 | 36 |
24 DISALLOW_COPY_AND_ASSIGN(CleanupActionHandler); | 37 DISALLOW_COPY_AND_ASSIGN(CleanupActionHandler); |
25 }; | 38 }; |
26 | 39 |
27 #endif // CHROME_BROWSER_UI_WEBUI_CLEANUP_TOOL_CLEANUP_ACTION_HANDLER_H_ | 40 #endif // CHROME_BROWSER_UI_WEBUI_CLEANUP_TOOL_CLEANUP_ACTION_HANDLER_H_ |
OLD | NEW |