summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-05 21:06:40 +0000
committermpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-05 21:06:40 +0000
commit82de743ee576b02cb1126a4f8a02c681fe186c86 (patch)
treebc7f66a7929cd8023775a2d5ca3fbcb4c23ad0c5
parent9ae17a8da38ff537e1c535b568b005e187be0072 (diff)
downloadchromium_src-82de743ee576b02cb1126a4f8a02c681fe186c86.zip
chromium_src-82de743ee576b02cb1126a4f8a02c681fe186c86.tar.gz
chromium_src-82de743ee576b02cb1126a4f8a02c681fe186c86.tar.bz2
about:omnibox - add "in keyword mode" checkbox
BTW, I changed the order of parameters in the message that gets sent in order to correspond with the order in AutocompleteInput. BUG=165542 Review URL: https://chromiumcodereview.appspot.com/12081002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180782 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/omnibox/omnibox.html6
-rw-r--r--chrome/browser/resources/omnibox/omnibox.js11
-rw-r--r--chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc21
-rw-r--r--chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h9
4 files changed, 29 insertions, 18 deletions
diff --git a/chrome/browser/resources/omnibox/omnibox.html b/chrome/browser/resources/omnibox/omnibox.html
index 73fa0c7..857358d 100644
--- a/chrome/browser/resources/omnibox/omnibox.html
+++ b/chrome/browser/resources/omnibox/omnibox.html
@@ -23,6 +23,12 @@
Prevent inline autocomplete
</label>
</p>
+ <p>
+ <label>
+ <input id="prefer-keyword" type="checkbox">
+ In keyword mode
+ </label>
+ </p>
<p>Display parameters:</p>
<p>
<label>
diff --git a/chrome/browser/resources/omnibox/omnibox.js b/chrome/browser/resources/omnibox/omnibox.js
index 5313a41..fb0137c 100644
--- a/chrome/browser/resources/omnibox/omnibox.js
+++ b/chrome/browser/resources/omnibox/omnibox.js
@@ -27,6 +27,7 @@ cr.define('omniboxDebug', function() {
'submit', startOmniboxQuery, false);
$('prevent-inline-autocomplete').addEventListener(
'change', startOmniboxQuery);
+ $('prefer-keyword').addEventListener('change', startOmniboxQuery);
$('show-details').addEventListener('change', refresh);
$('show-incomplete-results').addEventListener('change', refresh);
$('show-all-providers').addEventListener('change', refresh);
@@ -56,15 +57,17 @@ cr.define('omniboxDebug', function() {
function startOmniboxQuery(event) {
// First, clear the results of past calls (if any).
progressiveAutocompleteResults = [];
- // Then, call chrome with a three-element list:
+ // Then, call chrome with a four-element list:
// - first element: the value in the text box
- // - second element: the value of prevent-inline-autocomplete
- // - third element: the location of the cursor in the text box
+ // - second element: the location of the cursor in the text box
+ // - third element: the value of prevent-inline-autocomplete
+ // - forth element: the value of prefer-keyword
cursorPositionUsed = $('input-text').selectionEnd;
chrome.send('startOmniboxQuery', [
$('input-text').value,
+ cursorPositionUsed,
$('prevent-inline-autocomplete').checked,
- cursorPositionUsed]);
+ $('prefer-keyword').checked]);
// Cancel the submit action. i.e., don't submit the form. (We handle
// display the results solely with Javascript.)
event.preventDefault();
diff --git a/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc b/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc
index b530b17..4449359 100644
--- a/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc
+++ b/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc
@@ -139,20 +139,21 @@ void OmniboxUIHandler::AddResultToDictionary(const std::string& prefix,
output->SetInteger(prefix + ".num_items", i);
}
-void OmniboxUIHandler::StartOmniboxQuery(
- const base::ListValue* three_element_input_string) {
- DCHECK_EQ(3u, three_element_input_string->GetSize());
+void OmniboxUIHandler::StartOmniboxQuery(const base::ListValue* input) {
+ DCHECK_EQ(4u, input->GetSize());
string16 input_string;
- bool return_val = three_element_input_string->GetString(0, &input_string);
- DCHECK(return_val);
- bool prevent_inline_autocomplete;
- return_val =
- three_element_input_string->GetBoolean(1, &prevent_inline_autocomplete);
+ bool return_val = input->GetString(0, &input_string);
DCHECK(return_val);
int cursor_position_int;
- return_val = three_element_input_string->GetInteger(2, &cursor_position_int);
+ return_val = input->GetInteger(1, &cursor_position_int);
DCHECK(return_val);
size_t cursor_position = cursor_position_int;
+ bool prevent_inline_autocomplete;
+ return_val = input->GetBoolean(2, &prevent_inline_autocomplete);
+ DCHECK(return_val);
+ bool prefer_keyword;
+ return_val = input->GetBoolean(3, &prefer_keyword);
+ DCHECK(return_val);
string16 empty_string;
// Reset the controller. If we don't do this, then the
// AutocompleteController might inappropriately set its |minimal_changes|
@@ -166,7 +167,7 @@ void OmniboxUIHandler::StartOmniboxQuery(
cursor_position,
empty_string, // user's desired tld (top-level domain)
prevent_inline_autocomplete,
- false, // no preferred keyword provider
+ prefer_keyword,
true, // allow exact keyword matches
AutocompleteInput::ALL_MATCHES)); // want all matches
}
diff --git a/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h b/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h
index e040493..513d011 100644
--- a/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h
+++ b/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h
@@ -49,12 +49,13 @@ class OmniboxUIHandler : public AutocompleteControllerDelegate,
private:
// Gets called from the javascript when a user enters text into the
// chrome://omnibox/ text box and clicks submit or hits enter.
- // |three_element_input_string| is expected to be a three-element list:
+ // |input| is expected to be a four-element list:
// - first element: input string.
- // - second element: boolean indicating whether we should set
+ // - second element: the cursor position.
+ // - third element: boolean indicating whether we should set
// prevent_inline_autocomplete or not.
- // - third element: the cursor position.
- void StartOmniboxQuery(const base::ListValue* two_element_input_string);
+ // - fourth element: boolean indicating whether we should set prefer_keyword
+ void StartOmniboxQuery(const base::ListValue* input);
// Helper function for OnResultChanged().
// Takes an iterator over AutocompleteMatches and packages them into