Remove BaseSearchProvider::set_in_app_list

Instead, app_list::OmniboxProvider is responsible to set true to SearchTermsArgs::from_app_list.

BUG=388515

Review URL: https://codereview.chromium.org/399063002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285565 0039d316-1c4b-4281-b951-d872f2087c98
parent b0ec7c06
...@@ -222,6 +222,15 @@ public class AutocompleteController { ...@@ -222,6 +222,15 @@ public class AutocompleteController {
isDeletable); isDeletable);
} }
/**
* Use updateMatchDestinationUrlWithQueryFormulationTime instead.
*/
@Deprecated
public String updateMatchDestinationUrl(int selectedIndex, long elapsedTimeSinceInputChange) {
return updateMatchDestinationUrlWithQueryFormulationTime(selectedIndex,
elapsedTimeSinceInputChange);
}
/** /**
* Updates aqs parameters on the selected match that we will navigate to and returns the * Updates aqs parameters on the selected match that we will navigate to and returns the
* updated URL. |selected_index| is the position of the selected match and * updated URL. |selected_index| is the position of the selected match and
...@@ -235,9 +244,10 @@ public class AutocompleteController { ...@@ -235,9 +244,10 @@ public class AutocompleteController {
* @return The url to navigate to for this match with aqs parameter updated, if we are * @return The url to navigate to for this match with aqs parameter updated, if we are
* making a Google search query. * making a Google search query.
*/ */
public String updateMatchDestinationUrl(int selectedIndex, long elapsedTimeSinceInputChange) { public String updateMatchDestinationUrlWithQueryFormulationTime(int selectedIndex,
return nativeUpdateMatchDestinationURL(mNativeAutocompleteControllerAndroid, selectedIndex, long elapsedTimeSinceInputChange) {
elapsedTimeSinceInputChange); return nativeUpdateMatchDestinationURLWithQueryFormulationTime(
mNativeAutocompleteControllerAndroid, selectedIndex, elapsedTimeSinceInputChange);
} }
/** /**
...@@ -265,8 +275,9 @@ public class AutocompleteController { ...@@ -265,8 +275,9 @@ public class AutocompleteController {
boolean focusedFromFakebox); boolean focusedFromFakebox);
private native void nativeDeleteSuggestion(long nativeAutocompleteControllerAndroid, private native void nativeDeleteSuggestion(long nativeAutocompleteControllerAndroid,
int selectedIndex); int selectedIndex);
private native String nativeUpdateMatchDestinationURL(long nativeAutocompleteControllerAndroid, private native String nativeUpdateMatchDestinationURLWithQueryFormulationTime(
int selectedIndex, long elapsedTimeSinceInputChange); long nativeAutocompleteControllerAndroid, int selectedIndex,
long elapsedTimeSinceInputChange);
private native OmniboxSuggestion nativeGetTopSynchronousMatch( private native OmniboxSuggestion nativeGetTopSynchronousMatch(
long nativeAutocompleteControllerAndroid, String query); long nativeAutocompleteControllerAndroid, String query);
......
...@@ -243,12 +243,12 @@ void AutocompleteControllerAndroid::DeleteSuggestion(JNIEnv* env, ...@@ -243,12 +243,12 @@ void AutocompleteControllerAndroid::DeleteSuggestion(JNIEnv* env,
autocomplete_controller_->DeleteMatch(match); autocomplete_controller_->DeleteMatch(match);
} }
ScopedJavaLocalRef<jstring> ScopedJavaLocalRef<jstring> AutocompleteControllerAndroid::
AutocompleteControllerAndroid::UpdateMatchDestinationURL( UpdateMatchDestinationURLWithQueryFormulationTime(
JNIEnv* env, JNIEnv* env,
jobject obj, jobject obj,
jint selected_index, jint selected_index,
jlong elapsed_time_since_input_change) { jlong elapsed_time_since_input_change) {
// In rare cases, we navigate to cached matches and the underlying result // In rare cases, we navigate to cached matches and the underlying result
// has already been cleared, in that case ignore the URL update. // has already been cleared, in that case ignore the URL update.
if (autocomplete_controller_->result().empty()) if (autocomplete_controller_->result().empty())
...@@ -256,7 +256,7 @@ AutocompleteControllerAndroid::UpdateMatchDestinationURL( ...@@ -256,7 +256,7 @@ AutocompleteControllerAndroid::UpdateMatchDestinationURL(
AutocompleteMatch match( AutocompleteMatch match(
autocomplete_controller_->result().match_at(selected_index)); autocomplete_controller_->result().match_at(selected_index));
autocomplete_controller_->UpdateMatchDestinationURL( autocomplete_controller_->UpdateMatchDestinationURLWithQueryFormulationTime(
base::TimeDelta::FromMilliseconds(elapsed_time_since_input_change), base::TimeDelta::FromMilliseconds(elapsed_time_since_input_change),
&match); &match);
return ConvertUTF8ToJavaString(env, match.destination_url.spec()); return ConvertUTF8ToJavaString(env, match.destination_url.spec());
......
...@@ -62,11 +62,12 @@ class AutocompleteControllerAndroid : public AutocompleteControllerDelegate, ...@@ -62,11 +62,12 @@ class AutocompleteControllerAndroid : public AutocompleteControllerDelegate,
jlong elapsed_time_since_first_modified, jlong elapsed_time_since_first_modified,
jobject j_web_contents); jobject j_web_contents);
void DeleteSuggestion(JNIEnv* env, jobject obj, int selected_index); void DeleteSuggestion(JNIEnv* env, jobject obj, int selected_index);
base::android::ScopedJavaLocalRef<jstring> UpdateMatchDestinationURL( base::android::ScopedJavaLocalRef<jstring>
JNIEnv* env, UpdateMatchDestinationURLWithQueryFormulationTime(
jobject obj, JNIEnv* env,
jint selected_index, jobject obj,
jlong elapsed_time_since_input_change); jint selected_index,
jlong elapsed_time_since_input_change);
base::android::ScopedJavaLocalRef<jobject> GetTopSynchronousMatch( base::android::ScopedJavaLocalRef<jobject> GetTopSynchronousMatch(
JNIEnv* env, JNIEnv* env,
......
...@@ -389,12 +389,10 @@ void AutocompleteController::ResetSession() { ...@@ -389,12 +389,10 @@ void AutocompleteController::ResetSession() {
(*i)->ResetSession(); (*i)->ResetSession();
} }
void AutocompleteController::UpdateMatchDestinationURL( void AutocompleteController::UpdateMatchDestinationURLWithQueryFormulationTime(
base::TimeDelta query_formulation_time, base::TimeDelta query_formulation_time,
AutocompleteMatch* match) const { AutocompleteMatch* match) const {
TemplateURL* template_url = match->GetTemplateURL( if (!match->search_terms_args.get() ||
template_url_service_, false);
if (!template_url || !match->search_terms_args.get() ||
match->search_terms_args->assisted_query_stats.empty()) match->search_terms_args->assisted_query_stats.empty())
return; return;
...@@ -410,6 +408,17 @@ void AutocompleteController::UpdateMatchDestinationURL( ...@@ -410,6 +408,17 @@ void AutocompleteController::UpdateMatchDestinationURL(
(zero_suggest_provider_ && (zero_suggest_provider_ &&
zero_suggest_provider_->field_trial_triggered_in_session()), zero_suggest_provider_->field_trial_triggered_in_session()),
input_.current_page_classification()); input_.current_page_classification());
UpdateMatchDestinationURL(search_terms_args, match);
}
void AutocompleteController::UpdateMatchDestinationURL(
const TemplateURLRef::SearchTermsArgs& search_terms_args,
AutocompleteMatch* match) const {
TemplateURL* template_url = match->GetTemplateURL(
template_url_service_, false);
if (!template_url)
return;
match->destination_url = GURL(template_url->url_ref().ReplaceSearchTerms( match->destination_url = GURL(template_url->url_ref().ReplaceSearchTerms(
search_terms_args, template_url_service_->search_terms_data())); search_terms_args, template_url_service_->search_terms_data()));
} }
......
...@@ -114,8 +114,15 @@ class AutocompleteController : public AutocompleteProviderListener { ...@@ -114,8 +114,15 @@ class AutocompleteController : public AutocompleteProviderListener {
// parameters otherwise not available at initial construction time. This // parameters otherwise not available at initial construction time. This
// method should be called from OmniboxEditModel::OpenMatch() before the user // method should be called from OmniboxEditModel::OpenMatch() before the user
// navigates to the selected match. // navigates to the selected match.
void UpdateMatchDestinationURL(base::TimeDelta query_formulation_time, void UpdateMatchDestinationURLWithQueryFormulationTime(
AutocompleteMatch* match) const; base::TimeDelta query_formulation_time,
AutocompleteMatch* match) const;
// Constructs the final destination URL for a given match using additional
// parameters otherwise not available at initial construction time.
void UpdateMatchDestinationURL(
const TemplateURLRef::SearchTermsArgs& search_terms_args,
AutocompleteMatch* match) const;
HistoryURLProvider* history_url_provider() const { HistoryURLProvider* history_url_provider() const {
return history_url_provider_; return history_url_provider_;
......
...@@ -452,7 +452,8 @@ void AutocompleteProviderTest::CopyResults() { ...@@ -452,7 +452,8 @@ void AutocompleteProviderTest::CopyResults() {
GURL AutocompleteProviderTest::GetDestinationURL( GURL AutocompleteProviderTest::GetDestinationURL(
AutocompleteMatch match, AutocompleteMatch match,
base::TimeDelta query_formulation_time) const { base::TimeDelta query_formulation_time) const {
controller_->UpdateMatchDestinationURL(query_formulation_time, &match); controller_->UpdateMatchDestinationURLWithQueryFormulationTime(
query_formulation_time, &match);
return match.destination_url; return match.destination_url;
} }
......
...@@ -133,8 +133,7 @@ BaseSearchProvider::BaseSearchProvider(AutocompleteProviderListener* listener, ...@@ -133,8 +133,7 @@ BaseSearchProvider::BaseSearchProvider(AutocompleteProviderListener* listener,
profile_(profile), profile_(profile),
field_trial_triggered_(false), field_trial_triggered_(false),
field_trial_triggered_in_session_(false), field_trial_triggered_in_session_(false),
suggest_results_pending_(0), suggest_results_pending_(0) {
in_app_list_(false) {
} }
// static // static
...@@ -154,7 +153,7 @@ AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion( ...@@ -154,7 +153,7 @@ AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion(
suggestion, type, suggestion, base::string16(), base::string16(), suggestion, type, suggestion, base::string16(), base::string16(),
base::string16(), base::string16(), std::string(), std::string(), base::string16(), base::string16(), std::string(), std::string(),
from_keyword_provider, 0, false, false, base::string16()), from_keyword_provider, 0, false, false, base::string16()),
template_url, search_terms_data, 0, false, false); template_url, search_terms_data, 0, false);
} }
void BaseSearchProvider::Stop(bool clear_cached_results) { void BaseSearchProvider::Stop(bool clear_cached_results) {
...@@ -482,8 +481,7 @@ AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion( ...@@ -482,8 +481,7 @@ AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion(
const TemplateURL* template_url, const TemplateURL* template_url,
const SearchTermsData& search_terms_data, const SearchTermsData& search_terms_data,
int accepted_suggestion, int accepted_suggestion,
bool append_extra_query_params, bool append_extra_query_params) {
bool from_app_list) {
AutocompleteMatch match(autocomplete_provider, suggestion.relevance(), false, AutocompleteMatch match(autocomplete_provider, suggestion.relevance(), false,
suggestion.type()); suggestion.type());
...@@ -540,7 +538,6 @@ AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion( ...@@ -540,7 +538,6 @@ AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion(
suggestion.suggest_query_params(); suggestion.suggest_query_params();
match.search_terms_args->append_extra_query_params = match.search_terms_args->append_extra_query_params =
append_extra_query_params; append_extra_query_params;
match.search_terms_args->from_app_list = from_app_list;
// This is the destination URL sans assisted query stats. This must be set // This is the destination URL sans assisted query stats. This must be set
// so the AutocompleteController can properly de-dupe; the controller will // so the AutocompleteController can properly de-dupe; the controller will
// eventually overwrite it before it reaches the user. // eventually overwrite it before it reaches the user.
...@@ -716,7 +713,7 @@ void BaseSearchProvider::AddMatchToMap(const SuggestResult& result, ...@@ -716,7 +713,7 @@ void BaseSearchProvider::AddMatchToMap(const SuggestResult& result,
this, GetInput(result.from_keyword_provider()), result, this, GetInput(result.from_keyword_provider()), result,
GetTemplateURL(result.from_keyword_provider()), GetTemplateURL(result.from_keyword_provider()),
UIThreadSearchTermsData(profile_), accepted_suggestion, UIThreadSearchTermsData(profile_), accepted_suggestion,
ShouldAppendExtraParams(result), in_app_list_); ShouldAppendExtraParams(result));
if (!match.destination_url.is_valid()) if (!match.destination_url.is_valid())
return; return;
match.search_terms_args->bookmark_bar_pinned = match.search_terms_args->bookmark_bar_pinned =
......
...@@ -76,8 +76,6 @@ class BaseSearchProvider : public AutocompleteProvider, ...@@ -76,8 +76,6 @@ class BaseSearchProvider : public AutocompleteProvider,
return field_trial_triggered_in_session_; return field_trial_triggered_in_session_;
} }
void set_in_app_list() { in_app_list_ = true; }
protected: protected:
// The following keys are used to record additional information on matches. // The following keys are used to record additional information on matches.
...@@ -340,7 +338,6 @@ class BaseSearchProvider : public AutocompleteProvider, ...@@ -340,7 +338,6 @@ class BaseSearchProvider : public AutocompleteProvider,
// |append_extra_query_params| should be set if |template_url| is the default // |append_extra_query_params| should be set if |template_url| is the default
// search engine, so the destination URL will contain any // search engine, so the destination URL will contain any
// command-line-specified query params. // command-line-specified query params.
// |from_app_list| should be set if the search was made from the app list.
static AutocompleteMatch CreateSearchSuggestion( static AutocompleteMatch CreateSearchSuggestion(
AutocompleteProvider* autocomplete_provider, AutocompleteProvider* autocomplete_provider,
const AutocompleteInput& input, const AutocompleteInput& input,
...@@ -348,8 +345,7 @@ class BaseSearchProvider : public AutocompleteProvider, ...@@ -348,8 +345,7 @@ class BaseSearchProvider : public AutocompleteProvider,
const TemplateURL* template_url, const TemplateURL* template_url,
const SearchTermsData& search_terms_data, const SearchTermsData& search_terms_data,
int accepted_suggestion, int accepted_suggestion,
bool append_extra_query_params, bool append_extra_query_params);
bool from_app_list);
// Parses JSON response received from the provider, stripping XSSI // Parses JSON response received from the provider, stripping XSSI
// protection if needed. Returns the parsed data if successful, NULL // protection if needed. Returns the parsed data if successful, NULL
...@@ -517,11 +513,6 @@ class BaseSearchProvider : public AutocompleteProvider, ...@@ -517,11 +513,6 @@ class BaseSearchProvider : public AutocompleteProvider,
// causes us to auto-cancel all such requests on shutdown. // causes us to auto-cancel all such requests on shutdown.
SuggestionDeletionHandlers deletion_handlers_; SuggestionDeletionHandlers deletion_handlers_;
// True if this provider's results are being displayed in the app list. By
// default this is false, meaning that the results will be shown in the
// omnibox.
bool in_app_list_;
DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider); DISALLOW_COPY_AND_ASSIGN(BaseSearchProvider);
}; };
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "chrome/browser/autocomplete/autocomplete_controller.h" #include "chrome/browser/autocomplete/autocomplete_controller.h"
#include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
#include "chrome/browser/autocomplete/search_provider.h"
#include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/app_list/search/chrome_search_result.h" #include "chrome/browser/ui/app_list/search/chrome_search_result.h"
#include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_navigator.h"
...@@ -66,15 +65,23 @@ void ACMatchClassificationsToTags( ...@@ -66,15 +65,23 @@ void ACMatchClassificationsToTags(
class OmniboxResult : public ChromeSearchResult { class OmniboxResult : public ChromeSearchResult {
public: public:
OmniboxResult(Profile* profile, const AutocompleteMatch& match) OmniboxResult(Profile* profile,
AutocompleteController* autocomplete_controller,
const AutocompleteMatch& match)
: profile_(profile), : profile_(profile),
autocomplete_controller_(autocomplete_controller),
match_(match) { match_(match) {
set_id(match.destination_url.spec()); if (match_.search_terms_args) {
match_.search_terms_args->from_app_list = true;
autocomplete_controller_->UpdateMatchDestinationURL(
*match_.search_terms_args, &match_);
}
set_id(match_.destination_url.spec());
// Derive relevance from omnibox relevance and normalize it to [0, 1]. // Derive relevance from omnibox relevance and normalize it to [0, 1].
// The magic number 1500 is the highest score of an omnibox result. // The magic number 1500 is the highest score of an omnibox result.
// See comments in autocomplete_provider.h. // See comments in autocomplete_provider.h.
set_relevance(match.relevance / 1500.0); set_relevance(match_.relevance / 1500.0);
UpdateIcon(); UpdateIcon();
UpdateTitleAndDetails(); UpdateTitleAndDetails();
...@@ -94,7 +101,7 @@ class OmniboxResult : public ChromeSearchResult { ...@@ -94,7 +101,7 @@ class OmniboxResult : public ChromeSearchResult {
virtual scoped_ptr<ChromeSearchResult> Duplicate() OVERRIDE { virtual scoped_ptr<ChromeSearchResult> Duplicate() OVERRIDE {
return scoped_ptr<ChromeSearchResult>( return scoped_ptr<ChromeSearchResult>(
new OmniboxResult(profile_, match_)).Pass(); new OmniboxResult(profile_, autocomplete_controller_, match_)).Pass();
} }
virtual ChromeSearchResultType GetType() OVERRIDE { virtual ChromeSearchResultType GetType() OVERRIDE {
...@@ -126,6 +133,7 @@ class OmniboxResult : public ChromeSearchResult { ...@@ -126,6 +133,7 @@ class OmniboxResult : public ChromeSearchResult {
} }
Profile* profile_; Profile* profile_;
AutocompleteController* autocomplete_controller_;
AutocompleteMatch match_; AutocompleteMatch match_;
DISALLOW_COPY_AND_ASSIGN(OmniboxResult); DISALLOW_COPY_AND_ASSIGN(OmniboxResult);
...@@ -141,7 +149,6 @@ OmniboxProvider::OmniboxProvider(Profile* profile) ...@@ -141,7 +149,6 @@ OmniboxProvider::OmniboxProvider(Profile* profile)
this, this,
AutocompleteClassifier::kDefaultOmniboxProviders & AutocompleteClassifier::kDefaultOmniboxProviders &
~AutocompleteProvider::TYPE_ZERO_SUGGEST)) { ~AutocompleteProvider::TYPE_ZERO_SUGGEST)) {
controller_->search_provider()->set_in_app_list();
} }
OmniboxProvider::~OmniboxProvider() {} OmniboxProvider::~OmniboxProvider() {}
...@@ -165,7 +172,8 @@ void OmniboxProvider::PopulateFromACResult(const AutocompleteResult& result) { ...@@ -165,7 +172,8 @@ void OmniboxProvider::PopulateFromACResult(const AutocompleteResult& result) {
if (!it->destination_url.is_valid()) if (!it->destination_url.is_valid())
continue; continue;
Add(scoped_ptr<SearchResult>(new OmniboxResult(profile_, *it))); Add(scoped_ptr<SearchResult>(
new OmniboxResult(profile_, controller_.get(), *it)));
} }
} }
......
...@@ -711,7 +711,7 @@ void OmniboxEditModel::OpenMatch(AutocompleteMatch match, ...@@ -711,7 +711,7 @@ void OmniboxEditModel::OpenMatch(AutocompleteMatch match,
const base::TimeTicks& now(base::TimeTicks::Now()); const base::TimeTicks& now(base::TimeTicks::Now());
base::TimeDelta elapsed_time_since_user_first_modified_omnibox( base::TimeDelta elapsed_time_since_user_first_modified_omnibox(
now - time_user_first_modified_omnibox_); now - time_user_first_modified_omnibox_);
autocomplete_controller()->UpdateMatchDestinationURL( autocomplete_controller()->UpdateMatchDestinationURLWithQueryFormulationTime(
elapsed_time_since_user_first_modified_omnibox, &match); elapsed_time_since_user_first_modified_omnibox, &match);
base::string16 input_text(pasted_text); base::string16 input_text(pasted_text);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment