OLD | NEW |
---|---|
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_DATA_H_ | 5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_ |
6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_ | 6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "components/search_engines/template_url_id.h" | 13 #include "components/search_engines/template_url_id.h" |
14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
15 | 15 |
16 namespace base { | |
17 class ListValue; | |
18 } | |
19 | |
16 // The data for the TemplateURL. Separating this into its own class allows most | 20 // The data for the TemplateURL. Separating this into its own class allows most |
17 // users to do SSA-style usage of TemplateURL: construct a TemplateURLData with | 21 // users to do SSA-style usage of TemplateURL: construct a TemplateURLData with |
18 // whatever fields are desired, then create an immutable TemplateURL from it. | 22 // whatever fields are desired, then create an immutable TemplateURL from it. |
19 struct TemplateURLData { | 23 struct TemplateURLData { |
20 TemplateURLData(); | 24 TemplateURLData(); |
21 TemplateURLData(const TemplateURLData& other); | 25 TemplateURLData(const TemplateURLData& other); |
26 // Creates a TemplateURLData suitable for prepopulated engines. | |
27 // Note that unlike in the default constructor, |safe_for_autoreplace| will | |
28 // be set to true. date_created and last_modified will be set to null time | |
29 // value, instead of current time. | |
30 TemplateURLData(const base::string16& name, | |
31 const base::string16& keyword, | |
32 const base::StringPiece& search_url, | |
Peter Kasting
2016/11/21 21:03:54
Prefer to pass StringPiece by value (see https://c
| |
33 const base::StringPiece& suggest_url, | |
34 const base::StringPiece& instant_url, | |
35 const base::StringPiece& image_url, | |
36 const base::StringPiece& new_tab_url, | |
37 const base::StringPiece& contextual_search_url, | |
38 const base::StringPiece& search_url_post_params, | |
39 const base::StringPiece& suggest_url_post_params, | |
40 const base::StringPiece& instant_url_post_params, | |
41 const base::StringPiece& image_url_post_params, | |
42 const base::StringPiece& favicon_url, | |
43 const base::StringPiece& encoding, | |
44 const base::ListValue& alternate_urls_list, | |
45 const base::StringPiece& search_terms_replacement_key, | |
46 int prepopulate_id); | |
47 | |
22 ~TemplateURLData(); | 48 ~TemplateURLData(); |
23 | 49 |
24 // A short description of the template. This is the name we show to the user | 50 // A short description of the template. This is the name we show to the user |
25 // in various places that use TemplateURLs. For example, the location bar | 51 // in various places that use TemplateURLs. For example, the location bar |
26 // shows this when the user selects a substituting match. | 52 // shows this when the user selects a substituting match. |
27 void SetShortName(const base::string16& short_name); | 53 void SetShortName(const base::string16& short_name); |
28 const base::string16& short_name() const { return short_name_; } | 54 const base::string16& short_name() const { return short_name_; } |
29 | 55 |
30 // The shortcut for this TemplateURL. |keyword| must be non-empty. | 56 // The shortcut for this TemplateURL. |keyword| must be non-empty. |
31 void SetKeyword(const base::string16& keyword); | 57 void SetKeyword(const base::string16& keyword); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 | 136 |
111 private: | 137 private: |
112 // Private so we can enforce using the setters and thus enforce that these | 138 // Private so we can enforce using the setters and thus enforce that these |
113 // fields are never empty. | 139 // fields are never empty. |
114 base::string16 short_name_; | 140 base::string16 short_name_; |
115 base::string16 keyword_; | 141 base::string16 keyword_; |
116 std::string url_; | 142 std::string url_; |
117 }; | 143 }; |
118 | 144 |
119 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_ | 145 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_ |
OLD | NEW |