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