| 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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" | |
| 13 #include "base/prefs/pref_registry_simple.h" | 12 #include "base/prefs/pref_registry_simple.h" |
| 14 #include "base/prefs/testing_pref_service.h" | 13 #include "base/prefs/testing_pref_service.h" |
| 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "chrome/browser/policy/policy_helpers.h" | 15 #include "chrome/browser/policy/policy_helpers.h" |
| 16 #include "components/policy/core/common/policy_pref_names.h" | 16 #include "components/policy/core/common/policy_pref_names.h" |
| 17 #include "components/url_fixer/url_fixer.h" | 17 #include "components/url_fixer/url_fixer.h" |
| 18 #include "google_apis/gaia/gaia_urls.h" | 18 #include "google_apis/gaia/gaia_urls.h" |
| 19 #include "net/base/load_flags.h" | 19 #include "net/base/load_flags.h" |
| 20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 21 #include "net/base/request_priority.h" | 21 #include "net/base/request_priority.h" |
| 22 #include "net/url_request/url_request.h" | 22 #include "net/url_request/url_request.h" |
| 23 #include "net/url_request/url_request_context.h" | 23 #include "net/url_request/url_request_context.h" |
| 24 #include "net/url_request/url_request_test_util.h" | 24 #include "net/url_request/url_request_test_util.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 // Helper to get the disambiguated SegmentURL() function. | 38 // Helper to get the disambiguated SegmentURL() function. |
| 39 URLBlacklist::SegmentURLCallback GetSegmentURLCallback() { | 39 URLBlacklist::SegmentURLCallback GetSegmentURLCallback() { |
| 40 return url_fixer::SegmentURL; | 40 return url_fixer::SegmentURL; |
| 41 } | 41 } |
| 42 | 42 |
| 43 class TestingURLBlacklistManager : public URLBlacklistManager { | 43 class TestingURLBlacklistManager : public URLBlacklistManager { |
| 44 public: | 44 public: |
| 45 explicit TestingURLBlacklistManager(PrefService* pref_service) | 45 explicit TestingURLBlacklistManager(PrefService* pref_service) |
| 46 : URLBlacklistManager(pref_service, | 46 : URLBlacklistManager(pref_service, |
| 47 base::MessageLoopProxy::current(), | 47 base::ThreadTaskRunnerHandle::Get(), |
| 48 base::MessageLoopProxy::current(), | 48 base::ThreadTaskRunnerHandle::Get(), |
| 49 GetSegmentURLCallback(), | 49 GetSegmentURLCallback(), |
| 50 base::Bind(OverrideBlacklistForURL)), | 50 base::Bind(OverrideBlacklistForURL)), |
| 51 update_called_(0), | 51 update_called_(0), |
| 52 set_blacklist_called_(false) {} | 52 set_blacklist_called_(false) {} |
| 53 | 53 |
| 54 ~TestingURLBlacklistManager() override {} | 54 ~TestingURLBlacklistManager() override {} |
| 55 | 55 |
| 56 // Make this method public for testing. | 56 // Make this method public for testing. |
| 57 using URLBlacklistManager::ScheduleUpdate; | 57 using URLBlacklistManager::ScheduleUpdate; |
| 58 | 58 |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |