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

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

Issue 2623833005: Revert of Make extensions DSE persistent in browser prefs (Closed)
Patch Set: Created 3 years, 11 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 // An AssociatedExtensionInfo represents information about the extension that 505 // An AssociatedExtensionInfo represents information about the extension that
506 // added the search engine. 506 // added the search engine.
507 struct AssociatedExtensionInfo { 507 struct AssociatedExtensionInfo {
508 explicit AssociatedExtensionInfo(const std::string& extension_id); 508 explicit AssociatedExtensionInfo(const std::string& extension_id);
509 ~AssociatedExtensionInfo(); 509 ~AssociatedExtensionInfo();
510 510
511 std::string extension_id; 511 std::string extension_id;
512 512
513 // Whether the search engine is supposed to be default. 513 // Whether the search engine is supposed to be default.
514 bool wants_to_be_default_engine; 514 bool wants_to_be_default_engine;
515
516 // Used to resolve conflicts when there are multiple extensions specifying
517 // the default search engine. The most recently-installed wins.
518 base::Time install_time;
515 }; 519 };
516 520
517 explicit TemplateURL(const TemplateURLData& data, Type type = NORMAL); 521 explicit TemplateURL(const TemplateURLData& data, Type type = NORMAL);
518 ~TemplateURL(); 522 ~TemplateURL();
519 523
520 // Generates a suitable keyword for the specified url, which must be valid. 524 // Generates a suitable keyword for the specified url, which must be valid.
521 // This is guaranteed not to return an empty string, since TemplateURLs should 525 // This is guaranteed not to return an empty string, since TemplateURLs should
522 // never have an empty keyword. 526 // never have an empty keyword.
523 static base::string16 GenerateKeyword(const GURL& url); 527 static base::string16 GenerateKeyword(const GURL& url);
524 528
525 // Generates a favicon URL from the specified url. 529 // Generates a favicon URL from the specified url.
526 static GURL GenerateFaviconURL(const GURL& url); 530 static GURL GenerateFaviconURL(const GURL& url);
527 531
528 // Returns true if |t_url| and |data| are equal in all meaningful respects. 532 // Returns true if |t_url| and |data| are equal in all meaningful respects.
529 // Static to allow either or both params to be NULL. 533 // Static to allow either or both params to be NULL.
530 static bool MatchesData(const TemplateURL* t_url, 534 static bool MatchesData(const TemplateURL* t_url,
531 const TemplateURLData* data, 535 const TemplateURLData* data,
532 const SearchTermsData& search_terms_data); 536 const SearchTermsData& search_terms_data);
533 537
534 // Special case for search_terms_replacement_key comparison, because of
535 // its special initialization in TemplateURL constructor.
536 static bool SearchTermsReplacementKeysMatch(
537 const std::string& search_terms_replacement_key1,
538 const std::string& search_terms_replacement_key2);
539
540 const TemplateURLData& data() const { return data_; } 538 const TemplateURLData& data() const { return data_; }
541 539
542 const base::string16& short_name() const { return data_.short_name(); } 540 const base::string16& short_name() const { return data_.short_name(); }
543 // An accessor for the short_name, but adjusted so it can be appropriately 541 // An accessor for the short_name, but adjusted so it can be appropriately
544 // displayed even if it is LTR and the UI is RTL. 542 // displayed even if it is LTR and the UI is RTL.
545 base::string16 AdjustedShortNameForLocaleDirection() const; 543 base::string16 AdjustedShortNameForLocaleDirection() const;
546 544
547 const base::string16& keyword() const { return data_.keyword(); } 545 const base::string16& keyword() const { return data_.keyword(); }
548 546
549 const std::string& url() const { return data_.url(); } 547 const std::string& url() const { return data_.url(); }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 610
613 Type type() const { return type_; } 611 Type type() const { return type_; }
614 612
615 // This setter shouldn't be used except by TemplateURLService and 613 // This setter shouldn't be used except by TemplateURLService and
616 // TemplateURLServiceClient implementations. 614 // TemplateURLServiceClient implementations.
617 void set_extension_info( 615 void set_extension_info(
618 std::unique_ptr<AssociatedExtensionInfo> extension_info) { 616 std::unique_ptr<AssociatedExtensionInfo> extension_info) {
619 extension_info_ = std::move(extension_info); 617 extension_info_ = std::move(extension_info);
620 } 618 }
621 619
622 const AssociatedExtensionInfo* GetExtensionInfoForTesting() const {
623 return extension_info_.get();
624 }
625
626 // Returns true if |url| supports replacement. 620 // Returns true if |url| supports replacement.
627 bool SupportsReplacement(const SearchTermsData& search_terms_data) const; 621 bool SupportsReplacement(const SearchTermsData& search_terms_data) const;
628 622
629 // Returns true if any URLRefs use Googe base URLs. 623 // Returns true if any URLRefs use Googe base URLs.
630 bool HasGoogleBaseURLs(const SearchTermsData& search_terms_data) const; 624 bool HasGoogleBaseURLs(const SearchTermsData& search_terms_data) const;
631 625
632 // Returns true if this TemplateURL uses Google base URLs and has a keyword 626 // Returns true if this TemplateURL uses Google base URLs and has a keyword
633 // of "google.TLD". We use this to decide whether we can automatically 627 // of "google.TLD". We use this to decide whether we can automatically
634 // update the keyword to reflect the current Google base URL TLD. 628 // update the keyword to reflect the current Google base URL TLD.
635 bool IsGoogleSearchURLWithReplaceableKeyword( 629 bool IsGoogleSearchURLWithReplaceableKeyword(
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 754
761 // Caches the computed engine type across successive calls to GetEngineType(). 755 // Caches the computed engine type across successive calls to GetEngineType().
762 mutable SearchEngineType engine_type_; 756 mutable SearchEngineType engine_type_;
763 757
764 // TODO(sky): Add date last parsed OSD file. 758 // TODO(sky): Add date last parsed OSD file.
765 759
766 DISALLOW_COPY_AND_ASSIGN(TemplateURL); 760 DISALLOW_COPY_AND_ASSIGN(TemplateURL);
767 }; 761 };
768 762
769 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_ 763 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_
OLDNEW
« no previous file with comments | « components/search_engines/search_engines_test_util.cc ('k') | components/search_engines/template_url.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698