OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "base/metrics/histogram_base.h" | 11 #include "base/metrics/histogram_base.h" |
12 #include "base/metrics/histogram_samples.h" | 12 #include "base/metrics/histogram_samples.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "chrome/browser/search/instant_service.h" | 15 #include "chrome/browser/search/instant_service.h" |
16 #include "chrome/browser/search/instant_service_factory.h" | 16 #include "chrome/browser/search/instant_service_factory.h" |
17 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
18 #include "chrome/browser/search_engines/template_url_service_factory.h" | 18 #include "chrome/browser/search_engines/template_url_service_factory.h" |
19 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 19 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/features.h" |
22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
23 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
24 #include "chrome/test/base/browser_with_test_window_test.h" | 25 #include "chrome/test/base/browser_with_test_window_test.h" |
25 #include "chrome/test/base/search_test_utils.h" | 26 #include "chrome/test/base/search_test_utils.h" |
26 #include "components/google/core/browser/google_switches.h" | 27 #include "components/google/core/browser/google_switches.h" |
27 #include "components/prefs/pref_service.h" | 28 #include "components/prefs/pref_service.h" |
28 #include "components/search/search.h" | 29 #include "components/search/search.h" |
29 #include "components/search_engines/search_engines_switches.h" | 30 #include "components/search_engines/search_engines_switches.h" |
30 #include "components/search_engines/template_url_service.h" | 31 #include "components/search_engines/template_url_service.h" |
31 #include "components/variations/entropy_provider.h" | 32 #include "components/variations/entropy_provider.h" |
32 #include "content/public/browser/navigation_entry.h" | 33 #include "content/public/browser/navigation_entry.h" |
33 #include "content/public/browser/render_process_host.h" | 34 #include "content/public/browser/render_process_host.h" |
34 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
35 #include "content/public/browser/site_instance.h" | 36 #include "content/public/browser/site_instance.h" |
36 #include "content/public/browser/web_contents.h" | 37 #include "content/public/browser/web_contents.h" |
37 #include "content/public/common/renderer_preferences.h" | 38 #include "content/public/common/renderer_preferences.h" |
38 #include "url/gurl.h" | 39 #include "url/gurl.h" |
39 | 40 |
40 #if defined(ENABLE_SUPERVISED_USERS) | 41 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
41 #include "chrome/browser/supervised_user/supervised_user_service.h" | 42 #include "chrome/browser/supervised_user/supervised_user_service.h" |
42 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 43 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
43 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" | 44 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
44 #endif | 45 #endif |
45 | 46 |
46 namespace search { | 47 namespace search { |
47 | 48 |
48 class SearchTest : public BrowserWithTestWindowTest { | 49 class SearchTest : public BrowserWithTestWindowTest { |
49 protected: | 50 protected: |
50 void SetUp() override { | 51 void SetUp() override { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsNotSet) { | 426 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsNotSet) { |
426 // Set an insecure new tab page URL and verify that it's ignored. | 427 // Set an insecure new tab page URL and verify that it's ignored. |
427 SetSearchProvider(false, true); | 428 SetSearchProvider(false, true); |
428 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), | 429 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), |
429 GetNewTabPageURL(profile())); | 430 GetNewTabPageURL(profile())); |
430 GURL new_tab_url(chrome::kChromeUINewTabURL); | 431 GURL new_tab_url(chrome::kChromeUINewTabURL); |
431 EXPECT_TRUE(HandleNewTabURLRewrite(&new_tab_url, profile())); | 432 EXPECT_TRUE(HandleNewTabURLRewrite(&new_tab_url, profile())); |
432 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), new_tab_url); | 433 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), new_tab_url); |
433 } | 434 } |
434 | 435 |
435 #if defined(ENABLE_SUPERVISED_USERS) | 436 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
436 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsBlockedForSupervisedUser) { | 437 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsBlockedForSupervisedUser) { |
437 // Block access to foo.com in the URL filter. | 438 // Block access to foo.com in the URL filter. |
438 SupervisedUserService* supervised_user_service = | 439 SupervisedUserService* supervised_user_service = |
439 SupervisedUserServiceFactory::GetForProfile(profile()); | 440 SupervisedUserServiceFactory::GetForProfile(profile()); |
440 SupervisedUserURLFilter* url_filter = | 441 SupervisedUserURLFilter* url_filter = |
441 supervised_user_service->GetURLFilterForUIThread(); | 442 supervised_user_service->GetURLFilterForUIThread(); |
442 std::map<std::string, bool> hosts; | 443 std::map<std::string, bool> hosts; |
443 hosts["foo.com"] = false; | 444 hosts["foo.com"] = false; |
444 url_filter->SetManualHosts(&hosts); | 445 url_filter->SetManualHosts(&hosts); |
445 | 446 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 TemplateURLRef::SearchTermsArgs search_terms_args(base::ASCIIToUTF16("foo")); | 668 TemplateURLRef::SearchTermsArgs search_terms_args(base::ASCIIToUTF16("foo")); |
668 GURL result(template_url_->url_ref().ReplaceSearchTerms( | 669 GURL result(template_url_->url_ref().ReplaceSearchTerms( |
669 search_terms_args, UIThreadSearchTermsData(profile()))); | 670 search_terms_args, UIThreadSearchTermsData(profile()))); |
670 ASSERT_TRUE(result.is_valid()); | 671 ASSERT_TRUE(result.is_valid()); |
671 // Query extraction is disabled. Make sure | 672 // Query extraction is disabled. Make sure |
672 // {google:instantExtendedEnabledParameter} is not set in the search URL. | 673 // {google:instantExtendedEnabledParameter} is not set in the search URL. |
673 EXPECT_EQ("http://www.google.com/search?q=foo", result.spec()); | 674 EXPECT_EQ("http://www.google.com/search?q=foo", result.spec()); |
674 } | 675 } |
675 | 676 |
676 } // namespace search | 677 } // namespace search |
OLD | NEW |