summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-30 06:29:23 +0000
committermpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-30 06:29:23 +0000
commitae113f8339ed0559898ad1b26415add572740ceb (patch)
tree9af1903cea8fe3d3132b5af16060fc569cf26215
parentee2116c7cbf0a0e0a463ac2337367195afbb629a (diff)
downloadchromium_src-ae113f8339ed0559898ad1b26415add572740ceb.zip
chromium_src-ae113f8339ed0559898ad1b26415add572740ceb.tar.gz
chromium_src-ae113f8339ed0559898ad1b26415add572740ceb.tar.bz2
about:omnibox - add current page classification to possible settings
It's a bit ugly--I wish I could get the text and the dropdown indented a bit (the width of one checkbox) so it lines up with the other text. But it's not a big deal and not worth my time figuring out. BUG=265675 Review URL: https://codereview.chromium.org/149683005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247854 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/omnibox/omnibox.html14
-rw-r--r--chrome/browser/resources/omnibox/omnibox.js7
-rw-r--r--chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc8
-rw-r--r--chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h2
-rw-r--r--chrome/common/metrics/proto/omnibox_event.proto4
5 files changed, 31 insertions, 4 deletions
diff --git a/chrome/browser/resources/omnibox/omnibox.html b/chrome/browser/resources/omnibox/omnibox.html
index 857358d..df2c0ac 100644
--- a/chrome/browser/resources/omnibox/omnibox.html
+++ b/chrome/browser/resources/omnibox/omnibox.html
@@ -29,6 +29,20 @@
In keyword mode
</label>
</p>
+ <p>
+ Current page context:
+ <select id="page-classification">
+ <option value="0">Invalid spec</option>
+ <option value="1">(OBSOLETE) new tab page</option>
+ <option value="2">about:blank</option>
+ <option value="3">user's home page</option>
+ <option value="4">arbitrary URL</option>
+ <option value="6">search result page doing search term replacement</option>
+ <option value="9">search result page not doing search term replacement</option>
+ <option value="7" selected>new tab page with focus in omnibox</option>
+ <option value="8">new tab page with focus in fakebox</option>
+ </select>
+ </p>
<p>Display parameters:</p>
<p>
<label>
diff --git a/chrome/browser/resources/omnibox/omnibox.js b/chrome/browser/resources/omnibox/omnibox.js
index 242de52..e0721ad 100644
--- a/chrome/browser/resources/omnibox/omnibox.js
+++ b/chrome/browser/resources/omnibox/omnibox.js
@@ -28,6 +28,7 @@ cr.define('omniboxDebug', function() {
$('prevent-inline-autocomplete').addEventListener(
'change', startOmniboxQuery);
$('prefer-keyword').addEventListener('change', startOmniboxQuery);
+ $('page-classification').addEventListener('change', startOmniboxQuery);
$('show-details').addEventListener('change', refresh);
$('show-incomplete-results').addEventListener('change', refresh);
$('show-all-providers').addEventListener('change', refresh);
@@ -57,17 +58,19 @@ cr.define('omniboxDebug', function() {
function startOmniboxQuery(event) {
// First, clear the results of past calls (if any).
progressiveAutocompleteResults = [];
- // Then, call chrome with a four-element list:
+ // Then, call chrome with a five-element list:
// - first element: the value 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
+ // - fifth element: the value of page-classification
cursorPositionUsed = $('input-text').selectionEnd;
chrome.send('startOmniboxQuery', [
$('input-text').value,
cursorPositionUsed,
$('prevent-inline-autocomplete').checked,
- $('prefer-keyword').checked]);
+ $('prefer-keyword').checked,
+ parseInt($('page-classification').value)]);
// 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 33c324a..5a84bd7 100644
--- a/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc
+++ b/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc
@@ -173,7 +173,7 @@ bool OmniboxUIHandler::LookupIsTypedHost(const base::string16& host,
}
void OmniboxUIHandler::StartOmniboxQuery(const base::ListValue* input) {
- DCHECK_EQ(4u, input->GetSize());
+ DCHECK_EQ(5u, input->GetSize());
base::string16 input_string;
bool return_val = input->GetString(0, &input_string);
DCHECK(return_val);
@@ -186,6 +186,9 @@ void OmniboxUIHandler::StartOmniboxQuery(const base::ListValue* input) {
bool prefer_keyword;
return_val = input->GetBoolean(3, &prefer_keyword);
DCHECK(return_val);
+ int current_page_classification;
+ return_val = input->GetInteger(4, &current_page_classification);
+ DCHECK(return_val);
// Reset the controller. If we don't do this, then the
// AutocompleteController might inappropriately set its |minimal_changes|
// variable (or something else) and some providers will short-circuit
@@ -198,7 +201,8 @@ void OmniboxUIHandler::StartOmniboxQuery(const base::ListValue* input) {
cursor_position,
base::string16(), // user's desired tld (top-level domain)
GURL(),
- AutocompleteInput::INVALID_SPEC,
+ static_cast<AutocompleteInput::PageClassification>(
+ current_page_classification),
prevent_inline_autocomplete,
prefer_keyword,
true, // allow exact keyword matches
diff --git a/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h b/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h
index f19cbb4..ff03065 100644
--- a/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h
+++ b/chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h
@@ -55,6 +55,8 @@ class OmniboxUIHandler : public AutocompleteControllerDelegate,
// - third element: boolean indicating whether we should set
// prevent_inline_autocomplete or not.
// - fourth element: boolean indicating whether we should set prefer_keyword
+ // - fifth element: current page classification value (enum
+ // PageClassification from omnibox_event.proto)
void StartOmniboxQuery(const base::ListValue* input);
// Helper function for OnResultChanged().
diff --git a/chrome/common/metrics/proto/omnibox_event.proto b/chrome/common/metrics/proto/omnibox_event.proto
index 0896c4a..cc2ca04 100644
--- a/chrome/common/metrics/proto/omnibox_event.proto
+++ b/chrome/common/metrics/proto/omnibox_event.proto
@@ -108,6 +108,10 @@ message OmniboxEventProto {
// replacement, meaning the URL of the page should've appeared in the
// omnibox before the user started editing it, not the search terms.
SEARCH_RESULT_PAGE_NO_SEARCH_TERM_REPLACEMENT = 9;
+
+ // When adding new classifications, please consider adding them in
+ // chrome/browser/resources/omnibox/omnibox.html
+ // so that these new options are displayed on about:omnibox.
}
optional PageClassification current_page_classification = 10;