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

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

Issue 23536053: Fix read-after-free when loading two search engines with the same keyword. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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) 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 #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 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 418
419 // Removes the supplied template_url from the keyword maps. This searches 419 // Removes the supplied template_url from the keyword maps. This searches
420 // through all entries in the keyword map and does not generate the host or 420 // through all entries in the keyword map and does not generate the host or
421 // keyword. This is used when the cached content of the TemplateURL changes. 421 // keyword. This is used when the cached content of the TemplateURL changes.
422 void RemoveFromKeywordMapByPointer(TemplateURL* template_url); 422 void RemoveFromKeywordMapByPointer(TemplateURL* template_url);
423 423
424 void AddToMaps(TemplateURL* template_url); 424 void AddToMaps(TemplateURL* template_url);
425 425
426 // Sets the keywords. This is used once the keywords have been loaded. 426 // Sets the keywords. This is used once the keywords have been loaded.
427 // This does NOT notify the delegate or the database. 427 // This does NOT notify the delegate or the database.
428 void SetTemplateURLs(const TemplateURLVector& urls); 428 //
429 // This transfers ownership of the elements in |urls| to |this|, and may
430 // delete some elements, so it's not safe for callers to access any elements
431 // after calling; to reinforce this, this function clears |urls| on exit.
432 void SetTemplateURLs(TemplateURLVector* urls);
429 433
430 // Transitions to the loaded state. 434 // Transitions to the loaded state.
431 void ChangeToLoadedState(); 435 void ChangeToLoadedState();
432 436
433 // If there is a notification service, sends TEMPLATE_URL_SERVICE_LOADED 437 // If there is a notification service, sends TEMPLATE_URL_SERVICE_LOADED
434 // notification. 438 // notification.
435 void NotifyLoaded(); 439 void NotifyLoaded();
436 440
437 // Saves enough of url to preferences so that it can be loaded from 441 // Saves enough of url to preferences so that it can be loaded from
438 // preferences on start up. 442 // preferences on start up.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 // Goes through a vector of TemplateURLs and ensure that both the in-memory 612 // Goes through a vector of TemplateURLs and ensure that both the in-memory
609 // and database copies have valid sync_guids. This is to fix crbug.com/102038, 613 // and database copies have valid sync_guids. This is to fix crbug.com/102038,
610 // where old entries were being pushed to Sync without a sync_guid. 614 // where old entries were being pushed to Sync without a sync_guid.
611 void PatchMissingSyncGUIDs(TemplateURLVector* template_urls); 615 void PatchMissingSyncGUIDs(TemplateURLVector* template_urls);
612 616
613 void OnSyncedDefaultSearchProviderGUIDChanged(); 617 void OnSyncedDefaultSearchProviderGUIDChanged();
614 618
615 // Adds |template_urls| to |template_urls_| and sets up the default search 619 // Adds |template_urls| to |template_urls_| and sets up the default search
616 // provider. If |default_search_provider| is non-NULL, it must refer to one 620 // provider. If |default_search_provider| is non-NULL, it must refer to one
617 // of the |template_urls|, and will be used as the new default. 621 // of the |template_urls|, and will be used as the new default.
622 //
623 // This transfers ownership of the elements in |urls| to |this|, and may
624 // delete some elements, so it's not safe for callers to access any elements
625 // after calling; to reinforce this, this function clears |urls| on exit.
beaudoin 2013/09/14 03:24:03 Nit: |urls| --> |template_urls|
Peter Kasting 2013/09/16 21:10:12 Done.
618 void AddTemplateURLsAndSetupDefaultEngine( 626 void AddTemplateURLsAndSetupDefaultEngine(
619 TemplateURLVector* template_urls, 627 TemplateURLVector* template_urls,
620 TemplateURL* default_search_provider); 628 TemplateURL* default_search_provider);
621 629
622 // If there is no current default search provider, sets the default to the 630 // If there is no current default search provider, sets the default to the
623 // result of calling FindNewDefaultSearchProvider(). 631 // result of calling FindNewDefaultSearchProvider().
624 void EnsureDefaultSearchProviderExists(); 632 void EnsureDefaultSearchProviderExists();
625 633
626 // Returns a new TemplateURL for the given extension. 634 // Returns a new TemplateURL for the given extension.
627 TemplateURL* CreateTemplateURLForExtension( 635 TemplateURL* CreateTemplateURLForExtension(
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 723
716 // This is used to log the origin of changes to the default search provider. 724 // This is used to log the origin of changes to the default search provider.
717 // We set this value to increasingly specific values when we know what is the 725 // We set this value to increasingly specific values when we know what is the
718 // cause/origin of a default search change. 726 // cause/origin of a default search change.
719 DefaultSearchChangeOrigin dsp_change_origin_; 727 DefaultSearchChangeOrigin dsp_change_origin_;
720 728
721 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); 729 DISALLOW_COPY_AND_ASSIGN(TemplateURLService);
722 }; 730 };
723 731
724 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ 732 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698