| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 // NetworkPortalDetector implementation: | 67 // NetworkPortalDetector implementation: |
| 68 virtual void AddObserver(Observer* observer) OVERRIDE; | 68 virtual void AddObserver(Observer* observer) OVERRIDE; |
| 69 virtual void AddAndFireObserver(Observer* observer) OVERRIDE; | 69 virtual void AddAndFireObserver(Observer* observer) OVERRIDE; |
| 70 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 70 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
| 71 virtual CaptivePortalState GetCaptivePortalState( | 71 virtual CaptivePortalState GetCaptivePortalState( |
| 72 const std::string& service_path) OVERRIDE; | 72 const std::string& service_path) OVERRIDE; |
| 73 virtual bool IsEnabled() OVERRIDE; | 73 virtual bool IsEnabled() OVERRIDE; |
| 74 virtual void Enable(bool start_detection) OVERRIDE; | 74 virtual void Enable(bool start_detection) OVERRIDE; |
| 75 virtual bool StartDetectionIfIdle() OVERRIDE; | 75 virtual bool StartDetectionIfIdle() OVERRIDE; |
| 76 virtual void SetStrategy(PortalDetectorStrategy::StrategyId id) OVERRIDE; | |
| 77 | 76 |
| 78 // NetworkStateHandlerObserver implementation: | 77 // NetworkStateHandlerObserver implementation: |
| 79 virtual void DefaultNetworkChanged(const NetworkState* network) OVERRIDE; | 78 virtual void DefaultNetworkChanged(const NetworkState* network) OVERRIDE; |
| 80 | 79 |
| 81 // PortalDetectorStrategy::Delegate implementation: | 80 // PortalDetectorStrategy::Delegate implementation: |
| 82 virtual int AttemptCount() OVERRIDE; | 81 virtual int AttemptCount() OVERRIDE; |
| 83 virtual base::TimeTicks AttemptStartTime() OVERRIDE; | 82 virtual base::TimeTicks AttemptStartTime() OVERRIDE; |
| 84 virtual base::TimeTicks GetCurrentTimeTicks() OVERRIDE; | 83 virtual base::TimeTicks GetCurrentTimeTicks() OVERRIDE; |
| 85 | 84 |
| 85 // ErrorScreen::Observer implementation: |
| 86 virtual void OnErrorScreenShow() OVERRIDE; |
| 87 virtual void OnErrorScreenHide() OVERRIDE; |
| 88 |
| 86 private: | 89 private: |
| 87 friend class NetworkPortalDetectorImplTest; | 90 friend class NetworkPortalDetectorImplTest; |
| 88 friend class NetworkPortalDetectorImplBrowserTest; | 91 friend class NetworkPortalDetectorImplBrowserTest; |
| 89 | 92 |
| 90 typedef std::string NetworkId; | 93 typedef std::string NetworkId; |
| 91 typedef base::hash_map<NetworkId, CaptivePortalState> CaptivePortalStateMap; | 94 typedef base::hash_map<NetworkId, CaptivePortalState> CaptivePortalStateMap; |
| 92 | 95 |
| 93 enum State { | 96 enum State { |
| 94 // No portal check is running. | 97 // No portal check is running. |
| 95 STATE_IDLE = 0, | 98 STATE_IDLE = 0, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 const content::NotificationDetails& details) OVERRIDE; | 133 const content::NotificationDetails& details) OVERRIDE; |
| 131 | 134 |
| 132 // Stores captive portal state for a |network| and notifies observers. | 135 // Stores captive portal state for a |network| and notifies observers. |
| 133 void OnDetectionCompleted(const NetworkState* network, | 136 void OnDetectionCompleted(const NetworkState* network, |
| 134 const CaptivePortalState& results); | 137 const CaptivePortalState& results); |
| 135 | 138 |
| 136 // Notifies observers that portal detection is completed for a |network|. | 139 // Notifies observers that portal detection is completed for a |network|. |
| 137 void NotifyDetectionCompleted(const NetworkState* network, | 140 void NotifyDetectionCompleted(const NetworkState* network, |
| 138 const CaptivePortalState& state); | 141 const CaptivePortalState& state); |
| 139 | 142 |
| 143 // Updates current detection strategy according to the curren state: |
| 144 // error screen, login screen or user session. |
| 145 void UpdateCurrentStrategy(); |
| 146 |
| 147 // Sets current strategy according to |id|. If current detection id |
| 148 // doesn't equal to |id|, detection is restarted. |
| 149 void SetStrategy(PortalDetectorStrategy::StrategyId id); |
| 150 |
| 140 State state() const { return state_; } | 151 State state() const { return state_; } |
| 141 | 152 |
| 142 bool is_idle() const { | 153 bool is_idle() const { |
| 143 return state_ == STATE_IDLE; | 154 return state_ == STATE_IDLE; |
| 144 } | 155 } |
| 145 bool is_portal_check_pending() const { | 156 bool is_portal_check_pending() const { |
| 146 return state_ == STATE_PORTAL_CHECK_PENDING; | 157 return state_ == STATE_PORTAL_CHECK_PENDING; |
| 147 } | 158 } |
| 148 bool is_checking_for_portal() const { | 159 bool is_checking_for_portal() const { |
| 149 return state_ == STATE_CHECKING_FOR_PORTAL; | 160 return state_ == STATE_CHECKING_FOR_PORTAL; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 230 |
| 220 // Number of already performed detection attempts. | 231 // Number of already performed detection attempts. |
| 221 int attempt_count_; | 232 int attempt_count_; |
| 222 | 233 |
| 223 // Delay before next portal detection. | 234 // Delay before next portal detection. |
| 224 base::TimeDelta next_attempt_delay_; | 235 base::TimeDelta next_attempt_delay_; |
| 225 | 236 |
| 226 // Current detection strategy. | 237 // Current detection strategy. |
| 227 scoped_ptr<PortalDetectorStrategy> strategy_; | 238 scoped_ptr<PortalDetectorStrategy> strategy_; |
| 228 | 239 |
| 240 // True when error screen is displayed. |
| 241 bool error_screen_displayed_; |
| 242 |
| 229 // UI notification controller about captive portal state. | 243 // UI notification controller about captive portal state. |
| 230 NetworkPortalNotificationController notification_controller_; | 244 NetworkPortalNotificationController notification_controller_; |
| 231 | 245 |
| 232 content::NotificationRegistrar registrar_; | 246 content::NotificationRegistrar registrar_; |
| 233 | 247 |
| 234 // Test time ticks used by unit tests. | 248 // Test time ticks used by unit tests. |
| 235 base::TimeTicks time_ticks_for_testing_; | 249 base::TimeTicks time_ticks_for_testing_; |
| 236 | 250 |
| 237 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorImpl); | 251 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetectorImpl); |
| 238 }; | 252 }; |
| 239 | 253 |
| 240 } // namespace chromeos | 254 } // namespace chromeos |
| 241 | 255 |
| 242 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ | 256 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_IMPL_H_ |
| OLD | NEW |