OLD | NEW |
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 |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 // Specifies the resource request allowed state. | 41 // Specifies the resource request allowed state. |
42 enum State { | 42 enum State { |
43 ALLOWED, | 43 ALLOWED, |
44 DISALLOWED_EULA_NOT_ACCEPTED, | 44 DISALLOWED_EULA_NOT_ACCEPTED, |
45 DISALLOWED_NETWORK_DOWN, | 45 DISALLOWED_NETWORK_DOWN, |
46 DISALLOWED_COMMAND_LINE_DISABLED, | 46 DISALLOWED_COMMAND_LINE_DISABLED, |
47 }; | 47 }; |
48 | 48 |
49 ResourceRequestAllowedNotifier(); | 49 ResourceRequestAllowedNotifier(); |
50 virtual ~ResourceRequestAllowedNotifier(); | 50 ~ResourceRequestAllowedNotifier() override; |
51 | 51 |
52 // Sets |observer| as the service to be notified by this instance, and | 52 // Sets |observer| as the service to be notified by this instance, and |
53 // performs initial checks on the criteria. |observer| may not be NULL. | 53 // performs initial checks on the criteria. |observer| may not be NULL. |
54 // This is to be called immediately after construction of an instance of | 54 // This is to be called immediately after construction of an instance of |
55 // ResourceRequestAllowedNotifier to pass it the interested service. | 55 // ResourceRequestAllowedNotifier to pass it the interested service. |
56 void Init(Observer* observer); | 56 void Init(Observer* observer); |
57 | 57 |
58 // Returns whether resource requests are allowed, per the various criteria. | 58 // 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 | 59 // If not, this call will set some flags so it knows to notify the observer |
60 // if the criteria change. Note that the observer will not be notified unless | 60 // if the criteria change. Note that the observer will not be notified unless |
(...skipping 13 matching lines...) Expand all Loading... |
74 // Notifies the observer if all criteria needed for resource requests are met. | 74 // Notifies the observer if all criteria needed for resource requests are met. |
75 // This is protected so it can be called from subclasses for testing. | 75 // This is protected so it can be called from subclasses for testing. |
76 void MaybeNotifyObserver(); | 76 void MaybeNotifyObserver(); |
77 | 77 |
78 private: | 78 private: |
79 // Creates the EulaAcceptNotifier or NULL if one is not needed. Virtual so | 79 // Creates the EulaAcceptNotifier or NULL if one is not needed. Virtual so |
80 // that it can be overridden by test subclasses. | 80 // that it can be overridden by test subclasses. |
81 virtual EulaAcceptedNotifier* CreateEulaNotifier(); | 81 virtual EulaAcceptedNotifier* CreateEulaNotifier(); |
82 | 82 |
83 // EulaAcceptedNotifier::Observer overrides: | 83 // EulaAcceptedNotifier::Observer overrides: |
84 virtual void OnEulaAccepted() override; | 84 void OnEulaAccepted() override; |
85 | 85 |
86 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides: | 86 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides: |
87 virtual void OnConnectionTypeChanged( | 87 void OnConnectionTypeChanged( |
88 net::NetworkChangeNotifier::ConnectionType type) override; | 88 net::NetworkChangeNotifier::ConnectionType type) override; |
89 | 89 |
90 // Tracks whether or not the observer/service depending on this class actually | 90 // 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 | 91 // 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. | 92 // class should not notify it even if the criteria is met. |
93 bool observer_requested_permission_; | 93 bool observer_requested_permission_; |
94 | 94 |
95 // Tracks network connectivity criteria. | 95 // Tracks network connectivity criteria. |
96 bool waiting_for_network_; | 96 bool waiting_for_network_; |
97 | 97 |
98 // Tracks EULA acceptance criteria. | 98 // Tracks EULA acceptance criteria. |
99 bool waiting_for_user_to_accept_eula_; | 99 bool waiting_for_user_to_accept_eula_; |
100 | 100 |
101 // Platform-specific notifier of EULA acceptance, or NULL if not needed. | 101 // Platform-specific notifier of EULA acceptance, or NULL if not needed. |
102 scoped_ptr<EulaAcceptedNotifier> eula_notifier_; | 102 scoped_ptr<EulaAcceptedNotifier> eula_notifier_; |
103 | 103 |
104 // Observing service interested in request permissions. | 104 // Observing service interested in request permissions. |
105 Observer* observer_; | 105 Observer* observer_; |
106 | 106 |
107 DISALLOW_COPY_AND_ASSIGN(ResourceRequestAllowedNotifier); | 107 DISALLOW_COPY_AND_ASSIGN(ResourceRequestAllowedNotifier); |
108 }; | 108 }; |
109 | 109 |
110 #endif // CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_ | 110 #endif // CHROME_BROWSER_WEB_RESOURCE_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_ |
OLD | NEW |