Index: chrome/browser/ui/webui/cleanup_tool/cleanup_action_handler.cc |
diff --git a/chrome/browser/ui/webui/cleanup_tool/cleanup_action_handler.cc b/chrome/browser/ui/webui/cleanup_tool/cleanup_action_handler.cc |
index e6bd13e7224e1fcde2cee0ce17a771b84cf028ea..d1e6bacc8acecb2eeffd63ece04fcd86ef0e74bb 100644 |
--- a/chrome/browser/ui/webui/cleanup_tool/cleanup_action_handler.cc |
+++ b/chrome/browser/ui/webui/cleanup_tool/cleanup_action_handler.cc |
@@ -5,10 +5,10 @@ |
#include "chrome/browser/ui/webui/cleanup_tool/cleanup_action_handler.h" |
#include "base/bind.h" |
-#include "base/timer/timer.h" |
#include "base/values.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/component_updater/sw_reporter_installer_win.h" |
+#include "components/component_updater/component_updater_service.h" |
namespace { |
@@ -22,6 +22,18 @@ bool IsCleanupComponentRegistered() { |
component_ids.end(); |
} |
+// TODO(proberge): Connect this to the Cleanup Tool manager class once that's |
+// implemented. |
+void StartScan(base::Closure callback) { |
+ callback.Run(); |
+} |
+ |
+// TODO(proberge): Connect this to the Cleanup Tool manager class once that's |
+// implemented. |
+void StartCleanup(base::Closure callback) { |
+ callback.Run(); |
+} |
+ |
// TODO(proberge): Localize strings once they are finalized. |
constexpr char kDetectionOkText[] = "No problems detected"; |
constexpr char kDetectionUwSText[] = "2 potentially harmful programs detected"; |
@@ -44,6 +56,9 @@ void CleanupActionHandler::RegisterMessages() { |
web_ui()->RegisterMessageCallback( |
"startScan", base::Bind(&CleanupActionHandler::HandleStartScan, |
base::Unretained(this))); |
+ web_ui()->RegisterMessageCallback( |
+ "startCleanup", base::Bind(&CleanupActionHandler::HandleStartCleanup, |
+ base::Unretained(this))); |
} |
void CleanupActionHandler::OnJavascriptDisallowed() { |
@@ -52,8 +67,8 @@ void CleanupActionHandler::OnJavascriptDisallowed() { |
void CleanupActionHandler::HandleRequestLastScanResult( |
const base::ListValue* args) { |
- std::string webui_callback_id; |
CHECK_EQ(1U, args->GetSize()); |
+ std::string webui_callback_id; |
bool success = args->GetString(0, &webui_callback_id); |
DCHECK(success); |
@@ -86,9 +101,9 @@ void CleanupActionHandler::HandleStartScan(const base::ListValue* args) { |
return; |
} |
- component_updater::RegisterUserInitiatedSwReporterScan( |
- base::Bind(&CleanupActionHandler::ReportScanResults, |
- callback_weak_ptr_factory_.GetWeakPtr(), webui_callback_id)); |
+ StartScan(base::Bind(&CleanupActionHandler::ReportScanResults, |
+ callback_weak_ptr_factory_.GetWeakPtr(), |
+ webui_callback_id)); |
} |
void CleanupActionHandler::ReportScanResults(const std::string& callback_id) { |
@@ -102,3 +117,23 @@ void CleanupActionHandler::ReportScanResults(const std::string& callback_id) { |
AllowJavascript(); |
ResolveJavascriptCallback(base::Value(callback_id), scan_results); |
} |
+ |
+void CleanupActionHandler::HandleStartCleanup(const base::ListValue* args) { |
+ CHECK_EQ(1U, args->GetSize()); |
+ std::string webui_callback_id; |
+ bool success = args->GetString(0, &webui_callback_id); |
+ DCHECK(success); |
+ |
+ StartCleanup(base::Bind(&CleanupActionHandler::ReportCleanupResults, |
+ base::Unretained(this), webui_callback_id)); |
+} |
+ |
+void CleanupActionHandler::ReportCleanupResults( |
+ const std::string& callback_id) { |
+ base::DictionaryValue cleanup_results; |
+ // TODO(proberge): Return real information about the cleanup. |
+ cleanup_results.SetBoolean("wasCancelled", true); |
+ cleanup_results.SetBoolean("requiresReboot", false); |
+ |
+ ResolveJavascriptCallback(base::Value(callback_id), cleanup_results); |
+} |