Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: chrome/browser/autocomplete/search_provider.cc

Issue 21042013: Have SearchProvider look up the omnibox start margin directly. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Respond to comments. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/search_provider.cc
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index d4245fd34e8719b14b02a9213e22a51447052195..3d562c6ad9fbb63ef82c1dbc4674f7623878c672 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -36,6 +36,10 @@
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_instant_controller.h"
+#include "chrome/browser/ui/search/instant_controller.h"
#include "chrome/common/net/url_fixer_upper.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -250,8 +254,7 @@ SearchProvider::SearchProvider(AutocompleteProviderListener* listener,
providers_(TemplateURLServiceFactory::GetForProfile(profile)),
suggest_results_pending_(0),
field_trial_triggered_(false),
- field_trial_triggered_in_session_(false),
- omnibox_start_margin_(-1) {
+ field_trial_triggered_in_session_(false) {
}
// static
@@ -369,10 +372,6 @@ void SearchProvider::ResetSession() {
field_trial_triggered_in_session_ = false;
}
-void SearchProvider::SetOmniboxStartMargin(int omnibox_start_margin) {
- omnibox_start_margin_ = omnibox_start_margin;
-}
-
SearchProvider::~SearchProvider() {
}
@@ -1382,11 +1381,24 @@ void SearchProvider::AddMatchToMap(const string16& query_string,
int accepted_suggestion,
bool is_keyword,
MatchMap* map) {
+ int omnibox_start_margin = chrome::kDisableStartMargin;
+ #if !defined(OS_ANDROID)
samarth 2013/08/07 16:19:07 nit: don't indent this line or the #endif.
samarth 2013/08/07 16:19:07 Do you need this because browser finder doesn't ex
jeremycho 2013/08/07 22:16:05 Done.
jeremycho 2013/08/07 22:16:05 Yeah, done.
+ if (chrome::IsInstantExtendedAPIEnabled()) {
+ Browser* browser =
+ chrome::FindBrowserWithProfile(profile_, chrome::GetActiveDesktop());
+ if (browser && browser->instant_controller() &&
+ browser->instant_controller()->instant()) {
+ omnibox_start_margin =
+ browser->instant_controller()->instant()->omnibox_bounds().x();
+ }
+ }
+ #endif // !defined(OS_ANDROID)
+
const TemplateURL* template_url = is_keyword ?
providers_.GetKeywordProviderURL() : providers_.GetDefaultProviderURL();
AutocompleteMatch match = CreateSearchSuggestion(this, relevance, type,
template_url, query_string, input_text, input_, is_keyword,
- accepted_suggestion, omnibox_start_margin_,
+ accepted_suggestion, omnibox_start_margin,
!is_keyword || providers_.default_provider().empty());
if (!match.destination_url.is_valid())
return;
« no previous file with comments | « chrome/browser/autocomplete/search_provider.h ('k') | chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698