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

Side by Side Diff: ui/chromeos/network/network_state_notifier.cc

Issue 686503002: Move network_connect code to ui/chromeos/network (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month 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
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 "ui/chromeos/network/network_state_notifier.h"
6 6
7 #include "ash/system/chromeos/network/network_connect.h"
8 #include "ash/system/system_notifier.h"
9 #include "base/bind.h" 7 #include "base/bind.h"
10 #include "base/location.h" 8 #include "base/location.h"
11 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
12 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
14 #include "chromeos/network/network_configuration_handler.h" 12 #include "chromeos/network/network_configuration_handler.h"
15 #include "chromeos/network/network_connection_handler.h" 13 #include "chromeos/network/network_connection_handler.h"
16 #include "chromeos/network/network_event_log.h" 14 #include "chromeos/network/network_event_log.h"
17 #include "chromeos/network/network_state.h" 15 #include "chromeos/network/network_state.h"
18 #include "chromeos/network/network_state_handler.h" 16 #include "chromeos/network/network_state_handler.h"
19 #include "chromeos/network/shill_property_util.h" 17 #include "chromeos/network/shill_property_util.h"
20 #include "grit/ash_resources.h"
21 #include "grit/ash_strings.h"
22 #include "grit/ui_chromeos_resources.h"
23 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
24 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/chromeos/network/network_connect.h"
22 #include "ui/chromeos/resources/grit/ui_chromeos_resources.h"
23 #include "ui/chromeos/strings/grit/ui_chromeos_strings.h"
26 #include "ui/message_center/message_center.h" 24 #include "ui/message_center/message_center.h"
27 #include "ui/message_center/notification.h" 25 #include "ui/message_center/notification.h"
28 26
29 using chromeos::NetworkConnectionHandler; 27 using chromeos::NetworkConnectionHandler;
30 using chromeos::NetworkHandler; 28 using chromeos::NetworkHandler;
31 using chromeos::NetworkState; 29 using chromeos::NetworkState;
32 using chromeos::NetworkStateHandler; 30 using chromeos::NetworkStateHandler;
33 using chromeos::NetworkTypePattern; 31 using chromeos::NetworkTypePattern;
34 32
35 namespace { 33 namespace {
(...skipping 12 matching lines...) Expand all
48 if (error_name == NetworkConnectionHandler::kErrorNotFound) 46 if (error_name == NetworkConnectionHandler::kErrorNotFound)
49 return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_CONNECT_FAILED); 47 return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_CONNECT_FAILED);
50 if (error_name == NetworkConnectionHandler::kErrorConfigureFailed) { 48 if (error_name == NetworkConnectionHandler::kErrorConfigureFailed) {
51 return l10n_util::GetStringUTF16( 49 return l10n_util::GetStringUTF16(
52 IDS_CHROMEOS_NETWORK_ERROR_CONFIGURE_FAILED); 50 IDS_CHROMEOS_NETWORK_ERROR_CONFIGURE_FAILED);
53 } 51 }
54 if (error_name == NetworkConnectionHandler::kErrorCertLoadTimeout) { 52 if (error_name == NetworkConnectionHandler::kErrorCertLoadTimeout) {
55 return l10n_util::GetStringUTF16( 53 return l10n_util::GetStringUTF16(
56 IDS_CHROMEOS_NETWORK_ERROR_CERTIFICATES_NOT_LOADED); 54 IDS_CHROMEOS_NETWORK_ERROR_CERTIFICATES_NOT_LOADED);
57 } 55 }
58 if (error_name == ash::NetworkConnect::kErrorActivateFailed) { 56 if (error_name == ui::NetworkConnect::kErrorActivateFailed) {
59 return l10n_util::GetStringUTF16( 57 return l10n_util::GetStringUTF16(
60 IDS_CHROMEOS_NETWORK_ERROR_ACTIVATION_FAILED); 58 IDS_CHROMEOS_NETWORK_ERROR_ACTIVATION_FAILED);
61 } 59 }
62 return base::string16(); 60 return base::string16();
63 } 61 }
64 62
65 void ShowErrorNotification(const std::string& notification_id, 63 void ShowErrorNotification(const std::string& notification_id,
66 const std::string& network_type, 64 const std::string& network_type,
67 const base::string16& title, 65 const base::string16& title,
68 const base::string16& message, 66 const base::string16& message,
69 const base::Closure& callback) { 67 const base::Closure& callback) {
70 int icon_id = (network_type == shill::kTypeCellular) 68 int icon_id = (network_type == shill::kTypeCellular)
71 ? IDR_AURA_UBER_TRAY_CELLULAR_NETWORK_FAILED 69 ? IDR_AURA_UBER_TRAY_NETWORK_FAILED_CELLULAR
72 : IDR_AURA_UBER_TRAY_NETWORK_FAILED; 70 : IDR_AURA_UBER_TRAY_NETWORK_FAILED;
73 const gfx::Image& icon = 71 const gfx::Image& icon =
74 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); 72 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id);
75 message_center::MessageCenter::Get()->AddNotification( 73 message_center::MessageCenter::Get()->AddNotification(
76 message_center::Notification::CreateSystemNotification( 74 message_center::Notification::CreateSystemNotification(
77 notification_id, title, message, icon, 75 notification_id, title, message, icon,
78 ash::system_notifier::kNotifierNetworkError, callback)); 76 ui::NetworkStateNotifier::kNotifierNetworkError, callback));
79 } 77 }
80 78
81 } // namespace 79 } // namespace
82 80
83 namespace ash { 81 namespace ui {
82
83 const char NetworkStateNotifier::kNotifierNetwork[] = "ui.chromeos.network";
84 const char NetworkStateNotifier::kNotifierNetworkError[] =
85 "ui.chromeos.network.error";
84 86
85 const char NetworkStateNotifier::kNetworkConnectNotificationId[] = 87 const char NetworkStateNotifier::kNetworkConnectNotificationId[] =
86 "chrome://settings/internet/connect"; 88 "chrome://settings/internet/connect";
87 const char NetworkStateNotifier::kNetworkActivateNotificationId[] = 89 const char NetworkStateNotifier::kNetworkActivateNotificationId[] =
88 "chrome://settings/internet/activate"; 90 "chrome://settings/internet/activate";
89 const char NetworkStateNotifier::kNetworkOutOfCreditsNotificationId[] = 91 const char NetworkStateNotifier::kNetworkOutOfCreditsNotificationId[] =
90 "chrome://settings/internet/out-of-credits"; 92 "chrome://settings/internet/out-of-credits";
91 93
92 NetworkStateNotifier::NetworkStateNotifier(NetworkConnect* network_connect) 94 NetworkStateNotifier::NetworkStateNotifier(NetworkConnect* network_connect)
93 : network_connect_(network_connect), 95 : network_connect_(network_connect),
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 else 192 else
191 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G; 193 icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G;
192 const gfx::Image& icon = 194 const gfx::Image& icon =
193 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id); 195 ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id);
194 message_center::MessageCenter::Get()->AddNotification( 196 message_center::MessageCenter::Get()->AddNotification(
195 message_center::Notification::CreateSystemNotification( 197 message_center::Notification::CreateSystemNotification(
196 kNetworkActivateNotificationId, 198 kNetworkActivateNotificationId,
197 l10n_util::GetStringUTF16(IDS_NETWORK_CELLULAR_ACTIVATED_TITLE), 199 l10n_util::GetStringUTF16(IDS_NETWORK_CELLULAR_ACTIVATED_TITLE),
198 l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED, 200 l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED,
199 base::UTF8ToUTF16((cellular->name()))), 201 base::UTF8ToUTF16((cellular->name()))),
200 icon, system_notifier::kNotifierNetwork, 202 icon, kNotifierNetwork,
201 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, 203 base::Bind(&NetworkStateNotifier::ShowNetworkSettings,
202 weak_ptr_factory_.GetWeakPtr(), cellular->path()))); 204 weak_ptr_factory_.GetWeakPtr(), cellular->path())));
203 } 205 }
204 206
205 void NetworkStateNotifier::ShowNetworkConnectError( 207 void NetworkStateNotifier::ShowNetworkConnectError(
206 const std::string& error_name, 208 const std::string& error_name,
207 const std::string& service_path) { 209 const std::string& service_path) {
208 if (service_path.empty()) { 210 if (service_path.empty()) {
209 base::DictionaryValue shill_properties; 211 base::DictionaryValue shill_properties;
210 ShowConnectErrorNotification(error_name, service_path, shill_properties); 212 ShowConnectErrorNotification(error_name, service_path, shill_properties);
(...skipping 18 matching lines...) Expand all
229 service_path); 231 service_path);
230 return; 232 return;
231 } 233 }
232 message_center::MessageCenter::Get()->AddNotification( 234 message_center::MessageCenter::Get()->AddNotification(
233 message_center::Notification::CreateSystemNotification( 235 message_center::Notification::CreateSystemNotification(
234 kNetworkActivateNotificationId, 236 kNetworkActivateNotificationId,
235 l10n_util::GetStringUTF16(IDS_NETWORK_ACTIVATION_ERROR_TITLE), 237 l10n_util::GetStringUTF16(IDS_NETWORK_ACTIVATION_ERROR_TITLE),
236 l10n_util::GetStringFUTF16(IDS_NETWORK_ACTIVATION_NEEDS_CONNECTION, 238 l10n_util::GetStringFUTF16(IDS_NETWORK_ACTIVATION_NEEDS_CONNECTION,
237 base::UTF8ToUTF16(cellular->name())), 239 base::UTF8ToUTF16(cellular->name())),
238 ui::ResourceBundle::GetSharedInstance().GetImageNamed( 240 ui::ResourceBundle::GetSharedInstance().GetImageNamed(
239 IDR_AURA_UBER_TRAY_CELLULAR_NETWORK_FAILED), 241 IDR_AURA_UBER_TRAY_NETWORK_FAILED_CELLULAR),
240 ash::system_notifier::kNotifierNetworkError, 242 kNotifierNetworkError,
241 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, 243 base::Bind(&NetworkStateNotifier::ShowNetworkSettings,
242 weak_ptr_factory_.GetWeakPtr(), service_path))); 244 weak_ptr_factory_.GetWeakPtr(), service_path)));
243 } 245 }
244 246
245 void NetworkStateNotifier::RemoveConnectNotification() { 247 void NetworkStateNotifier::RemoveConnectNotification() {
246 message_center::MessageCenter* message_center = 248 message_center::MessageCenter* message_center =
247 message_center::MessageCenter::Get(); 249 message_center::MessageCenter::Get();
248 if (message_center) { 250 if (message_center) {
249 message_center->RemoveNotification(kNetworkConnectNotificationId, 251 message_center->RemoveNotification(kNetworkConnectNotificationId,
250 false /* not by user */); 252 false /* not by user */);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), error_msg, 355 l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), error_msg,
354 base::Bind(&NetworkStateNotifier::ShowNetworkSettings, 356 base::Bind(&NetworkStateNotifier::ShowNetworkSettings,
355 weak_ptr_factory_.GetWeakPtr(), service_path)); 357 weak_ptr_factory_.GetWeakPtr(), service_path));
356 } 358 }
357 359
358 void NetworkStateNotifier::ShowNetworkSettings( 360 void NetworkStateNotifier::ShowNetworkSettings(
359 const std::string& service_path) { 361 const std::string& service_path) {
360 network_connect_->ShowNetworkSettings(service_path); 362 network_connect_->ShowNetworkSettings(service_path);
361 } 363 }
362 364
363 } // namespace ash 365 } // namespace ui
OLDNEW
« no previous file with comments | « ui/chromeos/network/network_state_notifier.h ('k') | ui/chromeos/network/network_state_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698