| 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/declarative_webrequest/webrequest_action.h" | 5 #include "extensions/browser/api/declarative_webrequest/webrequest_action.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/common/extensions/extension_test_util.h" | 21 #include "chrome/common/extensions/extension_test_util.h" |
| 22 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
| 23 #include "extensions/browser/api/declarative_webrequest/request_stage.h" | 23 #include "extensions/browser/api/declarative_webrequest/request_stage.h" |
| 24 #include "extensions/browser/api/declarative_webrequest/webrequest_condition.h" | 24 #include "extensions/browser/api/declarative_webrequest/webrequest_condition.h" |
| 25 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" | 25 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" |
| 26 #include "extensions/browser/api/web_request/web_request_api_helpers.h" | 26 #include "extensions/browser/api/web_request/web_request_api_helpers.h" |
| 27 #include "extensions/browser/info_map.h" | 27 #include "extensions/browser/info_map.h" |
| 28 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
| 29 #include "net/base/request_priority.h" | 29 #include "net/base/request_priority.h" |
| 30 #include "net/http/http_response_headers.h" | 30 #include "net/http/http_response_headers.h" |
| 31 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
| 31 #include "net/url_request/url_request.h" | 32 #include "net/url_request/url_request.h" |
| 32 #include "net/url_request/url_request_test_util.h" | 33 #include "net/url_request/url_request_test_util.h" |
| 33 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
| 34 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 35 | 36 |
| 36 using base::DictionaryValue; | 37 using base::DictionaryValue; |
| 37 using base::ListValue; | 38 using base::ListValue; |
| 38 using extension_test_util::LoadManifestUnchecked; | 39 using extension_test_util::LoadManifestUnchecked; |
| 39 using testing::HasSubstr; | 40 using testing::HasSubstr; |
| 40 | 41 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 false /*incognito_enabled*/, | 140 false /*incognito_enabled*/, |
| 140 false /*notifications_disabled*/); | 141 false /*notifications_disabled*/); |
| 141 } | 142 } |
| 142 | 143 |
| 143 bool WebRequestActionWithThreadsTest::ActionWorksOnRequest( | 144 bool WebRequestActionWithThreadsTest::ActionWorksOnRequest( |
| 144 const char* url_string, | 145 const char* url_string, |
| 145 const std::string& extension_id, | 146 const std::string& extension_id, |
| 146 const WebRequestActionSet* action_set, | 147 const WebRequestActionSet* action_set, |
| 147 RequestStage stage) { | 148 RequestStage stage) { |
| 148 std::unique_ptr<net::URLRequest> regular_request( | 149 std::unique_ptr<net::URLRequest> regular_request( |
| 149 context_.CreateRequest(GURL(url_string), net::DEFAULT_PRIORITY, NULL)); | 150 context_.CreateRequest(GURL(url_string), net::DEFAULT_PRIORITY, NULL, |
| 151 TRAFFIC_ANNOTATION_FOR_TESTS)); |
| 150 std::list<LinkedPtrEventResponseDelta> deltas; | 152 std::list<LinkedPtrEventResponseDelta> deltas; |
| 151 scoped_refptr<net::HttpResponseHeaders> headers( | 153 scoped_refptr<net::HttpResponseHeaders> headers( |
| 152 new net::HttpResponseHeaders("")); | 154 new net::HttpResponseHeaders("")); |
| 153 WebRequestData request_data(regular_request.get(), stage, nullptr, | 155 WebRequestData request_data(regular_request.get(), stage, nullptr, |
| 154 headers.get()); | 156 headers.get()); |
| 155 std::set<std::string> ignored_tags; | 157 std::set<std::string> ignored_tags; |
| 156 WebRequestAction::ApplyInfo apply_info = { extension_info_map_.get(), | 158 WebRequestAction::ApplyInfo apply_info = { extension_info_map_.get(), |
| 157 request_data, | 159 request_data, |
| 158 false /*crosses_incognito*/, | 160 false /*crosses_incognito*/, |
| 159 &deltas, &ignored_tags }; | 161 &deltas, &ignored_tags }; |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 for (WebRequestActionSet::Actions::const_iterator it = | 590 for (WebRequestActionSet::Actions::const_iterator it = |
| 589 action_set->actions().begin(); | 591 action_set->actions().begin(); |
| 590 it != action_set->actions().end(); | 592 it != action_set->actions().end(); |
| 591 ++it) { | 593 ++it) { |
| 592 EXPECT_EQ(kExpectedNames[index], (*it)->GetName()); | 594 EXPECT_EQ(kExpectedNames[index], (*it)->GetName()); |
| 593 ++index; | 595 ++index; |
| 594 } | 596 } |
| 595 } | 597 } |
| 596 | 598 |
| 597 } // namespace extensions | 599 } // namespace extensions |
| OLD | NEW |