Chromium Code Reviews| Index: chrome/browser/autocomplete/autocomplete_edit.cc |
| diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc |
| index eb6c6a72b782779372fb4ea3fb45d43dfe1b4950..a21fc3f8a3290d16d4d5b64a9a70fdc5b1744ecd 100644 |
| --- a/chrome/browser/autocomplete/autocomplete_edit.cc |
| +++ b/chrome/browser/autocomplete/autocomplete_edit.cc |
| @@ -7,6 +7,7 @@ |
| #include <string> |
| #include "base/basictypes.h" |
| +#include "base/command_line.h" |
| #include "base/metrics/histogram.h" |
| #include "base/string_util.h" |
| #include "base/utf_string_conversions.h" |
| @@ -23,6 +24,7 @@ |
| #include "chrome/browser/instant/instant_controller.h" |
| #include "chrome/browser/net/predictor_api.h" |
| #include "chrome/browser/net/url_fixer_upper.h" |
| +#include "chrome/browser/prerender/prerender_manager.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/search_engines/template_url.h" |
| #include "chrome/browser/search_engines/template_url_service.h" |
| @@ -30,6 +32,7 @@ |
| #include "chrome/browser/ui/browser_list.h" |
| #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| +#include "chrome/common/chrome_switches.h" |
| #include "chrome/common/url_constants.h" |
| #include "content/browser/user_metrics.h" |
| #include "content/common/notification_service.h" |
| @@ -79,7 +82,7 @@ AutocompleteEditModel::AutocompleteEditModel( |
| control_key_state_(UP), |
| is_keyword_hint_(false), |
| profile_(profile), |
| - update_instant_(true), |
| + in_revert_(true), |
|
sky
2011/06/20 20:53:49
Sorry I wasn't clear. in_revert_ and update_instan
dominich
2011/06/20 21:02:36
Done.
|
| allow_exact_keyword_match_(false), |
| instant_complete_behavior_(INSTANT_COMPLETE_DELAYED) { |
| } |
| @@ -213,22 +216,36 @@ void AutocompleteEditModel::OnChanged() { |
| string16 suggested_text; |
| TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); |
| bool might_support_instant = false; |
| - if (update_instant_ && instant && tab) { |
| - if (user_input_in_progress() && popup_->IsOpen()) { |
| - AutocompleteMatch current_match = CurrentMatch(); |
| - if (current_match.destination_url == PermanentURL()) { |
| - // The destination is the same as the current url. This typically |
| - // happens if the user presses the down error in the omnibox, in which |
| - // case we don't want to load a preview. |
| - instant->DestroyPreviewContentsAndLeaveActive(); |
| + if (in_revert_ && tab) { |
| + if (instant) { |
| + if (user_input_in_progress() && popup_->IsOpen()) { |
| + AutocompleteMatch current_match = CurrentMatch(); |
| + if (current_match.destination_url == PermanentURL()) { |
| + // The destination is the same as the current url. This typically |
| + // happens if the user presses the down error in the omnibox, in which |
| + // case we don't want to load a preview. |
| + instant->DestroyPreviewContentsAndLeaveActive(); |
| + } else { |
| + instant->Update(tab, current_match, view_->GetText(), |
| + UseVerbatimInstant(), &suggested_text); |
| + } |
| } else { |
| - instant->Update(tab, CurrentMatch(), view_->GetText(), |
| - UseVerbatimInstant(), &suggested_text); |
| + instant->DestroyPreviewContents(); |
| + } |
| + might_support_instant = instant->MightSupportInstant(); |
| + } else if (tab->tab_contents() && user_input_in_progress() && |
| + popup_->IsOpen()) { |
| + // Start Prerender of this page instead. |
| + CommandLine* cl = CommandLine::ForCurrentProcess(); |
| + if (cl->HasSwitch(switches::kPrerenderFromOmnibox)) { |
| + prerender::PrerenderManager* prerender_manager = |
| + tab->tab_contents()->profile()->GetPrerenderManager(); |
| + if (prerender_manager) { |
| + prerender_manager->AddPrerenderWithNoTag( |
| + CurrentMatch().destination_url); |
| + } |
| } |
| - } else { |
| - instant->DestroyPreviewContents(); |
| } |
| - might_support_instant = instant->MightSupportInstant(); |
| } |
| if (!might_support_instant) { |
| @@ -399,7 +416,7 @@ void AutocompleteEditModel::StartAutocomplete( |
| } |
| void AutocompleteEditModel::StopAutocomplete() { |
| - if (popup_->IsOpen() && update_instant_) { |
| + if (popup_->IsOpen() && in_revert_) { |
| InstantController* instant = controller_->GetInstant(); |
| if (instant && !instant->commit_on_mouse_up()) |
| instant->DestroyPreviewContents(); |
| @@ -534,7 +551,7 @@ void AutocompleteEditModel::OpenMatch(const AutocompleteMatch& match, |
| } |
| if (disposition != NEW_BACKGROUND_TAB) { |
| - update_instant_ = false; |
| + in_revert_ = false; |
| view_->RevertAll(); // Revert the box to its unedited state |
| } |
| @@ -548,7 +565,7 @@ void AutocompleteEditModel::OpenMatch(const AutocompleteMatch& match, |
| InstantController* instant = controller_->GetInstant(); |
| if (instant && !popup_->IsOpen()) |
| instant->DestroyPreviewContents(); |
| - update_instant_ = true; |
| + in_revert_ = true; |
| } |
| bool AutocompleteEditModel::AcceptKeyword() { |