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

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

Issue 23701015: Merge 220596 "Differentiate between 'connect-failed' and 'bad-pa..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1599/src/
Patch Set: Created 7 years, 3 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 #include "ash/system/chromeos/network/network_state_notifier.h" 5 #include "ash/system/chromeos/network/network_state_notifier.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/chromeos/network/network_connect.h" 8 #include "ash/system/chromeos/network/network_connect.h"
9 #include "ash/system/chromeos/network/network_observer.h" 9 #include "ash/system/chromeos/network/network_observer.h"
10 #include "ash/system/tray/system_tray_notifier.h" 10 #include "ash/system/tray/system_tray_notifier.h"
(...skipping 17 matching lines...) Expand all
28 28
29 const int kMinTimeBetweenOutOfCreditsNotifySeconds = 10 * 60; 29 const int kMinTimeBetweenOutOfCreditsNotifySeconds = 10 * 60;
30 30
31 // Error messages based on |error_name|, not network_state->error(). 31 // Error messages based on |error_name|, not network_state->error().
32 string16 GetConnectErrorString(const std::string& error_name) { 32 string16 GetConnectErrorString(const std::string& error_name) {
33 if (error_name == NetworkConnectionHandler::kErrorNotFound) 33 if (error_name == NetworkConnectionHandler::kErrorNotFound)
34 return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_CONNECT_FAILED); 34 return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_CONNECT_FAILED);
35 if (error_name == NetworkConnectionHandler::kErrorConfigureFailed) 35 if (error_name == NetworkConnectionHandler::kErrorConfigureFailed)
36 return l10n_util::GetStringUTF16( 36 return l10n_util::GetStringUTF16(
37 IDS_CHROMEOS_NETWORK_ERROR_CONFIGURE_FAILED); 37 IDS_CHROMEOS_NETWORK_ERROR_CONFIGURE_FAILED);
38 if (error_name == NetworkConnectionHandler::kErrorActivateFailed) 38 if (error_name == ash::network_connect::kErrorActivateFailed)
39 return l10n_util::GetStringUTF16( 39 return l10n_util::GetStringUTF16(
40 IDS_CHROMEOS_NETWORK_ERROR_ACTIVATION_FAILED); 40 IDS_CHROMEOS_NETWORK_ERROR_ACTIVATION_FAILED);
41 return string16(); 41 return string16();
42 } 42 }
43 43
44 } // namespace 44 } // namespace
45 45
46 namespace ash { 46 namespace ash {
47 47
48 NetworkStateNotifier::NetworkStateNotifier() 48 NetworkStateNotifier::NetworkStateNotifier()
(...skipping 15 matching lines...) Expand all
64 NetworkHandler::Get()->network_state_handler()->RemoveObserver( 64 NetworkHandler::Get()->network_state_handler()->RemoveObserver(
65 this, FROM_HERE); 65 this, FROM_HERE);
66 } 66 }
67 67
68 void NetworkStateNotifier::NetworkListChanged() { 68 void NetworkStateNotifier::NetworkListChanged() {
69 // Trigger any pending connect failed error if the network list changes 69 // Trigger any pending connect failed error if the network list changes
70 // (which indicates all NetworkState entries are up to date). This is in 70 // (which indicates all NetworkState entries are up to date). This is in
71 // case a connect attempt fails because a network is no longer visible. 71 // case a connect attempt fails because a network is no longer visible.
72 if (!connect_failed_network_.empty()) { 72 if (!connect_failed_network_.empty()) {
73 ShowNetworkConnectError( 73 ShowNetworkConnectError(
74 NetworkConnectionHandler::kErrorConnectFailed, connect_failed_network_); 74 flimflam::kErrorConnectFailed, connect_failed_network_);
75 } 75 }
76 } 76 }
77 77
78 void NetworkStateNotifier::DefaultNetworkChanged(const NetworkState* network) { 78 void NetworkStateNotifier::DefaultNetworkChanged(const NetworkState* network) {
79 if (!network || !network->IsConnectedState()) 79 if (!network || !network->IsConnectedState())
80 return; 80 return;
81 if (network->path() != last_active_network_) { 81 if (network->path() != last_active_network_) {
82 last_active_network_ = network->path(); 82 last_active_network_ = network->path();
83 // Reset state for new connected network 83 // Reset state for new connected network
84 cellular_out_of_credits_ = false; 84 cellular_out_of_credits_ = false;
85 } 85 }
86 } 86 }
87 87
88 void NetworkStateNotifier::NetworkPropertiesUpdated( 88 void NetworkStateNotifier::NetworkPropertiesUpdated(
89 const NetworkState* network) { 89 const NetworkState* network) {
90 DCHECK(network); 90 DCHECK(network);
91 // Trigger a pending connect failed error for |network| when the Error 91 // Trigger a pending connect failed error for |network| when the Error
92 // property has been set. 92 // property has been set.
93 if (network->path() == connect_failed_network_ && !network->error().empty()) { 93 if (network->path() == connect_failed_network_ && !network->error().empty()) {
94 ShowNetworkConnectError( 94 ShowNetworkConnectError(
95 NetworkConnectionHandler::kErrorConnectFailed, connect_failed_network_); 95 flimflam::kErrorConnectFailed, connect_failed_network_);
96 } 96 }
97 // Trigger "Out of credits" notification if the cellular network is the most 97 // Trigger "Out of credits" notification if the cellular network is the most
98 // recent default network (i.e. we have not switched to another network). 98 // recent default network (i.e. we have not switched to another network).
99 if (network->type() == flimflam::kTypeCellular && 99 if (network->type() == flimflam::kTypeCellular &&
100 network->path() == last_active_network_) { 100 network->path() == last_active_network_) {
101 cellular_network_ = network->path(); 101 cellular_network_ = network->path();
102 if (network->cellular_out_of_credits() && 102 if (network->cellular_out_of_credits() &&
103 !cellular_out_of_credits_) { 103 !cellular_out_of_credits_) {
104 cellular_out_of_credits_ = true; 104 cellular_out_of_credits_ = true;
105 base::TimeDelta dtime = base::Time::Now() - out_of_credits_notify_time_; 105 base::TimeDelta dtime = base::Time::Now() - out_of_credits_notify_time_;
(...skipping 28 matching lines...) Expand all
134 ash::Shell::GetInstance()->system_tray_notifier()-> 134 ash::Shell::GetInstance()->system_tray_notifier()->
135 NotifyClearNetworkMessage(message_type); 135 NotifyClearNetworkMessage(message_type);
136 } 136 }
137 } 137 }
138 138
139 void NetworkStateNotifier::ShowNetworkConnectError( 139 void NetworkStateNotifier::ShowNetworkConnectError(
140 const std::string& error_name, 140 const std::string& error_name,
141 const std::string& service_path) { 141 const std::string& service_path) {
142 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> 142 const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
143 GetNetworkState(service_path); 143 GetNetworkState(service_path);
144 if (error_name == NetworkConnectionHandler::kErrorConnectFailed && 144 if (error_name == flimflam::kErrorConnectFailed &&
145 service_path != connect_failed_network_) { 145 service_path != connect_failed_network_) {
146 // Shill may not have set the Error property yet. First request an update 146 // Shill may not have set the Error property yet. First request an update
147 // and wait for either the update to complete or the network list to be 147 // and wait for either the update to complete or the network list to be
148 // updated before displaying the error. 148 // updated before displaying the error.
149 connect_failed_network_ = service_path; 149 connect_failed_network_ = service_path;
150 return; 150 return;
151 } 151 }
152 connect_failed_network_.clear(); 152 connect_failed_network_.clear();
153 153
154 string16 error = GetConnectErrorString(error_name); 154 string16 error = GetConnectErrorString(error_name);
(...skipping 20 matching lines...) Expand all
175 ash::Shell::GetInstance()->system_tray_notifier()->NotifySetNetworkMessage( 175 ash::Shell::GetInstance()->system_tray_notifier()->NotifySetNetworkMessage(
176 this, 176 this,
177 NetworkObserver::ERROR_CONNECT_FAILED, 177 NetworkObserver::ERROR_CONNECT_FAILED,
178 NetworkObserver::GetNetworkTypeForNetworkState(network), 178 NetworkObserver::GetNetworkTypeForNetworkState(network),
179 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), 179 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE),
180 error_msg, 180 error_msg,
181 no_links); 181 no_links);
182 } 182 }
183 183
184 } // namespace ash 184 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/network/network_connect.cc ('k') | chromeos/network/network_connection_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698