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