OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/search/instant_unittest_base.h" | 5 #include "chrome/browser/search/instant_unittest_base.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 TemplateURLData data; | 53 TemplateURLData data; |
54 data.SetKeyword(base::UTF8ToUTF16(base_url)); | 54 data.SetKeyword(base::UTF8ToUTF16(base_url)); |
55 data.SetURL(base_url + "url?bar={searchTerms}"); | 55 data.SetURL(base_url + "url?bar={searchTerms}"); |
56 data.instant_url = base_url + | 56 data.instant_url = base_url + |
57 "instant?{google:omniboxStartMarginParameter}{google:forceInstantResults}" | 57 "instant?{google:omniboxStartMarginParameter}{google:forceInstantResults}" |
58 "foo=foo#foo=foo&strk"; | 58 "foo=foo#foo=foo&strk"; |
59 data.new_tab_url = base_url + "newtab"; | 59 data.new_tab_url = base_url + "newtab"; |
60 data.alternate_urls.push_back(base_url + "alt#quux={searchTerms}"); | 60 data.alternate_urls.push_back(base_url + "alt#quux={searchTerms}"); |
61 data.search_terms_replacement_key = "strk"; | 61 data.search_terms_replacement_key = "strk"; |
62 | 62 |
63 TemplateURL* template_url = new TemplateURL(profile(), data); | 63 TemplateURL* template_url = new TemplateURL(data); |
64 // Takes ownership of |template_url|. | 64 // Takes ownership of |template_url|. |
65 template_url_service_->Add(template_url); | 65 template_url_service_->Add(template_url); |
66 template_url_service_->SetUserSelectedDefaultSearchProvider(template_url); | 66 template_url_service_->SetUserSelectedDefaultSearchProvider(template_url); |
67 } | 67 } |
68 | 68 |
69 void InstantUnitTestBase::NotifyGoogleBaseURLUpdate( | 69 void InstantUnitTestBase::NotifyGoogleBaseURLUpdate( |
70 const std::string& new_google_base_url) { | 70 const std::string& new_google_base_url) { |
71 // GoogleURLTracker is not created in tests. | 71 // GoogleURLTracker is not created in tests. |
72 // (See GoogleURLTrackerFactory::ServiceIsNULLWhileTesting()) | 72 // (See GoogleURLTrackerFactory::ServiceIsNULLWhileTesting()) |
73 // For determining google:baseURL for NTP, the following is used: | 73 // For determining google:baseURL for NTP, the following is used: |
(...skipping 22 matching lines...) Expand all Loading... |
96 template_url_service_ = TemplateURLServiceFactory::GetForProfile(profile()); | 96 template_url_service_ = TemplateURLServiceFactory::GetForProfile(profile()); |
97 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service_); | 97 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service_); |
98 | 98 |
99 UIThreadSearchTermsData::SetGoogleBaseURL("https://www.google.com/"); | 99 UIThreadSearchTermsData::SetGoogleBaseURL("https://www.google.com/"); |
100 TestingPrefServiceSyncable* pref_service = profile()->GetTestingPrefService(); | 100 TestingPrefServiceSyncable* pref_service = profile()->GetTestingPrefService(); |
101 pref_service->SetUserPref(prefs::kLastPromptedGoogleURL, | 101 pref_service->SetUserPref(prefs::kLastPromptedGoogleURL, |
102 new base::StringValue("https://www.google.com/")); | 102 new base::StringValue("https://www.google.com/")); |
103 SetUserSelectedDefaultSearchProvider("{google:baseURL}"); | 103 SetUserSelectedDefaultSearchProvider("{google:baseURL}"); |
104 instant_service_ = InstantServiceFactory::GetForProfile(profile()); | 104 instant_service_ = InstantServiceFactory::GetForProfile(profile()); |
105 } | 105 } |
OLD | NEW |