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/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/system_notifier.h" | 9 #include "ash/system/system_notifier.h" |
10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "third_party/cros_system_api/dbus/service_constants.h" | 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/message_center/message_center.h" | 25 #include "ui/message_center/message_center.h" |
26 #include "ui/message_center/notification.h" | 26 #include "ui/message_center/notification.h" |
27 | 27 |
28 using chromeos::NetworkConnectionHandler; | 28 using chromeos::NetworkConnectionHandler; |
29 using chromeos::NetworkHandler; | 29 using chromeos::NetworkHandler; |
30 using chromeos::NetworkState; | 30 using chromeos::NetworkState; |
31 using chromeos::NetworkStateHandler; | 31 using chromeos::NetworkStateHandler; |
| 32 using chromeos::NetworkTypePattern; |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 const char kNetworkOutOfCreditsNotificationId[] = | 36 const char kNetworkOutOfCreditsNotificationId[] = |
36 "chrome://settings/internet/out-of-credits"; | 37 "chrome://settings/internet/out-of-credits"; |
37 | 38 |
38 const int kMinTimeBetweenOutOfCreditsNotifySeconds = 10 * 60; | 39 const int kMinTimeBetweenOutOfCreditsNotifySeconds = 10 * 60; |
39 | 40 |
40 // Error messages based on |error_name|, not network_state->error(). | 41 // Error messages based on |error_name|, not network_state->error(). |
41 string16 GetConnectErrorString(const std::string& error_name) { | 42 string16 GetConnectErrorString(const std::string& error_name) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // shown a notification (or have since connected to another network type). | 132 // shown a notification (or have since connected to another network type). |
132 if (!cellular->cellular_out_of_credits() || did_show_out_of_credits_) | 133 if (!cellular->cellular_out_of_credits() || did_show_out_of_credits_) |
133 return; | 134 return; |
134 | 135 |
135 // Only display a notification if not connected, connecting, or waiting to | 136 // Only display a notification if not connected, connecting, or waiting to |
136 // connect to another network. | 137 // connect to another network. |
137 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 138 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
138 const NetworkState* default_network = handler->DefaultNetwork(); | 139 const NetworkState* default_network = handler->DefaultNetwork(); |
139 if (default_network && default_network != cellular) | 140 if (default_network && default_network != cellular) |
140 return; | 141 return; |
141 if (handler->ConnectingNetworkByType( | 142 if (handler->ConnectingNetworkByType(NetworkTypePattern::NonVirtual()) || |
142 NetworkStateHandler::kMatchTypeNonVirtual) || | |
143 NetworkHandler::Get()->network_connection_handler() | 143 NetworkHandler::Get()->network_connection_handler() |
144 ->HasPendingConnectRequest()) | 144 ->HasPendingConnectRequest()) |
145 return; | 145 return; |
146 | 146 |
147 did_show_out_of_credits_ = true; | 147 did_show_out_of_credits_ = true; |
148 base::TimeDelta dtime = base::Time::Now() - out_of_credits_notify_time_; | 148 base::TimeDelta dtime = base::Time::Now() - out_of_credits_notify_time_; |
149 if (dtime.InSeconds() > kMinTimeBetweenOutOfCreditsNotifySeconds) { | 149 if (dtime.InSeconds() > kMinTimeBetweenOutOfCreditsNotifySeconds) { |
150 out_of_credits_notify_time_ = base::Time::Now(); | 150 out_of_credits_notify_time_ = base::Time::Now(); |
151 string16 error_msg = l10n_util::GetStringFUTF16( | 151 string16 error_msg = l10n_util::GetStringFUTF16( |
152 IDS_NETWORK_OUT_OF_CREDITS_BODY, | 152 IDS_NETWORK_OUT_OF_CREDITS_BODY, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 ShowErrorNotification( | 273 ShowErrorNotification( |
274 network_connect::kNetworkConnectNotificationId, | 274 network_connect::kNetworkConnectNotificationId, |
275 network_type, | 275 network_type, |
276 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), | 276 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), |
277 error_msg, | 277 error_msg, |
278 base::Bind(&network_connect::ShowNetworkSettings, service_path)); | 278 base::Bind(&network_connect::ShowNetworkSettings, service_path)); |
279 } | 279 } |
280 | 280 |
281 } // namespace ash | 281 } // namespace ash |
OLD | NEW |