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

Side by Side Diff: chrome/browser/web_resource/resource_request_allowed_notifier.h

Issue 739173002: Remove dependencies of ResourceRequestAllowedNotifier on chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and cleanup Created 6 years, 1 month 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
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 #ifndef CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_ 5 #ifndef CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_
6 #define CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_ 6 #define CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_
7 7
8 #include "chrome/browser/web_resource/eula_accepted_notifier.h" 8 #include "chrome/browser/web_resource/eula_accepted_notifier.h"
9 #include "net/base/network_change_notifier.h" 9 #include "net/base/network_change_notifier.h"
10 10
11 class PrefService;
12
11 // This class informs an interested observer when resource requests over the 13 // This class informs an interested observer when resource requests over the
12 // network are permitted. 14 // network are permitted.
13 // 15 //
14 // Currently, the criteria for allowing resource requests are: 16 // Currently, the criteria for allowing resource requests are:
15 // 1. The network is currently available, 17 // 1. The network is currently available,
16 // 2. The EULA was accepted by the user (ChromeOS only), and 18 // 2. The EULA was accepted by the user (ChromeOS only), and
17 // 3. The --disable-background-networking command line switch is not set. 19 // 3. The --disable-background-networking command line switch is not set.
18 // 20 //
19 // Interested services should add themselves as an observer of 21 // Interested services should add themselves as an observer of
20 // ResourceRequestAllowedNotifier and check ResourceRequestsAllowed() to see if 22 // ResourceRequestAllowedNotifier and check ResourceRequestsAllowed() to see if
(...skipping 18 matching lines...) Expand all
39 }; 41 };
40 42
41 // Specifies the resource request allowed state. 43 // Specifies the resource request allowed state.
42 enum State { 44 enum State {
43 ALLOWED, 45 ALLOWED,
44 DISALLOWED_EULA_NOT_ACCEPTED, 46 DISALLOWED_EULA_NOT_ACCEPTED,
45 DISALLOWED_NETWORK_DOWN, 47 DISALLOWED_NETWORK_DOWN,
46 DISALLOWED_COMMAND_LINE_DISABLED, 48 DISALLOWED_COMMAND_LINE_DISABLED,
47 }; 49 };
48 50
49 ResourceRequestAllowedNotifier(); 51 explicit ResourceRequestAllowedNotifier(PrefService* local_state);
50 ~ResourceRequestAllowedNotifier() override; 52 ~ResourceRequestAllowedNotifier() override;
51 53
52 // Sets |observer| as the service to be notified by this instance, and 54 // Sets |observer| as the service to be notified by this instance, and
53 // performs initial checks on the criteria. |observer| may not be NULL. 55 // performs initial checks on the criteria. |observer| may not be NULL.
54 // This is to be called immediately after construction of an instance of 56 // This is to be called immediately after construction of an instance of
55 // ResourceRequestAllowedNotifier to pass it the interested service. 57 // ResourceRequestAllowedNotifier to pass it the interested service.
56 void Init(Observer* observer); 58 void Init(Observer* observer);
57 59
58 // Returns whether resource requests are allowed, per the various criteria. 60 // Returns whether resource requests are allowed, per the various criteria.
59 // If not, this call will set some flags so it knows to notify the observer 61 // If not, this call will set some flags so it knows to notify the observer
(...skipping 20 matching lines...) Expand all
80 // that it can be overridden by test subclasses. 82 // that it can be overridden by test subclasses.
81 virtual EulaAcceptedNotifier* CreateEulaNotifier(); 83 virtual EulaAcceptedNotifier* CreateEulaNotifier();
82 84
83 // EulaAcceptedNotifier::Observer overrides: 85 // EulaAcceptedNotifier::Observer overrides:
84 void OnEulaAccepted() override; 86 void OnEulaAccepted() override;
85 87
86 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides: 88 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides:
87 void OnConnectionTypeChanged( 89 void OnConnectionTypeChanged(
88 net::NetworkChangeNotifier::ConnectionType type) override; 90 net::NetworkChangeNotifier::ConnectionType type) override;
89 91
92 // The local state this class is observing.
93 PrefService* local_state_;
94
90 // Tracks whether or not the observer/service depending on this class actually 95 // Tracks whether or not the observer/service depending on this class actually
91 // requested permission to make a request or not. If it did not, then this 96 // requested permission to make a request or not. If it did not, then this
92 // class should not notify it even if the criteria is met. 97 // class should not notify it even if the criteria is met.
93 bool observer_requested_permission_; 98 bool observer_requested_permission_;
94 99
95 // Tracks network connectivity criteria. 100 // Tracks network connectivity criteria.
96 bool waiting_for_network_; 101 bool waiting_for_network_;
97 102
98 // Tracks EULA acceptance criteria. 103 // Tracks EULA acceptance criteria.
99 bool waiting_for_user_to_accept_eula_; 104 bool waiting_for_user_to_accept_eula_;
100 105
101 // Platform-specific notifier of EULA acceptance, or NULL if not needed. 106 // Platform-specific notifier of EULA acceptance, or NULL if not needed.
102 scoped_ptr<EulaAcceptedNotifier> eula_notifier_; 107 scoped_ptr<EulaAcceptedNotifier> eula_notifier_;
103 108
104 // Observing service interested in request permissions. 109 // Observing service interested in request permissions.
105 Observer* observer_; 110 Observer* observer_;
106 111
107 DISALLOW_COPY_AND_ASSIGN(ResourceRequestAllowedNotifier); 112 DISALLOW_COPY_AND_ASSIGN(ResourceRequestAllowedNotifier);
108 }; 113 };
109 114
110 #endif // CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_ 115 #endif // CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698