| 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_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "chrome/browser/chromeos/net/network_portal_detector_strategy.h" | 9 #include "chrome/browser/chromeos/login/screens/error_screen.h" |
| 10 #include "net/url_request/url_fetcher.h" | 10 #include "net/url_request/url_fetcher.h" |
| 11 | 11 |
| 12 namespace chromeos { | 12 namespace chromeos { |
| 13 | 13 |
| 14 class NetworkState; | 14 class NetworkState; |
| 15 | 15 |
| 16 // This class handles all notifications about network changes from | 16 // This class handles all notifications about network changes from |
| 17 // NetworkStateHandler and delegates portal detection for the active | 17 // NetworkStateHandler and delegates portal detection for the active |
| 18 // network to CaptivePortalService. | 18 // network to CaptivePortalService. |
| 19 class NetworkPortalDetector { | 19 class NetworkPortalDetector : public ErrorScreen::Observer { |
| 20 public: | 20 public: |
| 21 enum CaptivePortalStatus { | 21 enum CaptivePortalStatus { |
| 22 CAPTIVE_PORTAL_STATUS_UNKNOWN = 0, | 22 CAPTIVE_PORTAL_STATUS_UNKNOWN = 0, |
| 23 CAPTIVE_PORTAL_STATUS_OFFLINE = 1, | 23 CAPTIVE_PORTAL_STATUS_OFFLINE = 1, |
| 24 CAPTIVE_PORTAL_STATUS_ONLINE = 2, | 24 CAPTIVE_PORTAL_STATUS_ONLINE = 2, |
| 25 CAPTIVE_PORTAL_STATUS_PORTAL = 3, | 25 CAPTIVE_PORTAL_STATUS_PORTAL = 3, |
| 26 CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED = 4, | 26 CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED = 4, |
| 27 CAPTIVE_PORTAL_STATUS_COUNT | 27 CAPTIVE_PORTAL_STATUS_COUNT |
| 28 }; | 28 }; |
| 29 | 29 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // If |start_detection| is true and NetworkPortalDetector was | 89 // If |start_detection| is true and NetworkPortalDetector was |
| 90 // disabled previously, portal detection for the active network is | 90 // disabled previously, portal detection for the active network is |
| 91 // initiated by this method. | 91 // initiated by this method. |
| 92 virtual void Enable(bool start_detection) = 0; | 92 virtual void Enable(bool start_detection) = 0; |
| 93 | 93 |
| 94 // Restarts portal detection for the default network if currently in | 94 // Restarts portal detection for the default network if currently in |
| 95 // the idle state. Returns true if new portal detection attempt was | 95 // the idle state. Returns true if new portal detection attempt was |
| 96 // started. | 96 // started. |
| 97 virtual bool StartDetectionIfIdle() = 0; | 97 virtual bool StartDetectionIfIdle() = 0; |
| 98 | 98 |
| 99 // Sets current strategy according to |id|. If current detection id | 99 virtual void OnErrorScreenShow() OVERRIDE {} |
| 100 // doesn't equal to |id|, detection is restarted. | 100 virtual void OnErrorScreenHide() OVERRIDE {} |
| 101 virtual void SetStrategy(PortalDetectorStrategy::StrategyId id) = 0; | |
| 102 | 101 |
| 103 // Initializes network portal detector for testing. The | 102 // Initializes network portal detector for testing. The |
| 104 // |network_portal_detector| will be owned by the internal pointer | 103 // |network_portal_detector| will be owned by the internal pointer |
| 105 // and deleted by Shutdown(). | 104 // and deleted by Shutdown(). |
| 106 static void InitializeForTesting( | 105 static void InitializeForTesting( |
| 107 NetworkPortalDetector* network_portal_detector); | 106 NetworkPortalDetector* network_portal_detector); |
| 108 | 107 |
| 109 // Creates an instance of the NetworkPortalDetector. | 108 // Creates an instance of the NetworkPortalDetector. |
| 110 static void Initialize(); | 109 static void Initialize(); |
| 111 | 110 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 128 NetworkPortalDetector() {} | 127 NetworkPortalDetector() {} |
| 129 virtual ~NetworkPortalDetector() {} | 128 virtual ~NetworkPortalDetector() {} |
| 130 | 129 |
| 131 private: | 130 private: |
| 132 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetector); | 131 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetector); |
| 133 }; | 132 }; |
| 134 | 133 |
| 135 } // namespace chromeos | 134 } // namespace chromeos |
| 136 | 135 |
| 137 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_H_ | 136 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_H_ |
| OLD | NEW |