| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/common/new_window_client_proxy.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "content/public/common/service_names.mojom.h" | |
| 9 #include "services/service_manager/public/cpp/connector.h" | |
| 10 | |
| 11 namespace ash { | |
| 12 | |
| 13 NewWindowClientProxy::NewWindowClientProxy( | |
| 14 service_manager::Connector* connector) | |
| 15 : connector_(connector) {} | |
| 16 | |
| 17 NewWindowClientProxy::~NewWindowClientProxy() {} | |
| 18 | |
| 19 void NewWindowClientProxy::NewTab() { | |
| 20 EnsureInterface(); | |
| 21 client_->NewTab(); | |
| 22 } | |
| 23 | |
| 24 void NewWindowClientProxy::NewWindow(bool incognito) { | |
| 25 EnsureInterface(); | |
| 26 client_->NewWindow(incognito); | |
| 27 } | |
| 28 | |
| 29 void NewWindowClientProxy::OpenFileManager() { | |
| 30 EnsureInterface(); | |
| 31 client_->OpenFileManager(); | |
| 32 } | |
| 33 | |
| 34 void NewWindowClientProxy::OpenCrosh() { | |
| 35 EnsureInterface(); | |
| 36 client_->OpenCrosh(); | |
| 37 } | |
| 38 | |
| 39 void NewWindowClientProxy::OpenGetHelp() { | |
| 40 EnsureInterface(); | |
| 41 client_->OpenGetHelp(); | |
| 42 } | |
| 43 | |
| 44 void NewWindowClientProxy::RestoreTab() { | |
| 45 EnsureInterface(); | |
| 46 client_->RestoreTab(); | |
| 47 } | |
| 48 | |
| 49 void NewWindowClientProxy::ShowKeyboardOverlay() { | |
| 50 EnsureInterface(); | |
| 51 client_->ShowKeyboardOverlay(); | |
| 52 } | |
| 53 | |
| 54 void NewWindowClientProxy::ShowTaskManager() { | |
| 55 EnsureInterface(); | |
| 56 client_->ShowTaskManager(); | |
| 57 } | |
| 58 | |
| 59 void NewWindowClientProxy::OpenFeedbackPage() { | |
| 60 EnsureInterface(); | |
| 61 client_->OpenFeedbackPage(); | |
| 62 } | |
| 63 | |
| 64 void NewWindowClientProxy::EnsureInterface() { | |
| 65 // |connector_| can be null in unit tests. We check this at first usage | |
| 66 // instead of during construction because a NewWindowClientProxy is always | |
| 67 // created and is then replaced with a mock in the unit tests. | |
| 68 DCHECK(connector_); | |
| 69 | |
| 70 if (client_) | |
| 71 return; | |
| 72 connector_->ConnectToInterface(content::mojom::kBrowserServiceName, &client_); | |
| 73 client_.set_connection_error_handler(base::Bind( | |
| 74 &NewWindowClientProxy::OnClientConnectionError, base::Unretained(this))); | |
| 75 } | |
| 76 | |
| 77 void NewWindowClientProxy::OnClientConnectionError() { | |
| 78 client_.reset(); | |
| 79 } | |
| 80 | |
| 81 } // namespace ash | |
| OLD | NEW |