OLD | NEW |
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/sync/test/integration/search_engines_helper.h" | 5 #include "chrome/browser/sync/test/integration/search_engines_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "base/memory/ptr_util.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/search_engines/template_url_service_factory.h" | 17 #include "chrome/browser/search_engines/template_url_service_factory.h" |
17 #include "chrome/browser/sync/test/integration/await_match_status_change_checker
.h" | 18 #include "chrome/browser/sync/test/integration/await_match_status_change_checker
.h" |
18 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 19 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
19 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 20 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
20 #include "chrome/browser/sync/test/integration/sync_test.h" | 21 #include "chrome/browser/sync/test/integration/sync_test.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 for (int it = 1; it < test()->num_clients(); ++it) { | 180 for (int it = 1; it < test()->num_clients(); ++it) { |
180 if (!ServicesMatch(0, it)) { | 181 if (!ServicesMatch(0, it)) { |
181 DVLOG(1) << "TemplateURLService " << it << " does not match with " | 182 DVLOG(1) << "TemplateURLService " << it << " does not match with " |
182 << "service 0."; | 183 << "service 0."; |
183 return false; | 184 return false; |
184 } | 185 } |
185 } | 186 } |
186 return true; | 187 return true; |
187 } | 188 } |
188 | 189 |
189 TemplateURL* CreateTestTemplateURL(Profile* profile, int seed) { | 190 std::unique_ptr<TemplateURL> CreateTestTemplateURL(Profile* profile, int seed) { |
190 return CreateTestTemplateURL(profile, seed, CreateKeyword(seed), | 191 return CreateTestTemplateURL(profile, seed, CreateKeyword(seed), |
191 base::StringPrintf("0000-0000-0000-%04d", seed)); | 192 base::StringPrintf("0000-0000-0000-%04d", seed)); |
192 } | 193 } |
193 | 194 |
194 TemplateURL* CreateTestTemplateURL(Profile* profile, | 195 std::unique_ptr<TemplateURL> CreateTestTemplateURL( |
195 int seed, | 196 Profile* profile, |
196 const base::string16& keyword, | 197 int seed, |
197 const std::string& sync_guid) { | 198 const base::string16& keyword, |
| 199 const std::string& sync_guid) { |
198 return CreateTestTemplateURL(profile, seed, keyword, | 200 return CreateTestTemplateURL(profile, seed, keyword, |
199 base::StringPrintf("http://www.test%d.com/", seed), sync_guid); | 201 base::StringPrintf("http://www.test%d.com/", seed), sync_guid); |
200 } | 202 } |
201 | 203 |
202 TemplateURL* CreateTestTemplateURL(Profile* profile, | 204 std::unique_ptr<TemplateURL> CreateTestTemplateURL( |
203 int seed, | 205 Profile* profile, |
204 const base::string16& keyword, | 206 int seed, |
205 const std::string& url, | 207 const base::string16& keyword, |
206 const std::string& sync_guid) { | 208 const std::string& url, |
| 209 const std::string& sync_guid) { |
207 TemplateURLData data; | 210 TemplateURLData data; |
208 data.SetShortName(CreateKeyword(seed)); | 211 data.SetShortName(CreateKeyword(seed)); |
209 data.SetKeyword(keyword); | 212 data.SetKeyword(keyword); |
210 data.SetURL(url); | 213 data.SetURL(url); |
211 data.favicon_url = GURL("http://favicon.url"); | 214 data.favicon_url = GURL("http://favicon.url"); |
212 data.safe_for_autoreplace = true; | 215 data.safe_for_autoreplace = true; |
213 data.date_created = base::Time::FromTimeT(100); | 216 data.date_created = base::Time::FromTimeT(100); |
214 data.last_modified = base::Time::FromTimeT(100); | 217 data.last_modified = base::Time::FromTimeT(100); |
215 data.prepopulate_id = 999999; | 218 data.prepopulate_id = 999999; |
216 data.sync_guid = sync_guid; | 219 data.sync_guid = sync_guid; |
217 return new TemplateURL(data); | 220 return base::MakeUnique<TemplateURL>(data); |
218 } | 221 } |
219 | 222 |
220 void AddSearchEngine(int profile_index, int seed) { | 223 void AddSearchEngine(int profile_index, int seed) { |
221 Profile* profile = test()->GetProfile(profile_index); | 224 Profile* profile = test()->GetProfile(profile_index); |
222 TemplateURLServiceFactory::GetForProfile(profile)->Add( | 225 TemplateURLServiceFactory::GetForProfile(profile)->Add( |
223 CreateTestTemplateURL(profile, seed)); | 226 CreateTestTemplateURL(profile, seed)); |
224 if (test()->use_verifier()) | 227 if (test()->use_verifier()) |
225 GetVerifierService()->Add(CreateTestTemplateURL(profile, seed)); | 228 GetVerifierService()->Add(CreateTestTemplateURL(profile, seed)); |
226 } | 229 } |
227 | 230 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } | 279 } |
277 | 280 |
278 bool HasSearchEngine(int profile_index, int seed) { | 281 bool HasSearchEngine(int profile_index, int seed) { |
279 TemplateURLService* service = GetServiceForBrowserContext(profile_index); | 282 TemplateURLService* service = GetServiceForBrowserContext(profile_index); |
280 base::string16 keyword(CreateKeyword(seed)); | 283 base::string16 keyword(CreateKeyword(seed)); |
281 TemplateURL* turl = service->GetTemplateURLForKeyword(keyword); | 284 TemplateURL* turl = service->GetTemplateURLForKeyword(keyword); |
282 return turl != nullptr; | 285 return turl != nullptr; |
283 } | 286 } |
284 | 287 |
285 } // namespace search_engines_helper | 288 } // namespace search_engines_helper |
OLD | NEW |