[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / web_resource / resource_request_allowed_notifier_test_util.h
bloba76ec4a7483daeb2d58d8ceac730d7a5b2984f37
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
3 // found in the LICENSE file.
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_
8 #include "chrome/browser/web_resource/resource_request_allowed_notifier.h"
10 // A subclass of ResourceRequestAllowedNotifier used to expose some
11 // functionality for testing.
13 // By default, the constructor sets this class to override
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
16 // notifications of the ResourceRequestAllowedNotifier. Lower level tests can
17 // disable this by calling SetRequestsAllowedOverride with the value they want
18 // it to return.
19 class TestRequestAllowedNotifier : public ResourceRequestAllowedNotifier {
20 public:
21 TestRequestAllowedNotifier();
22 virtual ~TestRequestAllowedNotifier();
24 // A version of |Init()| that accepts a custom EulaAcceptedNotifier.
25 void InitWithEulaAcceptNotifier(
26 Observer* observer,
27 scoped_ptr<EulaAcceptedNotifier> eula_notifier);
29 // Makes ResourceRequestsAllowed return |allowed| when it is called.
30 void SetRequestsAllowedOverride(bool allowed);
32 // Notify observers that requests are allowed. This will only work if
33 // the observer is expecting a notification.
34 void NotifyObserver();
36 // ResourceRequestAllowedNotifier overrides:
37 virtual State GetResourceRequestsAllowedState() OVERRIDE;
38 virtual EulaAcceptedNotifier* CreateEulaNotifier() OVERRIDE;
40 private:
41 scoped_ptr<EulaAcceptedNotifier> test_eula_notifier_;
42 bool override_requests_allowed_;
43 bool requests_allowed_;
45 DISALLOW_COPY_AND_ASSIGN(TestRequestAllowedNotifier);
48 #endif // CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_TEST_UTIL_H_