OLD | NEW |
| (Empty) |
1 // Copyright 2012 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. | |
4 | |
5 #include "chrome/common/instant_types.h" | |
6 | |
7 #include "base/strings/utf_string_conversions.h" | |
8 #include "net/base/escape.h" | |
9 | |
10 namespace { | |
11 | |
12 std::string GetComponent(const std::string& url, | |
13 const url::Component component) { | |
14 return (component.len > 0) ? url.substr(component.begin, component.len) : | |
15 std::string(); | |
16 } | |
17 | |
18 } // namespace | |
19 | |
20 InstantSuggestion::InstantSuggestion() { | |
21 } | |
22 | |
23 InstantSuggestion::InstantSuggestion(const base::string16& in_text, | |
24 const std::string& in_metadata) | |
25 : text(in_text), | |
26 metadata(in_metadata) { | |
27 } | |
28 | |
29 InstantSuggestion::~InstantSuggestion() { | |
30 } | |
31 | |
32 RGBAColor::RGBAColor() | |
33 : r(0), | |
34 g(0), | |
35 b(0), | |
36 a(0) { | |
37 } | |
38 | |
39 RGBAColor::~RGBAColor() { | |
40 } | |
41 | |
42 bool RGBAColor::operator==(const RGBAColor& rhs) const { | |
43 return r == rhs.r && | |
44 g == rhs.g && | |
45 b == rhs.b && | |
46 a == rhs.a; | |
47 } | |
48 | |
49 ThemeBackgroundInfo::ThemeBackgroundInfo() | |
50 : using_default_theme(true), | |
51 background_color(), | |
52 text_color(), | |
53 link_color(), | |
54 text_color_light(), | |
55 header_color(), | |
56 section_border_color(), | |
57 image_horizontal_alignment(THEME_BKGRND_IMAGE_ALIGN_CENTER), | |
58 image_vertical_alignment(THEME_BKGRND_IMAGE_ALIGN_CENTER), | |
59 image_tiling(THEME_BKGRND_IMAGE_NO_REPEAT), | |
60 image_height(0), | |
61 has_attribution(false), | |
62 logo_alternate(false) { | |
63 } | |
64 | |
65 ThemeBackgroundInfo::~ThemeBackgroundInfo() { | |
66 } | |
67 | |
68 bool ThemeBackgroundInfo::operator==(const ThemeBackgroundInfo& rhs) const { | |
69 return using_default_theme == rhs.using_default_theme && | |
70 background_color == rhs.background_color && | |
71 text_color == rhs.text_color && | |
72 link_color == rhs.link_color && | |
73 text_color_light == rhs.text_color_light && | |
74 header_color == rhs.header_color && | |
75 section_border_color == rhs.section_border_color && | |
76 theme_id == rhs.theme_id && | |
77 image_horizontal_alignment == rhs.image_horizontal_alignment && | |
78 image_vertical_alignment == rhs.image_vertical_alignment && | |
79 image_tiling == rhs.image_tiling && | |
80 image_height == rhs.image_height && | |
81 has_attribution == rhs.has_attribution && | |
82 logo_alternate == rhs.logo_alternate; | |
83 } | |
84 | |
85 const char kSearchQueryKey[] = "q"; | |
86 const char kOriginalQueryKey[] = "oq"; | |
87 const char kRLZParameterKey[] = "rlz"; | |
88 const char kInputEncodingKey[] = "ie"; | |
89 const char kAssistedQueryStatsKey[] = "aqs"; | |
90 | |
91 InstantMostVisitedItem::InstantMostVisitedItem() {} | |
92 | |
93 InstantMostVisitedItem::InstantMostVisitedItem( | |
94 const InstantMostVisitedItem& other) = default; | |
95 | |
96 InstantMostVisitedItem::~InstantMostVisitedItem() {} | |
97 | |
98 EmbeddedSearchRequestParams::EmbeddedSearchRequestParams() { | |
99 } | |
100 | |
101 EmbeddedSearchRequestParams::EmbeddedSearchRequestParams(const GURL& url) { | |
102 const std::string& url_params(url.ref().empty()? url.query() : url.ref()); | |
103 url::Component query, key, value; | |
104 query.len = static_cast<int>(url_params.size()); | |
105 | |
106 const net::UnescapeRule::Type unescape_rules = | |
107 net::UnescapeRule::SPOOFING_AND_CONTROL_CHARS | | |
108 net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | | |
109 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS | | |
110 net::UnescapeRule::NORMAL | net::UnescapeRule::REPLACE_PLUS_WITH_SPACE; | |
111 | |
112 while (url::ExtractQueryKeyValue(url_params.c_str(), &query, &key, &value)) { | |
113 if (!key.is_nonempty()) | |
114 continue; | |
115 | |
116 std::string key_param(GetComponent(url_params, key)); | |
117 std::string value_param(GetComponent(url_params, value)); | |
118 if (key_param == kSearchQueryKey) { | |
119 search_query = base::UTF8ToUTF16(net::UnescapeURLComponent( | |
120 value_param, unescape_rules)); | |
121 } else if (key_param == kOriginalQueryKey) { | |
122 original_query = base::UTF8ToUTF16(net::UnescapeURLComponent( | |
123 value_param, unescape_rules)); | |
124 } else if (key_param == kRLZParameterKey) { | |
125 rlz_parameter_value = net::UnescapeAndDecodeUTF8URLComponent( | |
126 value_param, net::UnescapeRule::NORMAL); | |
127 } else if (key_param == kInputEncodingKey) { | |
128 input_encoding = net::UnescapeAndDecodeUTF8URLComponent( | |
129 value_param, net::UnescapeRule::NORMAL); | |
130 } else if (key_param == kAssistedQueryStatsKey) { | |
131 assisted_query_stats = net::UnescapeAndDecodeUTF8URLComponent( | |
132 value_param, net::UnescapeRule::NORMAL); | |
133 } | |
134 } | |
135 } | |
136 | |
137 EmbeddedSearchRequestParams::~EmbeddedSearchRequestParams() { | |
138 } | |
OLD | NEW |