| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_webrequest_api.h" | 5 #include "chrome/browser/extensions/extension_webrequest_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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 bool ExtensionWebRequestEventRouter::RequestFilter::InitFromValue( | 413 bool ExtensionWebRequestEventRouter::RequestFilter::InitFromValue( |
| 414 const DictionaryValue& value, std::string* error) { | 414 const DictionaryValue& value, std::string* error) { |
| 415 for (DictionaryValue::key_iterator key = value.begin_keys(); | 415 for (DictionaryValue::key_iterator key = value.begin_keys(); |
| 416 key != value.end_keys(); ++key) { | 416 key != value.end_keys(); ++key) { |
| 417 if (*key == "urls") { | 417 if (*key == "urls") { |
| 418 ListValue* urls_value = NULL; | 418 ListValue* urls_value = NULL; |
| 419 if (!value.GetList("urls", &urls_value)) | 419 if (!value.GetList("urls", &urls_value)) |
| 420 return false; | 420 return false; |
| 421 for (size_t i = 0; i < urls_value->GetSize(); ++i) { | 421 for (size_t i = 0; i < urls_value->GetSize(); ++i) { |
| 422 std::string url; | 422 std::string url; |
| 423 URLPattern pattern(URLPattern::SCHEME_ALL); | 423 URLPattern pattern( |
| 424 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS | |
| 425 URLPattern::SCHEME_FTP | URLPattern::SCHEME_FILE | |
| 426 URLPattern::SCHEME_EXTENSION); |
| 424 if (!urls_value->GetString(i, &url) || | 427 if (!urls_value->GetString(i, &url) || |
| 425 pattern.Parse(url, URLPattern::ERROR_ON_PORTS) != | 428 pattern.Parse(url, URLPattern::ERROR_ON_PORTS) != |
| 426 URLPattern::PARSE_SUCCESS) { | 429 URLPattern::PARSE_SUCCESS) { |
| 427 *error = ExtensionErrorUtils::FormatErrorMessage( | 430 *error = ExtensionErrorUtils::FormatErrorMessage( |
| 428 keys::kInvalidRequestFilterUrl, url); | 431 keys::kInvalidRequestFilterUrl, url); |
| 429 return false; | 432 return false; |
| 430 } | 433 } |
| 431 urls.AddPattern(pattern); | 434 urls.AddPattern(pattern); |
| 432 } | 435 } |
| 433 } else if (*key == "types") { | 436 } else if (*key == "types") { |
| (...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 1710 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
| 1708 adblock = true; | 1711 adblock = true; |
| 1709 } else { | 1712 } else { |
| 1710 other = true; | 1713 other = true; |
| 1711 } | 1714 } |
| 1712 } | 1715 } |
| 1713 } | 1716 } |
| 1714 | 1717 |
| 1715 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 1718 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
| 1716 } | 1719 } |
| OLD | NEW |