| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| 6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 const TemplateURL& turl); | 346 const TemplateURL& turl); |
| 347 | 347 |
| 348 // Creates a new heap-allocated TemplateURL* which is populated by overlaying | 348 // Creates a new heap-allocated TemplateURL* which is populated by overlaying |
| 349 // |sync_data| atop |existing_turl|. |existing_turl| may be NULL; if not it | 349 // |sync_data| atop |existing_turl|. |existing_turl| may be NULL; if not it |
| 350 // remains unmodified. The caller owns the returned TemplateURL*. | 350 // remains unmodified. The caller owns the returned TemplateURL*. |
| 351 // | 351 // |
| 352 // If the created TemplateURL is migrated in some way from out-of-date sync | 352 // If the created TemplateURL is migrated in some way from out-of-date sync |
| 353 // data, an appropriate SyncChange is added to |change_list|. If the sync | 353 // data, an appropriate SyncChange is added to |change_list|. If the sync |
| 354 // data is bad for some reason, an ACTION_DELETE change is added and the | 354 // data is bad for some reason, an ACTION_DELETE change is added and the |
| 355 // function returns NULL. | 355 // function returns NULL. |
| 356 static TemplateURL* CreateTemplateURLFromTemplateURLAndSyncData( | 356 static scoped_ptr<TemplateURL> CreateTemplateURLFromTemplateURLAndSyncData( |
| 357 TemplateURLServiceClient* client, |
| 357 PrefService* prefs, | 358 PrefService* prefs, |
| 358 const SearchTermsData& search_terms_data, | 359 const SearchTermsData& search_terms_data, |
| 359 TemplateURL* existing_turl, | 360 TemplateURL* existing_turl, |
| 360 const syncer::SyncData& sync_data, | 361 const syncer::SyncData& sync_data, |
| 361 syncer::SyncChangeList* change_list); | 362 syncer::SyncChangeList* change_list); |
| 362 | 363 |
| 363 // Returns a map mapping Sync GUIDs to pointers to syncer::SyncData. | 364 // Returns a map mapping Sync GUIDs to pointers to syncer::SyncData. |
| 364 static SyncDataMap CreateGUIDToSyncDataMap( | 365 static SyncDataMap CreateGUIDToSyncDataMap( |
| 365 const syncer::SyncDataList& sync_data); | 366 const syncer::SyncDataList& sync_data); |
| 366 | 367 |
| 367 #if defined(UNIT_TEST) | 368 #if defined(UNIT_TEST) |
| 368 // Sets a different time provider function, such as | 369 // Sets a different time provider function, such as |
| 369 // base::MockTimeProvider::StaticNow, for testing calls to base::Time::Now. | 370 // base::MockTimeProvider::StaticNow, for testing calls to base::Time::Now. |
| 370 void set_time_provider(TimeProvider* time_provider) { | 371 void set_time_provider(TimeProvider* time_provider) { |
| 371 time_provider_ = time_provider; | 372 time_provider_ = time_provider; |
| 372 } | 373 } |
| 373 #endif | 374 #endif |
| 374 | 375 |
| 375 private: | 376 private: |
| 376 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, TestManagedDefaultSearch); | 377 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, TestManagedDefaultSearch); |
| 377 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, | 378 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, |
| 378 UpdateKeywordSearchTermsForURL); | 379 UpdateKeywordSearchTermsForURL); |
| 379 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, | 380 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, |
| 380 DontUpdateKeywordSearchForNonReplaceable); | 381 DontUpdateKeywordSearchForNonReplaceable); |
| 381 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, ChangeGoogleBaseValue); | 382 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, ChangeGoogleBaseValue); |
| 382 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, MergeDeletesUnusedProviders); | 383 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, MergeDeletesUnusedProviders); |
| 384 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, AddExtensionKeyword); |
| 383 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, UniquifyKeyword); | 385 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, UniquifyKeyword); |
| 384 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, | 386 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, |
| 385 IsLocalTemplateURLBetter); | 387 IsLocalTemplateURLBetter); |
| 386 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, | 388 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, |
| 387 ResolveSyncKeywordConflict); | 389 ResolveSyncKeywordConflict); |
| 388 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, PreSyncDeletes); | 390 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, PreSyncDeletes); |
| 389 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, MergeInSyncTemplateURL); | 391 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, MergeInSyncTemplateURL); |
| 390 | 392 |
| 391 friend class InstantUnitTestBase; | 393 friend class InstantUnitTestBase; |
| 392 friend class TemplateURLServiceTestUtil; | 394 friend class TemplateURLServiceTestUtil; |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 | 742 |
| 741 // Helper class to manage the default search engine. | 743 // Helper class to manage the default search engine. |
| 742 DefaultSearchManager default_search_manager_; | 744 DefaultSearchManager default_search_manager_; |
| 743 | 745 |
| 744 scoped_ptr<GoogleURLTracker::Subscription> google_url_updated_subscription_; | 746 scoped_ptr<GoogleURLTracker::Subscription> google_url_updated_subscription_; |
| 745 | 747 |
| 746 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 748 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
| 747 }; | 749 }; |
| 748 | 750 |
| 749 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 751 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| OLD | NEW |