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

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

Issue 10692075: Enhance chrome://omnibox Presentation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Tweak layout so that Logged Info does not wrap. Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 /** 5 /**
6 * Javascript for omnibox.html, served from chrome://omnibox/ 6 * Javascript for omnibox.html, served from chrome://omnibox/
7 * This is used to debug omnibox ranking. The user enters some text 7 * This is used to debug omnibox ranking. The user enters some text
8 * into a box, submits it, and then sees lots of debug information 8 * into a box, submits it, and then sees lots of debug information
9 * from the autocompleter that shows what omnibox would do with that 9 * from the autocompleter that shows what omnibox would do with that
10 * input. 10 * input.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 /** 56 /**
57 * Returns a simple object with information about how to display an 57 * Returns a simple object with information about how to display an
58 * autocomplete result data field. 58 * autocomplete result data field.
59 * @param {string} header the label for the top of the column/table. 59 * @param {string} header the label for the top of the column/table.
60 * @param {string} urlLabelForHeader the URL that the header should point 60 * @param {string} urlLabelForHeader the URL that the header should point
61 * to (if non-empty). 61 * to (if non-empty).
62 * @param {string} propertyName the name of the property in the autocomplete 62 * @param {string} propertyName the name of the property in the autocomplete
63 * result record that we lookup. 63 * result record that we lookup.
64 * @param {boolean} displayAlways whether the property should be displayed 64 * @param {boolean} displayAlways whether the property should be displayed
65 * regardless of whether we're in detailed more. 65 * regardless of whether we're in detailed more.
66 * @param {string} tooltip a description of the property that will be
67 * presented as a tooltip.
Mark P 2012/07/10 14:51:34 Please mention hover here.
mrossetti 2012/07/10 17:57:08 Done.
66 * @constructor 68 * @constructor
67 */ 69 */
68 function PresentationInfoRecord(header, url, propertyName, displayAlways) { 70 function PresentationInfoRecord(header, url, propertyName, displayAlways,
71 tooltip) {
69 this.header = header; 72 this.header = header;
70 this.urlLabelForHeader = url; 73 this.urlLabelForHeader = url;
71 this.propertyName = propertyName; 74 this.propertyName = propertyName;
72 this.displayAlways = displayAlways; 75 this.displayAlways = displayAlways;
76 this.tooltip = tooltip;
73 } 77 }
74 78
75 /** 79 /**
76 * A constant that's used to decide what autocomplete result 80 * A constant that's used to decide what autocomplete result
77 * properties to output in what order. This is an array of 81 * properties to output in what order. This is an array of
78 * PresentationInfoRecord() objects; for details see that 82 * PresentationInfoRecord() objects; for details see that
79 * function. 83 * function.
80 * @type {Array.<Object>} 84 * @type {Array.<Object>}
81 * @const 85 * @const
82 */ 86 */
83 var PROPERTY_OUTPUT_ORDER = [ 87 var PROPERTY_OUTPUT_ORDER = [
84 new PresentationInfoRecord('Provider', '', 'provider_name', true), 88 new PresentationInfoRecord('Provider', '', 'provider_name', true,
85 new PresentationInfoRecord('Type', '', 'type', true), 89 'The AutocompleteProvider suggesting this result.'),
86 new PresentationInfoRecord('Relevance', '', 'relevance', true), 90 new PresentationInfoRecord('Type', '', 'type', true,
87 new PresentationInfoRecord('Contents', '', 'contents', true), 91 'The type of the results.'),
Mark P 2012/07/10 14:51:34 results -> result ?
mrossetti 2012/07/10 17:57:08 Done.
88 new PresentationInfoRecord('Starred', '', 'starred', false), 92 new PresentationInfoRecord('Relevance', '', 'relevance', true,
93 'The result score. Higher is more relevant.'),
94 new PresentationInfoRecord('Contents', '', 'contents', true,
95 'The text that is presented identifying the result.'),
96 new PresentationInfoRecord('Starred', '', 'starred', false,
97 'If checked the result has been bookmarked.'),
89 new PresentationInfoRecord( 98 new PresentationInfoRecord(
90 'Is History What You Typed Match', '', 99 'HWYT', '', 'is_history_what_you_typed_match', false,
91 'is_history_what_you_typed_match', false), 100 'If checked the result is an History What You Typed Match'),
92 new PresentationInfoRecord('Description', '', 'description', false), 101 new PresentationInfoRecord('Description', '', 'description', false,
93 new PresentationInfoRecord('URL', '', 'destination_url', true), 102 'The page title or suggestion provider name.'),
94 new PresentationInfoRecord('Fill Into Edit', '', 'fill_into_edit', false), 103 new PresentationInfoRecord('URL', '', 'destination_url', true,
104 'The URL for the result.'),
105 new PresentationInfoRecord('Fill Into Edit', '', 'fill_into_edit', false,
106 'The text shown in the omnibox when the suggestion is selected.'),
95 new PresentationInfoRecord( 107 new PresentationInfoRecord(
96 'Inline Autocomplete Offset', '', 'inline_autocomplete_offset', false), 108 'IAO', '', 'inline_autocomplete_offset', false,
97 new PresentationInfoRecord('Deletable', '', 'deletable', false), 109 'The Inline Autocomplete Offset.'),
98 new PresentationInfoRecord('From Previous', '', 'from_previous', false), 110 new PresentationInfoRecord('Del', '', 'deletable', false,
111 'Checked when the results can be deleted from the visit history.'),
112 new PresentationInfoRecord('Prev', '', 'from_previous', false,
113 'A green checkmkark indicates that the result was'),
99 new PresentationInfoRecord( 114 new PresentationInfoRecord(
100 'Transition Type', 115 'Tran',
101 'http://code.google.com/codesearch#OAMlx_jo-ck/src/content/public/' + 116 'http://code.google.com/codesearch#OAMlx_jo-ck/src/content/public/' +
102 'common/page_transition_types.h&exact_package=chromium&l=24', 117 'common/page_transition_types.h&exact_package=chromium&l=24',
103 'transition', false), 118 'transition', false,
119 'How the user got to the result.'),
104 new PresentationInfoRecord( 120 new PresentationInfoRecord(
105 'Is This Provider Done', '', 'provider_done', false), 121 'Done', '', 'provider_done', false,
122 'Checked when the provider is done looking for more suggestions.'),
106 new PresentationInfoRecord( 123 new PresentationInfoRecord(
107 'Template URL', '', 'template_url', false) 124 'Template URL', '', 'template_url', false, ''),
125 new PresentationInfoRecord(
126 'Logged Info', '', 'log_info', false,
127 'Provider-specific information about each suggestion.')
108 ]; 128 ];
109 129
110 /** 130 /**
111 * Returns an HTML Element of type table row that contains the 131 * Returns an HTML Element of type table row that contains the
112 * headers we'll use for labeling the columns. If we're in 132 * headers we'll use for labeling the columns. If we're in
113 * detailed_mode, we use all the headers. If not, we only use ones 133 * detailed_mode, we use all the headers. If not, we only use ones
114 * marked displayAlways. 134 * marked displayAlways.
115 */ 135 */
116 function createAutocompleteResultTableHeader() { 136 function createAutocompleteResultTableHeader() {
117 var row = document.createElement('tr'); 137 var row = document.createElement('tr');
118 var inDetailedMode = $('show-details').checked; 138 var inDetailedMode = $('show-details').checked;
119 for (var i = 0; i < PROPERTY_OUTPUT_ORDER.length; i++) { 139 for (var i = 0; i < PROPERTY_OUTPUT_ORDER.length; i++) {
120 if (inDetailedMode || PROPERTY_OUTPUT_ORDER[i].displayAlways) { 140 if (inDetailedMode || PROPERTY_OUTPUT_ORDER[i].displayAlways) {
121 var headerCell = document.createElement('th'); 141 var headerCell = document.createElement('th');
122 if (PROPERTY_OUTPUT_ORDER[i].urlLabelForHeader != '') { 142 if (PROPERTY_OUTPUT_ORDER[i].urlLabelForHeader != '') {
123 // Wrap header text in URL. 143 // Wrap header text in URL.
124 var linkNode = document.createElement('a'); 144 var linkNode = document.createElement('a');
125 linkNode.href = PROPERTY_OUTPUT_ORDER[i].urlLabelForHeader; 145 linkNode.href = PROPERTY_OUTPUT_ORDER[i].urlLabelForHeader;
126 linkNode.textContent = PROPERTY_OUTPUT_ORDER[i].header; 146 linkNode.textContent = PROPERTY_OUTPUT_ORDER[i].header;
127 headerCell.appendChild(linkNode); 147 headerCell.appendChild(linkNode);
128 } else { 148 } else {
129 // Output header text without a URL. 149 // Output header text without a URL.
130 headerCell.textContent = PROPERTY_OUTPUT_ORDER[i].header; 150 headerCell.textContent = PROPERTY_OUTPUT_ORDER[i].header;
131 headerCell.className = 'table-header'; 151 headerCell.className = 'table-header';
152 headerCell.title = PROPERTY_OUTPUT_ORDER[i].tooltip;
132 } 153 }
133 row.appendChild(headerCell); 154 row.appendChild(headerCell);
134 } 155 }
135 } 156 }
136 return row; 157 return row;
137 } 158 }
138 159
139 /** 160 /**
140 * @param {Object} autocompleteSuggestion the particular autocomplete 161 * @param {Object} autocompleteSuggestion the particular autocomplete
141 * suggestion we're in the process of displaying. 162 * suggestion we're in the process of displaying.
142 * @param {string} propertyName the particular property of the autocomplete 163 * @param {string} propertyName the particular property of the autocomplete
143 * suggestion that should go in this cell. 164 * suggestion that should go in this cell.
144 * @return {HTMLTableCellElement} that contains the value within this 165 * @return {HTMLTableCellElement} that contains the value within this
145 * autocompleteSuggestion associated with propertyName. 166 * autocompleteSuggestion associated with propertyName.
146 */ 167 */
147 function createCellForPropertyAndRemoveProperty(autocompleteSuggestion, 168 function createCellForPropertyAndRemoveProperty(autocompleteSuggestion,
148 propertyName) { 169 propertyName) {
149 var cell = document.createElement('td'); 170 var cell = document.createElement('td');
150 if (propertyName in autocompleteSuggestion) { 171 if (propertyName in autocompleteSuggestion) {
151 if (typeof autocompleteSuggestion[propertyName] == 'boolean') { 172 if (propertyName == 'log_info') {
173 // |log_info| presents a two-column table of provider-specific data.
174 var log_table = document.createElement('table');
175 for (var log_key in autocompleteSuggestion[propertyName]) {
176 var log_row = document.createElement('tr');
177 var title_cell = document.createElement('td');
178 title_cell.textContent = log_key + ':';
179 title_cell.className = 'logged-title';
180 log_row.appendChild(title_cell);
181 var value_cell = document.createElement('td');
182 value_cell.textContent =
183 autocompleteSuggestion[propertyName][log_key];
184 value_cell.className = 'logged-value';
185 log_row.appendChild(value_cell);
186 log_table.appendChild(log_row);
187 }
188 cell.appendChild(log_table);
189 } else if (typeof autocompleteSuggestion[propertyName] == 'boolean') {
152 // If this is a boolean, display a checkmark or an X instead of 190 // If this is a boolean, display a checkmark or an X instead of
153 // the strings true or false. 191 // the strings true or false.
154 if (autocompleteSuggestion[propertyName]) { 192 if (autocompleteSuggestion[propertyName]) {
155 cell.className = 'check-mark'; 193 cell.className = 'check-mark';
156 cell.textContent = '✔'; 194 cell.textContent = '✔';
157 } else { 195 } else {
158 cell.className = 'x-mark'; 196 cell.className = 'x-mark';
159 cell.textContent = '✗'; 197 cell.textContent = '✗';
160 } 198 }
161 } else { 199 } else {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 401 }
364 402
365 return { 403 return {
366 initialize: initialize, 404 initialize: initialize,
367 startOmniboxQuery: startOmniboxQuery, 405 startOmniboxQuery: startOmniboxQuery,
368 handleNewAutocompleteResult: handleNewAutocompleteResult 406 handleNewAutocompleteResult: handleNewAutocompleteResult
369 }; 407 };
370 }); 408 });
371 409
372 document.addEventListener('DOMContentLoaded', omniboxDebug.initialize); 410 document.addEventListener('DOMContentLoaded', omniboxDebug.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698