summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-29 07:55:34 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-29 07:55:34 +0000
commit7b1bb2072d15c31bbe72d304918e2bfc371950e9 (patch)
tree1201b24392f8cb5f0732e4a1bbc4b78cc8489703
parent00969d415a813753dc8202f25e8f84c2a0e3bba4 (diff)
downloadchromium_src-7b1bb2072d15c31bbe72d304918e2bfc371950e9.zip
chromium_src-7b1bb2072d15c31bbe72d304918e2bfc371950e9.tar.gz
chromium_src-7b1bb2072d15c31bbe72d304918e2bfc371950e9.tar.bz2
Unify ActivateCellular into network_connect.cc
BUG=242285 For ash delegate TBR=jamescook@chromium.org Review URL: https://chromiumcodereview.appspot.com/15937008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202807 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/shell/shell_delegate_impl.cc3
-rw-r--r--ash/shell/shell_delegate_impl.h1
-rw-r--r--ash/shell_delegate.h3
-rw-r--r--ash/test/test_shell_delegate.cc3
-rw-r--r--ash/test/test_shell_delegate.h1
-rw-r--r--chrome/browser/chromeos/options/network_connect.cc67
-rw-r--r--chrome/browser/chromeos/options/network_connect.h9
-rw-r--r--chrome/browser/chromeos/system/ash_system_tray_delegate.cc9
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate.h1
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc36
-rw-r--r--chrome/browser/ui/ash/chrome_shell_delegate_views.cc3
-rw-r--r--chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc46
12 files changed, 74 insertions, 108 deletions
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc
index 0ae5658..cd9e542 100644
--- a/ash/shell/shell_delegate_impl.cc
+++ b/ash/shell/shell_delegate_impl.cc
@@ -119,9 +119,6 @@ void ShellDelegateImpl::OpenFileManager(bool as_dialog) {
void ShellDelegateImpl::OpenCrosh() {
}
-void ShellDelegateImpl::OpenMobileSetup(const std::string& service_path) {
-}
-
void ShellDelegateImpl::RestoreTab() {
}
diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h
index fcb28c8..014e48c 100644
--- a/ash/shell/shell_delegate_impl.h
+++ b/ash/shell/shell_delegate_impl.h
@@ -39,7 +39,6 @@ class ShellDelegateImpl : public ash::ShellDelegate {
virtual void ToggleMaximized() OVERRIDE;
virtual void OpenFileManager(bool as_dialog) OVERRIDE;
virtual void OpenCrosh() OVERRIDE;
- virtual void OpenMobileSetup(const std::string& service_path) OVERRIDE;
virtual void RestoreTab() OVERRIDE;
virtual void ShowKeyboardOverlay() OVERRIDE;
virtual keyboard::KeyboardControllerProxy*
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h
index cf936e2..9aec503 100644
--- a/ash/shell_delegate.h
+++ b/ash/shell_delegate.h
@@ -141,9 +141,6 @@ class ASH_EXPORT ShellDelegate {
// Invoked when the user opens Crosh.
virtual void OpenCrosh() = 0;
- // Invoked when the user needs to set up mobile networking.
- virtual void OpenMobileSetup(const std::string& service_path) = 0;
-
// Invoked when the user uses Shift+Ctrl+T to restore the closed tab.
virtual void RestoreTab() = 0;
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
index 74e2e33..6b36f45 100644
--- a/ash/test/test_shell_delegate.cc
+++ b/ash/test/test_shell_delegate.cc
@@ -77,9 +77,6 @@ void TestShellDelegate::OpenFileManager(bool as_dialog) {
void TestShellDelegate::OpenCrosh() {
}
-void TestShellDelegate::OpenMobileSetup(const std::string& service_path) {
-}
-
void TestShellDelegate::RestoreTab() {
}
diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h
index 3a55f54..c8b2906 100644
--- a/ash/test/test_shell_delegate.h
+++ b/ash/test/test_shell_delegate.h
@@ -42,7 +42,6 @@ class TestShellDelegate : public ShellDelegate {
virtual void ToggleMaximized() OVERRIDE;
virtual void OpenFileManager(bool as_dialog) OVERRIDE;
virtual void OpenCrosh() OVERRIDE;
- virtual void OpenMobileSetup(const std::string& service_path) OVERRIDE;
virtual void RestoreTab() OVERRIDE;
virtual void ShowKeyboardOverlay() OVERRIDE;
virtual keyboard::KeyboardControllerProxy*
diff --git a/chrome/browser/chromeos/options/network_connect.cc b/chrome/browser/chromeos/options/network_connect.cc
index 955625b..4ad2fd2 100644
--- a/chrome/browser/chromeos/options/network_connect.cc
+++ b/chrome/browser/chromeos/options/network_connect.cc
@@ -6,29 +6,24 @@
#include "ash/shell.h"
#include "ash/shell_delegate.h"
+#include "ash/system/chromeos/network/network_observer.h"
+#include "ash/system/tray/system_tray_notifier.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/enrollment_dialog_view.h"
#include "chrome/browser/chromeos/options/network_config_view.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
+#include "grit/generated_resources.h"
+#include "third_party/cros_system_api/dbus/service_constants.h"
+#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
namespace network_connect {
namespace {
-void ActivateCellular(chromeos::CellularNetwork* cellular) {
- DCHECK(cellular);
- chromeos::NetworkLibrary* cros =
- chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- if (cros->CellularDeviceUsesDirectActivation()) {
- cellular->StartActivation();
- } else {
- ash::Shell::GetInstance()->delegate()->OpenMobileSetup(
- cellular->service_path());
- }
-}
-
void DoConnect(Network* network, gfx::NativeWindow parent_window) {
NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
if (network->type() == TYPE_VPN) {
@@ -65,7 +60,7 @@ void DoConnect(Network* network, gfx::NativeWindow parent_window) {
CellularNetwork* cellular = static_cast<CellularNetwork*>(network);
if (cellular->activation_state() != ACTIVATION_STATE_ACTIVATED ||
cellular->out_of_credits()) {
- ActivateCellular(cellular);
+ ActivateCellular(cellular->service_path());
} else {
cros->ConnectToCellularNetwork(cellular);
}
@@ -74,6 +69,50 @@ void DoConnect(Network* network, gfx::NativeWindow parent_window) {
} // namespace
+void ActivateCellular(const std::string& service_path) {
+ chromeos::NetworkLibrary* cros =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ if (!cros->CellularDeviceUsesDirectActivation()) {
+ // For non direct activation, show the mobile setup dialog which can be
+ // used to activate the network.
+ ShowMobileSetup(service_path);
+ return;
+ }
+ chromeos::CellularNetwork* cellular =
+ cros->FindCellularNetworkByPath(service_path);
+ if (!cellular)
+ return;
+ if (cellular->activation_state() != chromeos::ACTIVATION_STATE_ACTIVATED)
+ cellular->StartActivation();
+ return;
+}
+
+void ShowMobileSetup(const std::string& service_path) {
+ NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
+ const CellularNetwork* cellular =
+ cros->FindCellularNetworkByPath(service_path);
+ if (cellular && !cellular->activated() &&
+ cellular->activate_over_non_cellular_network() &&
+ (!cros->connected_network() || !cros->connected_network()->online())) {
+ NetworkTechnology technology = cellular->network_technology();
+ ash::NetworkObserver::NetworkType network_type =
+ (technology == chromeos::NETWORK_TECHNOLOGY_LTE ||
+ technology == chromeos::NETWORK_TECHNOLOGY_LTE_ADVANCED)
+ ? ash::NetworkObserver::NETWORK_CELLULAR_LTE
+ : ash::NetworkObserver::NETWORK_CELLULAR;
+ ash::Shell::GetInstance()->system_tray_notifier()->NotifySetNetworkMessage(
+ NULL,
+ ash::NetworkObserver::ERROR_CONNECT_FAILED,
+ network_type,
+ l10n_util::GetStringUTF16(IDS_NETWORK_ACTIVATION_ERROR_TITLE),
+ l10n_util::GetStringFUTF16(IDS_NETWORK_ACTIVATION_NEEDS_CONNECTION,
+ UTF8ToUTF16((cellular->name()))),
+ std::vector<string16>());
+ return;
+ }
+ MobileSetupDialog::Show(service_path);
+}
+
ConnectResult ConnectToNetwork(const std::string& service_path,
gfx::NativeWindow parent_window) {
NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
@@ -107,7 +146,7 @@ ConnectResult ConnectToNetwork(const std::string& service_path,
if (network->type() == TYPE_CELLULAR) {
CellularNetwork* cellular = static_cast<CellularNetwork*>(network);
if (cellular->NeedsActivation() || cellular->out_of_credits()) {
- ActivateCellular(cellular);
+ ActivateCellular(service_path);
return CONNECT_STARTED;
}
if (cellular->activation_state() == ACTIVATION_STATE_ACTIVATING)
diff --git a/chrome/browser/chromeos/options/network_connect.h b/chrome/browser/chromeos/options/network_connect.h
index a95fa14..6e5792a 100644
--- a/chrome/browser/chromeos/options/network_connect.h
+++ b/chrome/browser/chromeos/options/network_connect.h
@@ -18,6 +18,15 @@ enum ConnectResult {
CONNECT_STARTED
};
+// Activate the cellular network associated with |service_path| if direct
+// activation is supported, otherwise call ShowMobileSetup.
+void ActivateCellular(const std::string& service_path);
+
+// Shows the mobile setup dialog which handles:
+// * Activation for non direct-activation networks
+// * Showing network plan info
+void ShowMobileSetup(const std::string& service_path);
+
// Attempts to connect to the network specified by |service_path|.
// Returns one of the following results:
// NETWORK_NOT_FOUND if the network does not exist.
diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
index c0362c5..99719ee 100644
--- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
+++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
@@ -763,10 +763,11 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
NetworkConfigView::Show(cros_network, GetNativeWindow());
return;
}
- if (network->type() == flimflam::kTypeCellular &&
- (network->activation_state() != flimflam::kActivationStateActivated ||
- network->cellular_out_of_credits())) {
- ash::Shell::GetInstance()->delegate()->OpenMobileSetup(network_id);
+ if (network->type() == flimflam::kTypeCellular) {
+ if (network->activation_state() != flimflam::kActivationStateActivated)
+ network_connect::ActivateCellular(network_id);
+ else if (network->cellular_out_of_credits())
+ network_connect::ShowMobileSetup(network_id);
return;
}
// No special configure or setup for |network_id|, show the settings UI.
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.h b/chrome/browser/ui/ash/chrome_shell_delegate.h
index ec31a6e..0beea0d 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate.h
+++ b/chrome/browser/ui/ash/chrome_shell_delegate.h
@@ -56,7 +56,6 @@ class ChromeShellDelegate : public ash::ShellDelegate,
virtual void ToggleMaximized() OVERRIDE;
virtual void OpenFileManager(bool as_dialog) OVERRIDE;
virtual void OpenCrosh() OVERRIDE;
- virtual void OpenMobileSetup(const std::string& service_path) OVERRIDE;
virtual void RestoreTab() OVERRIDE;
virtual void ShowKeyboardOverlay() OVERRIDE;
virtual keyboard::KeyboardControllerProxy*
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
index dcd4e0b..199f8d8 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate_chromeos.cc
@@ -5,17 +5,12 @@
#include "chrome/browser/ui/ash/chrome_shell_delegate.h"
#include "ash/keyboard_overlay/keyboard_overlay_view.h"
-#include "ash/system/chromeos/network/network_observer.h"
-#include "ash/system/tray/system_tray_notifier.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/prefs/pref_service.h"
-#include "base/utf_string_conversions.h"
#include "chrome/browser/chromeos/accessibility/accessibility_util.h"
#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
#include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h"
-#include "chrome/browser/chromeos/cros/cros_library.h"
-#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/display/display_preferences.h"
#include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h"
#include "chrome/browser/chromeos/extensions/media_player_api.h"
@@ -38,7 +33,6 @@
#include "chrome/browser/ui/extensions/shell_window.h"
#include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
-#include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -49,8 +43,6 @@
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
bool ChromeShellDelegate::IsFirstRunAfterBoot() const {
return CommandLine::ForCurrentProcess()->HasSwitch(
@@ -119,34 +111,6 @@ void ChromeShellDelegate::OpenCrosh() {
page->GetView()->Focus();
}
-void ChromeShellDelegate::OpenMobileSetup(const std::string& service_path) {
- // TODO(stevenjb): Replace with non-NetworkLibrary UI.
- chromeos::NetworkLibrary* cros =
- chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- const chromeos::CellularNetwork* cellular =
- cros->FindCellularNetworkByPath(service_path);
- if (cellular && !cellular->activated() &&
- cellular->activate_over_non_cellular_network() &&
- (!cros->connected_network() || !cros->connected_network()->online())) {
- chromeos::NetworkTechnology technology = cellular->network_technology();
- ash::NetworkObserver::NetworkType network_type =
- (technology == chromeos::NETWORK_TECHNOLOGY_LTE ||
- technology == chromeos::NETWORK_TECHNOLOGY_LTE_ADVANCED)
- ? ash::NetworkObserver::NETWORK_CELLULAR_LTE
- : ash::NetworkObserver::NETWORK_CELLULAR;
- ash::Shell::GetInstance()->system_tray_notifier()->NotifySetNetworkMessage(
- NULL,
- ash::NetworkObserver::ERROR_CONNECT_FAILED,
- network_type,
- l10n_util::GetStringUTF16(IDS_NETWORK_ACTIVATION_ERROR_TITLE),
- l10n_util::GetStringFUTF16(IDS_NETWORK_ACTIVATION_NEEDS_CONNECTION,
- UTF8ToUTF16((cellular->name()))),
- std::vector<string16>());
- return;
- }
- MobileSetupDialog::Show(service_path);
-}
-
void ChromeShellDelegate::ToggleHighContrast() {
bool enabled = chromeos::accessibility::IsHighContrastEnabled();
chromeos::accessibility::EnableHighContrast(!enabled);
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_views.cc b/chrome/browser/ui/ash/chrome_shell_delegate_views.cc
index 3cd2927..bdc86ff 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate_views.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate_views.cc
@@ -39,9 +39,6 @@ void ChromeShellDelegate::OpenFileManager(bool as_dialog) {
void ChromeShellDelegate::OpenCrosh() {
}
-void ChromeShellDelegate::OpenMobileSetup(const std::string& service_path) {
-}
-
void ChromeShellDelegate::ShowKeyboardOverlay() {
}
diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
index a86e41a..43fdc6b 100644
--- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc
@@ -533,26 +533,6 @@ void PopulateVPNDetails(
hostname_ui_data);
}
-// Activate the cellular device pointed to by the service path.
-void Activate(std::string service_path) {
- chromeos::Network* network = NULL;
- if (!service_path.empty()) {
- network = chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
- FindNetworkByPath(service_path);
- } else {
- NOTREACHED();
- return;
- }
-
- if (network->type() != chromeos::TYPE_CELLULAR)
- return;
-
- chromeos::CellularNetwork* cellular =
- static_cast<chromeos::CellularNetwork*>(network);
- if (cellular->activation_state() != chromeos::ACTIVATION_STATE_ACTIVATED)
- cellular->StartActivation();
-}
-
// Given a list of supported carrier's by the device, return the index of
// the carrier the device is currently using.
int FindCurrentCarrierIndex(const base::ListValue* carriers,
@@ -923,12 +903,7 @@ void InternetOptionsHandler::ShowMorePlanInfoCallback(const ListValue* args) {
NOTREACHED();
return;
}
-
- const chromeos::CellularNetwork* cellular =
- cros_->FindCellularNetworkByPath(service_path);
- if (!cellular)
- return;
- ash::Shell::GetInstance()->delegate()->OpenMobileSetup(service_path);
+ chromeos::network_connect::ShowMobileSetup(service_path);
}
void InternetOptionsHandler::BuyDataPlanCallback(const ListValue* args) {
@@ -940,7 +915,7 @@ void InternetOptionsHandler::BuyDataPlanCallback(const ListValue* args) {
NOTREACHED();
return;
}
- ash::Shell::GetInstance()->delegate()->OpenMobileSetup(service_path);
+ chromeos::network_connect::ShowMobileSetup(service_path);
}
void InternetOptionsHandler::SetApnCallback(const ListValue* args) {
@@ -971,7 +946,7 @@ void InternetOptionsHandler::CarrierStatusCallback(
const std::string& error_message) {
if ((error == chromeos::NETWORK_METHOD_ERROR_NONE) &&
cros_->CellularDeviceUsesDirectActivation()) {
- Activate(service_path);
+ chromeos::network_connect::ActivateCellular(service_path);
UpdateConnectionData(cros_->FindNetworkByPath(service_path));
}
@@ -1667,17 +1642,10 @@ void InternetOptionsHandler::NetworkCommandCallback(const ListValue* args) {
} else if (command == kTagDisconnect && type != chromeos::TYPE_ETHERNET) {
cros_->DisconnectFromNetwork(network);
} else if (command == kTagActivate && type == chromeos::TYPE_CELLULAR) {
- if (!cros_->CellularDeviceUsesDirectActivation()) {
- ash::Shell::GetInstance()->delegate()->OpenMobileSetup(
- network->service_path());
- } else {
- Activate(service_path);
- // Update network properties after we start activation. The Activate
- // call is a blocking call, which blocks on finishing the "start" of
- // the activation, hence when we query for network properties after
- // this call is done, we will have the "activating" activation state.
- UpdateConnectionData(network);
- }
+ chromeos::network_connect::ActivateCellular(service_path);
+ // Activation may update network properties (e.g. ActivationState), so
+ // request them here in case they change.
+ UpdateConnectionData(network);
} else {
VLOG(1) << "Unknown command: " << command;
NOTREACHED();