| 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/sysui/app_list_presenter_mus.h" | |
| 6 | |
| 7 #include "services/shell/public/cpp/connector.h" | |
| 8 | |
| 9 namespace ash { | |
| 10 namespace { | |
| 11 | |
| 12 // TODO(mfomitchev): Remove when http://crbug.com/607300 is fixed. | |
| 13 // This method should not exist. Sys_ui has different display ids because it | |
| 14 // uses ScreenAsh instead of ScreenMus. | |
| 15 int64_t GetMusDisplayId(int64_t sysui_display_id) { | |
| 16 return 1; | |
| 17 } | |
| 18 | |
| 19 bool HasConnection(app_list::mojom::AppListPresenterPtr* interface_ptr) { | |
| 20 return interface_ptr->is_bound() && !interface_ptr->encountered_error(); | |
| 21 } | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 25 AppListPresenterMus::AppListPresenterMus(::shell::Connector* connector) | |
| 26 : connector_(connector) { | |
| 27 ConnectIfNeeded(); | |
| 28 } | |
| 29 | |
| 30 AppListPresenterMus::~AppListPresenterMus() {} | |
| 31 | |
| 32 void AppListPresenterMus::Show(int64_t display_id) { | |
| 33 display_id = GetMusDisplayId(display_id); | |
| 34 presenter_->Show(display_id); | |
| 35 } | |
| 36 | |
| 37 void AppListPresenterMus::Dismiss() { | |
| 38 ConnectIfNeeded(); | |
| 39 presenter_->Dismiss(); | |
| 40 } | |
| 41 | |
| 42 void AppListPresenterMus::ToggleAppList(int64_t display_id) { | |
| 43 display_id = GetMusDisplayId(display_id); | |
| 44 ConnectIfNeeded(); | |
| 45 presenter_->ToggleAppList(display_id); | |
| 46 } | |
| 47 | |
| 48 bool AppListPresenterMus::IsVisible() const { | |
| 49 return false; | |
| 50 } | |
| 51 | |
| 52 bool AppListPresenterMus::GetTargetVisibility() const { | |
| 53 // TODO(mfomitchev): we have GetTargetVisibility() in mojom, but this | |
| 54 // shouldn't be a synchronous method. We should go through the call sites and | |
| 55 // either teach them to use a callback, or perhaps use a visibility observer. | |
| 56 // NOTIMPLEMENTED(); | |
| 57 return false; | |
| 58 } | |
| 59 | |
| 60 bool AppListPresenterMus::ConnectIfNeeded() { | |
| 61 if (HasConnection(&presenter_)) | |
| 62 return true; | |
| 63 connector_->ConnectToInterface("exe:chrome", &presenter_); | |
| 64 CHECK(HasConnection(&presenter_)) | |
| 65 << "Could not connect to app_list::mojom::AppListPresenter."; | |
| 66 return true; | |
| 67 } | |
| 68 | |
| 69 } // namespace ash | |
| OLD | NEW |