diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 17:45:33 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 17:45:33 +0000 |
commit | 56ad3797dc8ea7d757dc2b12d606c14cedd564e1 (patch) | |
tree | 26fab7c6d4cbb0358b404ca3eb488aae75ebe1d3 /chrome/browser/autocomplete/autocomplete_edit.cc | |
parent | 79b663c6e6ddf89e85cdc566b5d4f368465bb858 (diff) | |
download | chromium_src-56ad3797dc8ea7d757dc2b12d606c14cedd564e1.zip chromium_src-56ad3797dc8ea7d757dc2b12d606c14cedd564e1.tar.gz chromium_src-56ad3797dc8ea7d757dc2b12d606c14cedd564e1.tar.bz2 |
First pass at experimental omnibox API. There are plenty of rough edges and features to work on, but it's in a usable state.
When an extension is installed that specifies an omnibox keyword in its manifest, we add that keyword to the user's list of Search Engines. The user can then edit this keyword later.
I'm leveraging most of the original search engine keyword code. An extension keyword has a special URL that identifies it as an extension keyword. There is some special case code to treat these keywords slightly differently throughout
the omnibox code.
BUG=38884
Review URL: http://codereview.chromium.org/2078021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48503 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit.cc')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit.cc | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc index a650e1d..de74891 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.cc +++ b/chrome/browser/autocomplete/autocomplete_edit.cc @@ -15,6 +15,7 @@ #include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/autocomplete/keyword_provider.h" #include "chrome/browser/command_updater.h" +#include "chrome/browser/extensions/extension_omnibox_api.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/net/dns_global.h" #include "chrome/browser/net/url_fixer_upper.h" @@ -265,6 +266,17 @@ void AutocompleteEditModel::AcceptInput(WindowOpenDisposition disposition, AutocompleteMatch match; GURL alternate_nav_url; GetInfoForCurrentText(&match, &alternate_nav_url); + + if (match.template_url && match.template_url->IsExtensionKeyword()) { + // Strip the keyword + leading space off the input. + size_t prefix_length = match.template_url->keyword().size() + 1; + ExtensionOmniboxEventRouter::OnInputEntered( + profile_, match.template_url->GetExtensionId(), + WideToUTF8(match.fill_into_edit.substr(prefix_length))); + view_->RevertAll(); + return; + } + if (!match.destination_url.is_valid()) return; @@ -606,9 +618,13 @@ void AutocompleteEditModel::Observe(NotificationType type, inline_autocomplete_text = match->fill_into_edit.substr(match->inline_autocomplete_offset); } - // Warm up DNS Prefetch Cache. - chrome_browser_net::DnsPrefetchUrl(match->destination_url, - IsPreconnectable(match->type)); + + if (!match->destination_url.SchemeIs(chrome::kExtensionScheme)) { + // Warm up DNS Prefetch Cache. + chrome_browser_net::DnsPrefetchUrl(match->destination_url, + IsPreconnectable(match->type)); + } + // We could prefetch the alternate nav URL, if any, but because there // can be many of these as a user types an initial series of characters, // the OS DNS cache could suffer eviction problems for minimal gain. |