[AndroidWebViewShell] Replace rebaseline script with a new version using test_runner.py
[chromium-blink-merge.git] / components / search_engines / template_url_data.h
blob15fbad023bb5c41e9a4ecb96720aba8468efce1a
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_
6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_
8 #include <string>
9 #include <vector>
11 #include "base/strings/string16.h"
12 #include "base/time/time.h"
13 #include "components/search_engines/template_url_id.h"
14 #include "url/gurl.h"
16 // 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
18 // whatever fields are desired, then create an immutable TemplateURL from it.
19 struct TemplateURLData {
20 TemplateURLData();
21 ~TemplateURLData();
23 // A short description of the template. This is the name we show to the user
24 // in various places that use TemplateURLs. For example, the location bar
25 // shows this when the user selects a substituting match.
26 void SetShortName(const base::string16& short_name);
27 const base::string16& short_name() const { return short_name_; }
29 // The shortcut for this TemplateURL. |keyword| must be non-empty.
30 void SetKeyword(const base::string16& keyword);
31 const base::string16& keyword() const { return keyword_; }
33 // The raw URL for the TemplateURL, which may not be valid as-is (e.g. because
34 // it requires substitutions first). This must be non-empty.
35 void SetURL(const std::string& url);
36 const std::string& url() const { return url_; }
38 // Optional additional raw URLs.
39 std::string suggestions_url;
40 std::string instant_url;
41 std::string image_url;
42 std::string new_tab_url;
43 std::string contextual_search_url;
45 // The following post_params are comma-separated lists used to specify the
46 // post parameters for the corresponding URL.
47 std::string search_url_post_params;
48 std::string suggestions_url_post_params;
49 std::string instant_url_post_params;
50 std::string image_url_post_params;
52 // Optional favicon for the TemplateURL.
53 GURL favicon_url;
55 // URL to the OSD file this came from. May be empty.
56 GURL originating_url;
58 // Whether this TemplateURL is shown in the default list of search providers.
59 // This is just a property and does not indicate whether the TemplateURL has a
60 // TemplateURLRef that supports replacement. Use
61 // TemplateURL::ShowInDefaultList() to test both.
62 bool show_in_default_list;
64 // Whether it's safe for auto-modification code (the autogenerator and the
65 // code that imports data from other browsers) to replace the TemplateURL.
66 // This should be set to false for any TemplateURL the user edits, or any
67 // TemplateURL that the user clearly manually edited in the past, like a
68 // bookmark keyword from another browser.
69 bool safe_for_autoreplace;
71 // The list of supported encodings for the search terms. This may be empty,
72 // which indicates the terms should be encoded with UTF-8.
73 std::vector<std::string> input_encodings;
75 // Unique identifier of this TemplateURL. The unique ID is set by the
76 // TemplateURLService when the TemplateURL is added to it.
77 TemplateURLID id;
79 // Date this TemplateURL was created.
81 // NOTE: this may be 0, which indicates the TemplateURL was created before we
82 // started tracking creation time.
83 base::Time date_created;
85 // The last time this TemplateURL was modified by a user, since creation.
87 // NOTE: Like date_created above, this may be 0.
88 base::Time last_modified;
90 // True if this TemplateURL was automatically created by the administrator via
91 // group policy.
92 bool created_by_policy;
94 // Number of times this TemplateURL has been explicitly used to load a URL.
95 // We don't increment this for uses as the "default search engine" since
96 // that's not really "explicit" usage and incrementing would result in pinning
97 // the user's default search engine(s) to the top of the list of searches on
98 // the New Tab page, de-emphasizing the omnibox as "where you go to search".
99 int usage_count;
101 // If this TemplateURL comes from prepopulated data the prepopulate_id is > 0.
102 int prepopulate_id;
104 // The primary unique identifier for Sync. This set on all TemplateURLs
105 // regardless of whether they have been associated with Sync.
106 std::string sync_guid;
108 // A list of URL patterns that can be used, in addition to |url_|, to extract
109 // search terms from a URL.
110 std::vector<std::string> alternate_urls;
112 // A parameter that, if present in the query or ref parameters of a search_url
113 // or instant_url, causes Chrome to replace the URL with the search term.
114 std::string search_terms_replacement_key;
116 private:
117 // Private so we can enforce using the setters and thus enforce that these
118 // fields are never empty.
119 base::string16 short_name_;
120 base::string16 keyword_;
121 std::string url_;
124 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_