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 SetDefaultSearchProviderIfNewlySynced(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* GetPendingSyncedDefaultSearchProvider(); |
| 504 |
499 // Goes through a vector of TemplateURLs and ensure that both the in-memory | 505 // Goes through a vector of TemplateURLs and ensure that both the in-memory |
500 // and database copies have valid sync_guids. This is to fix crbug.com/102038, | 506 // and database copies have valid sync_guids. This is to fix crbug.com/102038, |
501 // where old entries were being pushed to Sync without a sync_guid. | 507 // where old entries were being pushed to Sync without a sync_guid. |
502 void PatchMissingSyncGUIDs(std::vector<TemplateURL*>* template_urls); | 508 void PatchMissingSyncGUIDs(std::vector<TemplateURL*>* template_urls); |
503 | 509 |
504 content::NotificationRegistrar registrar_; | 510 content::NotificationRegistrar registrar_; |
505 | 511 |
506 // Mapping from keyword to the TemplateURL. | 512 // Mapping from keyword to the TemplateURL. |
507 KeywordToTemplateMap keyword_to_template_map_; | 513 KeywordToTemplateMap keyword_to_template_map_; |
508 | 514 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 // will look up the most recent values anyways). | 578 // will look up the most recent values anyways). |
573 bool models_associated_; | 579 bool models_associated_; |
574 | 580 |
575 // Whether we're currently processing changes from the syncer. While this is | 581 // Whether we're currently processing changes from the syncer. While this is |
576 // true, we ignore any local search engine changes, since we triggered them. | 582 // true, we ignore any local search engine changes, since we triggered them. |
577 bool processing_syncer_changes_; | 583 bool processing_syncer_changes_; |
578 | 584 |
579 // Sync's SyncChange handler. We push all our changes through this. | 585 // Sync's SyncChange handler. We push all our changes through this. |
580 SyncChangeProcessor* sync_processor_; | 586 SyncChangeProcessor* sync_processor_; |
581 | 587 |
| 588 // Whether or not we are waiting on the default search provider to come in |
| 589 // from Sync. This is to facilitate the fact that changes to the value of |
| 590 // prefs::kSyncedDefaultSearchProviderGUID do not always come before the |
| 591 // TemplateURL entry it refers to, and to handle the case when we want to use |
| 592 // the Synced default when the default search provider becomes unmanaged. |
| 593 bool pending_synced_default_search_; |
| 594 |
582 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 595 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
583 }; | 596 }; |
584 | 597 |
585 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 598 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
OLD | NEW |