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

Unified Diff: components/security_interstitials/core/browser/resources/interstitial_webview_quiet.js

Issue 2854263003: Add quiet safe browsing interstitial for WebView (Closed)
Patch Set: Common CSS changes Created 3 years, 8 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
Index: components/security_interstitials/core/browser/resources/interstitial_webview_quiet.js
diff --git a/components/security_interstitials/core/browser/resources/interstitial_webview_quiet.js b/components/security_interstitials/core/browser/resources/interstitial_webview_quiet.js
new file mode 100644
index 0000000000000000000000000000000000000000..4c5b020a1dcff0b4f686cd0c99ec3707d84c5ed5
--- /dev/null
+++ b/components/security_interstitials/core/browser/resources/interstitial_webview_quiet.js
@@ -0,0 +1,85 @@
+// 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.
+
+// This is the shared code for the new (Chrome 37) security interstitials. It is
+// used for both SSL interstitials and Safe Browsing interstitials.
+
+var expandedDetails = false;
+
+// Should match security_interstitials::SecurityInterstitialCommands
felt 2017/05/05 04:35:01 Some of this is shared, can it go in a shared JS f
edwardjung 2017/05/08 16:27:33 Done.
+var CMD_DONT_PROCEED = 0;
+var CMD_PROCEED = 1;
+// Ways for user to get more information
+var CMD_SHOW_MORE_SECTION = 2;
+var CMD_OPEN_HELP_CENTER = 3;
+var CMD_OPEN_DIAGNOSTIC = 4;
+// Primary button actions
+var CMD_RELOAD = 5;
+var CMD_OPEN_DATE_SETTINGS = 6;
+var CMD_OPEN_LOGIN = 7;
+// Safe Browsing Extended Reporting
+var CMD_DO_REPORT = 8;
+var CMD_DONT_REPORT = 9;
+var CMD_OPEN_REPORTING_PRIVACY = 10;
+var CMD_OPEN_WHITEPAPER = 11;
+// Report a phishing error.
+var CMD_REPORT_PHISHING_ERROR = 12;
+
+/**
+ * A convenience method for sending commands to the parent page.
+ * @param {string} cmd The command to send.
+ */
+function sendCommand(cmd) {
+ window.domAutomationController.setAutomationId(1);
+ window.domAutomationController.send(cmd);
+
+ // TODO(crbug.com/565877): Revisit message passing for WKWebView.
+ var iframe = document.createElement('IFRAME');
+ iframe.setAttribute('src', 'js-command:' + cmd);
+ document.documentElement.appendChild(iframe);
+ iframe.parentNode.removeChild(iframe);
+}
+
+function toggleDetails() {
+ var hiddenDetails = $('details').classList.toggle('hidden');
+ $('main-content').classList.toggle('hidden', !hiddenDetails);
+}
+
+function setupEvents() {
+ var overridable = loadTimeData.getBoolean('overridable');
+ var interstitialType = loadTimeData.getString('type');
+ var webViewSize = 'medium' // loadTimeData.getString('size');
felt 2017/05/05 04:35:01 guessing that's left in from testing?
+
+ $('body').classList.add(webViewSize);
+
+ // Only medium size WebViews have interactions.
+ if (webViewSize == 'medium') {
felt 2017/05/05 04:35:01 Hmm, so I was imagining that the HTML/CSS/JS will
felt 2017/05/05 04:35:01 nit: return early instead of having a long if-stat
edwardjung 2017/05/08 16:27:33 I can determine the small / medium size in the JS
+ if (overridable) {
+ $('proceed-link').addEventListener('click', function(event) {
+ sendCommand(CMD_PROCEED);
+ });
+ }
+
+ if ($('learn-more-link')) {
+ $('learn-more-link').addEventListener('click', function(event) {
+ sendCommand(CMD_OPEN_HELP_CENTER);
+ });
+ }
+
+ $('details-button').addEventListener('click', function(event) {
+ toggleDetails();
+
+ if (!expandedDetails) {
+ // Record a histogram entry only the first time that details is opened.
+ sendCommand(CMD_SHOW_MORE_SECTION);
+ expandedDetails = true;
+ }
+ });
+
+ $('hide-details-button').addEventListener('click', toggleDetails);
+ preventDefaultOnPoundLinkClicks();
+ }
+}
+
+document.addEventListener('DOMContentLoaded', setupEvents);

Powered by Google App Engine
This is Rietveld 408576698