Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: chrome/browser/metrics/variations/resource_request_allowed_notifier_test_util.cc

Issue 13620010: Refactor ResourceRequestAllowedNotifier EULA checking into a separate class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/metrics/variations/resource_request_allowed_notifier_te st_util.h" 5 #include "chrome/browser/metrics/variations/resource_request_allowed_notifier_te st_util.h"
6 6
7 TestRequestAllowedNotifier::TestRequestAllowedNotifier() : 7 TestRequestAllowedNotifier::TestRequestAllowedNotifier()
8 #if defined(OS_CHROMEOS) 8 : override_requests_allowed_(false),
9 needs_eula_acceptance_(true),
10 #endif
11 override_requests_allowed_(false),
12 requests_allowed_(true) { 9 requests_allowed_(true) {
13 } 10 }
14 11
15 TestRequestAllowedNotifier::~TestRequestAllowedNotifier() { 12 TestRequestAllowedNotifier::~TestRequestAllowedNotifier() {
16 } 13 }
17 14
18 #if defined(OS_CHROMEOS) 15 void TestRequestAllowedNotifier::InitWithEulaAcceptNotifier(
19 void TestRequestAllowedNotifier::SetNeedsEulaAcceptance(bool needs_acceptance) { 16 Observer* observer,
20 needs_eula_acceptance_ = needs_acceptance; 17 scoped_ptr<EulaAcceptedNotifier> eula_notifier) {
18 test_eula_notifier_.swap(eula_notifier);
19 Init(observer);
21 } 20 }
22 #endif
23 21
24 void TestRequestAllowedNotifier::SetRequestsAllowedOverride(bool allowed) { 22 void TestRequestAllowedNotifier::SetRequestsAllowedOverride(bool allowed) {
25 override_requests_allowed_ = true; 23 override_requests_allowed_ = true;
26 requests_allowed_ = allowed; 24 requests_allowed_ = allowed;
27 } 25 }
28 26
29 void TestRequestAllowedNotifier::NotifyObserver() { 27 void TestRequestAllowedNotifier::NotifyObserver() {
30 // Force the allowed state to true. This forces MaybeNotifyObserver to always 28 // Force the allowed state to true. This forces MaybeNotifyObserver to always
31 // notify observers, as MaybeNotifyObserver checks ResourceRequestsAllowed. 29 // notify observers, as MaybeNotifyObserver checks ResourceRequestsAllowed.
32 override_requests_allowed_ = true; 30 override_requests_allowed_ = true;
33 requests_allowed_ = true; 31 requests_allowed_ = true;
34 MaybeNotifyObserver(); 32 MaybeNotifyObserver();
35 } 33 }
36 34
37 bool TestRequestAllowedNotifier::ResourceRequestsAllowed() { 35 bool TestRequestAllowedNotifier::ResourceRequestsAllowed() {
38 // Call ResourceRequestAllowedNotifier::ResourceRequestsAllowed once to 36 // Call ResourceRequestAllowedNotifier::ResourceRequestsAllowed once to
39 // simulate that the user requested permission. Only return that result if 37 // simulate that the user requested permission. Only return that result if
40 // the override flag was set. 38 // the override flag was set.
41 bool requests_allowed = 39 bool requests_allowed =
42 ResourceRequestAllowedNotifier::ResourceRequestsAllowed(); 40 ResourceRequestAllowedNotifier::ResourceRequestsAllowed();
43 if (override_requests_allowed_) 41 if (override_requests_allowed_)
44 return requests_allowed_; 42 return requests_allowed_;
45 return requests_allowed; 43 return requests_allowed;
46 } 44 }
47 45
48 #if defined(OS_CHROMEOS) 46 EulaAcceptedNotifier* TestRequestAllowedNotifier::CreateEulaNotifier() {
49 bool TestRequestAllowedNotifier::NeedsEulaAcceptance() { 47 return test_eula_notifier_.release();
50 return needs_eula_acceptance_;
51 } 48 }
52 #endif 49
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698