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

Side by Side Diff: chrome/browser/search_engines/template_url_service.h

Issue 7826003: Retroactively addressed sky@'s comments from CL http://codereview.chromium.org/7566036/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Initial upload Created 9 years, 3 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
OLDNEW
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 void FindMatchingKeywords(const string16& prefix, 122 void FindMatchingKeywords(const string16& prefix,
123 bool support_replacement_only, 123 bool support_replacement_only,
124 std::vector<string16>* matches) const; 124 std::vector<string16>* matches) const;
125 125
126 // Looks up |keyword| and returns the element it maps to. Returns NULL if 126 // Looks up |keyword| and returns the element it maps to. Returns NULL if
127 // the keyword was not found. 127 // the keyword was not found.
128 // The caller should not try to delete the returned pointer; the data store 128 // The caller should not try to delete the returned pointer; the data store
129 // retains ownership of it. 129 // retains ownership of it.
130 const TemplateURL* GetTemplateURLForKeyword(const string16& keyword) const; 130 const TemplateURL* GetTemplateURLForKeyword(const string16& keyword) const;
131 131
132 // Looks up |sync_guid| and returns the element it maps to. Returns NULL if 132 // Returns that TemplateURL with the specified GUID, or NULL if not found.
133 // the guid was not found.
134 // The caller should not try to delete the returned pointer; the data store 133 // The caller should not try to delete the returned pointer; the data store
SteveT 2011/09/01 14:21:54 sky 2011/08/17 23:22:29 nit: Returns the TemplateU
135 // retains ownership of it. 134 // retains ownership of it.
136 const TemplateURL* GetTemplateURLForGUID(const std::string& sync_guid) const; 135 const TemplateURL* GetTemplateURLForGUID(const std::string& sync_guid) const;
137 136
138 // Returns the first TemplateURL found with a URL using the specified |host|, 137 // Returns the first TemplateURL found with a URL using the specified |host|,
139 // or NULL if there are no such TemplateURLs 138 // or NULL if there are no such TemplateURLs
140 const TemplateURL* GetTemplateURLForHost(const std::string& host) const; 139 const TemplateURL* GetTemplateURLForHost(const std::string& host) const;
141 140
142 // Adds a new TemplateURL to this model. TemplateURLService will own the 141 // Adds a new TemplateURL to this model. TemplateURLService will own the
143 // reference, and delete it when the TemplateURL is removed. 142 // reference, and delete it when the TemplateURL is removed.
144 void Add(TemplateURL* template_url); 143 void Add(TemplateURL* template_url);
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // to the database. This does not notify observers. 464 // to the database. This does not notify observers.
466 void ResetTemplateURLGUID(const TemplateURL* url, const std::string& guid); 465 void ResetTemplateURLGUID(const TemplateURL* url, const std::string& guid);
467 466
468 // Attempts to generate a unique keyword for |turl| based on its original 467 // Attempts to generate a unique keyword for |turl| based on its original
469 // keyword. If its keyword is already unique, that is returned. Otherwise, it 468 // keyword. If its keyword is already unique, that is returned. Otherwise, it
470 // tries to return the autogenerated keyword if that is unique to the Service, 469 // tries to return the autogenerated keyword if that is unique to the Service,
471 // and finally it repeatedly appends special characters to the keyword until 470 // and finally it repeatedly appends special characters to the keyword until
472 // it is unique to the Service. 471 // it is unique to the Service.
473 string16 UniquifyKeyword(const TemplateURL& turl) const; 472 string16 UniquifyKeyword(const TemplateURL& turl) const;
474 473
475 // Given a TemplateURL from Sync, resolves any keyword conflicts by checking 474 // Given a TemplateURL from Sync (cloud), resolves any keyword conflicts by
SteveT 2011/09/01 14:21:54 sky 2011/08/17 23:22:29 nit: add (cloud) after Syn
476 // the local keywords and uniquifying either the cloud keyword or a 475 // checking the local keywords and uniquifying either the cloud keyword or a
477 // conflicting local keyword (whichever is older). If the cloud TURL is 476 // conflicting local keyword (whichever is older). If the cloud TURL is
478 // changed, then an appropriate SyncChange is appended to |change_list|. If 477 // changed, then an appropriate SyncChange is appended to |change_list|. If
479 // a local TURL is changed, the service is updated with the new keyword. If 478 // a local TURL is changed, the service is updated with the new keyword. If
480 // there was no conflict to begin with, this does nothing. In the case of tied 479 // there was no conflict to begin with, this does nothing. In the case of tied
481 // last_modified dates, |sync_turl| wins. Returns true iff there was a 480 // last_modified dates, |sync_turl| wins. Returns true iff there was a
482 // conflict. 481 // conflict.
483 bool ResolveSyncKeywordConflict(TemplateURL* sync_turl, 482 bool ResolveSyncKeywordConflict(TemplateURL* sync_turl,
484 SyncChangeList& change_list); 483 SyncChangeList* change_list);
SteveT 2011/09/01 14:21:54 sky 2011/08/17 23:22:29 Because this may modify ch
485 484
486 // Returns a TemplateURL from the service that has the same keyword and search 485 // Returns a TemplateURL from the service that has the same keyword and search
487 // URL as |sync_turl|, if it exists. 486 // URL as |sync_turl|, if it exists.
488 const TemplateURL* FindDuplicateOfSyncTemplateURL( 487 const TemplateURL* FindDuplicateOfSyncTemplateURL(
489 const TemplateURL& sync_turl); 488 const TemplateURL& sync_turl);
490 489
491 // Given a TemplateURL from the cloud and a local matching duplicate found by 490 // Given a TemplateURL from the cloud and a local matching duplicate found by
492 // FindDuplcateOfSyncTemplateURL, merges the two. If |sync_url| is newer, this 491 // FindDuplcateOfSyncTemplateURL, merges the two. If |sync_url| is newer, this
493 // replaces |local_url| with |sync_url| using the service's Remove and Add. 492 // replaces |local_url| with |sync_url| using the service's Remove and Add.
494 // If |local_url| is newer, this copies the GUID from |sync_url| over to 493 // If |local_url| is newer, this copies the GUID from |sync_url| over to
495 // |local_url| and adds an update to change_list to notify the server of the 494 // |local_url| and adds an update to change_list to notify the server of the
496 // change. This method takes ownership of |sync_url|, and adds it to the model 495 // change. This method takes ownership of |sync_url|, and adds it to the model
497 // if it is newer, so the caller must release it if need be. 496 // if it is newer, so the caller must release it if need be.
498 void MergeSyncAndLocalURLDuplicates(TemplateURL* sync_url, 497 void MergeSyncAndLocalURLDuplicates(TemplateURL* sync_url,
499 TemplateURL* local_url, 498 TemplateURL* local_url,
500 SyncChangeList& change_list); 499 SyncChangeList* change_list);
SteveT 2011/09/01 14:21:54 sky 2011/08/17 23:22:29 change_list should be a po
501 500
502 NotificationRegistrar registrar_; 501 NotificationRegistrar registrar_;
503 502
504 // Mapping from keyword to the TemplateURL. 503 // Mapping from keyword to the TemplateURL.
505 KeywordToTemplateMap keyword_to_template_map_; 504 KeywordToTemplateMap keyword_to_template_map_;
506 505
507 // Mapping from Sync GUIDs to the TemplateURL. 506 // Mapping from Sync GUIDs to the TemplateURL.
508 GUIDToTemplateMap guid_to_template_map_; 507 GUIDToTemplateMap guid_to_template_map_;
509 508
510 TemplateURLVector template_urls_; 509 TemplateURLVector template_urls_;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 // true, we ignore any local search engine changes, since we triggered them. 573 // true, we ignore any local search engine changes, since we triggered them.
575 bool processing_syncer_changes_; 574 bool processing_syncer_changes_;
576 575
577 // Sync's SyncChange handler. We push all our changes through this. 576 // Sync's SyncChange handler. We push all our changes through this.
578 SyncChangeProcessor* sync_processor_; 577 SyncChangeProcessor* sync_processor_;
579 578
580 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); 579 DISALLOW_COPY_AND_ASSIGN(TemplateURLService);
581 }; 580 };
582 581
583 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ 582 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698