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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 define('main', [
6 'mojo/public/js/bindings',
7 'mojo/public/js/core',
8 'mojo/public/js/connection',
9 'chrome/browser/ui/webui/engagement/site_engagement.mojom',
10 'content/public/renderer/service_provider',
11 ], function(bindings, core, connection, browser, serviceProvider) {
12 'use strict';
13
14 var page;
15
16 function clearEngagementTable() {
17 var table = $('engagement-table');
18 table.removeChild(table.getElementsByTagName('tbody')[0]);
19 table.appendChild(document.createElement('tbody'));
20 }
21
22 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.
23 var tableBody = document.querySelector('#engagement-table > tbody');
24 var row = document.createElement('tr');
25
26 var originCell = document.createElement('td');
27 originCell.textContent = origin;
28 originCell.className = 'origin-cell';
29
30 var scoreCell = document.createElement('td');
31 scoreCell.textContent = score;
32
33 row.appendChild(originCell);
34 row.appendChild(scoreCell);
35 tableBody.appendChild(row);
36 }
37
38 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
39 clearEngagementTable();
40 for (var i = 0; i < page.info.length; i++) {
41 var site = page.info[i];
42 addEngagementTableRow(site.origin, site.score);
43 }
44 }
45
46 function SiteEngagementPageImpl(browser) {
47 this.browser_ = browser;
48 this.info = [];
49 }
50
51 SiteEngagementPageImpl.prototype =
52 Object.create(browser.SiteEngagementPage.stubClass.prototype);
53
54 SiteEngagementPageImpl.prototype.handleSiteEngagementInfo = function(info) {
55 this.info = info;
56 redrawEngagementTable();
57 };
58
59 return function() {
60 var browserProxy = connection.bindHandleToProxy(
61 serviceProvider.connectToService(
62 browser.SiteEngagementUIHandlerMojo.name),
63 browser.SiteEngagementUIHandlerMojo);
64 page = new SiteEngagementPageImpl(browserProxy);
65
66 var pipe = core.createMessagePipe();
67 var stub =
68 connection.bindHandleToStub(pipe.handle0, browser.SiteEngagementPage);
69 bindings.StubBindings(stub).delegate = page;
70 page.stub_ = stub;
71
72 // Populate engagement table.
73 page.browser_.getSiteEngagementInfo(pipe.handle1);
74 };
75 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698