Commit 4b840ba0 authored by Daniel Rubery's avatar Daniel Rubery Committed by Commit Bot

Fix how Threat Details are populated on chrome://safe-browsing

Threat Details had a few odd behaviors. If you had multiple threats,
and opened a new chrome://safe-browsing tab, only the oldest threat
would be shown on the new tab. Also, all threats prior to opening a
close and reopen the tab.

chrome: //safe-browsing tab were logged, so if you open a new
chrome: //safe-browsing tab, you see old threats that disappear if you
Change-Id: Ie2549cbe71fea6b30e013994f20d595df1b2195a
Reviewed-on: https://chromium-review.googlesource.com/1099691
Commit-Queue: Varun Khaneja <vakh@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567081}
parent d2a810ba
......@@ -21,7 +21,10 @@ cr.define('safe_browsing', function() {
addFullHashCacheInfo(fullHashCacheState);
});
cr.sendWithPromise('getSentThreatDetails', []).then((threatDetails) =>
addThreatDetailsInfo(threatDetails));
threatDetails.forEach(function(td) {
addThreatDetailsInfo(td);
})
);
cr.addWebUIListener('threat-details-update', function(result) {
addThreatDetailsInfo(result);
});
......
......@@ -47,8 +47,12 @@ WebUIInfoSingleton* WebUIInfoSingleton::GetInstance() {
void WebUIInfoSingleton::AddToReportsSent(
std::unique_ptr<ClientSafeBrowsingReportRequest> report_request) {
if (webui_instances_.empty())
return;
for (auto* webui_listener : webui_instances_)
webui_listener->NotifyThreatDetailsJsListener(report_request.get());
reports_sent_.push_back(std::move(report_request));
}
......@@ -367,12 +371,12 @@ void SafeBrowsingUIHandler::GetSentThreatDetails(const base::ListValue* args) {
for (const auto& report : reports) {
sent_reports.GetList().push_back(
base::Value(ParseThreatDetailsInfo(*report)));
AllowJavascript();
std::string callback_id;
args->GetString(0, &callback_id);
ResolveJavascriptCallback(base::Value(callback_id), sent_reports);
}
AllowJavascript();
std::string callback_id;
args->GetString(0, &callback_id);
ResolveJavascriptCallback(base::Value(callback_id), sent_reports);
}
void SafeBrowsingUIHandler::NotifyThreatDetailsJsListener(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment