Commit 0f9528ae authored by jamescook's avatar jamescook Committed by Commit bot

mustash: Fix crash when clicking on network in system tray

* Initialize ui::NetworkConnect during mash startup
* Provide a stub NetworkConnect::Delegate implementation

It still won't actually switch networks on the device (there are issues
talking to shill in lower-level code) but it's a step in the right direction.

BUG=644355
TEST=manual, click on network in system tray, no crash

Review-Url: https://codereview.chromium.org/2394503003
Cr-Commit-Position: refs/heads/master@{#423021}
parent 1ea8ac8f
......@@ -141,6 +141,7 @@ source_set("lib") {
"//chromeos",
"//chromeos:power_manager_proto",
"//device/bluetooth",
"//ui/chromeos",
]
}
}
......
......@@ -36,43 +36,33 @@
#include "chromeos/network/network_handler.h"
#include "chromeos/system/fake_statistics_provider.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h" // nogncheck
#include "ui/chromeos/network/network_connect.h"
#endif
namespace ash {
namespace mus {
namespace {
void InitializeComponents() {
message_center::MessageCenter::Initialize();
#if defined(OS_CHROMEOS)
// Must occur after mojo::ApplicationRunner has initialized AtExitManager, but
// before WindowManager::Init().
chromeos::DBusThreadManager::Initialize(
chromeos::DBusThreadManager::PROCESS_ASH);
// See ChromeBrowserMainPartsChromeos for ordering details.
bluez::BluezDBusManager::Initialize(
chromeos::DBusThreadManager::Get()->GetSystemBus(),
chromeos::DBusThreadManager::Get()->IsUsingFakes());
chromeos::NetworkHandler::Initialize();
// TODO(jamescook): Initialize real audio handler.
chromeos::CrasAudioHandler::InitializeForTesting();
PowerStatus::Initialize();
#endif
}
void ShutdownComponents() {
#if defined(OS_CHROMEOS)
PowerStatus::Shutdown();
chromeos::CrasAudioHandler::Shutdown();
chromeos::NetworkHandler::Shutdown();
bluez::BluezDBusManager::Shutdown();
chromeos::DBusThreadManager::Shutdown();
#endif
message_center::MessageCenter::Shutdown();
}
// TODO(mash): Replace ui::NetworkConnect::Delegate with a mojo interface on a
// NetworkConfig service. http://crbug.com/644355
class WindowManagerApplication::StubNetworkConnectDelegate
: public ui::NetworkConnect::Delegate {
public:
StubNetworkConnectDelegate() {}
~StubNetworkConnectDelegate() override {}
void ShowNetworkConfigure(const std::string& network_id) override {}
void ShowNetworkSettingsForGuid(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 {}
} // namespace
private:
DISALLOW_COPY_AND_ASSIGN(StubNetworkConnectDelegate);
};
#endif // OS_CHROMEOS
WindowManagerApplication::WindowManagerApplication()
: screenlock_state_listener_binding_(this) {}
......@@ -128,6 +118,40 @@ void WindowManagerApplication::InitWindowManager(
base::MakeUnique<NativeWidgetFactoryMus>(window_manager_.get());
}
void WindowManagerApplication::InitializeComponents() {
message_center::MessageCenter::Initialize();
#if defined(OS_CHROMEOS)
// Must occur after mojo::ApplicationRunner has initialized AtExitManager, but
// before WindowManager::Init().
chromeos::DBusThreadManager::Initialize(
chromeos::DBusThreadManager::PROCESS_ASH);
// See ChromeBrowserMainPartsChromeos for ordering details.
bluez::BluezDBusManager::Initialize(
chromeos::DBusThreadManager::Get()->GetSystemBus(),
chromeos::DBusThreadManager::Get()->IsUsingFakes());
chromeos::NetworkHandler::Initialize();
network_connect_delegate_.reset(new StubNetworkConnectDelegate());
ui::NetworkConnect::Initialize(network_connect_delegate_.get());
// TODO(jamescook): Initialize real audio handler.
chromeos::CrasAudioHandler::InitializeForTesting();
PowerStatus::Initialize();
#endif
}
void WindowManagerApplication::ShutdownComponents() {
#if defined(OS_CHROMEOS)
PowerStatus::Shutdown();
chromeos::CrasAudioHandler::Shutdown();
ui::NetworkConnect::Shutdown();
network_connect_delegate_.reset();
chromeos::NetworkHandler::Shutdown();
bluez::BluezDBusManager::Shutdown();
chromeos::DBusThreadManager::Shutdown();
#endif
message_center::MessageCenter::Shutdown();
}
void WindowManagerApplication::OnStart(const shell::Identity& identity) {
aura_init_.reset(new views::AuraInit(connector(), "ash_mus_resources.pak",
"ash_mus_resources_200.pak"));
......
......@@ -75,6 +75,10 @@ class WindowManagerApplication
std::unique_ptr<ui::WindowTreeClient> window_tree_client,
const scoped_refptr<base::SequencedWorkerPool>& blocking_pool);
// Initializes lower-level OS-specific components (e.g. D-Bus services).
void InitializeComponents();
void ShutdownComponents();
// shell::Service:
void OnStart(const shell::Identity& identity) override;
bool OnConnect(const shell::Identity& remote_identity,
......@@ -118,6 +122,8 @@ class WindowManagerApplication
screenlock_state_listener_binding_;
#if defined(OS_CHROMEOS)
class StubNetworkConnectDelegate;
std::unique_ptr<StubNetworkConnectDelegate> network_connect_delegate_;
std::unique_ptr<chromeos::system::ScopedFakeStatisticsProvider>
statistics_provider_;
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment