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

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

Issue 338363004: Remove Profile* from TemplateURL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 6 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_H_ 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/autocomplete/autocomplete_input.h" 15 #include "chrome/browser/autocomplete/autocomplete_input.h"
16 #include "components/search_engines/template_url_data.h" 16 #include "components/search_engines/template_url_data.h"
17 #include "components/search_engines/template_url_id.h" 17 #include "components/search_engines/template_url_id.h"
18 #include "ui/gfx/size.h" 18 #include "ui/gfx/size.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 #include "url/url_parse.h" 20 #include "url/url_parse.h"
21 21
22 class Profile;
23 class SearchTermsData; 22 class SearchTermsData;
24 class TemplateURL; 23 class TemplateURL;
25 24
26 25
27 // TemplateURLRef ------------------------------------------------------------- 26 // TemplateURLRef -------------------------------------------------------------
28 27
29 // A TemplateURLRef represents a single URL within the larger TemplateURL class 28 // A TemplateURLRef represents a single URL within the larger TemplateURL class
30 // (which represents an entire "search engine", see below). If 29 // (which represents an entire "search engine", see below). If
31 // SupportsReplacement() is true, this URL has placeholders in it, for which 30 // SupportsReplacement() is true, this URL has placeholders in it, for which
32 // callers can substitute values to get a "real" URL using ReplaceSearchTerms(). 31 // callers can substitute values to get a "real" URL using ReplaceSearchTerms().
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 456
458 // TemplateURL ---------------------------------------------------------------- 457 // TemplateURL ----------------------------------------------------------------
459 458
460 // A TemplateURL represents a single "search engine", defined primarily as a 459 // A TemplateURL represents a single "search engine", defined primarily as a
461 // subset of the Open Search Description Document 460 // subset of the Open Search Description Document
462 // (http://www.opensearch.org/Specifications/OpenSearch) plus some extensions. 461 // (http://www.opensearch.org/Specifications/OpenSearch) plus some extensions.
463 // One TemplateURL contains several TemplateURLRefs, which correspond to various 462 // One TemplateURL contains several TemplateURLRefs, which correspond to various
464 // different capabilities (e.g. doing searches or getting suggestions), as well 463 // different capabilities (e.g. doing searches or getting suggestions), as well
465 // as a TemplateURLData containing other details like the name, keyword, etc. 464 // as a TemplateURLData containing other details like the name, keyword, etc.
466 // 465 //
467 // TemplateURLs are intended to be read-only for most users; the only public 466 // TemplateURLs are intended to be read-only for most users.
468 // non-const method is the Profile getter, which returns a non-const Profile*.
469 // The TemplateURLService, which handles storing and manipulating TemplateURLs, 467 // The TemplateURLService, which handles storing and manipulating TemplateURLs,
470 // is made a friend so that it can be the exception to this pattern. 468 // is made a friend so that it can be the exception to this pattern.
471 class TemplateURL { 469 class TemplateURL {
472 public: 470 public:
473 enum Type { 471 enum Type {
474 // Regular search engine. 472 // Regular search engine.
475 NORMAL, 473 NORMAL,
476 // Installed by extension through Override Settings API. 474 // Installed by extension through Override Settings API.
477 NORMAL_CONTROLLED_BY_EXTENSION, 475 NORMAL_CONTROLLED_BY_EXTENSION,
478 // The keyword associated with an extension that uses the Omnibox API. 476 // The keyword associated with an extension that uses the Omnibox API.
479 OMNIBOX_API_EXTENSION, 477 OMNIBOX_API_EXTENSION,
480 }; 478 };
481 // |profile| may be NULL. This will affect the results of e.g. calling 479 explicit TemplateURL(const TemplateURLData& data);
482 // ReplaceSearchTerms() on the member TemplateURLRefs.
483 TemplateURL(Profile* profile, const TemplateURLData& data);
484 ~TemplateURL(); 480 ~TemplateURL();
485 481
486 // Generates a favicon URL from the specified url. 482 // Generates a favicon URL from the specified url.
487 static GURL GenerateFaviconURL(const GURL& url); 483 static GURL GenerateFaviconURL(const GURL& url);
488 484
489 // Returns true if |t_url| and |data| are equal in all meaningful respects. 485 // Returns true if |t_url| and |data| are equal in all meaningful respects.
490 // Static to allow either or both params to be NULL. 486 // Static to allow either or both params to be NULL.
491 static bool MatchesData(const TemplateURL* t_url, 487 static bool MatchesData(const TemplateURL* t_url,
492 const TemplateURLData* data, 488 const TemplateURLData* data,
493 const SearchTermsData& search_terms_data); 489 const SearchTermsData& search_terms_data);
494 490
495 Profile* profile() { return profile_; }
496 const TemplateURLData& data() const { return data_; } 491 const TemplateURLData& data() const { return data_; }
497 492
498 const base::string16& short_name() const { return data_.short_name; } 493 const base::string16& short_name() const { return data_.short_name; }
499 // An accessor for the short_name, but adjusted so it can be appropriately 494 // An accessor for the short_name, but adjusted so it can be appropriately
500 // displayed even if it is LTR and the UI is RTL. 495 // displayed even if it is LTR and the UI is RTL.
501 base::string16 AdjustedShortNameForLocaleDirection() const; 496 base::string16 AdjustedShortNameForLocaleDirection() const;
502 497
503 const base::string16& keyword() const { return data_.keyword(); } 498 const base::string16& keyword() const { return data_.keyword(); }
504 499
505 const std::string& url() const { return data_.url(); } 500 const std::string& url() const { return data_.url(); }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 // Uses the alternate URLs and the search URL to match the provided |url| 669 // Uses the alternate URLs and the search URL to match the provided |url|
675 // and extract |search_terms| from it as well as the |search_terms_component| 670 // and extract |search_terms| from it as well as the |search_terms_component|
676 // (either REF or QUERY) and |search_terms_component| at which the 671 // (either REF or QUERY) and |search_terms_component| at which the
677 // |search_terms| are found in |url|. See also ExtractSearchTermsFromURL(). 672 // |search_terms| are found in |url|. See also ExtractSearchTermsFromURL().
678 bool FindSearchTermsInURL(const GURL& url, 673 bool FindSearchTermsInURL(const GURL& url,
679 const SearchTermsData& search_terms_data, 674 const SearchTermsData& search_terms_data,
680 base::string16* search_terms, 675 base::string16* search_terms,
681 url::Parsed::ComponentType* search_terms_component, 676 url::Parsed::ComponentType* search_terms_component,
682 url::Component* search_terms_position); 677 url::Component* search_terms_position);
683 678
684 Profile* profile_;
685 TemplateURLData data_; 679 TemplateURLData data_;
686 TemplateURLRef url_ref_; 680 TemplateURLRef url_ref_;
687 TemplateURLRef suggestions_url_ref_; 681 TemplateURLRef suggestions_url_ref_;
688 TemplateURLRef instant_url_ref_; 682 TemplateURLRef instant_url_ref_;
689 TemplateURLRef image_url_ref_; 683 TemplateURLRef image_url_ref_;
690 TemplateURLRef new_tab_url_ref_; 684 TemplateURLRef new_tab_url_ref_;
691 TemplateURLRef contextual_search_url_ref_; 685 TemplateURLRef contextual_search_url_ref_;
692 scoped_ptr<AssociatedExtensionInfo> extension_info_; 686 scoped_ptr<AssociatedExtensionInfo> extension_info_;
693 687
694 // TODO(sky): Add date last parsed OSD file. 688 // TODO(sky): Add date last parsed OSD file.
695 689
696 DISALLOW_COPY_AND_ASSIGN(TemplateURL); 690 DISALLOW_COPY_AND_ASSIGN(TemplateURL);
697 }; 691 };
698 692
699 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ 693 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/search_provider_install_data_unittest.cc ('k') | chrome/browser/search_engines/template_url.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698