OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 CreateSyncDataFromTemplateURL); | 329 CreateSyncDataFromTemplateURL); |
330 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, | 330 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, |
331 CreateTemplateURLFromSyncData); | 331 CreateTemplateURLFromSyncData); |
332 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, UniquifyKeyword); | 332 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, UniquifyKeyword); |
333 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, | 333 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, |
334 ResolveSyncKeywordConflict); | 334 ResolveSyncKeywordConflict); |
335 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, | 335 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, |
336 FindDuplicateOfSyncTemplateURL); | 336 FindDuplicateOfSyncTemplateURL); |
337 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, | 337 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, |
338 MergeSyncAndLocalURLDuplicates); | 338 MergeSyncAndLocalURLDuplicates); |
339 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, | |
340 CreateGUIDToSyncDataMap); | |
341 | 339 |
342 friend class TemplateURLServiceTestUtil; | 340 friend class TemplateURLServiceTestUtil; |
343 | 341 |
344 typedef std::map<string16, const TemplateURL*> KeywordToTemplateMap; | 342 typedef std::map<string16, const TemplateURL*> KeywordToTemplateMap; |
345 typedef std::map<std::string, const TemplateURL*> GUIDToTemplateMap; | 343 typedef std::map<std::string, const TemplateURL*> GUIDToTemplateMap; |
346 | 344 |
347 // Helper functor for FindMatchingKeywords(), for finding the range of | 345 // Helper functor for FindMatchingKeywords(), for finding the range of |
348 // keywords which begin with a prefix. | 346 // keywords which begin with a prefix. |
349 class LessWithPrefix; | 347 class LessWithPrefix; |
350 | 348 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 // FindDuplcateOfSyncTemplateURL, merges the two. If |sync_url| is newer, this | 487 // FindDuplcateOfSyncTemplateURL, merges the two. If |sync_url| is newer, this |
490 // replaces |local_url| with |sync_url| using the service's Remove and Add. | 488 // replaces |local_url| with |sync_url| using the service's Remove and Add. |
491 // If |local_url| is newer, this copies the GUID from |sync_url| over to | 489 // If |local_url| is newer, this copies the GUID from |sync_url| over to |
492 // |local_url| and adds an update to change_list to notify the server of the | 490 // |local_url| and adds an update to change_list to notify the server of the |
493 // change. This method takes ownership of |sync_url|, and adds it to the model | 491 // change. This method takes ownership of |sync_url|, and adds it to the model |
494 // if it is newer, so the caller must release it if need be. | 492 // if it is newer, so the caller must release it if need be. |
495 void MergeSyncAndLocalURLDuplicates(TemplateURL* sync_url, | 493 void MergeSyncAndLocalURLDuplicates(TemplateURL* sync_url, |
496 TemplateURL* local_url, | 494 TemplateURL* local_url, |
497 SyncChangeList* change_list); | 495 SyncChangeList* change_list); |
498 | 496 |
| 497 // Checks a newly added TemplateURL from Sync by its sync_guid and sets it as |
| 498 // the default search provider if we were waiting for it. |
| 499 void CheckForSyncedDefaultSearchProvider(const std::string& guid); |
| 500 |
| 501 // Retrieve the pending default search provider according to Sync. Returns |
| 502 // NULL if there was no pending search provider from Sync. |
| 503 const TemplateURL* GetPendingSyncedDefaultSearchProvder(); |
| 504 |
499 content::NotificationRegistrar registrar_; | 505 content::NotificationRegistrar registrar_; |
500 | 506 |
501 // Mapping from keyword to the TemplateURL. | 507 // Mapping from keyword to the TemplateURL. |
502 KeywordToTemplateMap keyword_to_template_map_; | 508 KeywordToTemplateMap keyword_to_template_map_; |
503 | 509 |
504 // Mapping from Sync GUIDs to the TemplateURL. | 510 // Mapping from Sync GUIDs to the TemplateURL. |
505 GUIDToTemplateMap guid_to_template_map_; | 511 GUIDToTemplateMap guid_to_template_map_; |
506 | 512 |
507 TemplateURLVector template_urls_; | 513 TemplateURLVector template_urls_; |
508 | 514 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 // true, we ignore any local search engine changes, since we triggered them. | 577 // true, we ignore any local search engine changes, since we triggered them. |
572 bool processing_syncer_changes_; | 578 bool processing_syncer_changes_; |
573 | 579 |
574 // Sync's SyncChange handler. We push all our changes through this. | 580 // Sync's SyncChange handler. We push all our changes through this. |
575 SyncChangeProcessor* sync_processor_; | 581 SyncChangeProcessor* sync_processor_; |
576 | 582 |
577 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 583 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
578 }; | 584 }; |
579 | 585 |
580 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 586 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
OLD | NEW |