Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a36a75fa3f4d5c141d53a03190fb139d9e234618 |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/cleanup_tool/cleanup_action_handler.cc |
| @@ -0,0 +1,38 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/webui/cleanup_tool/cleanup_action_handler.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/values.h" |
| +#include "chrome/grit/generated_resources.h" |
| +#include "ui/base/l10n/l10n_util.h" |
|
Dan Beam
2017/04/04 00:00:00
why are these bottom 2 #includes needed?
proberge
2017/04/04 16:10:08
They were used before I split this CL. Removed for
|
| + |
| +CleanupActionHandler::CleanupActionHandler() {} |
| + |
| +void CleanupActionHandler::RegisterMessages() { |
| + web_ui()->RegisterMessageCallback( |
| + "requestLastScanResult", |
| + base::Bind(&CleanupActionHandler::HandleRequestLastScanResult, |
| + base::Unretained(this))); |
| +} |
| + |
| +void CleanupActionHandler::HandleRequestLastScanResult( |
| + const base::ListValue* args) { |
| + std::string webui_callback_id; |
| + CHECK_EQ(1U, args->GetSize()); |
| + bool success = args->GetString(0, &webui_callback_id); |
|
Dan Beam
2017/04/04 00:00:00
can you just get this as a base::Value instead of
proberge
2017/04/04 16:10:07
I copied this pattern from https://cs.chromium.org
|
| + DCHECK(success); |
| + |
| + base::DictionaryValue last_scan_results; |
| + // TODO(proberge): Return real information about the last run. |
| + // TODO(proberge): Localize strings once they are finalized. |
| + last_scan_results.SetBoolean("hasScanResults", false); |
| + last_scan_results.SetBoolean("isInfected", false); |
| + last_scan_results.SetString("detectionStatusText", "No problems detected"); |
| + last_scan_results.SetString("detectionTimeText", "Last scanned today"); |
| + |
| + AllowJavascript(); |
| + ResolveJavascriptCallback(base::Value(webui_callback_id), last_scan_results); |
| +} |