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

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

Issue 2497853002: Create TemplateUrlData to base::Dictionary utility functions (Closed)
Patch Set: Fixed android compilation Created 4 years 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_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 // StringPiece in arguments is used to pass const char* pointer members
31 // of PrepopulatedEngine structure which can be nullptr.
32 TemplateURLData(const base::string16& name,
33 const base::string16& keyword,
34 base::StringPiece search_url,
35 base::StringPiece suggest_url,
36 base::StringPiece instant_url,
37 base::StringPiece image_url,
38 base::StringPiece new_tab_url,
39 base::StringPiece contextual_search_url,
40 base::StringPiece search_url_post_params,
41 base::StringPiece suggest_url_post_params,
42 base::StringPiece instant_url_post_params,
43 base::StringPiece image_url_post_params,
44 base::StringPiece favicon_url,
45 base::StringPiece encoding,
46 const base::ListValue& alternate_urls_list,
47 base::StringPiece search_terms_replacement_key,
48 int prepopulate_id);
49
22 ~TemplateURLData(); 50 ~TemplateURLData();
23 51
24 // A short description of the template. This is the name we show to the user 52 // 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 53 // in various places that use TemplateURLs. For example, the location bar
26 // shows this when the user selects a substituting match. 54 // shows this when the user selects a substituting match.
27 void SetShortName(const base::string16& short_name); 55 void SetShortName(const base::string16& short_name);
28 const base::string16& short_name() const { return short_name_; } 56 const base::string16& short_name() const { return short_name_; }
29 57
30 // The shortcut for this TemplateURL. |keyword| must be non-empty. 58 // The shortcut for this TemplateURL. |keyword| must be non-empty.
31 void SetKeyword(const base::string16& keyword); 59 void SetKeyword(const base::string16& keyword);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 138
111 private: 139 private:
112 // Private so we can enforce using the setters and thus enforce that these 140 // Private so we can enforce using the setters and thus enforce that these
113 // fields are never empty. 141 // fields are never empty.
114 base::string16 short_name_; 142 base::string16 short_name_;
115 base::string16 keyword_; 143 base::string16 keyword_;
116 std::string url_; 144 std::string url_;
117 }; 145 };
118 146
119 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_ 147 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_
OLDNEW
« no previous file with comments | « components/search_engines/default_search_policy_handler_unittest.cc ('k') | components/search_engines/template_url_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698