Index: chrome/browser/ui/search/instant_controller.cc |
diff --git a/chrome/browser/ui/search/instant_controller.cc b/chrome/browser/ui/search/instant_controller.cc |
index 83f1e345833a15ef85e88f0bd2df06d9dfbae3a5..9a6629fbfaa4462ddf443de07225d56a729cca66 100644 |
--- a/chrome/browser/ui/search/instant_controller.cc |
+++ b/chrome/browser/ui/search/instant_controller.cc |
@@ -268,7 +268,7 @@ bool InstantController::Update(const AutocompleteMatch& match, |
// DCHECKs below because |user_text| and |full_text| have different semantics |
// when keyword search is in effect. |
if (is_keyword_search) { |
- if (UseInstantTabToShowSuggestions()) |
+ if (instant_tab_) |
instant_tab_->Update(string16(), 0, 0, true); |
else |
HideOverlay(); |
@@ -321,8 +321,8 @@ bool InstantController::Update(const AutocompleteMatch& match, |
// If we have an |instant_tab_| use it, else ensure we have an overlay that is |
// current or is using the local overlay. |
- if (!UseInstantTabToShowSuggestions() && |
- !(overlay_ && overlay_->IsLocalOverlay()) && |
+ if (!instant_tab_ && |
+ !(overlay_ && overlay_->IsLocalNTP()) && |
!EnsureOverlayIsCurrent(false)) { |
HideOverlay(); |
return false; |
@@ -333,7 +333,7 @@ bool InstantController::Update(const AutocompleteMatch& match, |
if (!user_input_in_progress) { |
// If the user isn't typing and the omnibox popup is closed, it means a |
// regular navigation, tab-switch or the user hitting Escape. |
- if (UseInstantTabToShowSuggestions()) { |
+ if (instant_tab_) { |
// The user is on a search results page. It may be showing results for |
// a partial query the user typed before they hit Escape. Send the |
// omnibox text to the page to restore the original results. |
@@ -357,7 +357,7 @@ bool InstantController::Update(const AutocompleteMatch& match, |
last_omnibox_text_.clear(); |
last_user_text_.clear(); |
last_suggestion_ = InstantSuggestion(); |
- if (UseInstantTabToShowSuggestions()) { |
+ if (instant_tab_) { |
// On a search results page, tell it to clear old results. |
instant_tab_->Update(string16(), 0, 0, true); |
} else if (search_mode_.is_origin_ntp()) { |
@@ -387,7 +387,7 @@ bool InstantController::Update(const AutocompleteMatch& match, |
last_omnibox_text_.clear(); |
last_user_text_.clear(); |
last_suggestion_ = InstantSuggestion(); |
- if (UseInstantTabToShowSuggestions()) |
+ if (instant_tab_) |
instant_tab_->Update(string16(), 0, 0, true); |
else if (search_mode_.is_origin_ntp()) |
overlay_->Update(string16(), 0, 0, true); |
@@ -442,7 +442,7 @@ bool InstantController::Update(const AutocompleteMatch& match, |
if (!extended_enabled_) |
search_mode_.mode = SearchMode::MODE_SEARCH_SUGGESTIONS; |
- if (UseInstantTabToShowSuggestions()) { |
+ if (instant_tab_) { |
// If we have an |instant_tab_| but it doesn't support Instant yet, sever |
// the connection to it so we use the overlay instead. This ensures that the |
// user interaction will be responsive and handles cases where |
@@ -453,7 +453,7 @@ bool InstantController::Update(const AutocompleteMatch& match, |
instant_tab_.reset(); |
} |
- if (!UseInstantTabToShowSuggestions()) { |
+ if (!instant_tab_) { |
if (first_interaction_time_.is_null()) |
first_interaction_time_ = base::Time::Now(); |
allow_overlay_to_show_search_suggestions_ = true; |
@@ -461,8 +461,8 @@ bool InstantController::Update(const AutocompleteMatch& match, |
// For extended mode, if the loader is not ready at this point, switch over |
// to a backup loader. |
if (extended_enabled_ && !overlay_->supports_instant() && |
- !overlay_->IsLocalOverlay() && browser_->GetActiveWebContents()) { |
- CreateOverlay(chrome::kChromeSearchLocalOmniboxPopupURL, |
+ !overlay_->IsLocalNTP() && browser_->GetActiveWebContents()) { |
+ CreateOverlay(chrome::GetLocalInstantURL(browser_->profile()).spec(), |
browser_->GetActiveWebContents()); |
} |
@@ -555,7 +555,7 @@ void InstantController::HandleAutocompleteResults( |
// Unless we are talking to the local overlay, skip SearchProvider, since |
samarth
2013/04/16 16:55:10
This check is no longer accurate (note that it cur
jeremycho
2013/04/16 20:39:09
Done.
|
// it only echoes suggestions. |
if (from_search_provider && |
- (UseInstantTabToShowSuggestions() || !overlay_->IsLocalOverlay())) |
+ (instant_tab_ || !overlay_->IsLocalNTP())) |
continue; |
// Only send autocomplete results when all the providers are done. Skip |
// this check for the SearchProvider, since it isn't done until the page |
@@ -587,7 +587,7 @@ void InstantController::HandleAutocompleteResults( |
"HandleAutocompleteResults: total_results=%d", |
static_cast<int>(results.size()))); |
- if (UseInstantTabToShowSuggestions()) |
+ if (instant_tab_) |
instant_tab_->SendAutocompleteResults(results); |
else |
overlay_->SendAutocompleteResults(results); |
@@ -600,7 +600,7 @@ bool InstantController::OnUpOrDownKeyPressed(int count) { |
if (!instant_tab_ && !overlay_) |
return false; |
- if (UseInstantTabToShowSuggestions()) |
+ if (instant_tab_) |
instant_tab_->UpOrDownKeyPressed(count); |
else |
overlay_->UpOrDownKeyPressed(count); |
@@ -629,7 +629,7 @@ void InstantController::OnCancel(const AutocompleteMatch& match, |
// inline autocompletion is "zon.com"; so the selection should span from |
// user_text.size() to full_text.size(). The selection bounds are inverted |
// because the caret is at the end of |user_text|, not |full_text|. |
- if (UseInstantTabToShowSuggestions()) { |
+ if (instant_tab_) { |
instant_tab_->CancelSelection(user_text, full_text.size(), user_text.size(), |
last_verbatim_); |
} else { |
@@ -668,8 +668,9 @@ bool InstantController::CommitIfPossible(InstantCommitType type) { |
// If we are on an already committed search results page, send a submit event |
// to the page, but otherwise, nothing else to do. |
- if (UseInstantTabToShowSuggestions()) { |
+ if (instant_tab_) { |
if (type == INSTANT_COMMIT_PRESSED_ENTER && |
+ !instant_tab_->IsLocalNTP() && |
(last_match_was_search_ || |
last_suggestion_.behavior == INSTANT_COMPLETE_NEVER)) { |
last_suggestion_.text.clear(); |
@@ -697,7 +698,7 @@ bool InstantController::CommitIfPossible(InstantCommitType type) { |
return false; |
// Never commit the local overlay. |
- if (overlay_->IsLocalOverlay()) |
+ if (overlay_->IsLocalNTP()) |
return false; |
if (type == INSTANT_COMMIT_FOCUS_LOST) { |
@@ -929,7 +930,7 @@ void InstantController::FocusedOverlayContents() { |
void InstantController::ReloadOverlayIfStale() { |
// The local overlay is never stale. |
- if (overlay_ && overlay_->IsLocalOverlay()) |
+ if (overlay_ && overlay_->IsLocalNTP()) |
return; |
// If the overlay is showing or the omnibox has focus, don't delete the |
@@ -1119,7 +1120,7 @@ void InstantController::SetSuggestions( |
// Ignore if the message is from an unexpected source. |
if (IsContentsFrom(ntp(), contents)) |
return; |
- if (UseInstantTabToShowSuggestions() && |
+ if (instant_tab_ && |
samarth
2013/04/16 16:55:10
nit: fits on one line?
jeremycho
2013/04/16 20:39:09
Done.
|
!IsContentsFrom(instant_tab(), contents)) |
return; |
if (IsContentsFrom(overlay(), contents) && |
@@ -1132,7 +1133,7 @@ void InstantController::SetSuggestions( |
// TODO(samarth): allow InstantTabs to call SetSuggestions() from the NTP once |
// that is better supported. |
- bool can_use_instant_tab = UseInstantTabToShowSuggestions() && |
+ bool can_use_instant_tab = instant_tab_ && |
samarth
2013/04/16 16:55:10
nit: fits on one line?
jeremycho
2013/04/16 20:39:09
Done.
|
search_mode_.is_search(); |
bool can_use_overlay = search_mode_.is_search_suggestions() && |
!last_omnibox_text_.empty(); |
@@ -1268,7 +1269,7 @@ void InstantController::ResetNTP(bool ignore_blacklist, bool use_local_ntp) { |
std::string instant_url; |
if (use_local_ntp || |
!GetInstantURL(browser_->profile(), ignore_blacklist, &instant_url)) |
- instant_url = chrome::kChromeSearchLocalNtpUrl; |
+ instant_url = chrome::GetLocalInstantURL(browser_->profile()).spec(); |
ntp_.reset(new InstantNTP(this, instant_url)); |
ntp_->InitContents(browser_->profile(), browser_->GetActiveWebContents(), |
base::Bind(&InstantController::ResetNTP, |
@@ -1287,7 +1288,7 @@ bool InstantController::EnsureOverlayIsCurrent(bool ignore_blacklist) { |
if (!GetInstantURL(profile, ignore_blacklist, &instant_url)) { |
// If we are in extended mode, fallback to the local overlay. |
if (extended_enabled_) |
- instant_url = chrome::kChromeSearchLocalOmniboxPopupURL; |
+ instant_url = chrome::GetLocalInstantURL(browser_->profile()).spec(); |
else |
return false; |
} |
@@ -1369,7 +1370,7 @@ void InstantController::HideInternal() { |
void InstantController::ShowOverlay(int height, InstantSizeUnits units) { |
// If we are on a committed search results page, the |overlay_| is not in use. |
- if (UseInstantTabToShowSuggestions()) |
+ if (instant_tab_) |
return; |
LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf( |
@@ -1398,7 +1399,7 @@ void InstantController::ShowOverlay(int height, InstantSizeUnits units) { |
// - Instant is disabled. The page needs to be able to show only a dropdown. |
// - The page is over a website other than search or an NTP, and is not |
// already showing at 100% height. |
- if (overlay_->IsLocalOverlay() || !instant_enabled_ || |
+ if (overlay_->IsLocalNTP() || !instant_enabled_ || |
(search_mode_.is_origin_default() && !IsFullHeight(model_))) |
model_.SetOverlayState(search_mode_, height, units); |
else |
@@ -1614,10 +1615,6 @@ bool InstantController::FixSuggestion(InstantSuggestion* suggestion) const { |
return false; |
} |
-bool InstantController::UseInstantTabToShowSuggestions() const { |
- return instant_tab_ && !instant_tab_->IsLocalNTP(); |
-} |
- |
bool InstantController::ShouldSwitchToLocalNTP() const { |
// If there is no Instant URL or the NTP is stale, switch. |
std::string instant_url; |