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

Side by Side Diff: components/search_engines/template_url.h

Issue 2639153002: Make extensions DSE persistent in browser prefs (Reland) (Closed)
Patch Set: Fixed flakiness caused by extension reload while TemplateURLService is not loaded Created 3 years, 10 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
OLDNEW
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_H_ 5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_
6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_ 6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // An AssociatedExtensionInfo represents information about the extension that 482 // An AssociatedExtensionInfo represents information about the extension that
483 // added the search engine. 483 // added the search engine.
484 struct AssociatedExtensionInfo { 484 struct AssociatedExtensionInfo {
485 explicit AssociatedExtensionInfo(const std::string& extension_id); 485 explicit AssociatedExtensionInfo(const std::string& extension_id);
486 ~AssociatedExtensionInfo(); 486 ~AssociatedExtensionInfo();
487 487
488 std::string extension_id; 488 std::string extension_id;
489 489
490 // Whether the search engine is supposed to be default. 490 // Whether the search engine is supposed to be default.
491 bool wants_to_be_default_engine; 491 bool wants_to_be_default_engine;
492
493 // Used to resolve conflicts when there are multiple extensions specifying
494 // the default search engine. The most recently-installed wins.
495 base::Time install_time;
496 }; 492 };
497 493
498 explicit TemplateURL(const TemplateURLData& data, Type type = NORMAL); 494 explicit TemplateURL(const TemplateURLData& data, Type type = NORMAL);
499 ~TemplateURL(); 495 ~TemplateURL();
500 496
501 // Generates a suitable keyword for the specified url, which must be valid. 497 // Generates a suitable keyword for the specified url, which must be valid.
502 // This is guaranteed not to return an empty string, since TemplateURLs should 498 // This is guaranteed not to return an empty string, since TemplateURLs should
503 // never have an empty keyword. 499 // never have an empty keyword.
504 static base::string16 GenerateKeyword(const GURL& url); 500 static base::string16 GenerateKeyword(const GURL& url);
505 501
506 // Generates a favicon URL from the specified url. 502 // Generates a favicon URL from the specified url.
507 static GURL GenerateFaviconURL(const GURL& url); 503 static GURL GenerateFaviconURL(const GURL& url);
508 504
509 // Returns true if |t_url| and |data| are equal in all meaningful respects. 505 // Returns true if |t_url| and |data| are equal in all meaningful respects.
510 // Static to allow either or both params to be NULL. 506 // Static to allow either or both params to be NULL.
511 static bool MatchesData(const TemplateURL* t_url, 507 static bool MatchesData(const TemplateURL* t_url,
512 const TemplateURLData* data, 508 const TemplateURLData* data,
513 const SearchTermsData& search_terms_data); 509 const SearchTermsData& search_terms_data);
514 510
511 // Special case for search_terms_replacement_key comparison, because of
512 // its special initialization in TemplateURL constructor.
513 static bool SearchTermsReplacementKeysMatch(
514 const std::string& search_terms_replacement_key1,
515 const std::string& search_terms_replacement_key2);
516
515 const TemplateURLData& data() const { return data_; } 517 const TemplateURLData& data() const { return data_; }
516 518
517 const base::string16& short_name() const { return data_.short_name(); } 519 const base::string16& short_name() const { return data_.short_name(); }
518 // An accessor for the short_name, but adjusted so it can be appropriately 520 // An accessor for the short_name, but adjusted so it can be appropriately
519 // displayed even if it is LTR and the UI is RTL. 521 // displayed even if it is LTR and the UI is RTL.
520 base::string16 AdjustedShortNameForLocaleDirection() const; 522 base::string16 AdjustedShortNameForLocaleDirection() const;
521 523
522 const base::string16& keyword() const { return data_.keyword(); } 524 const base::string16& keyword() const { return data_.keyword(); }
523 525
524 const std::string& url() const { return data_.url(); } 526 const std::string& url() const { return data_.url(); }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 589
588 Type type() const { return type_; } 590 Type type() const { return type_; }
589 591
590 // This setter shouldn't be used except by TemplateURLService and 592 // This setter shouldn't be used except by TemplateURLService and
591 // TemplateURLServiceClient implementations. 593 // TemplateURLServiceClient implementations.
592 void set_extension_info( 594 void set_extension_info(
593 std::unique_ptr<AssociatedExtensionInfo> extension_info) { 595 std::unique_ptr<AssociatedExtensionInfo> extension_info) {
594 extension_info_ = std::move(extension_info); 596 extension_info_ = std::move(extension_info);
595 } 597 }
596 598
599 const AssociatedExtensionInfo* GetExtensionInfoForTesting() const {
600 return extension_info_.get();
601 }
602
597 // Returns true if |url| supports replacement. 603 // Returns true if |url| supports replacement.
598 bool SupportsReplacement(const SearchTermsData& search_terms_data) const; 604 bool SupportsReplacement(const SearchTermsData& search_terms_data) const;
599 605
600 // Returns true if any URLRefs use Googe base URLs. 606 // Returns true if any URLRefs use Googe base URLs.
601 bool HasGoogleBaseURLs(const SearchTermsData& search_terms_data) const; 607 bool HasGoogleBaseURLs(const SearchTermsData& search_terms_data) const;
602 608
603 // Returns true if this TemplateURL uses Google base URLs and has a keyword 609 // Returns true if this TemplateURL uses Google base URLs and has a keyword
604 // of "google.TLD". We use this to decide whether we can automatically 610 // of "google.TLD". We use this to decide whether we can automatically
605 // update the keyword to reflect the current Google base URL TLD. 611 // update the keyword to reflect the current Google base URL TLD.
606 bool IsGoogleSearchURLWithReplaceableKeyword( 612 bool IsGoogleSearchURLWithReplaceableKeyword(
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 737
732 // Caches the computed engine type across successive calls to GetEngineType(). 738 // Caches the computed engine type across successive calls to GetEngineType().
733 mutable SearchEngineType engine_type_; 739 mutable SearchEngineType engine_type_;
734 740
735 // TODO(sky): Add date last parsed OSD file. 741 // TODO(sky): Add date last parsed OSD file.
736 742
737 DISALLOW_COPY_AND_ASSIGN(TemplateURL); 743 DISALLOW_COPY_AND_ASSIGN(TemplateURL);
738 }; 744 };
739 745
740 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_ 746 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698