OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "extensions/browser/api/web_request/web_request_api_helpers.h" | 5 #include "extensions/browser/api/web_request/web_request_api_helpers.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 130 } |
131 | 131 |
132 bool NullableEquals(const std::string* a, const std::string* b) { | 132 bool NullableEquals(const std::string* a, const std::string* b) { |
133 if ((a && !b) || (!a && b)) | 133 if ((a && !b) || (!a && b)) |
134 return false; | 134 return false; |
135 return (!a) || (*a == *b); | 135 return (!a) || (*a == *b); |
136 } | 136 } |
137 | 137 |
138 } // namespace | 138 } // namespace |
139 | 139 |
| 140 bool ExtraInfoSpec::InitFromValue(const base::ListValue& value, |
| 141 int* extra_info_spec) { |
| 142 *extra_info_spec = 0; |
| 143 for (size_t i = 0; i < value.GetSize(); ++i) { |
| 144 std::string str; |
| 145 if (!value.GetString(i, &str)) |
| 146 return false; |
| 147 |
| 148 if (str == "requestHeaders") |
| 149 *extra_info_spec |= REQUEST_HEADERS; |
| 150 else if (str == "responseHeaders") |
| 151 *extra_info_spec |= RESPONSE_HEADERS; |
| 152 else if (str == "blocking") |
| 153 *extra_info_spec |= BLOCKING; |
| 154 else if (str == "asyncBlocking") |
| 155 *extra_info_spec |= ASYNC_BLOCKING; |
| 156 else if (str == "requestBody") |
| 157 *extra_info_spec |= REQUEST_BODY; |
| 158 else |
| 159 return false; |
| 160 } |
| 161 // BLOCKING and ASYNC_BLOCKING are mutually exclusive. |
| 162 if ((*extra_info_spec & BLOCKING) && (*extra_info_spec & ASYNC_BLOCKING)) |
| 163 return false; |
| 164 return true; |
| 165 } |
| 166 |
140 RequestCookie::RequestCookie() {} | 167 RequestCookie::RequestCookie() {} |
141 RequestCookie::~RequestCookie() {} | 168 RequestCookie::~RequestCookie() {} |
142 | 169 |
143 bool NullableEquals(const RequestCookie* a, const RequestCookie* b) { | 170 bool NullableEquals(const RequestCookie* a, const RequestCookie* b) { |
144 if ((a && !b) || (!a && b)) | 171 if ((a && !b) || (!a && b)) |
145 return false; | 172 return false; |
146 if (!a) | 173 if (!a) |
147 return true; | 174 return true; |
148 return NullableEquals(a->name.get(), b->name.get()) && | 175 return NullableEquals(a->name.get(), b->name.get()) && |
149 NullableEquals(a->value.get(), b->value.get()); | 176 NullableEquals(a->value.get(), b->value.get()); |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 std::find(kResourceTypeStrings, | 1313 std::find(kResourceTypeStrings, |
1287 kResourceTypeStrings + kResourceTypeStringsLength, | 1314 kResourceTypeStrings + kResourceTypeStringsLength, |
1288 type_str); | 1315 type_str); |
1289 if (iter == (kResourceTypeStrings + kResourceTypeStringsLength)) | 1316 if (iter == (kResourceTypeStrings + kResourceTypeStringsLength)) |
1290 return false; | 1317 return false; |
1291 *type = kResourceTypeValues[iter - kResourceTypeStrings]; | 1318 *type = kResourceTypeValues[iter - kResourceTypeStrings]; |
1292 return true; | 1319 return true; |
1293 } | 1320 } |
1294 | 1321 |
1295 } // namespace extension_web_request_api_helpers | 1322 } // namespace extension_web_request_api_helpers |
OLD | NEW |