| Index: ash/common/new_window_client_proxy.cc
|
| diff --git a/ash/common/new_window_client_proxy.cc b/ash/common/new_window_client_proxy.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d25456efc3ba563287c233bb0b80635a4d641685
|
| --- /dev/null
|
| +++ b/ash/common/new_window_client_proxy.cc
|
| @@ -0,0 +1,80 @@
|
| +// Copyright 2016 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/common/new_window_client_proxy.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "services/service_manager/public/cpp/connector.h"
|
| +
|
| +namespace ash {
|
| +
|
| +NewWindowClientProxy::NewWindowClientProxy(
|
| + service_manager::Connector* connector)
|
| + : connector_(connector) {}
|
| +
|
| +NewWindowClientProxy::~NewWindowClientProxy() {}
|
| +
|
| +void NewWindowClientProxy::NewTab() {
|
| + EnsureInterface();
|
| + client_->NewTab();
|
| +}
|
| +
|
| +void NewWindowClientProxy::NewWindow(bool incognito) {
|
| + EnsureInterface();
|
| + client_->NewWindow(incognito);
|
| +}
|
| +
|
| +void NewWindowClientProxy::OpenFileManager() {
|
| + EnsureInterface();
|
| + client_->OpenFileManager();
|
| +}
|
| +
|
| +void NewWindowClientProxy::OpenCrosh() {
|
| + EnsureInterface();
|
| + client_->OpenCrosh();
|
| +}
|
| +
|
| +void NewWindowClientProxy::OpenGetHelp() {
|
| + EnsureInterface();
|
| + client_->OpenGetHelp();
|
| +}
|
| +
|
| +void NewWindowClientProxy::RestoreTab() {
|
| + EnsureInterface();
|
| + client_->RestoreTab();
|
| +}
|
| +
|
| +void NewWindowClientProxy::ShowKeyboardOverlay() {
|
| + EnsureInterface();
|
| + client_->ShowKeyboardOverlay();
|
| +}
|
| +
|
| +void NewWindowClientProxy::ShowTaskManager() {
|
| + EnsureInterface();
|
| + client_->ShowTaskManager();
|
| +}
|
| +
|
| +void NewWindowClientProxy::OpenFeedbackPage() {
|
| + EnsureInterface();
|
| + client_->OpenFeedbackPage();
|
| +}
|
| +
|
| +void NewWindowClientProxy::EnsureInterface() {
|
| + // |connector_| can be null in unit tests. We check this at first usage
|
| + // instead of during construction because a NewWindowClientProxy is always
|
| + // created and is then replaced with a mock in the unit tests.
|
| + DCHECK(connector_);
|
| +
|
| + if (client_)
|
| + return;
|
| + connector_->ConnectToInterface("service:content_browser", &client_);
|
| + client_.set_connection_error_handler(base::Bind(
|
| + &NewWindowClientProxy::OnClientConnectionError, base::Unretained(this)));
|
| +}
|
| +
|
| +void NewWindowClientProxy::OnClientConnectionError() {
|
| + client_.reset();
|
| +}
|
| +
|
| +} // namespace ash
|
|
|