Commit b36b0d3b authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Move search::IsSuggestPrefEnabled to webservice_search_provider.cc

That's the only call site, and none of the other code in search::
depends on that preference anymore.

Bug: none
Change-Id: Id10ab76d2e8566f2e5c48c389ceec79ac38093d3
Reviewed-on: https://chromium-review.googlesource.com/803282Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521305}
parent bcbda755
...@@ -16,10 +16,8 @@ ...@@ -16,10 +16,8 @@
#include "chrome/browser/search_engines/ui_thread_search_terms_data.h" #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "components/google/core/browser/google_util.h" #include "components/google/core/browser/google_util.h"
#include "components/prefs/pref_service.h"
#include "components/search/search.h" #include "components/search/search.h"
#include "components/search_engines/search_engine_type.h" #include "components/search_engines/search_engine_type.h"
#include "components/search_engines/template_url_service.h" #include "components/search_engines/template_url_service.h"
...@@ -319,11 +317,6 @@ bool IsInstantNTPURL(const GURL& url, Profile* profile) { ...@@ -319,11 +317,6 @@ bool IsInstantNTPURL(const GURL& url, Profile* profile) {
return new_tab_url.is_valid() && MatchesOriginAndPath(url, new_tab_url); return new_tab_url.is_valid() && MatchesOriginAndPath(url, new_tab_url);
} }
bool IsSuggestPrefEnabled(Profile* profile) {
return profile && !profile->IsOffTheRecord() && profile->GetPrefs() &&
profile->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled);
}
GURL GetNewTabPageURL(Profile* profile) { GURL GetNewTabPageURL(Profile* profile) {
return NewTabURLDetails::ForProfile(profile).url; return NewTabURLDetails::ForProfile(profile).url;
} }
......
...@@ -24,9 +24,6 @@ enum CacheableNTPLoad { ...@@ -24,9 +24,6 @@ enum CacheableNTPLoad {
CACHEABLE_NTP_LOAD_MAX = 2 CACHEABLE_NTP_LOAD_MAX = 2
}; };
// Returns whether the suggest is enabled for the given |profile|.
bool IsSuggestPrefEnabled(Profile* profile);
// Returns true if |url| should be rendered in the Instant renderer process. // Returns true if |url| should be rendered in the Instant renderer process.
bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile); bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile);
......
...@@ -2,10 +2,13 @@ ...@@ -2,10 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/search/search.h"
#include <stddef.h> #include <stddef.h>
#include <map> #include <map>
#include <memory> #include <string>
#include <utility>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
...@@ -13,16 +16,11 @@ ...@@ -13,16 +16,11 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/search/instant_service.h" #include "chrome/browser/search/instant_service.h"
#include "chrome/browser/search/instant_service_factory.h" #include "chrome/browser/search/instant_service_factory.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/search_test_utils.h" #include "chrome/test/base/search_test_utils.h"
#include "components/prefs/pref_service.h"
#include "components/search/search.h"
#include "components/search_engines/template_url_service.h" #include "components/search_engines/template_url_service.h"
#include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
...@@ -396,8 +394,7 @@ TEST_F(SearchTest, IsNTPURL) { ...@@ -396,8 +394,7 @@ TEST_F(SearchTest, IsNTPURL) {
GURL local_ntp_url(chrome::kChromeSearchLocalNtpUrl); GURL local_ntp_url(chrome::kChromeSearchLocalNtpUrl);
EXPECT_FALSE(IsNTPURL(invalid_url, profile())); EXPECT_FALSE(IsNTPURL(invalid_url, profile()));
// No margin.
profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true);
GURL remote_ntp_url(GetNewTabPageURL(profile())); GURL remote_ntp_url(GetNewTabPageURL(profile()));
GURL remote_ntp_service_worker_url("https://foo.com/newtab-serviceworker.js"); GURL remote_ntp_service_worker_url("https://foo.com/newtab-serviceworker.js");
GURL search_url_with_search_terms("https://foo.com/url?bar=abc"); GURL search_url_with_search_terms("https://foo.com/url?bar=abc");
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "chrome/browser/search/search.h" #include "chrome/browser/search/search.h"
#include "chrome/browser/ui/app_list/search/common/webservice_cache.h" #include "chrome/browser/ui/app_list/search/common/webservice_cache.h"
#include "chrome/browser/ui/app_list/search/common/webservice_cache_factory.h" #include "chrome/browser/ui/app_list/search/common/webservice_cache_factory.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "url/gurl.h" #include "url/gurl.h"
#include "url/url_constants.h" #include "url/url_constants.h"
...@@ -24,6 +26,11 @@ namespace { ...@@ -24,6 +26,11 @@ namespace {
const int kWebserviceQueryThrottleIntrevalInMs = 100; const int kWebserviceQueryThrottleIntrevalInMs = 100;
const size_t kMinimumQueryLength = 3u; const size_t kMinimumQueryLength = 3u;
bool IsSuggestPrefEnabled(Profile* profile) {
return profile && !profile->IsOffTheRecord() && profile->GetPrefs() &&
profile->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled);
}
} // namespace } // namespace
WebserviceSearchProvider::WebserviceSearchProvider(Profile* profile) WebserviceSearchProvider::WebserviceSearchProvider(Profile* profile)
...@@ -50,7 +57,7 @@ bool WebserviceSearchProvider::IsValidQuery(const base::string16& query) { ...@@ -50,7 +57,7 @@ bool WebserviceSearchProvider::IsValidQuery(const base::string16& query) {
// If |query| contains sensitive data, bail out and do not create the place // If |query| contains sensitive data, bail out and do not create the place
// holder "search-web-store" result. // holder "search-web-store" result.
if (IsSensitiveInput(query) || (query.size() < kMinimumQueryLength) || if (IsSensitiveInput(query) || (query.size() < kMinimumQueryLength) ||
!search::IsSuggestPrefEnabled(profile_)) { !IsSuggestPrefEnabled(profile_)) {
return false; return false;
} }
......
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