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

Side by Side Diff: chrome/browser/resources/snippets_internals.js

Issue 2569663004: [NTPSnippets] Switch from TickClock to Clock for storing the last background fetched time. (Closed)
Patch Set: Add a DCHECK to check that the num or args passed to the new method is 0 Created 4 years 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 cr.define('chrome.SnippetsInternals', function() { 5 cr.define('chrome.SnippetsInternals', function() {
6 'use strict'; 6 'use strict';
7 7
8 // Stores the list of suggestions we received in receiveContentSuggestions. 8 // Stores the list of suggestions we received in receiveContentSuggestions.
9 var lastSuggestions = []; 9 var lastSuggestions = [];
10 10
(...skipping 15 matching lines...) Expand all
26 $('last-json-dump').addEventListener('click', function(event) { 26 $('last-json-dump').addEventListener('click', function(event) {
27 downloadJson($('last-json-text').innerText); 27 downloadJson($('last-json-text').innerText);
28 event.preventDefault(); 28 event.preventDefault();
29 }); 29 });
30 30
31 $('clear-classification').addEventListener('click', function(event) { 31 $('clear-classification').addEventListener('click', function(event) {
32 chrome.send('clearClassification'); 32 chrome.send('clearClassification');
33 event.preventDefault(); 33 event.preventDefault();
34 }); 34 });
35 35
36 $('background-fetch-button').addEventListener('click', function(event) {
37 chrome.send('fetchRemoteSuggestionsInTheBackground');
38 event.preventDefault();
39 });
40
36 window.addEventListener('focus', refreshContent); 41 window.addEventListener('focus', refreshContent);
37 window.setInterval(refreshContent, 1000); 42 window.setInterval(refreshContent, 1000);
38 43
39 refreshContent(); 44 refreshContent();
40 } 45 }
41 46
42 function receiveProperty(propertyId, value) { 47 function receiveProperty(propertyId, value) {
43 $(propertyId).textContent = value; 48 $(propertyId).textContent = value;
44 } 49 }
45 50
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 106 }
102 107
103 function receiveClassification( 108 function receiveClassification(
104 userClass, timeToOpenNTP, timeToShow, timeToUse) { 109 userClass, timeToOpenNTP, timeToShow, timeToUse) {
105 receiveProperty('user-class', userClass); 110 receiveProperty('user-class', userClass);
106 receiveProperty('avg-time-to-open-ntp', timeToOpenNTP); 111 receiveProperty('avg-time-to-open-ntp', timeToOpenNTP);
107 receiveProperty('avg-time-to-show', timeToShow); 112 receiveProperty('avg-time-to-show', timeToShow);
108 receiveProperty('avg-time-to-use', timeToUse); 113 receiveProperty('avg-time-to-use', timeToUse);
109 } 114 }
110 115
116 function receiveLastRemoteSuggestionsBackgroundFetchTime(
117 lastRemoteSuggestionsBackgroundFetchTime) {
118 receiveProperty('last-background-fetch-time-label',
119 lastRemoteSuggestionsBackgroundFetchTime);
120 }
121
111 function downloadJson(json) { 122 function downloadJson(json) {
112 // Redirect the browser to download data in |json| as a file "snippets.json" 123 // Redirect the browser to download data in |json| as a file "snippets.json"
113 // (Setting Content-Disposition: attachment via a data: URL is not possible; 124 // (Setting Content-Disposition: attachment via a data: URL is not possible;
114 // create a link with download attribute and simulate a click, instead.) 125 // create a link with download attribute and simulate a click, instead.)
115 var link = document.createElement('a'); 126 var link = document.createElement('a');
116 link.download = 'snippets.json'; 127 link.download = 'snippets.json';
117 link.href = 'data:,' + json; 128 link.href = 'data:,' + json;
118 link.click(); 129 link.click();
119 } 130 }
120 131
(...skipping 29 matching lines...) Expand all
150 } 161 }
151 } 162 }
152 163
153 // Return an object with all of the exports. 164 // Return an object with all of the exports.
154 return { 165 return {
155 initialize: initialize, 166 initialize: initialize,
156 receiveProperty: receiveProperty, 167 receiveProperty: receiveProperty,
157 receiveContentSuggestions: receiveContentSuggestions, 168 receiveContentSuggestions: receiveContentSuggestions,
158 receiveJson: receiveJson, 169 receiveJson: receiveJson,
159 receiveClassification: receiveClassification, 170 receiveClassification: receiveClassification,
171 receiveLastRemoteSuggestionsBackgroundFetchTime:
172 receiveLastRemoteSuggestionsBackgroundFetchTime,
160 }; 173 };
161 }); 174 });
162 175
163 document.addEventListener('DOMContentLoaded', 176 document.addEventListener('DOMContentLoaded',
164 chrome.SnippetsInternals.initialize); 177 chrome.SnippetsInternals.initialize);
OLDNEW
« no previous file with comments | « chrome/browser/resources/snippets_internals.html ('k') | chrome/browser/ui/webui/snippets_internals_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698