diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 18:18:59 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 18:18:59 +0000 |
commit | 7c71e94b9702df4cb7eec1ae4920847a4269674f (patch) | |
tree | d2d1f83a9b7b0a9b4d23cdd7f613bf58da6f032a /chrome/browser | |
parent | 9657938c4b074eadb8c4004598469ef164c5ff2a (diff) | |
download | chromium_src-7c71e94b9702df4cb7eec1ae4920847a4269674f.zip chromium_src-7c71e94b9702df4cb7eec1ae4920847a4269674f.tar.gz chromium_src-7c71e94b9702df4cb7eec1ae4920847a4269674f.tar.bz2 |
Makes instant use instant_url for instant results rather than search
url.
BUG=58756
TEST=none
Review URL: http://codereview.chromium.org/3754004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62591 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/instant/instant_controller.cc | 21 | ||||
-rw-r--r-- | chrome/browser/instant/instant_controller.h | 8 | ||||
-rw-r--r-- | chrome/browser/instant/instant_loader.cc | 14 | ||||
-rw-r--r-- | chrome/browser/instant/instant_loader.h | 2 |
4 files changed, 27 insertions, 18 deletions
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index 5afaca7..24c70f8 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -72,13 +72,14 @@ void InstantController::Update(TabContents* tab_contents, return; } - TemplateURLID template_url_id = GetTemplateURLID(match); + const TemplateURL* template_url = GetTemplateURL(match); + TemplateURLID template_url_id = template_url ? template_url->id() : 0; if (!loader_manager_.get()) loader_manager_.reset(new InstantLoaderManager(this)); if (ShouldUpdateNow(template_url_id, match.destination_url)) { - UpdateLoader(template_url_id, match.destination_url, match.transition, + UpdateLoader(template_url, match.destination_url, match.transition, user_text, suggested_text); } else { ScheduleUpdate(match.destination_url); @@ -269,11 +270,11 @@ void InstantController::ProcessScheduledUpdate() { // We only delay loading of sites that don't support instant, so we can ignore // suggested_text here. string16 suggested_text; - UpdateLoader(0, scheduled_url_, last_transition_type_, string16(), + UpdateLoader(NULL, scheduled_url_, last_transition_type_, string16(), &suggested_text); } -void InstantController::UpdateLoader(TemplateURLID template_url_id, +void InstantController::UpdateLoader(const TemplateURL* template_url, const GURL& url, PageTransition::Type transition_type, const string16& user_text, @@ -282,11 +283,12 @@ void InstantController::UpdateLoader(TemplateURLID template_url_id, InstantLoader* old_loader = loader_manager_->current_loader(); scoped_ptr<InstantLoader> owned_loader; + TemplateURLID template_url_id = template_url ? template_url->id() : 0; InstantLoader* new_loader = loader_manager_->UpdateLoader(template_url_id, &owned_loader); new_loader->SetOmniboxBounds(omnibox_bounds_); - new_loader->Update(tab_contents_, template_url_id, url, transition_type, + new_loader->Update(tab_contents_, template_url, url, transition_type, user_text, suggested_text); if (old_loader != new_loader && new_loader->ready()) delegate_->ShowInstant(new_loader->preview_contents()); @@ -308,7 +310,7 @@ void InstantController::ClearBlacklist() { blacklisted_ids_.clear(); } -TemplateURLID InstantController::GetTemplateURLID( +const TemplateURL* InstantController::GetTemplateURL( const AutocompleteMatch& match) { const TemplateURL* template_url = match.template_url; if (match.type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || @@ -318,9 +320,10 @@ TemplateURLID InstantController::GetTemplateURLID( template_url = model ? model->GetDefaultSearchProvider() : NULL; } if (template_url && template_url->id() && + template_url->instant_url() && !IsBlacklistedFromInstant(template_url->id()) && - TemplateURL::SupportsReplacement(template_url)) { - return template_url->id(); + template_url->instant_url()->SupportsReplacement()) { + return template_url; } - return 0; + return NULL; } diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h index d06bde6..0430083 100644 --- a/chrome/browser/instant/instant_controller.h +++ b/chrome/browser/instant/instant_controller.h @@ -136,7 +136,7 @@ class InstantController : public InstantLoaderDelegate { // Updates InstantLoaderManager and its current InstantLoader. This is invoked // internally from Update. - void UpdateLoader(TemplateURLID template_url_id, + void UpdateLoader(const TemplateURL* template_url, const GURL& url, PageTransition::Type transition_type, const string16& user_text, @@ -155,9 +155,9 @@ class InstantController : public InstantLoaderDelegate { // Clears the set of search engines blacklisted. void ClearBlacklist(); - // Returns the id of the template url to use for the specified - // AutocompleteMatch. - TemplateURLID GetTemplateURLID(const AutocompleteMatch& match); + // Returns the TemplateURL to use for the specified AutocompleteMatch, or NULL + // if non TemplateURL should be used. + const TemplateURL* GetTemplateURL(const AutocompleteMatch& match); InstantDelegate* delegate_; diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc index ed0f59e..b7d6554 100644 --- a/chrome/browser/instant/instant_loader.cc +++ b/chrome/browser/instant/instant_loader.cc @@ -517,7 +517,7 @@ InstantLoader::~InstantLoader() { } void InstantLoader::Update(TabContents* tab_contents, - TemplateURLID template_url_id, + const TemplateURL* template_url, const GURL& url, PageTransition::Type transition_type, const string16& user_text, @@ -557,8 +557,8 @@ void InstantLoader::Update(TabContents* tab_contents, } preview_tab_contents_delegate_->PrepareForNewLoad(); - if (template_url_id) { - DCHECK(template_url_id_ == template_url_id); + if (template_url) { + DCHECK(template_url_id_ == template_url->id()); if (!created_preview_contents) { if (is_waiting_for_load()) { // The page hasn't loaded yet. We'll send the script down when it does. @@ -571,8 +571,14 @@ void InstantLoader::Update(TabContents* tab_contents, *suggested_text = complete_suggested_text_.substr(user_text_.size()); } } else { + // Load the instant URL. We don't reflect the url we load in url() as + // callers expect that we're loading the URL they tell us to. + GURL instant_url( + template_url->instant_url()->ReplaceSearchTerms( + *template_url, UTF16ToWideHack(user_text), -1, std::wstring())); initial_instant_url_ = url; - preview_contents_->controller().LoadURL(url, GURL(), transition_type); + preview_contents_->controller().LoadURL( + instant_url, GURL(), transition_type); frame_load_observer_.reset(new FrameLoadObserver(this, user_text_)); } } else { diff --git a/chrome/browser/instant/instant_loader.h b/chrome/browser/instant/instant_loader.h index cc9cd5e..15746e5 100644 --- a/chrome/browser/instant/instant_loader.h +++ b/chrome/browser/instant/instant_loader.h @@ -39,7 +39,7 @@ class InstantLoader { // Invoked to load a URL. |tab_contents| is the TabContents the preview is // going to be shown on top of and potentially replace. void Update(TabContents* tab_contents, - TemplateURLID template_url_id, + const TemplateURL* template_url, const GURL& url, PageTransition::Type transition_type, const string16& user_text, |