| OLD | NEW |
| 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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), | 166 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), |
| 167 l10n_util::GetStringFUTF16( | 167 l10n_util::GetStringFUTF16( |
| 168 IDS_NETWORK_CONNECTION_ERROR_MESSAGE_WITH_DETAILS, | 168 IDS_NETWORK_CONNECTION_ERROR_MESSAGE_WITH_DETAILS, |
| 169 UTF8ToUTF16(network->name()), error), | 169 UTF8ToUTF16(network->name()), error), |
| 170 no_links); | 170 no_links); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void NetworkStateNotifier::NetworkPropertiesUpdated( | 173 void NetworkStateNotifier::NetworkPropertiesUpdated( |
| 174 const NetworkState* network) { | 174 const NetworkState* network) { |
| 175 DCHECK(network); | 175 DCHECK(network); |
| 176 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 177 ash::switches::kAshDisableNewNetworkStatusArea)) { | |
| 178 return; | |
| 179 } | |
| 180 // Trigger "Out of credits" notification if the cellular network is the most | 176 // Trigger "Out of credits" notification if the cellular network is the most |
| 181 // recent default network (i.e. we have not switched to another network). | 177 // recent default network (i.e. we have not switched to another network). |
| 182 if (network->type() == flimflam::kTypeCellular && | 178 if (network->type() == flimflam::kTypeCellular && |
| 183 network->path() == last_active_network_) { | 179 network->path() == last_active_network_) { |
| 184 cellular_network_ = network->path(); | 180 cellular_network_ = network->path(); |
| 185 if (network->cellular_out_of_credits() && | 181 if (network->cellular_out_of_credits() && |
| 186 !cellular_out_of_credits_) { | 182 !cellular_out_of_credits_) { |
| 187 cellular_out_of_credits_ = true; | 183 cellular_out_of_credits_ = true; |
| 188 base::TimeDelta dtime = base::Time::Now() - out_of_credits_notify_time_; | 184 base::TimeDelta dtime = base::Time::Now() - out_of_credits_notify_time_; |
| 189 if (dtime.InSeconds() > kMinTimeBetweenOutOfCreditsNotifySeconds) { | 185 if (dtime.InSeconds() > kMinTimeBetweenOutOfCreditsNotifySeconds) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 204 } | 200 } |
| 205 } | 201 } |
| 206 } | 202 } |
| 207 | 203 |
| 208 void NetworkStateNotifier::NotificationLinkClicked( | 204 void NetworkStateNotifier::NotificationLinkClicked( |
| 209 NetworkObserver::MessageType message_type, | 205 NetworkObserver::MessageType message_type, |
| 210 size_t link_index) { | 206 size_t link_index) { |
| 211 if (message_type == ash::NetworkObserver::ERROR_OUT_OF_CREDITS) { | 207 if (message_type == ash::NetworkObserver::ERROR_OUT_OF_CREDITS) { |
| 212 if (!cellular_network_.empty()) { | 208 if (!cellular_network_.empty()) { |
| 213 // This will trigger the activation / portal code. | 209 // This will trigger the activation / portal code. |
| 214 Shell::GetInstance()->system_tray_delegate()->ConnectToNetwork( | 210 Shell::GetInstance()->system_tray_delegate()->ConfigureNetwork( |
| 215 cellular_network_); | 211 cellular_network_); |
| 216 } | 212 } |
| 217 ash::Shell::GetInstance()->system_tray_notifier()-> | 213 ash::Shell::GetInstance()->system_tray_notifier()-> |
| 218 NotifyClearNetworkMessage(message_type); | 214 NotifyClearNetworkMessage(message_type); |
| 219 } | 215 } |
| 220 } | 216 } |
| 221 | 217 |
| 222 void NetworkStateNotifier::InitializeNetworks() { | 218 void NetworkStateNotifier::InitializeNetworks() { |
| 223 NetworkStateList network_list; | 219 NetworkStateList network_list; |
| 224 NetworkStateHandler::Get()->GetNetworkList(&network_list); | 220 NetworkStateHandler::Get()->GetNetworkList(&network_list); |
| 225 VLOG(1) << "NetworkStateNotifier:InitializeNetworks: " | 221 VLOG(1) << "NetworkStateNotifier:InitializeNetworks: " |
| 226 << network_list.size(); | 222 << network_list.size(); |
| 227 for (NetworkStateList::iterator iter = network_list.begin(); | 223 for (NetworkStateList::iterator iter = network_list.begin(); |
| 228 iter != network_list.end(); ++iter) { | 224 iter != network_list.end(); ++iter) { |
| 229 const NetworkState* network = *iter; | 225 const NetworkState* network = *iter; |
| 230 VLOG(2) << " Network: " << network->path(); | 226 VLOG(2) << " Network: " << network->path(); |
| 231 cached_state_[network->path()] = network->connection_state(); | 227 cached_state_[network->path()] = network->connection_state(); |
| 232 } | 228 } |
| 233 const NetworkState* default_network = | 229 const NetworkState* default_network = |
| 234 NetworkStateHandler::Get()->DefaultNetwork(); | 230 NetworkStateHandler::Get()->DefaultNetwork(); |
| 235 if (default_network && default_network->IsConnectedState()) | 231 if (default_network && default_network->IsConnectedState()) |
| 236 last_active_network_ = default_network->path(); | 232 last_active_network_ = default_network->path(); |
| 237 } | 233 } |
| 238 | 234 |
| 239 } // namespace internal | 235 } // namespace internal |
| 240 } // namespace ash | 236 } // namespace ash |
| OLD | NEW |