| 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_rules_registr
y.h" | 5 #include "extensions/browser/api/declarative_webrequest/webrequest_rules_registr
y.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 std::unique_ptr<net::URLRequest> http_request( | 281 std::unique_ptr<net::URLRequest> http_request( |
| 282 context.CreateRequest(http_url, net::DEFAULT_PRIORITY, NULL)); | 282 context.CreateRequest(http_url, net::DEFAULT_PRIORITY, NULL)); |
| 283 WebRequestData request_data(http_request.get(), ON_BEFORE_REQUEST); | 283 WebRequestData request_data(http_request.get(), ON_BEFORE_REQUEST); |
| 284 matches = registry->GetMatches(request_data); | 284 matches = registry->GetMatches(request_data); |
| 285 EXPECT_EQ(2u, matches.size()); | 285 EXPECT_EQ(2u, matches.size()); |
| 286 | 286 |
| 287 std::set<WebRequestRule::GlobalRuleId> matches_ids; | 287 std::set<WebRequestRule::GlobalRuleId> matches_ids; |
| 288 for (std::set<const WebRequestRule*>::const_iterator it = matches.begin(); | 288 for (std::set<const WebRequestRule*>::const_iterator it = matches.begin(); |
| 289 it != matches.end(); ++it) | 289 it != matches.end(); ++it) |
| 290 matches_ids.insert((*it)->id()); | 290 matches_ids.insert((*it)->id()); |
| 291 EXPECT_TRUE(ContainsKey(matches_ids, std::make_pair(kExtensionId, kRuleId1))); | 291 EXPECT_TRUE( |
| 292 EXPECT_TRUE(ContainsKey(matches_ids, std::make_pair(kExtensionId, kRuleId2))); | 292 base::ContainsKey(matches_ids, std::make_pair(kExtensionId, kRuleId1))); |
| 293 EXPECT_TRUE( |
| 294 base::ContainsKey(matches_ids, std::make_pair(kExtensionId, kRuleId2))); |
| 293 | 295 |
| 294 GURL foobar_url("http://www.foobar.com"); | 296 GURL foobar_url("http://www.foobar.com"); |
| 295 std::unique_ptr<net::URLRequest> foobar_request( | 297 std::unique_ptr<net::URLRequest> foobar_request( |
| 296 context.CreateRequest(foobar_url, net::DEFAULT_PRIORITY, NULL)); | 298 context.CreateRequest(foobar_url, net::DEFAULT_PRIORITY, NULL)); |
| 297 request_data.request = foobar_request.get(); | 299 request_data.request = foobar_request.get(); |
| 298 matches = registry->GetMatches(request_data); | 300 matches = registry->GetMatches(request_data); |
| 299 EXPECT_EQ(1u, matches.size()); | 301 EXPECT_EQ(1u, matches.size()); |
| 300 WebRequestRule::GlobalRuleId expected_pair = | 302 WebRequestRule::GlobalRuleId expected_pair = |
| 301 std::make_pair(kExtensionId, kRuleId2); | 303 std::make_pair(kExtensionId, kRuleId2); |
| 302 EXPECT_EQ(expected_pair, (*matches.begin())->id()); | 304 EXPECT_EQ(expected_pair, (*matches.begin())->id()); |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 // This is a correct match. | 811 // This is a correct match. |
| 810 GURL url2("http://foo.com/index.html"); | 812 GURL url2("http://foo.com/index.html"); |
| 811 std::unique_ptr<net::URLRequest> request2( | 813 std::unique_ptr<net::URLRequest> request2( |
| 812 context.CreateRequest(url2, net::DEFAULT_PRIORITY, NULL)); | 814 context.CreateRequest(url2, net::DEFAULT_PRIORITY, NULL)); |
| 813 WebRequestData request_data2(request2.get(), ON_BEFORE_REQUEST); | 815 WebRequestData request_data2(request2.get(), ON_BEFORE_REQUEST); |
| 814 deltas = registry->CreateDeltas(NULL, request_data2, false); | 816 deltas = registry->CreateDeltas(NULL, request_data2, false); |
| 815 EXPECT_EQ(1u, deltas.size()); | 817 EXPECT_EQ(1u, deltas.size()); |
| 816 } | 818 } |
| 817 | 819 |
| 818 } // namespace extensions | 820 } // namespace extensions |
| OLD | NEW |