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

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

Issue 22796014: Eliminate c/b/chromeos/options/network_connect.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 <map>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "ash/system/chromeos/network/network_tray_delegate.h" 11 #include "ash/system/chromeos/network/network_tray_delegate.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
14 #include "base/time/time.h" 16 #include "base/time/time.h"
15 #include "chromeos/network/network_state_handler_observer.h" 17 #include "chromeos/network/network_state_handler_observer.h"
16 18
19 namespace base {
20 class DictionaryValue;
21 }
22
17 namespace chromeos { 23 namespace chromeos {
18 class NetworkState; 24 class NetworkState;
19 } 25 }
20 26
21 namespace ash { 27 namespace ash {
22 28
23 // This class has two purposes: 29 // This class has two purposes:
24 // 1. ShowNetworkConnectError() gets called after any user initiated connect 30 // 1. ShowNetworkConnectError() gets called after any user initiated connect
25 // failure. This will handle displaying an error notification. 31 // failure. This will handle displaying an error notification.
26 // NOTE: Because Shill sets the Error property of a Service *after*
27 // the Connect call fails, this class will delay the notification if
28 // necessary until the Error property is set so that the correct
29 // message can be displayed.
30 // TODO(stevenjb): convert this class to use the new MessageCenter 32 // TODO(stevenjb): convert this class to use the new MessageCenter
31 // notification system, generate a notification immediately, and update 33 // notification system.
32 // it when the Error property is set to guarantee that a notification is
33 // displayed for every failure.
34 // 2. It observes NetworkState changes to generate notifications when a 34 // 2. It observes NetworkState changes to generate notifications when a
35 // Cellular network is out of credits. 35 // Cellular network is out of credits.
36 class ASH_EXPORT NetworkStateNotifier : 36 class ASH_EXPORT NetworkStateNotifier :
37 public chromeos::NetworkStateHandlerObserver, 37 public chromeos::NetworkStateHandlerObserver,
38 public NetworkTrayDelegate { 38 public NetworkTrayDelegate {
39 public: 39 public:
40 NetworkStateNotifier(); 40 NetworkStateNotifier();
41 virtual ~NetworkStateNotifier(); 41 virtual ~NetworkStateNotifier();
42 42
43 // NetworkStateHandlerObserver 43 // NetworkStateHandlerObserver
44 virtual void NetworkListChanged() OVERRIDE;
45 virtual void DefaultNetworkChanged( 44 virtual void DefaultNetworkChanged(
46 const chromeos::NetworkState* network) OVERRIDE; 45 const chromeos::NetworkState* network) OVERRIDE;
47 virtual void NetworkPropertiesUpdated( 46 virtual void NetworkPropertiesUpdated(
48 const chromeos::NetworkState* network) OVERRIDE; 47 const chromeos::NetworkState* network) OVERRIDE;
49 48
50 // NetworkTrayDelegate 49 // NetworkTrayDelegate
51 virtual void NotificationLinkClicked( 50 virtual void NotificationLinkClicked(
52 NetworkObserver::MessageType message_type, 51 NetworkObserver::MessageType message_type,
53 size_t link_index) OVERRIDE; 52 size_t link_index) OVERRIDE;
54 53
55 // Show a connection error notification. 54 // Show a connection error notification. If |error_name| matches an error
55 // defined in NetworkConnectionHandler for connect, configure, or activation
56 // failed, then the associated message is shown, otherwise the Shill
57 // error for Service.Error is used (from network_connect::ErrorString), or
58 // "Unknown network error".
56 void ShowNetworkConnectError(const std::string& error_name, 59 void ShowNetworkConnectError(const std::string& error_name,
57 const std::string& service_path); 60 const std::string& service_path);
58 61
59 private: 62 private:
60 typedef std::map<std::string, std::string> CachedStateMap; 63 void ConnectErrorPropertiesSucceeded(
64 const std::string& error_name,
65 const std::string& service_path,
66 const base::DictionaryValue& shill_properties);
67 void ConnectErrorPropertiesFailed(
68 const std::string& error_name,
69 const std::string& service_path,
70 const std::string& shill_error_name,
71 scoped_ptr<base::DictionaryValue> shill_error_data);
72 void ShowConnectErrorNotification(
73 const std::string& error_name,
74 const std::string& service_path,
75 const base::DictionaryValue& shill_properties);
61 76
62 std::string last_active_network_; 77 std::string last_active_network_;
63 std::string cellular_network_; 78 std::string cellular_network_;
64 std::string connect_failed_network_;
65 bool cellular_out_of_credits_; 79 bool cellular_out_of_credits_;
66 base::Time out_of_credits_notify_time_; 80 base::Time out_of_credits_notify_time_;
81 base::WeakPtrFactory<NetworkStateNotifier> weak_ptr_factory_;
67 82
68 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier); 83 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier);
69 }; 84 };
70 85
71 } // namespace ash 86 } // namespace ash
72 87
73 #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_connect.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