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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 GURL("http://google.com"), net::DEFAULT_PRIORITY, NULL, NULL)); | 647 GURL("http://google.com"), net::DEFAULT_PRIORITY, NULL, 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 | |
658 // On most platforms, sync gets a free pass due to signin flows. | |
659 bool block_signin_urls = false; | |
660 #if defined(OS_CHROMEOS) | |
661 // There are no sync specific signin flows on Chrome OS, so no special | |
662 // treatment. | |
663 block_signin_urls = true; | |
664 #endif | |
665 | |
666 GURL sync_url(GaiaUrls::GetInstance()->service_login_url().Resolve( | |
667 "?service=chromiumsync")); | |
668 scoped_ptr<net::URLRequest> sync_request(context.CreateRequest( | |
669 sync_url, net::DEFAULT_PRIORITY, NULL, NULL)); | |
670 sync_request->SetLoadFlags(net::LOAD_MAIN_FRAME); | |
671 EXPECT_EQ(block_signin_urls, | |
672 blacklist_manager_->IsRequestBlocked(*sync_request.get(), &reason)); | |
673 } | 657 } |
674 | 658 |
675 TEST_F(URLBlacklistManagerTest, DefaultBlacklistExceptions) { | 659 TEST_F(URLBlacklistManagerTest, DefaultBlacklistExceptions) { |
676 URLBlacklist blacklist(GetSegmentURLCallback()); | 660 URLBlacklist blacklist(GetSegmentURLCallback()); |
677 scoped_ptr<base::ListValue> blocked(new base::ListValue); | 661 scoped_ptr<base::ListValue> blocked(new base::ListValue); |
678 | 662 |
679 // Blacklist everything: | 663 // Blacklist everything: |
680 blocked->Append(new base::StringValue("*")); | 664 blocked->Append(new base::StringValue("*")); |
681 blacklist.Block(blocked.get()); | 665 blacklist.Block(blocked.get()); |
682 | 666 |
(...skipping 11 matching lines...) Expand all Loading... |
694 blacklist.Allow(allowed.get()); | 678 blacklist.Allow(allowed.get()); |
695 | 679 |
696 EXPECT_TRUE(blacklist.IsURLBlocked(GURL("http://www.google.com"))); | 680 EXPECT_TRUE(blacklist.IsURLBlocked(GURL("http://www.google.com"))); |
697 EXPECT_TRUE((blacklist.IsURLBlocked(GURL("chrome-extension://xyz")))); | 681 EXPECT_TRUE((blacklist.IsURLBlocked(GURL("chrome-extension://xyz")))); |
698 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-extension://abc")))); | 682 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-extension://abc")))); |
699 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-search://local-ntp")))); | 683 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-search://local-ntp")))); |
700 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-native://ntp")))); | 684 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-native://ntp")))); |
701 } | 685 } |
702 | 686 |
703 } // namespace policy | 687 } // namespace policy |
OLD | NEW |