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

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

Issue 149683005: about:omnibox - add current page classification to possible settings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 10 matching lines...) Expand all
21 21
22 /** 22 /**
23 * Register our event handlers. 23 * Register our event handlers.
24 */ 24 */
25 function initialize() { 25 function initialize() {
26 $('omnibox-input-form').addEventListener( 26 $('omnibox-input-form').addEventListener(
27 'submit', startOmniboxQuery, false); 27 'submit', startOmniboxQuery, false);
28 $('prevent-inline-autocomplete').addEventListener( 28 $('prevent-inline-autocomplete').addEventListener(
29 'change', startOmniboxQuery); 29 'change', startOmniboxQuery);
30 $('prefer-keyword').addEventListener('change', startOmniboxQuery); 30 $('prefer-keyword').addEventListener('change', startOmniboxQuery);
31 $('page-classification').addEventListener('change', startOmniboxQuery);
31 $('show-details').addEventListener('change', refresh); 32 $('show-details').addEventListener('change', refresh);
32 $('show-incomplete-results').addEventListener('change', refresh); 33 $('show-incomplete-results').addEventListener('change', refresh);
33 $('show-all-providers').addEventListener('change', refresh); 34 $('show-all-providers').addEventListener('change', refresh);
34 } 35 }
35 36
36 /** 37 /**
37 * @type {Array.<Object>} an array of all autocomplete results we've seen 38 * @type {Array.<Object>} an array of all autocomplete results we've seen
38 * for this query. We append to this list once for every call to 39 * for this query. We append to this list once for every call to
39 * handleNewAutocompleteResult. For details on the structure of 40 * handleNewAutocompleteResult. For details on the structure of
40 * the object inside, see the comments by addResultToOutput. 41 * the object inside, see the comments by addResultToOutput.
41 */ 42 */
42 var progressiveAutocompleteResults = []; 43 var progressiveAutocompleteResults = [];
43 44
44 /** 45 /**
45 * @type {number} the value for cursor position we sent with the most 46 * @type {number} the value for cursor position we sent with the most
46 * recent request. We need to remember this in order to display it 47 * recent request. We need to remember this in order to display it
47 * in the output; otherwise it's hard or impossible to determine 48 * in the output; otherwise it's hard or impossible to determine
48 * from screen captures or print-to-PDFs. 49 * from screen captures or print-to-PDFs.
49 */ 50 */
50 var cursorPositionUsed = -1; 51 var cursorPositionUsed = -1;
51 52
52 /** 53 /**
53 * Extracts the input text from the text field and sends it to the 54 * Extracts the input text from the text field and sends it to the
54 * C++ portion of chrome to handle. The C++ code will iteratively 55 * C++ portion of chrome to handle. The C++ code will iteratively
55 * call handleNewAutocompleteResult as results come in. 56 * call handleNewAutocompleteResult as results come in.
56 */ 57 */
57 function startOmniboxQuery(event) { 58 function startOmniboxQuery(event) {
58 // First, clear the results of past calls (if any). 59 // First, clear the results of past calls (if any).
59 progressiveAutocompleteResults = []; 60 progressiveAutocompleteResults = [];
60 // Then, call chrome with a four-element list: 61 // Then, call chrome with a five-element list:
61 // - first element: the value in the text box 62 // - first element: the value in the text box
62 // - second element: the location of the cursor in the text box 63 // - second element: the location of the cursor in the text box
63 // - third element: the value of prevent-inline-autocomplete 64 // - third element: the value of prevent-inline-autocomplete
64 // - forth element: the value of prefer-keyword 65 // - forth element: the value of prefer-keyword
66 // - fifth element: the value of page-classification
65 cursorPositionUsed = $('input-text').selectionEnd; 67 cursorPositionUsed = $('input-text').selectionEnd;
66 chrome.send('startOmniboxQuery', [ 68 chrome.send('startOmniboxQuery', [
67 $('input-text').value, 69 $('input-text').value,
68 cursorPositionUsed, 70 cursorPositionUsed,
69 $('prevent-inline-autocomplete').checked, 71 $('prevent-inline-autocomplete').checked,
70 $('prefer-keyword').checked]); 72 $('prefer-keyword').checked,
73 parseInt($('page-classification').value)]);
71 // Cancel the submit action. i.e., don't submit the form. (We handle 74 // Cancel the submit action. i.e., don't submit the form. (We handle
72 // display the results solely with Javascript.) 75 // display the results solely with Javascript.)
73 event.preventDefault(); 76 event.preventDefault();
74 } 77 }
75 78
76 /** 79 /**
77 * Returns a simple object with information about how to display an 80 * Returns a simple object with information about how to display an
78 * autocomplete result data field. 81 * autocomplete result data field.
79 * @param {string} header the label for the top of the column/table. 82 * @param {string} header the label for the top of the column/table.
80 * @param {string} urlLabelForHeader the URL that the header should point 83 * @param {string} urlLabelForHeader the URL that the header should point
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 461 }
459 462
460 return { 463 return {
461 initialize: initialize, 464 initialize: initialize,
462 startOmniboxQuery: startOmniboxQuery, 465 startOmniboxQuery: startOmniboxQuery,
463 handleNewAutocompleteResult: handleNewAutocompleteResult 466 handleNewAutocompleteResult: handleNewAutocompleteResult
464 }; 467 };
465 }); 468 });
466 469
467 document.addEventListener('DOMContentLoaded', omniboxDebug.initialize); 470 document.addEventListener('DOMContentLoaded', omniboxDebug.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698