| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/metrics/variations/resource_request_allowed_notifier_te
st_util.h" |
| 6 |
| 7 TestRequestAllowedNotifier::TestRequestAllowedNotifier() : |
| 8 #if defined(OS_CHROMEOS) |
| 9 needs_eula_acceptance_(true), |
| 10 #endif |
| 11 override_requests_allowed_(false), |
| 12 requests_allowed_(true) { |
| 13 } |
| 14 |
| 15 TestRequestAllowedNotifier::~TestRequestAllowedNotifier() { |
| 16 } |
| 17 |
| 18 #if defined(OS_CHROMEOS) |
| 19 void TestRequestAllowedNotifier::SetNeedsEulaAcceptance(bool needs_acceptance) { |
| 20 needs_eula_acceptance_ = needs_acceptance; |
| 21 } |
| 22 #endif |
| 23 |
| 24 void TestRequestAllowedNotifier::SetRequestsAllowedOverride(bool allowed) { |
| 25 override_requests_allowed_ = true; |
| 26 requests_allowed_ = allowed; |
| 27 } |
| 28 |
| 29 void TestRequestAllowedNotifier::NotifyObserver() { |
| 30 // Force the allowed state to true. This forces MaybeNotifyObserver to always |
| 31 // notify observers, as MaybeNotifyObserver checks ResourceRequestsAllowed. |
| 32 override_requests_allowed_ = true; |
| 33 requests_allowed_ = true; |
| 34 MaybeNotifyObserver(); |
| 35 } |
| 36 |
| 37 bool TestRequestAllowedNotifier::ResourceRequestsAllowed() { |
| 38 // Call ResourceRequestAllowedNotifier::ResourceRequestsAllowed once to |
| 39 // simulate that the user requested permission. Only return that result if |
| 40 // the override flag was set. |
| 41 bool requests_allowed = |
| 42 ResourceRequestAllowedNotifier::ResourceRequestsAllowed(); |
| 43 if (override_requests_allowed_) |
| 44 return requests_allowed_; |
| 45 return requests_allowed; |
| 46 } |
| 47 |
| 48 #if defined(OS_CHROMEOS) |
| 49 bool TestRequestAllowedNotifier::NeedsEulaAcceptance() { |
| 50 return needs_eula_acceptance_; |
| 51 } |
| 52 #endif |
| OLD | NEW |