Commit 3153e097 authored by Mark Pearson's avatar Mark Pearson Committed by Commit Bot

chrome://omnibox - Show Inferred Input Type

as this can affect what suggestions are offered a lot, and sometimes
isn't obvious from looking at the input.

Only show this in "detailed" mode.

Also move cursor position information into detailed mode
section, as we rarely need it.

Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Ic78751fe07c968f4fa30854cb7e3bb1442f0fcb2
Reviewed-on: https://chromium-review.googlesource.com/1119232Reviewed-by: default avatarGreg Kerr <kerrnel@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Commit-Queue: Mark Pearson <mpearson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575114}
parent 6599d295
......@@ -261,6 +261,15 @@ function createCellForPropertyAndRemoveProperty(
return cell;
}
/**
* Appends a paragraph node containing text to the parent node.
*/
function addParagraph(parent, text) {
var p = document.createElement('p');
p.textContent = text;
parent.appendChild(p);
}
/**
* Appends some human-readable information about the provided
* autocomplete result to the HTML node with id omnibox-debug-text.
......@@ -274,32 +283,28 @@ function addResultToOutput(result) {
var showIncompleteResults = $('show-incomplete-results').checked;
var showPerProviderResults = $('show-all-providers').checked;
// Always output cursor position.
var p = document.createElement('p');
p.textContent = 'cursor position = ' + cursorPositionUsed;
output.appendChild(p);
// Output the result-level features in detailed mode and in
// show incomplete results mode. We do the latter because without
// these result-level features, one can't make sense of each
// batch of results.
if (inDetailedMode || showIncompleteResults) {
var p1 = document.createElement('p');
p1.textContent =
'elapsed time = ' + result.timeSinceOmniboxStartedMs + 'ms';
output.appendChild(p1);
var p2 = document.createElement('p');
p2.textContent = 'all providers done = ' + result.done;
output.appendChild(p2);
var p3 = document.createElement('p');
p3.textContent = 'host = ' + result.host;
addParagraph(output, `cursor position = ${cursorPositionUsed}`);
addParagraph(output, `inferred input type = ${result.type}`);
addParagraph(
output, `elapsed time = ${result.timeSinceOmniboxStartedMs}ms`);
addParagraph(output, `all providers done = ${result.done}`);
var p = document.createElement('p');
p.textContent = `host = ${result.host}`;
// The field isn't actually optional in the mojo object; instead it assumes
// failed lookups are not typed hosts. Fix this to make it optional.
// http://crbug.com/863201
if ('isTypedHost' in result) {
// Only output the isTypedHost information if available. (It may
// be missing if the history database lookup failed.)
p3.textContent =
p3.textContent + ' has isTypedHost = ' + result.isTypedHost;
p.textContent =
p.textContent + ` has isTypedHost = ${result.isTypedHost}`;
}
output.appendChild(p3);
output.appendChild(p);
}
// Combined results go after the lines below.
......
......@@ -43,6 +43,9 @@ struct OmniboxResult {
bool done;
// Time delta since the request was started, in milliseconds.
int32 time_since_omnibox_started_ms;
// The inferred metrics::OmniboxInputType of the request represented as a
// string.
string type;
string host;
bool is_typed_host;
array<AutocompleteMatch> combined_results;
......
......@@ -130,6 +130,7 @@ void OmniboxPageHandler::OnResultChanged(bool default_match_changed) {
const base::string16 host =
input_.text().substr(input_.parts().host.begin, input_.parts().host.len);
result->host = base::UTF16ToUTF8(host);
result->type = AutocompleteInput::TypeToString(input_.type());
bool is_typed_host;
if (!LookupIsTypedHost(host, &is_typed_host))
is_typed_host = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment