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

Side by Side Diff: chrome/browser/search_engines/template_url_service_test_util.cc

Issue 287103002: Introduce ability to register callback with GoogleURLTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to review Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/search_engines/template_url_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_engines/template_url_service_test_util.h" 5 #include "chrome/browser/search_engines/template_url_service_test_util.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/google/google_url_tracker.h" 12 #include "chrome/browser/google/google_url_tracker.h"
13 #include "chrome/browser/search_engines/default_search_manager.h" 13 #include "chrome/browser/search_engines/default_search_manager.h"
14 #include "chrome/browser/search_engines/search_terms_data.h" 14 #include "chrome/browser/search_engines/search_terms_data.h"
15 #include "chrome/browser/search_engines/template_url_service.h" 15 #include "chrome/browser/search_engines/template_url_service.h"
16 #include "chrome/browser/search_engines/template_url_service_factory.h" 16 #include "chrome/browser/search_engines/template_url_service_factory.h"
17 #include "chrome/browser/webdata/web_data_service_factory.h" 17 #include "chrome/browser/webdata/web_data_service_factory.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "chrome/test/base/testing_pref_service_syncable.h" 19 #include "chrome/test/base/testing_pref_service_syncable.h"
20 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
21 #include "content/public/browser/notification_service.h"
22 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
23 22
24 #if defined(OS_CHROMEOS) 23 #if defined(OS_CHROMEOS)
25 #include "chrome/browser/google/google_util_chromeos.h" 24 #include "chrome/browser/google/google_util_chromeos.h"
26 #endif 25 #endif
27 26
28 // Trivial subclass of TemplateURLService that records the last invocation of 27 // Trivial subclass of TemplateURLService that records the last invocation of
29 // SetKeywordSearchTermsForURL. 28 // SetKeywordSearchTermsForURL.
30 class TestingTemplateURLService : public TemplateURLService { 29 class TestingTemplateURLService : public TemplateURLService {
31 public: 30 public:
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 119
121 base::string16 TemplateURLServiceTestUtilBase::GetAndClearSearchTerm() { 120 base::string16 TemplateURLServiceTestUtilBase::GetAndClearSearchTerm() {
122 return 121 return
123 static_cast<TestingTemplateURLService*>(model())->GetAndClearSearchTerm(); 122 static_cast<TestingTemplateURLService*>(model())->GetAndClearSearchTerm();
124 } 123 }
125 124
126 void TemplateURLServiceTestUtilBase::SetGoogleBaseURL( 125 void TemplateURLServiceTestUtilBase::SetGoogleBaseURL(
127 const GURL& base_url) const { 126 const GURL& base_url) const {
128 DCHECK(base_url.is_valid()); 127 DCHECK(base_url.is_valid());
129 UIThreadSearchTermsData data(profile()); 128 UIThreadSearchTermsData data(profile());
130 GoogleURLTracker::UpdatedDetails urls(GURL(data.GoogleBaseURLValue()), 129 GURL old_url = GURL(data.GoogleBaseURLValue());
131 base_url);
132 UIThreadSearchTermsData::SetGoogleBaseURL(base_url.spec()); 130 UIThreadSearchTermsData::SetGoogleBaseURL(base_url.spec());
133 content::NotificationService::current()->Notify( 131 TemplateURLServiceFactory::GetForProfile(profile())
134 chrome::NOTIFICATION_GOOGLE_URL_UPDATED, 132 ->OnGoogleURLUpdated(old_url, base_url);
135 content::Source<Profile>(profile()),
136 content::Details<GoogleURLTracker::UpdatedDetails>(&urls));
137 } 133 }
138 134
139 void TemplateURLServiceTestUtilBase::SetManagedDefaultSearchPreferences( 135 void TemplateURLServiceTestUtilBase::SetManagedDefaultSearchPreferences(
140 bool enabled, 136 bool enabled,
141 const std::string& name, 137 const std::string& name,
142 const std::string& keyword, 138 const std::string& keyword,
143 const std::string& search_url, 139 const std::string& search_url,
144 const std::string& suggest_url, 140 const std::string& suggest_url,
145 const std::string& icon_url, 141 const std::string& icon_url,
146 const std::string& encodings, 142 const std::string& encodings,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 225
230 UIThreadSearchTermsData::SetGoogleBaseURL(std::string()); 226 UIThreadSearchTermsData::SetGoogleBaseURL(std::string());
231 227
232 // Flush the message loop to make application verifiers happy. 228 // Flush the message loop to make application verifiers happy.
233 base::RunLoop().RunUntilIdle(); 229 base::RunLoop().RunUntilIdle();
234 } 230 }
235 231
236 TestingProfile* TemplateURLServiceTestUtil::profile() const { 232 TestingProfile* TemplateURLServiceTestUtil::profile() const {
237 return profile_.get(); 233 return profile_.get();
238 } 234 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698