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

Side by Side Diff: chrome/browser/web_resource/resource_request_allowed_notifier_test_util.cc

Issue 16841020: ResourceRequestAllowedNotifier didn't work as expected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (rebase) Created 7 years, 6 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 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 #include "chrome/browser/web_resource/resource_request_allowed_notifier_test_uti l.h" 5 #include "chrome/browser/web_resource/resource_request_allowed_notifier_test_uti l.h"
6 6
7 TestRequestAllowedNotifier::TestRequestAllowedNotifier() 7 TestRequestAllowedNotifier::TestRequestAllowedNotifier()
8 : override_requests_allowed_(false), 8 : override_requests_allowed_(false),
9 requests_allowed_(true) { 9 requests_allowed_(true) {
10 } 10 }
11 11
12 TestRequestAllowedNotifier::~TestRequestAllowedNotifier() { 12 TestRequestAllowedNotifier::~TestRequestAllowedNotifier() {
13 } 13 }
14 14
15 void TestRequestAllowedNotifier::InitWithEulaAcceptNotifier( 15 void TestRequestAllowedNotifier::InitWithEulaAcceptNotifier(
16 Observer* observer, 16 Observer* observer,
17 scoped_ptr<EulaAcceptedNotifier> eula_notifier) { 17 scoped_ptr<EulaAcceptedNotifier> eula_notifier) {
18 test_eula_notifier_.swap(eula_notifier); 18 test_eula_notifier_.swap(eula_notifier);
19 Init(observer); 19 Init(observer);
20 } 20 }
21 21
22 void TestRequestAllowedNotifier::SetRequestsAllowedOverride(bool allowed) { 22 void TestRequestAllowedNotifier::SetRequestsAllowedOverride(bool allowed) {
23 override_requests_allowed_ = true; 23 override_requests_allowed_ = true;
24 requests_allowed_ = allowed; 24 requests_allowed_ = allowed;
25 } 25 }
26 26
27 void TestRequestAllowedNotifier::NotifyObserver() { 27 void TestRequestAllowedNotifier::NotifyObserver() {
28 // Force the allowed state to true. This forces MaybeNotifyObserver to always 28 // Force the allowed state and requested state to true. This forces
29 // notify observers, as MaybeNotifyObserver checks ResourceRequestsAllowed. 29 // MaybeNotifyObserver to always notify observers, as MaybeNotifyObserver
30 // checks ResourceRequestsAllowed and requested state.
30 override_requests_allowed_ = true; 31 override_requests_allowed_ = true;
31 requests_allowed_ = true; 32 requests_allowed_ = true;
33 SetObserverRequestedForTesting(true);
32 MaybeNotifyObserver(); 34 MaybeNotifyObserver();
33 } 35 }
34 36
35 bool TestRequestAllowedNotifier::ResourceRequestsAllowed() { 37 bool TestRequestAllowedNotifier::ResourceRequestsAllowed() {
36 // Call ResourceRequestAllowedNotifier::ResourceRequestsAllowed once to
37 // simulate that the user requested permission. Only return that result if
38 // the override flag was set.
39 bool requests_allowed =
40 ResourceRequestAllowedNotifier::ResourceRequestsAllowed();
41 if (override_requests_allowed_) 38 if (override_requests_allowed_)
42 return requests_allowed_; 39 return requests_allowed_;
43 return requests_allowed; 40 return ResourceRequestAllowedNotifier::ResourceRequestsAllowed();
44 } 41 }
45 42
46 EulaAcceptedNotifier* TestRequestAllowedNotifier::CreateEulaNotifier() { 43 EulaAcceptedNotifier* TestRequestAllowedNotifier::CreateEulaNotifier() {
47 return test_eula_notifier_.release(); 44 return test_eula_notifier_.release();
48 } 45 }
49 46
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698