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

Side by Side Diff: chrome/browser/chromeos/net/network_portal_detector.h

Issue 14134007: NetworkPortalDetector/NetworkStateInformer: Switch over to use NetworkStateHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 (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 "net/url_request/url_fetcher.h" 9 #include "net/url_request/url_fetcher.h"
10 10
11 namespace chromeos { 11 namespace chromeos {
12 12
13 class Network; 13 class NetworkState;
14 14
15 // This class handles all notifications about network changes from 15 // This class handles all notifications about network changes from
16 // NetworkLibrary and delegates portal detection for the active 16 // NetworkLibrary and delegates portal detection for the active
17 // network to CaptivePortalService. 17 // network to CaptivePortalService.
18 class NetworkPortalDetector { 18 class NetworkPortalDetector {
19 public: 19 public:
20 enum CaptivePortalStatus { 20 enum CaptivePortalStatus {
21 CAPTIVE_PORTAL_STATUS_UNKNOWN = 0, 21 CAPTIVE_PORTAL_STATUS_UNKNOWN = 0,
22 CAPTIVE_PORTAL_STATUS_OFFLINE = 1, 22 CAPTIVE_PORTAL_STATUS_OFFLINE = 1,
23 CAPTIVE_PORTAL_STATUS_ONLINE = 2, 23 CAPTIVE_PORTAL_STATUS_ONLINE = 2,
(...skipping 14 matching lines...) Expand all
38 38
39 class Observer { 39 class Observer {
40 public: 40 public:
41 // Called when portal detection is completed for |network|, or 41 // Called when portal detection is completed for |network|, or
42 // when observers add themselves via AddAndFireObserver(). In the 42 // when observers add themselves via AddAndFireObserver(). In the
43 // second case, |network| is the active network and |state| is a 43 // second case, |network| is the active network and |state| is a
44 // current portal state for the active network, which can be 44 // current portal state for the active network, which can be
45 // currently in the unknown state, for instance, if portal 45 // currently in the unknown state, for instance, if portal
46 // detection is in process for the active network. 46 // detection is in process for the active network.
47 virtual void OnPortalDetectionCompleted( 47 virtual void OnPortalDetectionCompleted(
48 const Network* network, 48 const NetworkState* network,
49 const CaptivePortalState& state) = 0; 49 const CaptivePortalState& state) = 0;
50 50
51 protected: 51 protected:
52 virtual ~Observer() {} 52 virtual ~Observer() {}
53 }; 53 };
54 54
55 virtual void Init() = 0; 55 virtual void Init() = 0;
56 virtual void Shutdown() = 0; 56 virtual void Shutdown() = 0;
57 57
58 // Adds |observer| to the observers list. 58 // Adds |observer| to the observers list.
59 virtual void AddObserver(Observer* observer) = 0; 59 virtual void AddObserver(Observer* observer) = 0;
60 60
61 // Adds |observer| to the observers list and immediately calls 61 // Adds |observer| to the observers list and immediately calls
62 // OnPortalDetectionCompleted() with the active network (which may 62 // OnPortalDetectionCompleted() with the active network (which may
63 // be NULL) and captive portal state for the active network (which 63 // be NULL) and captive portal state for the active network (which
64 // may be unknown, if, for instance, portal detection is in process 64 // may be unknown, if, for instance, portal detection is in process
65 // for the active network). 65 // for the active network).
66 // 66 //
67 // WARNING: don't call this method from the Observer's ctors or 67 // WARNING: don't call this method from the Observer's ctors or
68 // dtors, as it implicitly calls OnPortalDetectionCompleted(), which 68 // dtors, as it implicitly calls OnPortalDetectionCompleted(), which
69 // is virtual. 69 // is virtual.
70 // TODO (ygorshenin@): find a way to avoid this restriction. 70 // TODO (ygorshenin@): find a way to avoid this restriction.
71 virtual void AddAndFireObserver(Observer* observer) = 0; 71 virtual void AddAndFireObserver(Observer* observer) = 0;
72 72
73 // Removes |observer| from the observers list. 73 // Removes |observer| from the observers list.
74 virtual void RemoveObserver(Observer* observer) = 0; 74 virtual void RemoveObserver(Observer* observer) = 0;
75 75
76 // Returns Captive Portal state for a given |network|. 76 // Returns Captive Portal state for a given |network|.
77 virtual CaptivePortalState GetCaptivePortalState( 77 virtual CaptivePortalState GetCaptivePortalState(
78 const chromeos::Network* network) = 0; 78 const chromeos::NetworkState* network) = 0;
79 79
80 // Returns true if portal detection is enabled. 80 // Returns true if portal detection is enabled.
81 virtual bool IsEnabled() = 0; 81 virtual bool IsEnabled() = 0;
82 82
83 // Enable portal detection. This method is needed because we can't 83 // Enable portal detection. This method is needed because we can't
84 // check current network for portal state unless user accepts EULA. 84 // check current network for portal state unless user accepts EULA.
85 // If |start_detection| is true and NetworkPortalDetector was 85 // If |start_detection| is true and NetworkPortalDetector was
86 // disabled previously, portal detection for the active network is 86 // disabled previously, portal detection for the active network is
87 // initiated by this method. 87 // initiated by this method.
88 virtual void Enable(bool start_detection) = 0; 88 virtual void Enable(bool start_detection) = 0;
(...skipping 18 matching lines...) Expand all
107 NetworkPortalDetector(); 107 NetworkPortalDetector();
108 virtual ~NetworkPortalDetector(); 108 virtual ~NetworkPortalDetector();
109 109
110 private: 110 private:
111 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetector); 111 DISALLOW_COPY_AND_ASSIGN(NetworkPortalDetector);
112 }; 112 };
113 113
114 } // namespace chromeos 114 } // namespace chromeos
115 115
116 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_H_ 116 #endif // CHROME_BROWSER_CHROMEOS_NET_NETWORK_PORTAL_DETECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698