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

Unified Diff: chrome/browser/resources/engagement/site_engagement.js

Issue 1316043003: Add chrome://site-engagement WebUI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation_smarter
Patch Set: fix build more Created 5 years, 4 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: chrome/browser/resources/engagement/site_engagement.js
diff --git a/chrome/browser/resources/engagement/site_engagement.js b/chrome/browser/resources/engagement/site_engagement.js
new file mode 100644
index 0000000000000000000000000000000000000000..137d5f0f08f4a08e3b5ffa27611a81b60dc22262
--- /dev/null
+++ b/chrome/browser/resources/engagement/site_engagement.js
@@ -0,0 +1,75 @@
+// Copyright 2015 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.
+
+define('main', [
+ 'mojo/public/js/bindings',
+ 'mojo/public/js/core',
+ 'mojo/public/js/connection',
+ 'chrome/browser/ui/webui/engagement/site_engagement.mojom',
+ 'content/public/renderer/service_provider',
+], function(bindings, core, connection, browser, serviceProvider) {
+ 'use strict';
+
+ var page;
+
+ function clearEngagementTable() {
+ var table = $('engagement-table');
+ table.removeChild(table.getElementsByTagName('tbody')[0]);
+ table.appendChild(document.createElement('tbody'));
+ }
+
+ function addEngagementTableRow(origin, score) {
Sam McNally 2015/08/26 08:23:21 It might be worth using polymer data binding and t
calamity 2015/09/08 07:30:06 Done.
+ var tableBody = document.querySelector('#engagement-table > tbody');
+ var row = document.createElement('tr');
+
+ var originCell = document.createElement('td');
+ originCell.textContent = origin;
+ originCell.className = 'origin-cell';
+
+ var scoreCell = document.createElement('td');
+ scoreCell.textContent = score;
+
+ row.appendChild(originCell);
+ row.appendChild(scoreCell);
+ tableBody.appendChild(row);
+ }
+
+ function redrawEngagementTable() {
Sam McNally 2015/08/26 08:23:21 Why not make this a method of SiteEngagementPageIm
calamity 2015/09/08 07:30:06 I guess I thought that SiteEngagementPageImpl was
+ clearEngagementTable();
+ for (var i = 0; i < page.info.length; i++) {
+ var site = page.info[i];
+ addEngagementTableRow(site.origin, site.score);
+ }
+ }
+
+ function SiteEngagementPageImpl(browser) {
+ this.browser_ = browser;
+ this.info = [];
+ }
+
+ SiteEngagementPageImpl.prototype =
+ Object.create(browser.SiteEngagementPage.stubClass.prototype);
+
+ SiteEngagementPageImpl.prototype.handleSiteEngagementInfo = function(info) {
+ this.info = info;
+ redrawEngagementTable();
+ };
+
+ return function() {
+ var browserProxy = connection.bindHandleToProxy(
+ serviceProvider.connectToService(
+ browser.SiteEngagementUIHandlerMojo.name),
+ browser.SiteEngagementUIHandlerMojo);
+ page = new SiteEngagementPageImpl(browserProxy);
+
+ var pipe = core.createMessagePipe();
+ var stub =
+ connection.bindHandleToStub(pipe.handle0, browser.SiteEngagementPage);
+ bindings.StubBindings(stub).delegate = page;
+ page.stub_ = stub;
+
+ // Populate engagement table.
+ page.browser_.getSiteEngagementInfo(pipe.handle1);
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698