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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api.cc

Issue 10834004: Correct const accessors in base/values.(h|cc) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reverting webdriver:Command::parameters_ to const Created 8 years, 4 months 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 (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 "chrome/browser/extensions/api/web_request/web_request_api.h" 5 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // We require either a "value" or a "binaryValue" entry. 168 // We require either a "value" or a "binaryValue" entry.
169 if (!(header_value->HasKey(keys::kHeaderValueKey) ^ 169 if (!(header_value->HasKey(keys::kHeaderValueKey) ^
170 header_value->HasKey(keys::kHeaderBinaryValueKey))) 170 header_value->HasKey(keys::kHeaderBinaryValueKey)))
171 return false; 171 return false;
172 172
173 if (header_value->HasKey(keys::kHeaderValueKey)) { 173 if (header_value->HasKey(keys::kHeaderValueKey)) {
174 if (!header_value->GetString(keys::kHeaderValueKey, value)) { 174 if (!header_value->GetString(keys::kHeaderValueKey, value)) {
175 return false; 175 return false;
176 } 176 }
177 } else if (header_value->HasKey(keys::kHeaderBinaryValueKey)) { 177 } else if (header_value->HasKey(keys::kHeaderBinaryValueKey)) {
178 ListValue* list = NULL; 178 const ListValue* list = NULL;
179 if (!header_value->GetList(keys::kHeaderBinaryValueKey, &list) || 179 if (!header_value->GetList(keys::kHeaderBinaryValueKey, &list) ||
180 !helpers::CharListToString(list, value)) { 180 !helpers::CharListToString(list, value)) {
181 return false; 181 return false;
182 } 182 }
183 } 183 }
184 return true; 184 return true;
185 } 185 }
186 186
187 // Converts the |name|, |value| pair of a http header to a HttpHeaders 187 // Converts the |name|, |value| pair of a http header to a HttpHeaders
188 // dictionary. Ownership is passed to the caller. 188 // dictionary. Ownership is passed to the caller.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 }; 343 };
344 344
345 bool ExtensionWebRequestEventRouter::RequestFilter::InitFromValue( 345 bool ExtensionWebRequestEventRouter::RequestFilter::InitFromValue(
346 const DictionaryValue& value, std::string* error) { 346 const DictionaryValue& value, std::string* error) {
347 if (!value.HasKey("urls")) 347 if (!value.HasKey("urls"))
348 return false; 348 return false;
349 349
350 for (DictionaryValue::key_iterator key = value.begin_keys(); 350 for (DictionaryValue::key_iterator key = value.begin_keys();
351 key != value.end_keys(); ++key) { 351 key != value.end_keys(); ++key) {
352 if (*key == "urls") { 352 if (*key == "urls") {
353 ListValue* urls_value = NULL; 353 const ListValue* urls_value = NULL;
354 if (!value.GetList("urls", &urls_value)) 354 if (!value.GetList("urls", &urls_value))
355 return false; 355 return false;
356 for (size_t i = 0; i < urls_value->GetSize(); ++i) { 356 for (size_t i = 0; i < urls_value->GetSize(); ++i) {
357 std::string url; 357 std::string url;
358 URLPattern pattern( 358 URLPattern pattern(
359 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | 359 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS |
360 URLPattern::SCHEME_FTP | URLPattern::SCHEME_FILE | 360 URLPattern::SCHEME_FTP | URLPattern::SCHEME_FILE |
361 URLPattern::SCHEME_EXTENSION); 361 URLPattern::SCHEME_EXTENSION);
362 if (!urls_value->GetString(i, &url) || 362 if (!urls_value->GetString(i, &url) ||
363 pattern.Parse(url) != URLPattern::PARSE_SUCCESS) { 363 pattern.Parse(url) != URLPattern::PARSE_SUCCESS) {
364 *error = ExtensionErrorUtils::FormatErrorMessage( 364 *error = ExtensionErrorUtils::FormatErrorMessage(
365 keys::kInvalidRequestFilterUrl, url); 365 keys::kInvalidRequestFilterUrl, url);
366 return false; 366 return false;
367 } 367 }
368 urls.AddPattern(pattern); 368 urls.AddPattern(pattern);
369 } 369 }
370 } else if (*key == "types") { 370 } else if (*key == "types") {
371 ListValue* types_value = NULL; 371 const ListValue* types_value = NULL;
372 if (!value.GetList("types", &types_value)) 372 if (!value.GetList("types", &types_value))
373 return false; 373 return false;
374 for (size_t i = 0; i < types_value->GetSize(); ++i) { 374 for (size_t i = 0; i < types_value->GetSize(); ++i) {
375 std::string type_str; 375 std::string type_str;
376 ResourceType::Type type; 376 ResourceType::Type type;
377 if (!types_value->GetString(i, &type_str) || 377 if (!types_value->GetString(i, &type_str) ||
378 !helpers::ParseResourceType(type_str, &type)) 378 !helpers::ParseResourceType(type_str, &type))
379 return false; 379 return false;
380 types.push_back(type); 380 types.push_back(type);
381 } 381 }
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 } else if ((*it)->name().find("AdBlock") != std::string::npos) { 1787 } else if ((*it)->name().find("AdBlock") != std::string::npos) {
1788 adblock = true; 1788 adblock = true;
1789 } else { 1789 } else {
1790 other = true; 1790 other = true;
1791 } 1791 }
1792 } 1792 }
1793 } 1793 }
1794 1794
1795 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); 1795 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other));
1796 } 1796 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698