| 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" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "components/component_updater/component_updater_service.h" | |
| 12 #include "content/public/browser/web_ui_message_handler.h" | 11 #include "content/public/browser/web_ui_message_handler.h" |
| 13 | 12 |
| 14 // The handler for Javascript messages related to the "Chrome Cleanup" view. | 13 // The handler for Javascript messages related to the "Chrome Cleanup" view. |
| 15 class CleanupActionHandler : public content::WebUIMessageHandler { | 14 class CleanupActionHandler : public content::WebUIMessageHandler { |
| 16 public: | 15 public: |
| 17 CleanupActionHandler(); | 16 CleanupActionHandler(); |
| 18 ~CleanupActionHandler() override; | 17 ~CleanupActionHandler() override; |
| 19 | 18 |
| 20 // WebUIMessageHandler implementation. | 19 // WebUIMessageHandler implementation. |
| 21 void RegisterMessages() override; | 20 void RegisterMessages() override; |
| 22 | 21 |
| 23 private: | 22 private: |
| 24 // Invalidates the weak pointers in callbacks that are no longer safe to run. | 23 // Invalidates the weak pointers in callbacks that are no longer safe to run. |
| 25 void OnJavascriptDisallowed() override; | 24 void OnJavascriptDisallowed() override; |
| 26 | 25 |
| 27 void HandleRequestLastScanResult(const base::ListValue* args); | 26 void HandleRequestLastScanResult(const base::ListValue* args); |
| 28 void HandleStartScan(const base::ListValue* args); | 27 void HandleStartScan(const base::ListValue* args); |
| 28 void HandleStartCleanup(const base::ListValue* args); |
| 29 | 29 |
| 30 // Returns the scan result initiated by HandleStartScan() to the Javascript | 30 // Returns the scan result initiated by HandleStartScan() to the Javascript |
| 31 // caller refererenced by |callback_id|. | 31 // caller refererenced by |callback_id|. |
| 32 void ReportScanResults(const std::string& callback_id); | 32 void ReportScanResults(const std::string& callback_id); |
| 33 | 33 |
| 34 // Returns the cleanup result initiated by HandleStartCleanup() to the |
| 35 // Javascript caller refererenced by |callback_id|. |
| 36 void ReportCleanupResults(const std::string& callback_id); |
| 37 |
| 34 // Used to cancel callbacks when JavaScript becomes disallowed. | 38 // Used to cancel callbacks when JavaScript becomes disallowed. |
| 35 base::WeakPtrFactory<CleanupActionHandler> callback_weak_ptr_factory_; | 39 base::WeakPtrFactory<CleanupActionHandler> callback_weak_ptr_factory_; |
| 36 | 40 |
| 37 DISALLOW_COPY_AND_ASSIGN(CleanupActionHandler); | 41 DISALLOW_COPY_AND_ASSIGN(CleanupActionHandler); |
| 38 }; | 42 }; |
| 39 | 43 |
| 40 #endif // CHROME_BROWSER_UI_WEBUI_CLEANUP_TOOL_CLEANUP_ACTION_HANDLER_H_ | 44 #endif // CHROME_BROWSER_UI_WEBUI_CLEANUP_TOOL_CLEANUP_ACTION_HANDLER_H_ |
| OLD | NEW |