Commit 6584792a authored by Xinghui Lu's avatar Xinghui Lu Committed by Commit Bot

Add RT Lookup Experiment Enabled in chrome://safe-browsing/#tab-rt-lookup

This flag will be useful for testing on Android, because it takes memory
threshold into account.

Screenshot: http://screen/7NSFgNqotba.png

Bug: 1014202
Change-Id: I5c647c73228a875144df514ea344203cd0e46583
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024409Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Commit-Queue: Xinghui Lu <xinghuilu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735932}
parent c4a54306
......@@ -23,6 +23,7 @@ static_library("web_ui") {
"//components/safe_browsing/core/browser:referrer_chain_provider",
"//components/safe_browsing/core/common:safe_browsing_prefs",
"//components/safe_browsing/core/db:v4_local_database_manager",
"//components/safe_browsing/core/realtime:policy_engine",
"//components/safe_browsing/core/web_ui:constants",
"//components/strings:components_strings_grit",
"//components/sync/protocol:protocol",
......
......@@ -91,6 +91,7 @@
</tabpanel>
<tabpanel>
<h2>RT Lookup Pings</h2>
<p id="rt-lookup-experiment-enabled"></p>
<table id="rt-lookup-ping-list" class="request-response"></table>
</tabpanel>
<tabpanel>
......
......@@ -111,6 +111,9 @@ cr.define('safe_browsing', function() {
addRTLookupResponse(result);
});
cr.sendWithPromise('getRTLookupExperimentEnabled', [])
.then((enabled) => addRTLookupExperimentEnabled(enabled));
cr.sendWithPromise('getLogMessages', []).then((logMessages) => {
logMessages.forEach(function(message) {
addLogMessage(message);
......@@ -272,6 +275,11 @@ cr.define('safe_browsing', function() {
addResultToTable('rt-lookup-ping-list', result, 1);
}
function addRTLookupExperimentEnabled(enabled) {
const enabledFormatted = '<b>RT Lookup Experiment Enabled:</b> ' + enabled;
$('rt-lookup-experiment-enabled').innerHTML = enabledFormatted;
}
function addLogMessage(result) {
const logDiv = $('log-messages');
const eventFormatted = "[" + (new Date(result["time"])).toLocaleString() +
......
......@@ -32,6 +32,7 @@
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/safe_browsing/core/features.h"
#include "components/safe_browsing/core/proto/csd.pb.h"
#include "components/safe_browsing/core/realtime/policy_engine.h"
#include "components/safe_browsing/core/web_ui/constants.h"
#include "components/strings/grit/components_strings.h"
#include "components/user_prefs/user_prefs.h"
......@@ -1514,6 +1515,17 @@ void SafeBrowsingUIHandler::GetRTLookupResponses(const base::ListValue* args) {
ResolveJavascriptCallback(base::Value(callback_id), responses_sent);
}
void SafeBrowsingUIHandler::GetRTLookupExperimentEnabled(
const base::ListValue* args) {
base::ListValue value;
value.Append(base::Value(RealTimePolicyEngine::IsUrlLookupEnabled()));
AllowJavascript();
std::string callback_id;
args->GetString(0, &callback_id);
ResolveJavascriptCallback(base::Value(callback_id), value);
}
void SafeBrowsingUIHandler::GetReferrerChain(const base::ListValue* args) {
std::string url_string;
args->GetString(1, &url_string);
......@@ -1724,6 +1736,10 @@ void SafeBrowsingUIHandler::RegisterMessages() {
"getRTLookupResponses",
base::BindRepeating(&SafeBrowsingUIHandler::GetRTLookupResponses,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"getRTLookupExperimentEnabled",
base::BindRepeating(&SafeBrowsingUIHandler::GetRTLookupExperimentEnabled,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"getLogMessages",
base::BindRepeating(&SafeBrowsingUIHandler::GetLogMessages,
......
......@@ -92,6 +92,10 @@ class SafeBrowsingUIHandler : public content::WebUIMessageHandler {
// currently open chrome://safe-browsing tab was opened.
void GetRTLookupResponses(const base::ListValue* args);
// Show whether real time lookup experiment is enabled. This is useful for
// testing on Android, because it also takes memory threshold into account.
void GetRTLookupExperimentEnabled(const base::ListValue* args);
// Get the current referrer chain for a given URL.
void GetReferrerChain(const base::ListValue* args);
......
......@@ -39,6 +39,7 @@ class RealTimePolicyEngine {
static bool CanPerformFullURLLookup(content::BrowserContext* browser_context);
friend class SafeBrowsingService;
friend class SafeBrowsingUIHandler;
private:
// Is the feature to perform real-time URL lookup enabled?
......
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