| OLD | NEW |
| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 | 107 |
| 108 function receiveClassification( | 108 function receiveClassification( |
| 109 userClass, timeToOpenNTP, timeToShow, timeToUse) { | 109 userClass, timeToOpenNTP, timeToShow, timeToUse) { |
| 110 receiveProperty('user-class', userClass); | 110 receiveProperty('user-class', userClass); |
| 111 receiveProperty('avg-time-to-open-ntp', timeToOpenNTP); | 111 receiveProperty('avg-time-to-open-ntp', timeToOpenNTP); |
| 112 receiveProperty('avg-time-to-show', timeToShow); | 112 receiveProperty('avg-time-to-show', timeToShow); |
| 113 receiveProperty('avg-time-to-use', timeToUse); | 113 receiveProperty('avg-time-to-use', timeToUse); |
| 114 } | 114 } |
| 115 | 115 |
| 116 function receiveRankerDebugData(itemsList) { |
| 117 displayList(itemsList, 'ranker', 'no-togler'); |
| 118 } |
| 119 |
| 116 function receiveLastRemoteSuggestionsBackgroundFetchTime( | 120 function receiveLastRemoteSuggestionsBackgroundFetchTime( |
| 117 lastRemoteSuggestionsBackgroundFetchTime) { | 121 lastRemoteSuggestionsBackgroundFetchTime) { |
| 118 receiveProperty('last-background-fetch-time-label', | 122 receiveProperty('last-background-fetch-time-label', |
| 119 lastRemoteSuggestionsBackgroundFetchTime); | 123 lastRemoteSuggestionsBackgroundFetchTime); |
| 120 } | 124 } |
| 121 | 125 |
| 122 function downloadJson(json) { | 126 function downloadJson(json) { |
| 123 // Redirect the browser to download data in |json| as a file "snippets.json" | 127 // Redirect the browser to download data in |json| as a file "snippets.json" |
| 124 // (Setting Content-Disposition: attachment via a data: URL is not possible; | 128 // (Setting Content-Disposition: attachment via a data: URL is not possible; |
| 125 // create a link with download attribute and simulate a click, instead.) | 129 // create a link with download attribute and simulate a click, instead.) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 165 } |
| 162 } | 166 } |
| 163 | 167 |
| 164 // Return an object with all of the exports. | 168 // Return an object with all of the exports. |
| 165 return { | 169 return { |
| 166 initialize: initialize, | 170 initialize: initialize, |
| 167 receiveProperty: receiveProperty, | 171 receiveProperty: receiveProperty, |
| 168 receiveContentSuggestions: receiveContentSuggestions, | 172 receiveContentSuggestions: receiveContentSuggestions, |
| 169 receiveJson: receiveJson, | 173 receiveJson: receiveJson, |
| 170 receiveClassification: receiveClassification, | 174 receiveClassification: receiveClassification, |
| 175 receiveRankerDebugData: receiveRankerDebugData, |
| 171 receiveLastRemoteSuggestionsBackgroundFetchTime: | 176 receiveLastRemoteSuggestionsBackgroundFetchTime: |
| 172 receiveLastRemoteSuggestionsBackgroundFetchTime, | 177 receiveLastRemoteSuggestionsBackgroundFetchTime, |
| 173 }; | 178 }; |
| 174 }); | 179 }); |
| 175 | 180 |
| 176 document.addEventListener('DOMContentLoaded', | 181 document.addEventListener('DOMContentLoaded', |
| 177 chrome.SnippetsInternals.initialize); | 182 chrome.SnippetsInternals.initialize); |
| OLD | NEW |