| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_TEST_UTIL_
H_ | 5 #ifndef CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_TEST_UTIL_
H_ |
| 6 #define CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_TEST_UTIL_
H_ | 6 #define CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_TEST_UTIL_
H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/web_resource/resource_request_allowed_notifier.h" | 9 #include "chrome/browser/web_resource/resource_request_allowed_notifier.h" |
| 9 | 10 |
| 11 class PrefService; |
| 12 |
| 10 // A subclass of ResourceRequestAllowedNotifier used to expose some | 13 // A subclass of ResourceRequestAllowedNotifier used to expose some |
| 11 // functionality for testing. | 14 // functionality for testing. |
| 12 // | 15 // |
| 13 // By default, the constructor sets this class to override | 16 // By default, the constructor sets this class to override |
| 14 // ResourceRequestsAllowed, so its state can be set with SetRequestsAllowed. | 17 // ResourceRequestsAllowed, so its state can be set with SetRequestsAllowed. |
| 15 // This is meant for higher level tests of services to ensure they adhere to the | 18 // This is meant for higher level tests of services to ensure they adhere to the |
| 16 // notifications of the ResourceRequestAllowedNotifier. Lower level tests can | 19 // notifications of the ResourceRequestAllowedNotifier. Lower level tests can |
| 17 // disable this by calling SetRequestsAllowedOverride with the value they want | 20 // disable this by calling SetRequestsAllowedOverride with the value they want |
| 18 // it to return. | 21 // it to return. |
| 19 class TestRequestAllowedNotifier : public ResourceRequestAllowedNotifier { | 22 class TestRequestAllowedNotifier : public ResourceRequestAllowedNotifier { |
| 20 public: | 23 public: |
| 21 TestRequestAllowedNotifier(); | 24 explicit TestRequestAllowedNotifier(PrefService* local_state); |
| 22 ~TestRequestAllowedNotifier() override; | 25 ~TestRequestAllowedNotifier() override; |
| 23 | 26 |
| 24 // A version of |Init()| that accepts a custom EulaAcceptedNotifier. | 27 // A version of |Init()| that accepts a custom EulaAcceptedNotifier. |
| 25 void InitWithEulaAcceptNotifier( | 28 void InitWithEulaAcceptNotifier( |
| 26 Observer* observer, | 29 Observer* observer, |
| 27 scoped_ptr<EulaAcceptedNotifier> eula_notifier); | 30 scoped_ptr<EulaAcceptedNotifier> eula_notifier); |
| 28 | 31 |
| 29 // Makes ResourceRequestsAllowed return |allowed| when it is called. | 32 // Makes ResourceRequestsAllowed return |allowed| when it is called. |
| 30 void SetRequestsAllowedOverride(bool allowed); | 33 void SetRequestsAllowedOverride(bool allowed); |
| 31 | 34 |
| 32 // Notify observers that requests are allowed. This will only work if | 35 // Notify observers that requests are allowed. This will only work if |
| 33 // the observer is expecting a notification. | 36 // the observer is expecting a notification. |
| 34 void NotifyObserver(); | 37 void NotifyObserver(); |
| 35 | 38 |
| 36 // ResourceRequestAllowedNotifier overrides: | 39 // ResourceRequestAllowedNotifier overrides: |
| 37 State GetResourceRequestsAllowedState() override; | 40 State GetResourceRequestsAllowedState() override; |
| 38 EulaAcceptedNotifier* CreateEulaNotifier() override; | 41 EulaAcceptedNotifier* CreateEulaNotifier() override; |
| 39 | 42 |
| 40 private: | 43 private: |
| 41 scoped_ptr<EulaAcceptedNotifier> test_eula_notifier_; | 44 scoped_ptr<EulaAcceptedNotifier> test_eula_notifier_; |
| 42 bool override_requests_allowed_; | 45 bool override_requests_allowed_; |
| 43 bool requests_allowed_; | 46 bool requests_allowed_; |
| 44 | 47 |
| 45 DISALLOW_COPY_AND_ASSIGN(TestRequestAllowedNotifier); | 48 DISALLOW_COPY_AND_ASSIGN(TestRequestAllowedNotifier); |
| 46 }; | 49 }; |
| 47 | 50 |
| 48 #endif // CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_TEST_UT
IL_H_ | 51 #endif // CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_TEST_UT
IL_H_ |
| OLD | NEW |