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

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

Issue 23712002: Cleanup network type matching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit test in Debug. 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/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
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
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
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
OLDNEW
« no previous file with comments | « ash/system/chromeos/network/network_state_list_detailed_view.cc ('k') | ash/system/chromeos/network/tray_network.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698