| 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 "components/policy/core/browser/url_blacklist_manager.h" | 5 #include "components/policy/core/browser/url_blacklist_manager.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 TEST_F(URLBlacklistManagerTest, DontBlockResources) { | 637 TEST_F(URLBlacklistManagerTest, DontBlockResources) { |
| 638 scoped_ptr<URLBlacklist> blacklist(new URLBlacklist(GetSegmentURLCallback())); | 638 scoped_ptr<URLBlacklist> blacklist(new URLBlacklist(GetSegmentURLCallback())); |
| 639 scoped_ptr<base::ListValue> blocked(new base::ListValue); | 639 scoped_ptr<base::ListValue> blocked(new base::ListValue); |
| 640 blocked->Append(new base::StringValue("google.com")); | 640 blocked->Append(new base::StringValue("google.com")); |
| 641 blacklist->Block(blocked.get()); | 641 blacklist->Block(blocked.get()); |
| 642 blacklist_manager_->SetBlacklist(blacklist.Pass()); | 642 blacklist_manager_->SetBlacklist(blacklist.Pass()); |
| 643 EXPECT_TRUE(blacklist_manager_->IsURLBlocked(GURL("http://google.com"))); | 643 EXPECT_TRUE(blacklist_manager_->IsURLBlocked(GURL("http://google.com"))); |
| 644 | 644 |
| 645 net::TestURLRequestContext context; | 645 net::TestURLRequestContext context; |
| 646 scoped_ptr<net::URLRequest> request(context.CreateRequest( | 646 scoped_ptr<net::URLRequest> request(context.CreateRequest( |
| 647 GURL("http://google.com"), net::DEFAULT_PRIORITY, NULL, NULL)); | 647 GURL("http://google.com"), net::DEFAULT_PRIORITY, NULL)); |
| 648 | 648 |
| 649 int reason = net::ERR_UNEXPECTED; | 649 int reason = net::ERR_UNEXPECTED; |
| 650 // Background requests aren't filtered. | 650 // Background requests aren't filtered. |
| 651 EXPECT_FALSE(blacklist_manager_->IsRequestBlocked(*request.get(), &reason)); | 651 EXPECT_FALSE(blacklist_manager_->IsRequestBlocked(*request.get(), &reason)); |
| 652 | 652 |
| 653 // Main frames are filtered. | 653 // Main frames are filtered. |
| 654 request->SetLoadFlags(net::LOAD_MAIN_FRAME); | 654 request->SetLoadFlags(net::LOAD_MAIN_FRAME); |
| 655 EXPECT_TRUE(blacklist_manager_->IsRequestBlocked(*request.get(), &reason)); | 655 EXPECT_TRUE(blacklist_manager_->IsRequestBlocked(*request.get(), &reason)); |
| 656 EXPECT_EQ(net::ERR_BLOCKED_BY_ADMINISTRATOR, reason); | 656 EXPECT_EQ(net::ERR_BLOCKED_BY_ADMINISTRATOR, reason); |
| 657 } | 657 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 678 blacklist.Allow(allowed.get()); | 678 blacklist.Allow(allowed.get()); |
| 679 | 679 |
| 680 EXPECT_TRUE(blacklist.IsURLBlocked(GURL("http://www.google.com"))); | 680 EXPECT_TRUE(blacklist.IsURLBlocked(GURL("http://www.google.com"))); |
| 681 EXPECT_TRUE((blacklist.IsURLBlocked(GURL("chrome-extension://xyz")))); | 681 EXPECT_TRUE((blacklist.IsURLBlocked(GURL("chrome-extension://xyz")))); |
| 682 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-extension://abc")))); | 682 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-extension://abc")))); |
| 683 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-search://local-ntp")))); | 683 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-search://local-ntp")))); |
| 684 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-native://ntp")))); | 684 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-native://ntp")))); |
| 685 } | 685 } |
| 686 | 686 |
| 687 } // namespace policy | 687 } // namespace policy |
| OLD | NEW |