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