| Index: extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc
|
| diff --git a/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc b/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc
|
| index c9c51f17acddb912b6d4ec39b81257c5648569b8..4b1ee0e5d633106c6792d320c859b2f7da8ac971 100644
|
| --- a/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc
|
| +++ b/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc
|
| @@ -13,6 +13,7 @@
|
| #include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| #include "base/macros.h"
|
| +#include "base/memory/ptr_util.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/values.h"
|
| @@ -305,7 +306,8 @@ class HeaderMatcher {
|
| // Creates an instance based on a list |tests| of test groups, encoded as
|
| // dictionaries of the type declarativeWebRequest.HeaderFilter (see
|
| // declarative_web_request.json).
|
| - static scoped_ptr<const HeaderMatcher> Create(const base::ListValue* tests);
|
| + static std::unique_ptr<const HeaderMatcher> Create(
|
| + const base::ListValue* tests);
|
|
|
| // Does |this| match the header "|name|: |value|"?
|
| bool TestNameValue(const std::string& name, const std::string& value) const;
|
| @@ -318,9 +320,9 @@ class HeaderMatcher {
|
|
|
| // |data| is the pattern to be matched in the position given by |type|.
|
| // Note that |data| must point to a StringValue object.
|
| - static scoped_ptr<StringMatchTest> Create(const base::Value* data,
|
| - MatchType type,
|
| - bool case_sensitive);
|
| + static std::unique_ptr<StringMatchTest> Create(const base::Value* data,
|
| + MatchType type,
|
| + bool case_sensitive);
|
| ~StringMatchTest();
|
|
|
| // Does |str| pass |this| StringMatchTest?
|
| @@ -345,7 +347,7 @@ class HeaderMatcher {
|
|
|
| // Gets the test group description in |tests| and creates the corresponding
|
| // HeaderMatchTest. On failure returns NULL.
|
| - static scoped_ptr<const HeaderMatchTest> Create(
|
| + static std::unique_ptr<const HeaderMatchTest> Create(
|
| const base::DictionaryValue* tests);
|
|
|
| // Does the header "|name|: |value|" match all tests in |this|?
|
| @@ -353,20 +355,22 @@ class HeaderMatcher {
|
|
|
| private:
|
| // Takes ownership of the content of both |name_match| and |value_match|.
|
| - HeaderMatchTest(std::vector<scoped_ptr<const StringMatchTest>> name_match,
|
| - std::vector<scoped_ptr<const StringMatchTest>> value_match);
|
| + HeaderMatchTest(
|
| + std::vector<std::unique_ptr<const StringMatchTest>> name_match,
|
| + std::vector<std::unique_ptr<const StringMatchTest>> value_match);
|
|
|
| // Tests to be passed by a header's name.
|
| - const std::vector<scoped_ptr<const StringMatchTest>> name_match_;
|
| + const std::vector<std::unique_ptr<const StringMatchTest>> name_match_;
|
| // Tests to be passed by a header's value.
|
| - const std::vector<scoped_ptr<const StringMatchTest>> value_match_;
|
| + const std::vector<std::unique_ptr<const StringMatchTest>> value_match_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(HeaderMatchTest);
|
| };
|
|
|
| - explicit HeaderMatcher(std::vector<scoped_ptr<const HeaderMatchTest>> tests);
|
| + explicit HeaderMatcher(
|
| + std::vector<std::unique_ptr<const HeaderMatchTest>> tests);
|
|
|
| - const std::vector<scoped_ptr<const HeaderMatchTest>> tests_;
|
| + const std::vector<std::unique_ptr<const HeaderMatchTest>> tests_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(HeaderMatcher);
|
| };
|
| @@ -376,23 +380,23 @@ class HeaderMatcher {
|
| HeaderMatcher::~HeaderMatcher() {}
|
|
|
| // static
|
| -scoped_ptr<const HeaderMatcher> HeaderMatcher::Create(
|
| +std::unique_ptr<const HeaderMatcher> HeaderMatcher::Create(
|
| const base::ListValue* tests) {
|
| - std::vector<scoped_ptr<const HeaderMatchTest>> header_tests;
|
| + std::vector<std::unique_ptr<const HeaderMatchTest>> header_tests;
|
| for (base::ListValue::const_iterator it = tests->begin();
|
| it != tests->end(); ++it) {
|
| const base::DictionaryValue* tests = NULL;
|
| if (!(*it)->GetAsDictionary(&tests))
|
| - return scoped_ptr<const HeaderMatcher>();
|
| + return std::unique_ptr<const HeaderMatcher>();
|
|
|
| - scoped_ptr<const HeaderMatchTest> header_test(
|
| + std::unique_ptr<const HeaderMatchTest> header_test(
|
| HeaderMatchTest::Create(tests));
|
| if (header_test.get() == NULL)
|
| - return scoped_ptr<const HeaderMatcher>();
|
| + return std::unique_ptr<const HeaderMatcher>();
|
| header_tests.push_back(std::move(header_test));
|
| }
|
|
|
| - return scoped_ptr<const HeaderMatcher>(
|
| + return std::unique_ptr<const HeaderMatcher>(
|
| new HeaderMatcher(std::move(header_tests)));
|
| }
|
|
|
| @@ -406,19 +410,19 @@ bool HeaderMatcher::TestNameValue(const std::string& name,
|
| }
|
|
|
| HeaderMatcher::HeaderMatcher(
|
| - std::vector<scoped_ptr<const HeaderMatchTest>> tests)
|
| + std::vector<std::unique_ptr<const HeaderMatchTest>> tests)
|
| : tests_(std::move(tests)) {}
|
|
|
| // HeaderMatcher::StringMatchTest implementation.
|
|
|
| // static
|
| -scoped_ptr<HeaderMatcher::StringMatchTest>
|
| +std::unique_ptr<HeaderMatcher::StringMatchTest>
|
| HeaderMatcher::StringMatchTest::Create(const base::Value* data,
|
| MatchType type,
|
| bool case_sensitive) {
|
| std::string str;
|
| CHECK(data->GetAsString(&str));
|
| - return scoped_ptr<StringMatchTest>(
|
| + return std::unique_ptr<StringMatchTest>(
|
| new StringMatchTest(str, type, case_sensitive));
|
| }
|
|
|
| @@ -458,18 +462,18 @@ HeaderMatcher::StringMatchTest::StringMatchTest(const std::string& data,
|
| // HeaderMatcher::HeaderMatchTest implementation.
|
|
|
| HeaderMatcher::HeaderMatchTest::HeaderMatchTest(
|
| - std::vector<scoped_ptr<const StringMatchTest>> name_match,
|
| - std::vector<scoped_ptr<const StringMatchTest>> value_match)
|
| + std::vector<std::unique_ptr<const StringMatchTest>> name_match,
|
| + std::vector<std::unique_ptr<const StringMatchTest>> value_match)
|
| : name_match_(std::move(name_match)),
|
| value_match_(std::move(value_match)) {}
|
|
|
| HeaderMatcher::HeaderMatchTest::~HeaderMatchTest() {}
|
|
|
| // static
|
| -scoped_ptr<const HeaderMatcher::HeaderMatchTest>
|
| +std::unique_ptr<const HeaderMatcher::HeaderMatchTest>
|
| HeaderMatcher::HeaderMatchTest::Create(const base::DictionaryValue* tests) {
|
| - std::vector<scoped_ptr<const StringMatchTest>> name_match;
|
| - std::vector<scoped_ptr<const StringMatchTest>> value_match;
|
| + std::vector<std::unique_ptr<const StringMatchTest>> name_match;
|
| + std::vector<std::unique_ptr<const StringMatchTest>> value_match;
|
|
|
| for (base::DictionaryValue::Iterator it(*tests);
|
| !it.IsAtEnd(); it.Advance()) {
|
| @@ -497,11 +501,11 @@ HeaderMatcher::HeaderMatchTest::Create(const base::DictionaryValue* tests) {
|
| match_type = StringMatchTest::kEquals;
|
| } else {
|
| NOTREACHED(); // JSON schema type checking should prevent this.
|
| - return scoped_ptr<const HeaderMatchTest>();
|
| + return std::unique_ptr<const HeaderMatchTest>();
|
| }
|
| const base::Value* content = &it.value();
|
|
|
| - std::vector<scoped_ptr<const StringMatchTest>>* tests =
|
| + std::vector<std::unique_ptr<const StringMatchTest>>* tests =
|
| is_name ? &name_match : &value_match;
|
| switch (content->GetType()) {
|
| case base::Value::TYPE_LIST: {
|
| @@ -509,24 +513,24 @@ HeaderMatcher::HeaderMatchTest::Create(const base::DictionaryValue* tests) {
|
| CHECK(content->GetAsList(&list));
|
| for (base::ListValue::const_iterator it = list->begin();
|
| it != list->end(); ++it) {
|
| - tests->push_back(make_scoped_ptr(
|
| + tests->push_back(base::WrapUnique(
|
| StringMatchTest::Create(*it, match_type, !is_name).release()));
|
| }
|
| break;
|
| }
|
| case base::Value::TYPE_STRING: {
|
| - tests->push_back(make_scoped_ptr(
|
| + tests->push_back(base::WrapUnique(
|
| StringMatchTest::Create(content, match_type, !is_name).release()));
|
| break;
|
| }
|
| default: {
|
| NOTREACHED(); // JSON schema type checking should prevent this.
|
| - return scoped_ptr<const HeaderMatchTest>();
|
| + return std::unique_ptr<const HeaderMatchTest>();
|
| }
|
| }
|
| }
|
|
|
| - return scoped_ptr<const HeaderMatchTest>(
|
| + return std::unique_ptr<const HeaderMatchTest>(
|
| new HeaderMatchTest(std::move(name_match), std::move(value_match)));
|
| }
|
|
|
| @@ -551,7 +555,7 @@ bool HeaderMatcher::HeaderMatchTest::Matches(const std::string& name,
|
|
|
| WebRequestConditionAttributeRequestHeaders::
|
| WebRequestConditionAttributeRequestHeaders(
|
| - scoped_ptr<const HeaderMatcher> header_matcher,
|
| + std::unique_ptr<const HeaderMatcher> header_matcher,
|
| bool positive)
|
| : header_matcher_(std::move(header_matcher)), positive_(positive) {}
|
|
|
| @@ -560,17 +564,17 @@ WebRequestConditionAttributeRequestHeaders::
|
|
|
| namespace {
|
|
|
| -scoped_ptr<const HeaderMatcher> PrepareHeaderMatcher(
|
| +std::unique_ptr<const HeaderMatcher> PrepareHeaderMatcher(
|
| const std::string& name,
|
| const base::Value* value,
|
| std::string* error) {
|
| const base::ListValue* value_as_list = NULL;
|
| if (!value->GetAsList(&value_as_list)) {
|
| *error = ErrorUtils::FormatErrorMessage(kInvalidValue, name);
|
| - return scoped_ptr<const HeaderMatcher>();
|
| + return std::unique_ptr<const HeaderMatcher>();
|
| }
|
|
|
| - scoped_ptr<const HeaderMatcher> header_matcher(
|
| + std::unique_ptr<const HeaderMatcher> header_matcher(
|
| HeaderMatcher::Create(value_as_list));
|
| if (header_matcher.get() == NULL)
|
| *error = ErrorUtils::FormatErrorMessage(kInvalidValue, name);
|
| @@ -589,7 +593,7 @@ WebRequestConditionAttributeRequestHeaders::Create(
|
| DCHECK(name == keys::kRequestHeadersKey ||
|
| name == keys::kExcludeRequestHeadersKey);
|
|
|
| - scoped_ptr<const HeaderMatcher> header_matcher(
|
| + std::unique_ptr<const HeaderMatcher> header_matcher(
|
| PrepareHeaderMatcher(name, value, error));
|
| if (header_matcher.get() == NULL)
|
| return scoped_refptr<const WebRequestConditionAttribute>(NULL);
|
| @@ -645,7 +649,7 @@ bool WebRequestConditionAttributeRequestHeaders::Equals(
|
|
|
| WebRequestConditionAttributeResponseHeaders::
|
| WebRequestConditionAttributeResponseHeaders(
|
| - scoped_ptr<const HeaderMatcher> header_matcher,
|
| + std::unique_ptr<const HeaderMatcher> header_matcher,
|
| bool positive)
|
| : header_matcher_(std::move(header_matcher)), positive_(positive) {}
|
|
|
| @@ -662,7 +666,7 @@ WebRequestConditionAttributeResponseHeaders::Create(
|
| DCHECK(name == keys::kResponseHeadersKey ||
|
| name == keys::kExcludeResponseHeadersKey);
|
|
|
| - scoped_ptr<const HeaderMatcher> header_matcher(
|
| + std::unique_ptr<const HeaderMatcher> header_matcher(
|
| PrepareHeaderMatcher(name, value, error));
|
| if (header_matcher.get() == NULL)
|
| return scoped_refptr<const WebRequestConditionAttribute>(NULL);
|
|
|