Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Unified Diff: components/safe_browsing/web_ui/safe_browsing_ui.cc

Issue 2964693003: Added experiments section and exported the list of SafeBrowsing features in WebUI (Closed)
Patch Set: Fixed the variable names according to the standard 01 Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/safe_browsing/web_ui/safe_browsing_ui.h ('k') | components/safe_browsing_db/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing/web_ui/safe_browsing_ui.cc
diff --git a/components/safe_browsing/web_ui/safe_browsing_ui.cc b/components/safe_browsing/web_ui/safe_browsing_ui.cc
index 761b7cbd217c7c3b48efb4a40fe621912b217653..fe19f300fa5d5a335bb19303485ec7208ec077c6 100644
--- a/components/safe_browsing/web_ui/safe_browsing_ui.cc
+++ b/components/safe_browsing/web_ui/safe_browsing_ui.cc
@@ -1,28 +1,41 @@
-// Copyright (c) 2017 The Chromium Authors. All rights reserved.
+// 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 "components/safe_browsing/web_ui/safe_browsing_ui.h"
+
+#include <algorithm>
+#include <utility>
+#include "base/macros.h"
+#include "base/values.h"
#include "components/grit/components_resources.h"
#include "components/grit/components_scaled_resources.h"
+#include "components/safe_browsing/features.h"
#include "components/safe_browsing/web_ui/constants.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_data_source.h"
-
+#include "content/public/browser/web_ui_message_handler.h"
+namespace safe_browsing {
SafeBrowsingUI::SafeBrowsingUI(content::WebUI* web_ui)
: content::WebUIController(web_ui) {
// Set up the chrome://safe-browsing source.
+
content::WebUIDataSource* html_source = content::WebUIDataSource::Create(
safe_browsing::kChromeUISafeBrowsingHost);
+ // Register callback handler.
+ // Handles messages from JavaScript to C++ via chrome.send().
+ web_ui->AddMessageHandler(base::MakeUnique<SafeBrowsingUIHandler>());
+
// Add localized string resources.
html_source->AddLocalizedString("sbUnderConstruction",
IDS_SB_UNDER_CONSTRUCTION);
// Add required resources.
html_source->AddResourcePath("safe_browsing.css", IDR_SAFE_BROWSING_CSS);
+ html_source->AddResourcePath("safe_browsing.js", IDR_SAFE_BROWSING_JS);
html_source->SetDefaultResource(IDR_SAFE_BROWSING_HTML);
content::BrowserContext* browser_context =
@@ -31,3 +44,19 @@ SafeBrowsingUI::SafeBrowsingUI(content::WebUI* web_ui)
}
SafeBrowsingUI::~SafeBrowsingUI() {}
+
+SafeBrowsingUIHandler::SafeBrowsingUIHandler(){};
+
+void SafeBrowsingUIHandler::ExpParamList(const base::ListValue* unused) {
+ AllowJavascript();
+ CallJavascriptFunction("safe_browsing.addExperiment", GetFeatureStatusList());
+}
+
+void SafeBrowsingUIHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "expParamList",
+ base::Bind(&SafeBrowsingUIHandler::ExpParamList, base::Unretained(this)));
+}
+
+SafeBrowsingUIHandler::~SafeBrowsingUIHandler() {}
+} // namespace safe_browsing
« no previous file with comments | « components/safe_browsing/web_ui/safe_browsing_ui.h ('k') | components/safe_browsing_db/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698