summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorstevenjb <stevenjb@chromium.org>2014-10-30 09:43:46 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-30 16:44:15 +0000
commitc49ac404f05590cd8834c5fe3db7915c02af6910 (patch)
tree56f63a7768100bf9d730fe278eff0953e53bf671 /ash
parent9477d5b04dc373288d48268d387658a35a01086d (diff)
downloadchromium_src-c49ac404f05590cd8834c5fe3db7915c02af6910.zip
chromium_src-c49ac404f05590cd8834c5fe3db7915c02af6910.tar.gz
chromium_src-c49ac404f05590cd8834c5fe3db7915c02af6910.tar.bz2
Move network_connect code to ui/chromeos/network
BUG=425996 Review URL: https://codereview.chromium.org/686503002 Cr-Commit-Position: refs/heads/master@{#302092}
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp5
-rw-r--r--ash/ash_chromeos_strings.grdp110
-rw-r--r--ash/resources/ash_resources.grd3
-rw-r--r--ash/resources/default_100_percent/cros/network/notification_3g.pngbin1170 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/cros/network/notification_lte.pngbin909 -> 0 bytes
-rw-r--r--ash/resources/default_100_percent/cros/network/status_cellular_failed.pngbin729 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/cros/network/notification_3g.pngbin2540 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/cros/network/notification_lte.pngbin1584 -> 0 bytes
-rw-r--r--ash/resources/default_200_percent/cros/network/status_cellular_failed.pngbin1465 -> 0 bytes
-rw-r--r--ash/system/chromeos/network/network_connect.cc648
-rw-r--r--ash/system/chromeos/network/network_connect.h115
-rw-r--r--ash/system/chromeos/network/network_state_list_detailed_view.cc8
-rw-r--r--ash/system/chromeos/network/network_state_notifier.cc363
-rw-r--r--ash/system/chromeos/network/network_state_notifier.h103
-rw-r--r--ash/system/chromeos/network/network_state_notifier_unittest.cc129
-rw-r--r--ash/system/system_notifier.cc16
16 files changed, 15 insertions, 1485 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index bdc41b5..4f8dc15 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -291,15 +291,11 @@
'system/chromeos/label_tray_view.h',
'system/chromeos/multi_user/user_switch_util.cc',
'system/chromeos/multi_user/user_switch_util.h',
- 'system/chromeos/network/network_connect.cc',
- 'system/chromeos/network/network_connect.h',
'system/chromeos/network/network_detailed_view.h',
'system/chromeos/network/network_observer.h',
'system/chromeos/network/network_portal_detector_observer.h',
'system/chromeos/network/network_state_list_detailed_view.cc',
'system/chromeos/network/network_state_list_detailed_view.h',
- 'system/chromeos/network/network_state_notifier.cc',
- 'system/chromeos/network/network_state_notifier.h',
'system/chromeos/network/tray_network.cc',
'system/chromeos/network/tray_network.h',
'system/chromeos/network/tray_network_state_observer.cc',
@@ -816,7 +812,6 @@
'sticky_keys/sticky_keys_overlay_unittest.cc',
'sticky_keys/sticky_keys_unittest.cc',
'system/chromeos/brightness/tray_brightness_unittest.cc',
- 'system/chromeos/network/network_state_notifier_unittest.cc',
'system/chromeos/power/power_event_observer_unittest.cc',
'system/chromeos/power/power_status_unittest.cc',
'system/chromeos/power/power_status_view_unittest.cc',
diff --git a/ash/ash_chromeos_strings.grdp b/ash/ash_chromeos_strings.grdp
index ae39085..41b90dd 100644
--- a/ash/ash_chromeos_strings.grdp
+++ b/ash/ash_chromeos_strings.grdp
@@ -98,42 +98,6 @@
Bluetooth device "<ph name="DEVICE_NAME">$1<ex>Nexus S</ex></ph>" has been paired and is now available to all users. You may remove this pairing using Settings.
</message>
- <!-- Other Network UI strings -->
- <message name="IDS_NETWORK_CONNECTION_ERROR_TITLE" desc="Title for network connection error notification">
- Network Connection Error
- </message>
- <message name="IDS_NETWORK_CONNECTION_ERROR_MESSAGE" desc="Message for network connection error notification">
- Failed to connect to network '<ph name="name">$1<ex>GoogleGuest</ex></ph>': <ph name="details">$2<ex>Unrecognized error</ex></ph>
- </message>
- <message name="IDS_NETWORK_CONNECTION_ERROR_MESSAGE_WITH_SERVER_MESSAGE" desc="Message for network connection error notification with details and a server message">
-Failed to connect to '<ph name="name">$1<ex>GoogleGuest</ex></ph>': <ph name="details">$2<ex>Unrecognized error</ex></ph>
-Server message: <ph name="server_msg">$3<ex>Incorrect password</ex></ph>
- </message>
- <message name="IDS_NETWORK_CONNECTION_ERROR_MESSAGE_NO_NAME" desc="Message for network connection error where the network name is unavailable">
- Failed to connect to network: <ph name="details">$1<ex>Unrecognized error</ex></ph>
- </message>
- <message name="IDS_NETWORK_OUT_OF_CREDITS_TITLE" desc="Title for network out of data error notification">
- Network Connection Error
- </message>
- <message name="IDS_NETWORK_OUT_OF_CREDITS_BODY" desc="Message body for network out of data error notification">
- You may have used up your mobile data allowance. Visit the <ph name="name">$1<ex>GoogleGuest</ex></ph> activation portal to buy more data.
- </message>
- <message name="IDS_NETWORK_UNRECOGNIZED_ERROR" desc="Unrecognized Network error text">
- Unrecognized error: <ph name="desc">$1<ex>ShillErrorString</ex></ph>
- </message>
- <message name="IDS_NETWORK_CELLULAR_ACTIVATED_TITLE" desc="Title for cellular activated notification">
- Cellular Activated
- </message>
- <message name="IDS_NETWORK_CELLULAR_ACTIVATED" desc="Text of the cellular activated notification">
- Congratulations! Your '<ph name="name">$1<ex>Generic Wireless</ex></ph>' data service has been activated and is ready to go.
- </message>
- <message name="IDS_NETWORK_ACTIVATION_ERROR_TITLE" desc="Title for network activation error notification">
- Network Activation Error
- </message>
- <message name="IDS_NETWORK_ACTIVATION_NEEDS_CONNECTION" desc="Message when attempting to activate a mobile network that requires a connection">
- Activation of '<ph name="name">$1<ex>Generic Wireless</ex></ph>' requires a network connection.
- </message>
-
<!-- Ash multi-user warning dialog -->
<message name="IDS_DESKTOP_CASTING_ACTIVE_TITLE" desc="The title for the dialog which tells the user that desktop casting is in progress, asking if the casting should be stopped before switching - or - the switch should be aborted.">
Stop screen sharing?
@@ -148,80 +112,6 @@ Server message: <ph name="server_msg">$3<ex>Incorrect password</ex></ph>
No
</message>
- <!-- Network error strings -->
- <message name="IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN" desc="Network error details in notifications: UNKNOWN">
- Unknown network error
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_OUT_OF_RANGE" desc="Network error details in notifications: OUT_OF_RANGE">
- Out of range
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_PIN_MISSING" desc="Network error details in notifications: PIN_MISSING">
- PIN missing
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_DHCP_FAILED" desc="Network error details in notifications: DHCP_FAILED">
- DHCP lookup failed
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_CONNECT_FAILED" desc="Network error details in notifications: CONNECT_FAILED">
- Connect failed
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_BAD_PASSPHRASE" desc="Network error details in notifications: BAD_PASSPHRASE. Error when a bad wifi password/passphrase is entered.">
- Bad password
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_BAD_WEPKEY" desc="Network error details in notifications: BAD_WEPKEY">
- Bad WEP key
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_ACTIVATION_FAILED" desc="Network error details in notifications: ACTIVATION_FAILED">
- Activation failed
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_NEED_EVDO" desc="Network error details in notifications: NEED_EVDO">
- Need EVDO
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_NEED_HOME_NETWORK" desc="Network error details in notifications: NEED_HOME_NETWORK">
- Need home network
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_OTASP_FAILED" desc="Network error details in notifications: OTASP_FAILED">
- OTASP failed
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_AAA_FAILED" desc="Network error details in notifications: AAA_FAILED">
- AAA check failed
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_INTERNAL" desc="Network error details in notifications: INTERNAL">
- Internal error
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_DNS_LOOKUP_FAILED" desc="Network error details in notifications: DNS_LOOKUP_FAILED">
- DNS lookup failed
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_HTTP_GET_FAILED" desc="Network error details in notifications: HTTP_GET_FAILED">
- HTTP get failed
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_IPSEC_PSK_AUTH_FAILED" desc="Network error details in notifications: IPSEC_PSK_AUTH_FAILED">
- Incorrect password
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_CERT_AUTH_FAILED" desc="Network error details in notifications: IPSEC_CERT_AUTH_FAILED">
- Authentication certificate rejected by network
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_EAP_LOCAL_TLS_FAILED" desc="Network error details in notifications: EAP_LOCAL_TLS_FAILED">
- Authentication certificate rejected locally
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_EAP_REMOTE_TLS_FAILED" desc="Network error details in notifications: EAP_REMOTE_TLS_FAILED">
- Authentication certificate rejected remotely
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_EAP_AUTH_FAILED" desc="Network error details in notifications: IPSEC_CERT_AUTH_FAILED">
- Username/password incorrect or EAP-auth failed
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_PPP_AUTH_FAILED" desc="Network error details in notifications: PPP_AUTH_FAILED">
- PPP authentication failed due to an incorrect username or password
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_CONFIGURE_FAILED" desc="Network error details in notifications: Configuration error">
- Failed to configure network
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_CERTIFICATES_NOT_LOADED" desc="Network error details in notifications: Certificates not loaded">
- Certificates not loaded
- </message>
- <message name="IDS_CHROMEOS_NETWORK_ERROR_UNRECOGNIZED" desc="Network error details in notifications: Unrecognized">
- Unrecognized error
- </message>
-
<!-- Status tray screen capture strings. -->
<message name="IDS_ASH_STATUS_TRAY_SCREEN_CAPTURE_STOP" desc="label used for screen capture stop button">
Stop
diff --git a/ash/resources/ash_resources.grd b/ash/resources/ash_resources.grd
index 01e5af7..713524f 100644
--- a/ash/resources/ash_resources.grd
+++ b/ash/resources/ash_resources.grd
@@ -123,7 +123,6 @@
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_CELLULAR_DISABLED_HOVER" file="cros/network/status_cellular_disabled_hover.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_CELLULAR_ENABLED" file="cros/network/status_cellular_enabled.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_CELLULAR_ENABLED_HOVER" file="cros/network/status_cellular_enabled_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_CELLULAR_NETWORK_FAILED" file="cros/network/status_cellular_failed.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_DISPLAY" file="cros/status/status_display_dark.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_ENTERPRISE" file="cros/status/status_managed.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_BOTTOM" file="cros/status/status_logout_button_normal_bottom.png" />
@@ -147,8 +146,6 @@
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_SUPERVISED_USER" file="cros/status/status_managed_mode_user.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NETWORK_INFO" file="cros/network/status_network_info.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NETWORK_INFO_HOVER" file="cros/network/status_network_info_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NOTIFICATION_3G" file="cros/network/notification_3g.png" />
- <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NOTIFICATION_LTE" file="cros/network/notification_lte.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NOTIFICATION_SESSION_LENGTH_LIMIT" file="cros/notification/notification_session_length_timer.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_POWER_SMALL" file="cros/status/status_power_small_all.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_POWER_SMALL_CHARGING_UNRELIABLE" file="cros/status/status_power_small_all_fluctuating.png" />
diff --git a/ash/resources/default_100_percent/cros/network/notification_3g.png b/ash/resources/default_100_percent/cros/network/notification_3g.png
deleted file mode 100644
index ced1c67..0000000
--- a/ash/resources/default_100_percent/cros/network/notification_3g.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/cros/network/notification_lte.png b/ash/resources/default_100_percent/cros/network/notification_lte.png
deleted file mode 100644
index 6139623..0000000
--- a/ash/resources/default_100_percent/cros/network/notification_lte.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_100_percent/cros/network/status_cellular_failed.png b/ash/resources/default_100_percent/cros/network/status_cellular_failed.png
deleted file mode 100644
index 412d9d4..0000000
--- a/ash/resources/default_100_percent/cros/network/status_cellular_failed.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/cros/network/notification_3g.png b/ash/resources/default_200_percent/cros/network/notification_3g.png
deleted file mode 100644
index 6c04076..0000000
--- a/ash/resources/default_200_percent/cros/network/notification_3g.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/cros/network/notification_lte.png b/ash/resources/default_200_percent/cros/network/notification_lte.png
deleted file mode 100644
index 0ca53f7..0000000
--- a/ash/resources/default_200_percent/cros/network/notification_lte.png
+++ /dev/null
Binary files differ
diff --git a/ash/resources/default_200_percent/cros/network/status_cellular_failed.png b/ash/resources/default_200_percent/cros/network/status_cellular_failed.png
deleted file mode 100644
index 282cc07..0000000
--- a/ash/resources/default_200_percent/cros/network/status_cellular_failed.png
+++ /dev/null
Binary files differ
diff --git a/ash/system/chromeos/network/network_connect.cc b/ash/system/chromeos/network/network_connect.cc
deleted file mode 100644
index 82c80f5..0000000
--- a/ash/system/chromeos/network/network_connect.cc
+++ /dev/null
@@ -1,648 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/system/chromeos/network/network_connect.h"
-
-#include "ash/system/chromeos/network/network_state_notifier.h"
-#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/values.h"
-#include "chromeos/login/login_state.h"
-#include "chromeos/network/device_state.h"
-#include "chromeos/network/network_activation_handler.h"
-#include "chromeos/network/network_configuration_handler.h"
-#include "chromeos/network/network_connection_handler.h"
-#include "chromeos/network/network_event_log.h"
-#include "chromeos/network/network_handler_callbacks.h"
-#include "chromeos/network/network_profile.h"
-#include "chromeos/network/network_profile_handler.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
-#include "grit/ash_resources.h"
-#include "grit/ash_strings.h"
-#include "third_party/cros_system_api/dbus/service_constants.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/message_center/message_center.h"
-#include "ui/message_center/notification.h"
-
-using chromeos::DeviceState;
-using chromeos::NetworkConfigurationHandler;
-using chromeos::NetworkConnectionHandler;
-using chromeos::NetworkHandler;
-using chromeos::NetworkProfile;
-using chromeos::NetworkProfileHandler;
-using chromeos::NetworkState;
-using chromeos::NetworkStateHandler;
-using chromeos::NetworkTypePattern;
-
-namespace ash {
-
-namespace {
-
-// Returns true for carriers that can be activated through Shill instead of
-// through a WebUI dialog.
-bool IsDirectActivatedCarrier(const std::string& carrier) {
- if (carrier == shill::kCarrierSprint)
- return true;
- return false;
-}
-
-const NetworkState* GetNetworkState(const std::string& service_path) {
- return NetworkHandler::Get()->network_state_handler()->GetNetworkState(
- service_path);
-}
-
-class NetworkConnectImpl : public NetworkConnect {
- public:
- explicit NetworkConnectImpl(Delegate* delegate);
- ~NetworkConnectImpl() override;
-
- // NetworkConnect
- void ConnectToNetwork(const std::string& service_path) override;
- void SetTechnologyEnabled(const chromeos::NetworkTypePattern& technology,
- bool enabled_state) override;
- void ActivateCellular(const std::string& service_path) override;
- void ShowMobileSetup(const std::string& service_path) override;
- void ConfigureNetworkAndConnect(const std::string& service_path,
- const base::DictionaryValue& properties,
- bool shared) override;
- void CreateConfigurationAndConnect(base::DictionaryValue* properties,
- bool shared) override;
- void CreateConfiguration(base::DictionaryValue* properties,
- bool shared) override;
- base::string16 GetErrorString(const std::string& error,
- const std::string& service_path) override;
- void ShowNetworkSettings(const std::string& service_path) override;
-
- private:
- void HandleUnconfiguredNetwork(const std::string& service_path);
- void OnConnectFailed(const std::string& service_path,
- const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data);
- bool GetNetworkProfilePath(bool shared, std::string* profile_path);
- void OnConnectSucceeded(const std::string& service_path);
- void CallConnectToNetwork(const std::string& service_path,
- bool check_error_state);
- void OnActivateFailed(const std::string& service_path,
- const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data);
- void OnActivateSucceeded(const std::string& service_path);
- void OnConfigureFailed(const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data);
- void OnConfigureSucceeded(bool connect_on_configure,
- const std::string& service_path);
- void CallCreateConfiguration(base::DictionaryValue* properties,
- bool shared,
- bool connect_on_configure);
- void SetPropertiesFailed(const std::string& desc,
- const std::string& service_path,
- const std::string& config_error_name,
- scoped_ptr<base::DictionaryValue> error_data);
- void SetPropertiesToClear(base::DictionaryValue* properties_to_set,
- std::vector<std::string>* properties_to_clear);
- void ClearPropertiesAndConnect(
- const std::string& service_path,
- const std::vector<std::string>& properties_to_clear);
- void ConfigureSetProfileSucceeded(
- const std::string& service_path,
- scoped_ptr<base::DictionaryValue> properties_to_set);
-
- Delegate* delegate_;
- scoped_ptr<NetworkStateNotifier> network_state_notifier_;
- base::WeakPtrFactory<NetworkConnectImpl> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(NetworkConnectImpl);
-};
-
-NetworkConnectImpl::NetworkConnectImpl(Delegate* delegate)
- : delegate_(delegate), weak_factory_(this) {
- network_state_notifier_.reset(new NetworkStateNotifier(this));
-}
-
-NetworkConnectImpl::~NetworkConnectImpl() {
-}
-
-void NetworkConnectImpl::HandleUnconfiguredNetwork(
- const std::string& service_path) {
- const NetworkState* network = GetNetworkState(service_path);
- if (!network) {
- NET_LOG_ERROR("Configuring unknown network", service_path);
- return;
- }
-
- if (network->type() == shill::kTypeWifi) {
- // Only show the config view for secure networks, otherwise do nothing.
- if (network->security() != shill::kSecurityNone) {
- delegate_->ShowNetworkConfigure(service_path);
- }
- return;
- }
-
- if (network->type() == shill::kTypeWimax ||
- network->type() == shill::kTypeVPN) {
- delegate_->ShowNetworkConfigure(service_path);
- return;
- }
-
- if (network->type() == shill::kTypeCellular) {
- if (network->RequiresActivation()) {
- ActivateCellular(service_path);
- return;
- }
- if (network->cellular_out_of_credits()) {
- ShowMobileSetup(service_path);
- return;
- }
- // No special configure or setup for |network|, show the settings UI.
- if (chromeos::LoginState::Get()->IsUserLoggedIn()) {
- delegate_->ShowNetworkSettings(service_path);
- }
- return;
- }
- NOTREACHED();
-}
-
-// If |shared| is true, sets |profile_path| to the shared profile path.
-// Otherwise sets |profile_path| to the user profile path if authenticated and
-// available. Returns 'false' if unable to set |profile_path|.
-bool NetworkConnectImpl::GetNetworkProfilePath(bool shared,
- std::string* profile_path) {
- if (shared) {
- *profile_path = NetworkProfileHandler::GetSharedProfilePath();
- return true;
- }
-
- if (!chromeos::LoginState::Get()->UserHasNetworkProfile()) {
- NET_LOG_ERROR("User profile specified before login", "");
- return false;
- }
-
- const NetworkProfile* profile =
- NetworkHandler::Get()->network_profile_handler()->GetDefaultUserProfile();
- if (!profile) {
- NET_LOG_ERROR("No user profile for unshared network configuration", "");
- return false;
- }
-
- *profile_path = profile->path;
- return true;
-}
-
-void NetworkConnectImpl::OnConnectFailed(
- const std::string& service_path,
- const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
- NET_LOG_ERROR("Connect Failed: " + error_name, service_path);
-
- // If a new connect attempt canceled this connect, no need to notify the
- // user.
- if (error_name == NetworkConnectionHandler::kErrorConnectCanceled)
- return;
-
- if (error_name == shill::kErrorBadPassphrase ||
- error_name == NetworkConnectionHandler::kErrorPassphraseRequired ||
- error_name == NetworkConnectionHandler::kErrorConfigurationRequired ||
- error_name == NetworkConnectionHandler::kErrorAuthenticationRequired) {
- HandleUnconfiguredNetwork(service_path);
- return;
- }
-
- if (error_name == NetworkConnectionHandler::kErrorCertificateRequired) {
- if (!delegate_->ShowEnrollNetwork(service_path)) {
- HandleUnconfiguredNetwork(service_path);
- }
- return;
- }
-
- if (error_name == NetworkConnectionHandler::kErrorActivationRequired) {
- ActivateCellular(service_path);
- return;
- }
-
- if (error_name == NetworkConnectionHandler::kErrorConnected ||
- error_name == NetworkConnectionHandler::kErrorConnecting) {
- ShowNetworkSettings(service_path);
- return;
- }
-
- // ConnectFailed or unknown error; show a notification.
- network_state_notifier_->ShowNetworkConnectError(error_name, service_path);
-
- // Only show a configure dialog if there was a ConnectFailed error.
- if (error_name != shill::kErrorConnectFailed)
- return;
-
- // If Shill reports an InProgress error, don't try to configure the network.
- std::string dbus_error_name;
- error_data.get()->GetString(chromeos::network_handler::kDbusErrorName,
- &dbus_error_name);
- if (dbus_error_name == shill::kErrorResultInProgress)
- return;
-
- HandleUnconfiguredNetwork(service_path);
-}
-
-void NetworkConnectImpl::OnConnectSucceeded(const std::string& service_path) {
- NET_LOG_USER("Connect Succeeded", service_path);
- network_state_notifier_->RemoveConnectNotification();
-}
-
-// If |check_error_state| is true, error state for the network is checked,
-// otherwise any current error state is ignored (e.g. for recently configured
-// networks or repeat connect attempts).
-void NetworkConnectImpl::CallConnectToNetwork(const std::string& service_path,
- bool check_error_state) {
- network_state_notifier_->RemoveConnectNotification();
- NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork(
- service_path, base::Bind(&NetworkConnectImpl::OnConnectSucceeded,
- weak_factory_.GetWeakPtr(), service_path),
- base::Bind(&NetworkConnectImpl::OnConnectFailed,
- weak_factory_.GetWeakPtr(), service_path),
- check_error_state);
-}
-
-void NetworkConnectImpl::OnActivateFailed(
- const std::string& service_path,
- const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
- NET_LOG_ERROR("Unable to activate network", service_path);
- network_state_notifier_->ShowNetworkConnectError(kErrorActivateFailed,
- service_path);
-}
-
-void NetworkConnectImpl::OnActivateSucceeded(const std::string& service_path) {
- NET_LOG_USER("Activation Succeeded", service_path);
-}
-
-void NetworkConnectImpl::OnConfigureFailed(
- const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
- NET_LOG_ERROR("Unable to configure network", "");
- network_state_notifier_->ShowNetworkConnectError(
- NetworkConnectionHandler::kErrorConfigureFailed, "");
-}
-
-void NetworkConnectImpl::OnConfigureSucceeded(bool connect_on_configure,
- const std::string& service_path) {
- NET_LOG_USER("Configure Succeeded", service_path);
- if (!connect_on_configure)
- return;
- // After configuring a network, ignore any (possibly stale) error state.
- const bool check_error_state = false;
- CallConnectToNetwork(service_path, check_error_state);
-}
-
-void NetworkConnectImpl::CallCreateConfiguration(
- base::DictionaryValue* properties,
- bool shared,
- bool connect_on_configure) {
- std::string profile_path;
- if (!GetNetworkProfilePath(shared, &profile_path)) {
- network_state_notifier_->ShowNetworkConnectError(
- NetworkConnectionHandler::kErrorConfigureFailed, "");
- return;
- }
- properties->SetStringWithoutPathExpansion(shill::kProfileProperty,
- profile_path);
- NetworkHandler::Get()->network_configuration_handler()->CreateConfiguration(
- *properties, base::Bind(&NetworkConnectImpl::OnConfigureSucceeded,
- weak_factory_.GetWeakPtr(), connect_on_configure),
- base::Bind(&NetworkConnectImpl::OnConfigureFailed,
- weak_factory_.GetWeakPtr()));
-}
-
-void NetworkConnectImpl::SetPropertiesFailed(
- const std::string& desc,
- const std::string& service_path,
- const std::string& config_error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
- NET_LOG_ERROR(desc + ": Failed: " + config_error_name, service_path);
- network_state_notifier_->ShowNetworkConnectError(
- NetworkConnectionHandler::kErrorConfigureFailed, service_path);
-}
-
-void NetworkConnectImpl::SetPropertiesToClear(
- base::DictionaryValue* properties_to_set,
- std::vector<std::string>* properties_to_clear) {
- // Move empty string properties to properties_to_clear.
- for (base::DictionaryValue::Iterator iter(*properties_to_set);
- !iter.IsAtEnd(); iter.Advance()) {
- std::string value_str;
- if (iter.value().GetAsString(&value_str) && value_str.empty())
- properties_to_clear->push_back(iter.key());
- }
- // Remove cleared properties from properties_to_set.
- for (std::vector<std::string>::iterator iter = properties_to_clear->begin();
- iter != properties_to_clear->end(); ++iter) {
- properties_to_set->RemoveWithoutPathExpansion(*iter, NULL);
- }
-}
-
-void NetworkConnectImpl::ClearPropertiesAndConnect(
- const std::string& service_path,
- const std::vector<std::string>& properties_to_clear) {
- NET_LOG_USER("ClearPropertiesAndConnect", service_path);
- // After configuring a network, ignore any (possibly stale) error state.
- const bool check_error_state = false;
- NetworkHandler::Get()->network_configuration_handler()->ClearProperties(
- service_path, properties_to_clear,
- base::Bind(&NetworkConnectImpl::CallConnectToNetwork,
- weak_factory_.GetWeakPtr(), service_path, check_error_state),
- base::Bind(&NetworkConnectImpl::SetPropertiesFailed,
- weak_factory_.GetWeakPtr(), "ClearProperties", service_path));
-}
-
-void NetworkConnectImpl::ConfigureSetProfileSucceeded(
- const std::string& service_path,
- scoped_ptr<base::DictionaryValue> properties_to_set) {
- std::vector<std::string> properties_to_clear;
- SetPropertiesToClear(properties_to_set.get(), &properties_to_clear);
- NetworkHandler::Get()->network_configuration_handler()->SetProperties(
- service_path, *properties_to_set,
- base::Bind(&NetworkConnectImpl::ClearPropertiesAndConnect,
- weak_factory_.GetWeakPtr(), service_path, properties_to_clear),
- base::Bind(&NetworkConnectImpl::SetPropertiesFailed,
- weak_factory_.GetWeakPtr(), "SetProperties", service_path));
-}
-
-// Public methods
-
-void NetworkConnectImpl::ConnectToNetwork(const std::string& service_path) {
- NET_LOG_USER("ConnectToNetwork", service_path);
- const NetworkState* network = GetNetworkState(service_path);
- if (network) {
- if (!network->error().empty() && !network->security().empty()) {
- NET_LOG_USER("Configure: " + network->error(), service_path);
- // If the network is in an error state, show the configuration UI
- // directly to avoid a spurious notification.
- HandleUnconfiguredNetwork(service_path);
- return;
- } else if (network->RequiresActivation()) {
- ActivateCellular(service_path);
- return;
- }
- }
- const bool check_error_state = true;
- CallConnectToNetwork(service_path, check_error_state);
-}
-
-void NetworkConnectImpl::SetTechnologyEnabled(
- const NetworkTypePattern& technology,
- bool enabled_state) {
- std::string log_string = base::StringPrintf(
- "technology %s, target state: %s", technology.ToDebugString().c_str(),
- (enabled_state ? "ENABLED" : "DISABLED"));
- NET_LOG_USER("SetTechnologyEnabled", log_string);
- NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
- bool enabled = handler->IsTechnologyEnabled(technology);
- if (enabled_state == enabled) {
- NET_LOG_USER("Technology already in target state.", log_string);
- return;
- }
- if (enabled) {
- // User requested to disable the technology.
- handler->SetTechnologyEnabled(technology, false,
- chromeos::network_handler::ErrorCallback());
- return;
- }
- // If we're dealing with a mobile network, then handle SIM lock here.
- // SIM locking only applies to cellular, so the code below won't execute
- // if |technology| has been explicitly set to WiMAX.
- if (technology.MatchesPattern(NetworkTypePattern::Mobile())) {
- const DeviceState* mobile = handler->GetDeviceStateByType(technology);
- if (!mobile) {
- NET_LOG_ERROR("SetTechnologyEnabled with no device", log_string);
- return;
- }
- // The following only applies to cellular.
- if (mobile->type() == shill::kTypeCellular) {
- if (mobile->IsSimAbsent()) {
- // If this is true, then we have a cellular device with no SIM
- // inserted. TODO(armansito): Chrome should display a notification here,
- // prompting the user to insert a SIM card and restart the device to
- // enable cellular. See crbug.com/125171.
- NET_LOG_USER("Cannot enable cellular device without SIM.", log_string);
- return;
- }
- if (!mobile->sim_lock_type().empty()) {
- // A SIM has been inserted, but it is locked. Let the user unlock it
- // via the dialog.
- delegate_->ShowMobileSimDialog();
- return;
- }
- }
- }
- handler->SetTechnologyEnabled(technology, true,
- chromeos::network_handler::ErrorCallback());
-}
-
-void NetworkConnectImpl::ActivateCellular(const std::string& service_path) {
- NET_LOG_USER("ActivateCellular", service_path);
- const NetworkState* cellular = GetNetworkState(service_path);
- if (!cellular || cellular->type() != shill::kTypeCellular) {
- NET_LOG_ERROR("ActivateCellular with no Service", service_path);
- return;
- }
- const DeviceState* cellular_device =
- NetworkHandler::Get()->network_state_handler()->GetDeviceState(
- cellular->device_path());
- if (!cellular_device) {
- NET_LOG_ERROR("ActivateCellular with no Device", service_path);
- return;
- }
- if (!IsDirectActivatedCarrier(cellular_device->carrier())) {
- // For non direct activation, show the mobile setup dialog which can be
- // used to activate the network.
- ShowMobileSetup(service_path);
- return;
- }
- if (cellular->activation_state() == shill::kActivationStateActivated) {
- NET_LOG_ERROR("ActivateCellular for activated service", service_path);
- return;
- }
-
- NetworkHandler::Get()->network_activation_handler()->Activate(
- service_path,
- "", // carrier
- base::Bind(&NetworkConnectImpl::OnActivateSucceeded,
- weak_factory_.GetWeakPtr(), service_path),
- base::Bind(&NetworkConnectImpl::OnActivateFailed,
- weak_factory_.GetWeakPtr(), service_path));
-}
-
-void NetworkConnectImpl::ShowMobileSetup(const std::string& service_path) {
- NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
- const NetworkState* cellular = handler->GetNetworkState(service_path);
- if (!cellular || cellular->type() != shill::kTypeCellular) {
- NET_LOG_ERROR("ShowMobileSetup without Cellular network", service_path);
- return;
- }
- if (cellular->activation_state() != shill::kActivationStateActivated &&
- cellular->activation_type() == shill::kActivationTypeNonCellular &&
- !handler->DefaultNetwork()) {
- network_state_notifier_->ShowMobileActivationError(service_path);
- return;
- }
- delegate_->ShowMobileSetupDialog(service_path);
-}
-
-void NetworkConnectImpl::ConfigureNetworkAndConnect(
- const std::string& service_path,
- const base::DictionaryValue& properties,
- bool shared) {
- NET_LOG_USER("ConfigureNetworkAndConnect", service_path);
-
- scoped_ptr<base::DictionaryValue> properties_to_set(properties.DeepCopy());
-
- std::string profile_path;
- if (!GetNetworkProfilePath(shared, &profile_path)) {
- network_state_notifier_->ShowNetworkConnectError(
- NetworkConnectionHandler::kErrorConfigureFailed, service_path);
- return;
- }
- NetworkHandler::Get()->network_configuration_handler()->SetNetworkProfile(
- service_path, profile_path,
- base::Bind(&NetworkConnectImpl::ConfigureSetProfileSucceeded,
- weak_factory_.GetWeakPtr(), service_path,
- base::Passed(&properties_to_set)),
- base::Bind(&NetworkConnectImpl::SetPropertiesFailed,
- weak_factory_.GetWeakPtr(), "SetProfile: " + profile_path,
- service_path));
-}
-
-void NetworkConnectImpl::CreateConfigurationAndConnect(
- base::DictionaryValue* properties,
- bool shared) {
- NET_LOG_USER("CreateConfigurationAndConnect", "");
- CallCreateConfiguration(properties, shared, true /* connect_on_configure */);
-}
-
-void NetworkConnectImpl::CreateConfiguration(base::DictionaryValue* properties,
- bool shared) {
- NET_LOG_USER("CreateConfiguration", "");
- CallCreateConfiguration(properties, shared, false /* connect_on_configure */);
-}
-
-base::string16 NetworkConnectImpl::GetErrorString(
- const std::string& error,
- const std::string& service_path) {
- if (error.empty())
- return base::string16();
- if (error == shill::kErrorOutOfRange)
- return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_OUT_OF_RANGE);
- if (error == shill::kErrorPinMissing)
- return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_PIN_MISSING);
- if (error == shill::kErrorDhcpFailed)
- return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_DHCP_FAILED);
- if (error == shill::kErrorConnectFailed)
- return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_CONNECT_FAILED);
- if (error == shill::kErrorBadPassphrase)
- return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_BAD_PASSPHRASE);
- if (error == shill::kErrorBadWEPKey)
- return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_BAD_WEPKEY);
- if (error == shill::kErrorActivationFailed) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_ACTIVATION_FAILED);
- }
- if (error == shill::kErrorNeedEvdo)
- return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_NEED_EVDO);
- if (error == shill::kErrorNeedHomeNetwork) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_NEED_HOME_NETWORK);
- }
- if (error == shill::kErrorOtaspFailed)
- return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_OTASP_FAILED);
- if (error == shill::kErrorAaaFailed)
- return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_AAA_FAILED);
- if (error == shill::kErrorInternal)
- return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_INTERNAL);
- if (error == shill::kErrorDNSLookupFailed) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_DNS_LOOKUP_FAILED);
- }
- if (error == shill::kErrorHTTPGetFailed) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_HTTP_GET_FAILED);
- }
- if (error == shill::kErrorIpsecPskAuthFailed) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_IPSEC_PSK_AUTH_FAILED);
- }
- if (error == shill::kErrorIpsecCertAuthFailed) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_CERT_AUTH_FAILED);
- }
- if (error == shill::kErrorEapAuthenticationFailed) {
- const NetworkState* network = GetNetworkState(service_path);
- // TLS always requires a client certificate, so show a cert auth
- // failed message for TLS. Other EAP methods do not generally require
- // a client certicate.
- if (network && network->eap_method() == shill::kEapMethodTLS) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_CERT_AUTH_FAILED);
- } else {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_EAP_AUTH_FAILED);
- }
- }
- if (error == shill::kErrorEapLocalTlsFailed) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_EAP_LOCAL_TLS_FAILED);
- }
- if (error == shill::kErrorEapRemoteTlsFailed) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_EAP_REMOTE_TLS_FAILED);
- }
- if (error == shill::kErrorPppAuthFailed) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_PPP_AUTH_FAILED);
- }
-
- if (base::StringToLowerASCII(error) ==
- base::StringToLowerASCII(std::string(shill::kUnknownString))) {
- return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN);
- }
- return l10n_util::GetStringFUTF16(IDS_NETWORK_UNRECOGNIZED_ERROR,
- base::UTF8ToUTF16(error));
-}
-
-void NetworkConnectImpl::ShowNetworkSettings(const std::string& service_path) {
- delegate_->ShowNetworkSettings(service_path);
-}
-
-} // namespace
-
-const char NetworkConnect::kErrorActivateFailed[] = "activate-failed";
-
-static NetworkConnect* g_network_connect = NULL;
-
-// static
-void NetworkConnect::Initialize(Delegate* delegate) {
- CHECK(g_network_connect == NULL);
- g_network_connect = new NetworkConnectImpl(delegate);
-}
-
-// static
-void NetworkConnect::Shutdown() {
- CHECK(g_network_connect);
- delete g_network_connect;
- g_network_connect = NULL;
-}
-
-// static
-NetworkConnect* NetworkConnect::Get() {
- CHECK(g_network_connect);
- return g_network_connect;
-}
-
-NetworkConnect::NetworkConnect() {
-}
-
-NetworkConnect::~NetworkConnect() {
-}
-
-} // ash
diff --git a/ash/system/chromeos/network/network_connect.h b/ash/system/chromeos/network/network_connect.h
deleted file mode 100644
index 382eb20..0000000
--- a/ash/system/chromeos/network/network_connect.h
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_CONNECT_H
-#define ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_CONNECT_H
-
-#include <string>
-
-#include "ash/ash_export.h"
-#include "base/strings/string16.h"
-
-namespace base {
-class DictionaryValue;
-}
-
-namespace chromeos {
-class NetworkTypePattern;
-}
-
-namespace ash {
-
-class ASH_EXPORT NetworkConnect {
- public:
- class Delegate {
- public:
- // Shows UI to configure or activate the network specified by |network_id|,
- // which may include showing Payment or Portal UI when appropriate.
- virtual void ShowNetworkConfigure(const std::string& network_id) = 0;
-
- // Shows the settings related to network. If |network_id| is not empty,
- // show the settings for that network.
- virtual void ShowNetworkSettings(const std::string& network_id) = 0;
-
- // Shows UI to enroll the network specified by |network_id| if appropriate
- // and returns true, otherwise returns false.
- virtual bool ShowEnrollNetwork(const std::string& network_id) = 0;
-
- // Shows UI to unlock a mobile sim.
- virtual void ShowMobileSimDialog() = 0;
-
- // Shows UI to setup a mobile network.
- virtual void ShowMobileSetupDialog(const std::string& service_path) = 0;
-
- protected:
- virtual ~Delegate() {}
- };
-
- // Creates the global NetworkConnect object. |delegate| is owned by the
- // caller.
- static void Initialize(Delegate* delegate);
-
- // Destroys the global NetworkConnect object.
- static void Shutdown();
-
- // Returns the global NetworkConnect object if initialized or NULL.
- static NetworkConnect* Get();
-
- static const char kErrorActivateFailed[];
-
- virtual ~NetworkConnect();
-
- // Requests a network connection and handles any errors and notifications.
- virtual void ConnectToNetwork(const std::string& service_path) = 0;
-
- // Enables or disables a network technology. If |technology| refers to
- // cellular and the device cannot be enabled due to a SIM lock, this function
- // will launch the SIM unlock dialog.
- virtual void SetTechnologyEnabled(
- const chromeos::NetworkTypePattern& technology,
- bool enabled_state) = 0;
-
- // Requests network activation and handles any errors and notifications.
- virtual void ActivateCellular(const std::string& service_path) = 0;
-
- // Determines whether or not a network requires a connection to activate or
- // setup and either shows a notification or opens the mobile setup dialog.
- virtual void ShowMobileSetup(const std::string& service_path) = 0;
-
- // Configures a network with a dictionary of Shill properties, then sends a
- // connect request. The profile is set according to 'shared' if allowed.
- virtual void ConfigureNetworkAndConnect(
- const std::string& service_path,
- const base::DictionaryValue& properties,
- bool shared) = 0;
-
- // Requests a new network configuration to be created from a dictionary of
- // Shill properties and sends a connect request if the configuration succeeds.
- // The profile used is determined by |shared|.
- virtual void CreateConfigurationAndConnect(base::DictionaryValue* properties,
- bool shared) = 0;
-
- // Requests a new network configuration to be created from a dictionary of
- // Shill properties. The profile used is determined by |shared|.
- virtual void CreateConfiguration(base::DictionaryValue* properties,
- bool shared) = 0;
-
- // Returns the localized string for shill error string |error|.
- virtual base::string16 GetErrorString(const std::string& error,
- const std::string& service_path) = 0;
-
- // Shows the settings for the network specified by |service_path|. If empty,
- // or no matching network exists, shows the general internet settings page.
- virtual void ShowNetworkSettings(const std::string& service_path) = 0;
-
- protected:
- NetworkConnect();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(NetworkConnect);
-};
-
-} // ash
-
-#endif // ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_CONNECT_H
diff --git a/ash/system/chromeos/network/network_state_list_detailed_view.cc b/ash/system/chromeos/network/network_state_list_detailed_view.cc
index ec5807c..3f334b5 100644
--- a/ash/system/chromeos/network/network_state_list_detailed_view.cc
+++ b/ash/system/chromeos/network/network_state_list_detailed_view.cc
@@ -10,7 +10,6 @@
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
-#include "ash/system/chromeos/network/network_connect.h"
#include "ash/system/chromeos/network/tray_network_state_observer.h"
#include "ash/system/tray/fixed_sized_scroll_view.h"
#include "ash/system/tray/hover_highlight_view.h"
@@ -36,6 +35,7 @@
#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/chromeos/network/network_connect.h"
#include "ui/chromeos/network/network_icon.h"
#include "ui/chromeos/network/network_icon_animation.h"
#include "ui/chromeos/network/network_info.h"
@@ -271,7 +271,7 @@ void NetworkStateListDetailedView::OnViewClicked(views::View* sender) {
list_type_ == LIST_TYPE_VPN ?
ash::UMA_STATUS_AREA_CONNECT_TO_VPN :
ash::UMA_STATUS_AREA_CONNECT_TO_CONFIGURED_NETWORK);
- ash::NetworkConnect::Get()->ConnectToNetwork(service_path);
+ ui::NetworkConnect::Get()->ConnectToNetwork(service_path);
}
}
@@ -587,8 +587,8 @@ void NetworkStateListDetailedView::ToggleMobile() {
NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
bool enabled =
handler->IsTechnologyEnabled(NetworkTypePattern::Mobile());
- ash::NetworkConnect::Get()->SetTechnologyEnabled(NetworkTypePattern::Mobile(),
- !enabled);
+ ui::NetworkConnect::Get()->SetTechnologyEnabled(NetworkTypePattern::Mobile(),
+ !enabled);
}
views::View* NetworkStateListDetailedView::CreateViewForNetwork(
diff --git a/ash/system/chromeos/network/network_state_notifier.cc b/ash/system/chromeos/network/network_state_notifier.cc
deleted file mode 100644
index 7867b92..0000000
--- a/ash/system/chromeos/network/network_state_notifier.cc
+++ /dev/null
@@ -1,363 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/system/chromeos/network/network_state_notifier.h"
-
-#include "ash/system/chromeos/network/network_connect.h"
-#include "ash/system/system_notifier.h"
-#include "base/bind.h"
-#include "base/location.h"
-#include "base/strings/string16.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chromeos/network/network_configuration_handler.h"
-#include "chromeos/network/network_connection_handler.h"
-#include "chromeos/network/network_event_log.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
-#include "chromeos/network/shill_property_util.h"
-#include "grit/ash_resources.h"
-#include "grit/ash_strings.h"
-#include "grit/ui_chromeos_resources.h"
-#include "third_party/cros_system_api/dbus/service_constants.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/message_center/message_center.h"
-#include "ui/message_center/notification.h"
-
-using chromeos::NetworkConnectionHandler;
-using chromeos::NetworkHandler;
-using chromeos::NetworkState;
-using chromeos::NetworkStateHandler;
-using chromeos::NetworkTypePattern;
-
-namespace {
-
-const int kMinTimeBetweenOutOfCreditsNotifySeconds = 10 * 60;
-
-// Ignore in-progress error.
-bool ShillErrorIsIgnored(const std::string& shill_error) {
- if (shill_error == shill::kErrorResultInProgress)
- return true;
- return false;
-}
-
-// Error messages based on |error_name|, not network_state->error().
-base::string16 GetConnectErrorString(const std::string& error_name) {
- if (error_name == NetworkConnectionHandler::kErrorNotFound)
- return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_CONNECT_FAILED);
- if (error_name == NetworkConnectionHandler::kErrorConfigureFailed) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_CONFIGURE_FAILED);
- }
- if (error_name == NetworkConnectionHandler::kErrorCertLoadTimeout) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_CERTIFICATES_NOT_LOADED);
- }
- if (error_name == ash::NetworkConnect::kErrorActivateFailed) {
- return l10n_util::GetStringUTF16(
- IDS_CHROMEOS_NETWORK_ERROR_ACTIVATION_FAILED);
- }
- return base::string16();
-}
-
-void ShowErrorNotification(const std::string& notification_id,
- const std::string& network_type,
- const base::string16& title,
- const base::string16& message,
- const base::Closure& callback) {
- int icon_id = (network_type == shill::kTypeCellular)
- ? IDR_AURA_UBER_TRAY_CELLULAR_NETWORK_FAILED
- : IDR_AURA_UBER_TRAY_NETWORK_FAILED;
- const gfx::Image& icon =
- ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id);
- message_center::MessageCenter::Get()->AddNotification(
- message_center::Notification::CreateSystemNotification(
- notification_id, title, message, icon,
- ash::system_notifier::kNotifierNetworkError, callback));
-}
-
-} // namespace
-
-namespace ash {
-
-const char NetworkStateNotifier::kNetworkConnectNotificationId[] =
- "chrome://settings/internet/connect";
-const char NetworkStateNotifier::kNetworkActivateNotificationId[] =
- "chrome://settings/internet/activate";
-const char NetworkStateNotifier::kNetworkOutOfCreditsNotificationId[] =
- "chrome://settings/internet/out-of-credits";
-
-NetworkStateNotifier::NetworkStateNotifier(NetworkConnect* network_connect)
- : network_connect_(network_connect),
- did_show_out_of_credits_(false),
- weak_ptr_factory_(this) {
- if (!NetworkHandler::IsInitialized())
- return;
- NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
- handler->AddObserver(this, FROM_HERE);
- UpdateDefaultNetwork(handler->DefaultNetwork());
-}
-
-NetworkStateNotifier::~NetworkStateNotifier() {
- if (!NetworkHandler::IsInitialized())
- return;
- NetworkHandler::Get()->network_state_handler()->RemoveObserver(this,
- FROM_HERE);
-}
-
-void NetworkStateNotifier::DefaultNetworkChanged(const NetworkState* network) {
- if (!UpdateDefaultNetwork(network))
- return;
- // If the default network changes to another network, allow the out of
- // credits notification to be shown again. A delay prevents the notification
- // from being shown too frequently (see below).
- if (network)
- did_show_out_of_credits_ = false;
-}
-
-void NetworkStateNotifier::NetworkPropertiesUpdated(
- const NetworkState* network) {
- if (network->type() != shill::kTypeCellular)
- return;
- UpdateCellularOutOfCredits(network);
- UpdateCellularActivating(network);
-}
-
-bool NetworkStateNotifier::UpdateDefaultNetwork(const NetworkState* network) {
- std::string default_network_path;
- if (network)
- default_network_path = network->path();
- if (default_network_path != last_default_network_) {
- last_default_network_ = default_network_path;
- return true;
- }
- return false;
-}
-
-void NetworkStateNotifier::UpdateCellularOutOfCredits(
- const NetworkState* cellular) {
- // Only display a notification if we are out of credits and have not already
- // shown a notification (or have since connected to another network type).
- if (!cellular->cellular_out_of_credits() || did_show_out_of_credits_)
- return;
-
- // Only display a notification if not connected, connecting, or waiting to
- // connect to another network.
- NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
- const NetworkState* default_network = handler->DefaultNetwork();
- if (default_network && default_network != cellular)
- return;
- if (handler->ConnectingNetworkByType(NetworkTypePattern::NonVirtual()) ||
- NetworkHandler::Get()
- ->network_connection_handler()
- ->HasPendingConnectRequest())
- return;
-
- did_show_out_of_credits_ = true;
- base::TimeDelta dtime = base::Time::Now() - out_of_credits_notify_time_;
- if (dtime.InSeconds() > kMinTimeBetweenOutOfCreditsNotifySeconds) {
- out_of_credits_notify_time_ = base::Time::Now();
- base::string16 error_msg = l10n_util::GetStringFUTF16(
- IDS_NETWORK_OUT_OF_CREDITS_BODY, base::UTF8ToUTF16(cellular->name()));
- ShowErrorNotification(
- kNetworkOutOfCreditsNotificationId, cellular->type(),
- l10n_util::GetStringUTF16(IDS_NETWORK_OUT_OF_CREDITS_TITLE), error_msg,
- base::Bind(&NetworkStateNotifier::ShowNetworkSettings,
- weak_ptr_factory_.GetWeakPtr(), cellular->path()));
- }
-}
-
-void NetworkStateNotifier::UpdateCellularActivating(
- const NetworkState* cellular) {
- // Keep track of any activating cellular network.
- std::string activation_state = cellular->activation_state();
- if (activation_state == shill::kActivationStateActivating) {
- cellular_activating_.insert(cellular->path());
- return;
- }
- // Only display a notification if this network was activating and is now
- // activated.
- if (!cellular_activating_.count(cellular->path()) ||
- activation_state != shill::kActivationStateActivated)
- return;
-
- cellular_activating_.erase(cellular->path());
- int icon_id;
- if (cellular->network_technology() == shill::kNetworkTechnologyLte)
- icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_LTE;
- else
- icon_id = IDR_AURA_UBER_TRAY_NOTIFICATION_3G;
- const gfx::Image& icon =
- ui::ResourceBundle::GetSharedInstance().GetImageNamed(icon_id);
- message_center::MessageCenter::Get()->AddNotification(
- message_center::Notification::CreateSystemNotification(
- kNetworkActivateNotificationId,
- l10n_util::GetStringUTF16(IDS_NETWORK_CELLULAR_ACTIVATED_TITLE),
- l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED,
- base::UTF8ToUTF16((cellular->name()))),
- icon, system_notifier::kNotifierNetwork,
- base::Bind(&NetworkStateNotifier::ShowNetworkSettings,
- weak_ptr_factory_.GetWeakPtr(), cellular->path())));
-}
-
-void NetworkStateNotifier::ShowNetworkConnectError(
- const std::string& error_name,
- const std::string& service_path) {
- if (service_path.empty()) {
- base::DictionaryValue shill_properties;
- ShowConnectErrorNotification(error_name, service_path, shill_properties);
- return;
- }
- // Get the up-to-date properties for the network and display the error.
- NetworkHandler::Get()->network_configuration_handler()->GetProperties(
- service_path,
- base::Bind(&NetworkStateNotifier::ConnectErrorPropertiesSucceeded,
- weak_ptr_factory_.GetWeakPtr(), error_name),
- base::Bind(&NetworkStateNotifier::ConnectErrorPropertiesFailed,
- weak_ptr_factory_.GetWeakPtr(), error_name, service_path));
-}
-
-void NetworkStateNotifier::ShowMobileActivationError(
- const std::string& service_path) {
- const NetworkState* cellular =
- NetworkHandler::Get()->network_state_handler()->GetNetworkState(
- service_path);
- if (!cellular || cellular->type() != shill::kTypeCellular) {
- NET_LOG_ERROR("ShowMobileActivationError without Cellular network",
- service_path);
- return;
- }
- message_center::MessageCenter::Get()->AddNotification(
- message_center::Notification::CreateSystemNotification(
- kNetworkActivateNotificationId,
- l10n_util::GetStringUTF16(IDS_NETWORK_ACTIVATION_ERROR_TITLE),
- l10n_util::GetStringFUTF16(IDS_NETWORK_ACTIVATION_NEEDS_CONNECTION,
- base::UTF8ToUTF16(cellular->name())),
- ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- IDR_AURA_UBER_TRAY_CELLULAR_NETWORK_FAILED),
- ash::system_notifier::kNotifierNetworkError,
- base::Bind(&NetworkStateNotifier::ShowNetworkSettings,
- weak_ptr_factory_.GetWeakPtr(), service_path)));
-}
-
-void NetworkStateNotifier::RemoveConnectNotification() {
- message_center::MessageCenter* message_center =
- message_center::MessageCenter::Get();
- if (message_center) {
- message_center->RemoveNotification(kNetworkConnectNotificationId,
- false /* not by user */);
- }
-}
-
-void NetworkStateNotifier::ConnectErrorPropertiesSucceeded(
- const std::string& error_name,
- const std::string& service_path,
- const base::DictionaryValue& shill_properties) {
- std::string state;
- shill_properties.GetStringWithoutPathExpansion(shill::kStateProperty, &state);
- if (chromeos::NetworkState::StateIsConnected(state) ||
- chromeos::NetworkState::StateIsConnecting(state)) {
- // Network is no longer in an error state. This can happen if an
- // unexpected idle state transition occurs, see crbug.com/333955.
- return;
- }
- ShowConnectErrorNotification(error_name, service_path, shill_properties);
-}
-
-void NetworkStateNotifier::ConnectErrorPropertiesFailed(
- const std::string& error_name,
- const std::string& service_path,
- const std::string& shill_connect_error,
- scoped_ptr<base::DictionaryValue> shill_error_data) {
- base::DictionaryValue shill_properties;
- ShowConnectErrorNotification(error_name, service_path, shill_properties);
-}
-
-void NetworkStateNotifier::ShowConnectErrorNotification(
- const std::string& error_name,
- const std::string& service_path,
- const base::DictionaryValue& shill_properties) {
- base::string16 error = GetConnectErrorString(error_name);
- if (error.empty()) {
- std::string shill_error;
- shill_properties.GetStringWithoutPathExpansion(shill::kErrorProperty,
- &shill_error);
- if (!chromeos::NetworkState::ErrorIsValid(shill_error)) {
- shill_properties.GetStringWithoutPathExpansion(
- shill::kPreviousErrorProperty, &shill_error);
- NET_LOG_DEBUG("Notify Service.PreviousError: " + shill_error,
- service_path);
- if (!chromeos::NetworkState::ErrorIsValid(shill_error))
- shill_error.clear();
- } else {
- NET_LOG_DEBUG("Notify Service.Error: " + shill_error, service_path);
- }
-
- const NetworkState* network =
- NetworkHandler::Get()->network_state_handler()->GetNetworkState(
- service_path);
- if (network) {
- // Always log last_error, but only use it if shill_error is empty.
- // TODO(stevenjb): This shouldn't ever be necessary, but is kept here as
- // a failsafe since more information is better than less when debugging
- // and we have encountered some strange edge cases before.
- NET_LOG_DEBUG("Notify Network.last_error: " + network->last_error(),
- service_path);
- if (shill_error.empty())
- shill_error = network->last_error();
- }
-
- if (ShillErrorIsIgnored(shill_error)) {
- NET_LOG_DEBUG("Notify Ignoring error: " + error_name, service_path);
- return;
- }
-
- error = network_connect_->GetErrorString(shill_error, service_path);
- if (error.empty())
- error = l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN);
- }
- NET_LOG_ERROR("Notify connect error: " + base::UTF16ToUTF8(error),
- service_path);
-
- std::string network_name =
- chromeos::shill_property_util::GetNameFromProperties(service_path,
- shill_properties);
- std::string network_error_details;
- shill_properties.GetStringWithoutPathExpansion(shill::kErrorDetailsProperty,
- &network_error_details);
-
- base::string16 error_msg;
- if (!network_error_details.empty()) {
- // network_name should't be empty if network_error_details is set.
- error_msg = l10n_util::GetStringFUTF16(
- IDS_NETWORK_CONNECTION_ERROR_MESSAGE_WITH_SERVER_MESSAGE,
- base::UTF8ToUTF16(network_name), error,
- base::UTF8ToUTF16(network_error_details));
- } else if (network_name.empty()) {
- error_msg = l10n_util::GetStringFUTF16(
- IDS_NETWORK_CONNECTION_ERROR_MESSAGE_NO_NAME, error);
- } else {
- error_msg =
- l10n_util::GetStringFUTF16(IDS_NETWORK_CONNECTION_ERROR_MESSAGE,
- base::UTF8ToUTF16(network_name), error);
- }
-
- std::string network_type;
- shill_properties.GetStringWithoutPathExpansion(shill::kTypeProperty,
- &network_type);
-
- ShowErrorNotification(
- kNetworkConnectNotificationId, network_type,
- l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE), error_msg,
- base::Bind(&NetworkStateNotifier::ShowNetworkSettings,
- weak_ptr_factory_.GetWeakPtr(), service_path));
-}
-
-void NetworkStateNotifier::ShowNetworkSettings(
- const std::string& service_path) {
- network_connect_->ShowNetworkSettings(service_path);
-}
-
-} // namespace ash
diff --git a/ash/system/chromeos/network/network_state_notifier.h b/ash/system/chromeos/network/network_state_notifier.h
deleted file mode 100644
index de3dd10..0000000
--- a/ash/system/chromeos/network/network_state_notifier.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_
-#define ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_
-
-#include <set>
-
-#include "ash/ash_export.h"
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "base/time/time.h"
-#include "chromeos/network/network_state_handler_observer.h"
-
-namespace base {
-class DictionaryValue;
-}
-
-namespace chromeos {
-class NetworkState;
-}
-
-namespace ash {
-
-class NetworkConnect;
-
-// This class has two purposes:
-// 1. ShowNetworkConnectError() gets called after any user initiated connect
-// failure. This will handle displaying an error notification.
-// TODO(stevenjb): convert this class to use the new MessageCenter
-// notification system.
-// 2. It observes NetworkState changes to generate notifications when a
-// Cellular network is out of credits.
-class ASH_EXPORT NetworkStateNotifier :
- public chromeos::NetworkStateHandlerObserver {
- public:
- explicit NetworkStateNotifier(NetworkConnect* network_connect);
- virtual ~NetworkStateNotifier();
-
- // NetworkStateHandlerObserver
- virtual void DefaultNetworkChanged(
- const chromeos::NetworkState* network) override;
- virtual void NetworkPropertiesUpdated(
- const chromeos::NetworkState* network) override;
-
- // Show a connection error notification. If |error_name| matches an error
- // defined in NetworkConnectionHandler for connect, configure, or activation
- // failed, then the associated message is shown; otherwise use the last_error
- // value for the network or a Shill property if available.
- void ShowNetworkConnectError(const std::string& error_name,
- const std::string& service_path);
-
- // Show a mobile activation error notification.
- void ShowMobileActivationError(const std::string& service_path);
-
- // Removes any existing connect notifications.
- void RemoveConnectNotification();
-
- static const char kNetworkConnectNotificationId[];
- static const char kNetworkActivateNotificationId[];
- static const char kNetworkOutOfCreditsNotificationId[];
-
- private:
- void ConnectErrorPropertiesSucceeded(
- const std::string& error_name,
- const std::string& service_path,
- const base::DictionaryValue& shill_properties);
- void ConnectErrorPropertiesFailed(
- const std::string& error_name,
- const std::string& service_path,
- const std::string& shill_connect_error,
- scoped_ptr<base::DictionaryValue> shill_error_data);
- void ShowConnectErrorNotification(
- const std::string& error_name,
- const std::string& service_path,
- const base::DictionaryValue& shill_properties);
-
- // Returns true if the default network changed.
- bool UpdateDefaultNetwork(const chromeos::NetworkState* network);
-
- // Helper methods to update state and check for notifications.
- void UpdateCellularOutOfCredits(const chromeos::NetworkState* cellular);
- void UpdateCellularActivating(const chromeos::NetworkState* cellular);
-
- // Invokes network_connect_->ShowNetworkSettings from a callback.
- void ShowNetworkSettings(const std::string& service_path);
-
- NetworkConnect* network_connect_; // unowned
- std::string last_default_network_;
- bool did_show_out_of_credits_;
- base::Time out_of_credits_notify_time_;
- std::set<std::string> cellular_activating_;
- base::WeakPtrFactory<NetworkStateNotifier> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier);
-};
-
-} // namespace ash
-
-#endif // ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_NOTIFIER_H_
diff --git a/ash/system/chromeos/network/network_state_notifier_unittest.cc b/ash/system/chromeos/network/network_state_notifier_unittest.cc
deleted file mode 100644
index 70e7a78..0000000
--- a/ash/system/chromeos/network/network_state_notifier_unittest.cc
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/system/chromeos/network/network_state_notifier.h"
-
-#include "ash/root_window_controller.h"
-#include "ash/shelf/shelf_widget.h"
-#include "ash/shell.h"
-#include "ash/system/chromeos/network/network_connect.h"
-#include "ash/system/status_area_widget.h"
-#include "ash/system/tray/system_tray.h"
-#include "ash/test/ash_test_base.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/shill_device_client.h"
-#include "chromeos/dbus/shill_service_client.h"
-#include "chromeos/login/login_state.h"
-#include "chromeos/network/network_handler.h"
-#include "third_party/cros_system_api/dbus/service_constants.h"
-#include "ui/message_center/message_center.h"
-
-namespace {
-
-ash::SystemTray* GetSystemTray() {
- return ash::Shell::GetPrimaryRootWindowController()
- ->shelf()
- ->status_area_widget()
- ->system_tray();
-}
-
-} // namespace
-
-using chromeos::DBusThreadManager;
-using chromeos::ShillDeviceClient;
-using chromeos::ShillServiceClient;
-
-namespace ash {
-namespace test {
-
-class NetworkConnectTestDelegate : public NetworkConnect::Delegate {
- public:
- NetworkConnectTestDelegate() {}
- ~NetworkConnectTestDelegate() override {}
-
- // NetworkConnect::Delegate
- void ShowNetworkConfigure(const std::string& network_id) override {}
- void ShowNetworkSettings(const std::string& network_id) override {}
- bool ShowEnrollNetwork(const std::string& network_id) override {
- return false;
- }
- void ShowMobileSimDialog() override {}
- void ShowMobileSetupDialog(const std::string& service_path) override {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(NetworkConnectTestDelegate);
-};
-
-class NetworkStateNotifierTest : public AshTestBase {
- public:
- NetworkStateNotifierTest() {}
- ~NetworkStateNotifierTest() override {}
-
- void SetUp() override {
- DBusThreadManager::Initialize();
- chromeos::LoginState::Initialize();
- SetupDefaultShillState();
- chromeos::NetworkHandler::Initialize();
- RunAllPendingInMessageLoop();
- AshTestBase::SetUp();
- network_connect_delegate_.reset(new NetworkConnectTestDelegate);
- NetworkConnect::Initialize(network_connect_delegate_.get());
- }
-
- void TearDown() override {
- NetworkConnect::Shutdown();
- network_connect_delegate_.reset();
- AshTestBase::TearDown();
- chromeos::LoginState::Shutdown();
- chromeos::NetworkHandler::Shutdown();
- DBusThreadManager::Shutdown();
- }
-
- protected:
- void SetupDefaultShillState() {
- RunAllPendingInMessageLoop();
- ShillDeviceClient::TestInterface* device_test =
- DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface();
- device_test->ClearDevices();
- device_test->AddDevice("/device/stub_wifi_device1", shill::kTypeWifi,
- "stub_wifi_device1");
- device_test->AddDevice("/device/stub_cellular_device1",
- shill::kTypeCellular, "stub_cellular_device1");
-
- ShillServiceClient::TestInterface* service_test =
- DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
- service_test->ClearServices();
- const bool add_to_visible = true;
- // Create a wifi network and set to online.
- service_test->AddService("/service/wifi1", "wifi1_guid", "wifi1",
- shill::kTypeWifi, shill::kStateIdle,
- add_to_visible);
- service_test->SetServiceProperty("wifi1", shill::kSecurityProperty,
- base::StringValue(shill::kSecurityWep));
- service_test->SetServiceProperty("wifi1", shill::kConnectableProperty,
- base::FundamentalValue(true));
- service_test->SetServiceProperty("wifi1", shill::kPassphraseProperty,
- base::StringValue("failure"));
- RunAllPendingInMessageLoop();
- }
-
- scoped_ptr<NetworkConnectTestDelegate> network_connect_delegate_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifierTest);
-};
-
-TEST_F(NetworkStateNotifierTest, ConnectionFailure) {
- EXPECT_FALSE(GetSystemTray()->HasNotificationBubble());
- NetworkConnect::Get()->ConnectToNetwork("wifi1");
- RunAllPendingInMessageLoop();
- // Failure should spawn a notification.
- message_center::MessageCenter* message_center =
- message_center::MessageCenter::Get();
- EXPECT_TRUE(message_center->FindVisibleNotificationById(
- NetworkStateNotifier::kNetworkConnectNotificationId));
-}
-
-} // namespace test
-} // namespace ash
diff --git a/ash/system/system_notifier.cc b/ash/system/system_notifier.cc
index 2910862..6bf6884 100644
--- a/ash/system/system_notifier.cc
+++ b/ash/system/system_notifier.cc
@@ -6,6 +6,10 @@
#include "base/logging.h"
+#if defined(OS_CHROMEOS)
+#include "ui/chromeos/network/network_state_notifier.h"
+#endif
+
namespace ash {
namespace system_notifier {
@@ -16,7 +20,9 @@ namespace {
const char* kAlwaysShownNotifierIds[] = {
kNotifierDisplay,
kNotifierDisplayError,
- kNotifierNetworkError,
+#if defined(OS_CHROMEOS)
+ ui::NetworkStateNotifier::kNotifierNetworkError,
+#endif
kNotifierPower,
// Note: Order doesn't matter here, so keep this in alphabetic order, don't
// just add your stuff at the end!
@@ -30,8 +36,10 @@ const char* kAshSystemNotifiers[] = {
kNotifierDisplayResolutionChange,
kNotifierLocale,
kNotifierMultiProfileFirstRun,
- kNotifierNetwork,
- kNotifierNetworkError,
+#if defined(OS_CHROMEOS)
+ ui::NetworkStateNotifier::kNotifierNetwork,
+ ui::NetworkStateNotifier::kNotifierNetworkError,
+#endif
kNotifierNetworkPortalDetector,
kNotifierPower,
kNotifierScreenshot,
@@ -64,8 +72,6 @@ const char kNotifierDisplayError[] = "ash.display.error";
const char kNotifierDisplayResolutionChange[] = "ash.display.resolution-change";
const char kNotifierLocale[] = "ash.locale";
const char kNotifierMultiProfileFirstRun[] = "ash.multi-profile.first-run";
-const char kNotifierNetwork[] = "ash.network";
-const char kNotifierNetworkError[] = "ash.network.error";
const char kNotifierNetworkPortalDetector[] = "ash.network.portal-detector";
const char kNotifierPower[] = "ash.power";
const char kNotifierScreenshot[] = "ash.screenshot";