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

Side by Side Diff: ash/system/chromeos/network/network_state_notifier.h

Issue 23075012: Update NetworkStateNotifier to use message_center. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Track deafult_network and reset did_show_out_of_credits on any change Created 7 years, 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_ 5 #ifndef ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_
6 #define ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_ 6 #define ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_
7 7
8 #include <map> 8 #include <set>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "ash/system/chromeos/network/network_tray_delegate.h"
12 #include "base/basictypes.h" 11 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
16 #include "base/time/time.h" 15 #include "base/time/time.h"
17 #include "chromeos/network/network_state_handler_observer.h" 16 #include "chromeos/network/network_state_handler_observer.h"
18 17
19 namespace base { 18 namespace base {
20 class DictionaryValue; 19 class DictionaryValue;
21 } 20 }
22 21
23 namespace chromeos { 22 namespace chromeos {
24 class NetworkState; 23 class NetworkState;
25 } 24 }
26 25
27 namespace ash { 26 namespace ash {
28 27
29 // This class has two purposes: 28 // This class has two purposes:
30 // 1. ShowNetworkConnectError() gets called after any user initiated connect 29 // 1. ShowNetworkConnectError() gets called after any user initiated connect
31 // failure. This will handle displaying an error notification. 30 // failure. This will handle displaying an error notification.
32 // TODO(stevenjb): convert this class to use the new MessageCenter 31 // TODO(stevenjb): convert this class to use the new MessageCenter
33 // notification system. 32 // notification system.
34 // 2. It observes NetworkState changes to generate notifications when a 33 // 2. It observes NetworkState changes to generate notifications when a
35 // Cellular network is out of credits. 34 // Cellular network is out of credits.
36 class ASH_EXPORT NetworkStateNotifier : 35 class ASH_EXPORT NetworkStateNotifier :
37 public chromeos::NetworkStateHandlerObserver, 36 public chromeos::NetworkStateHandlerObserver {
38 public NetworkTrayDelegate {
39 public: 37 public:
40 NetworkStateNotifier(); 38 NetworkStateNotifier();
41 virtual ~NetworkStateNotifier(); 39 virtual ~NetworkStateNotifier();
42 40
43 // NetworkStateHandlerObserver 41 // NetworkStateHandlerObserver
44 virtual void DefaultNetworkChanged( 42 virtual void DefaultNetworkChanged(
45 const chromeos::NetworkState* network) OVERRIDE; 43 const chromeos::NetworkState* network) OVERRIDE;
46 virtual void NetworkPropertiesUpdated( 44 virtual void NetworkPropertiesUpdated(
47 const chromeos::NetworkState* network) OVERRIDE; 45 const chromeos::NetworkState* network) OVERRIDE;
48 46
49 // NetworkTrayDelegate
50 virtual void NotificationLinkClicked(
51 NetworkObserver::MessageType message_type,
52 size_t link_index) OVERRIDE;
53
54 // Show a connection error notification. If |error_name| matches an error 47 // Show a connection error notification. If |error_name| matches an error
55 // defined in NetworkConnectionHandler for connect, configure, or activation 48 // defined in NetworkConnectionHandler for connect, configure, or activation
56 // failed, then the associated message is shown, otherwise the Shill 49 // failed, then the associated message is shown, otherwise the Shill
57 // error for Service.Error is used (from network_connect::ErrorString), or 50 // error for Service.Error is used (from network_connect::ErrorString), or
58 // "Unknown network error". 51 // "Unknown network error".
59 void ShowNetworkConnectError(const std::string& error_name, 52 void ShowNetworkConnectError(const std::string& error_name,
60 const std::string& service_path); 53 const std::string& service_path);
61 54
62 private: 55 private:
63 void ConnectErrorPropertiesSucceeded( 56 void ConnectErrorPropertiesSucceeded(
64 const std::string& error_name, 57 const std::string& error_name,
65 const std::string& service_path, 58 const std::string& service_path,
66 const base::DictionaryValue& shill_properties); 59 const base::DictionaryValue& shill_properties);
67 void ConnectErrorPropertiesFailed( 60 void ConnectErrorPropertiesFailed(
68 const std::string& error_name, 61 const std::string& error_name,
69 const std::string& service_path, 62 const std::string& service_path,
70 const std::string& shill_error_name, 63 const std::string& shill_error_name,
71 scoped_ptr<base::DictionaryValue> shill_error_data); 64 scoped_ptr<base::DictionaryValue> shill_error_data);
72 void ShowConnectErrorNotification( 65 void ShowConnectErrorNotification(
73 const std::string& error_name, 66 const std::string& error_name,
74 const std::string& service_path, 67 const std::string& service_path,
75 const base::DictionaryValue& shill_properties); 68 const base::DictionaryValue& shill_properties);
76 69
77 std::string last_active_network_; 70 // Returns true if the default network changed.
78 std::string cellular_network_; 71 bool UpdateDefaultNetwork(const chromeos::NetworkState* network);
79 bool cellular_out_of_credits_; 72
73 // Helper methods to update state and check for notifications.
74 void UpdateCellularOutOfCredits(const chromeos::NetworkState* cellular);
75 void UpdateCellularActivating(const chromeos::NetworkState* cellular);
76
77 std::string last_default_network_;
78 bool did_show_out_of_credits_;
80 base::Time out_of_credits_notify_time_; 79 base::Time out_of_credits_notify_time_;
80 std::set<std::string> cellular_activating_;
81 base::WeakPtrFactory<NetworkStateNotifier> weak_ptr_factory_; 81 base::WeakPtrFactory<NetworkStateNotifier> weak_ptr_factory_;
82 82
83 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier); 83 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier);
84 }; 84 };
85 85
86 } // namespace ash 86 } // namespace ash
87 87
88 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_ 88 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_
OLDNEW
« no previous file with comments | « ash/system/chromeos/network/network_observer.cc ('k') | ash/system/chromeos/network/network_state_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698