OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 define('main', [ | 7 define('main', [ |
8 'mojo/public/js/connection', | 8 'mojo/public/js/connection', |
9 'chrome/browser/ui/webui/engagement/site_engagement.mojom', | 9 'chrome/browser/ui/webui/engagement/site_engagement.mojom', |
10 'content/public/renderer/service_provider', | 10 'content/public/renderer/service_provider', |
11 ], function(connection, siteEngagementMojom, serviceProvider) { | 11 ], function(connection, siteEngagementMojom, serviceProvider) { |
12 | |
13 return function() { | 12 return function() { |
14 var uiHandler = connection.bindHandleToProxy( | 13 var uiHandler = connection.bindHandleToProxy( |
15 serviceProvider.connectToService( | 14 serviceProvider.connectToService( |
16 siteEngagementMojom.SiteEngagementUIHandler.name), | 15 siteEngagementMojom.SiteEngagementUIHandler.name), |
17 siteEngagementMojom.SiteEngagementUIHandler); | 16 siteEngagementMojom.SiteEngagementUIHandler); |
18 | 17 |
19 // Populate engagement table. | 18 var updateEngagementTable = function() { |
20 uiHandler.getSiteEngagementInfo().then(function(response) { | 19 // Populate engagement table. |
21 // Round each score to 2 decimal places. | 20 uiHandler.getSiteEngagementInfo().then(function(response) { |
22 response.info.forEach(function(x) { | 21 // Round each score to 2 decimal places. |
23 x.score = Number(Math.round(x.score * 100) / 100); | 22 response.info.forEach(function(x) { |
| 23 x.score = Number(Math.round(x.score * 100) / 100); |
| 24 }); |
| 25 $('engagement-table').engagementInfo = response.info; |
24 }); | 26 }); |
25 $('engagement-table').engagementInfo = response.info; | 27 |
26 }); | 28 setTimeout(updateEngagementTable, 2000); |
| 29 }; |
| 30 updateEngagementTable(); |
27 }; | 31 }; |
28 }); | 32 }); |
OLD | NEW |