| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/sysui/app_list_presenter_mus.h" | 5 #include "ash/mus/app_list_presenter_mus.h" |
| 6 | 6 |
| 7 #include "services/shell/public/cpp/connector.h" | 7 #include "services/shell/public/cpp/connector.h" |
| 8 | 8 |
| 9 namespace ash { | 9 namespace ash { |
| 10 |
| 10 namespace { | 11 namespace { |
| 11 | 12 |
| 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) { | 13 bool HasConnection(app_list::mojom::AppListPresenterPtr* interface_ptr) { |
| 20 return interface_ptr->is_bound() && !interface_ptr->encountered_error(); | 14 return interface_ptr->is_bound() && !interface_ptr->encountered_error(); |
| 21 } | 15 } |
| 22 | 16 |
| 23 } // namespace | 17 } // namespace |
| 24 | 18 |
| 25 AppListPresenterMus::AppListPresenterMus(::shell::Connector* connector) | 19 AppListPresenterMus::AppListPresenterMus(::shell::Connector* connector) |
| 26 : connector_(connector) { | 20 : connector_(connector) {} |
| 27 ConnectIfNeeded(); | |
| 28 } | |
| 29 | 21 |
| 30 AppListPresenterMus::~AppListPresenterMus() {} | 22 AppListPresenterMus::~AppListPresenterMus() {} |
| 31 | 23 |
| 32 void AppListPresenterMus::Show(int64_t display_id) { | 24 void AppListPresenterMus::Show(int64_t display_id) { |
| 33 display_id = GetMusDisplayId(display_id); | 25 ConnectIfNeeded(); |
| 34 presenter_->Show(display_id); | 26 presenter_->Show(display_id); |
| 35 } | 27 } |
| 36 | 28 |
| 37 void AppListPresenterMus::Dismiss() { | 29 void AppListPresenterMus::Dismiss() { |
| 38 ConnectIfNeeded(); | 30 ConnectIfNeeded(); |
| 39 presenter_->Dismiss(); | 31 presenter_->Dismiss(); |
| 40 } | 32 } |
| 41 | 33 |
| 42 void AppListPresenterMus::ToggleAppList(int64_t display_id) { | 34 void AppListPresenterMus::ToggleAppList(int64_t display_id) { |
| 43 display_id = GetMusDisplayId(display_id); | |
| 44 ConnectIfNeeded(); | 35 ConnectIfNeeded(); |
| 45 presenter_->ToggleAppList(display_id); | 36 presenter_->ToggleAppList(display_id); |
| 46 } | 37 } |
| 47 | 38 |
| 48 bool AppListPresenterMus::IsVisible() const { | 39 bool AppListPresenterMus::IsVisible() const { |
| 49 return false; | 40 return false; |
| 50 } | 41 } |
| 51 | 42 |
| 52 bool AppListPresenterMus::GetTargetVisibility() const { | 43 bool AppListPresenterMus::GetTargetVisibility() const { |
| 53 // TODO(mfomitchev): we have GetTargetVisibility() in mojom, but this | 44 // TODO(mfomitchev): we have GetTargetVisibility() in mojom, but this |
| 54 // shouldn't be a synchronous method. We should go through the call sites and | 45 // 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. | 46 // either teach them to use a callback, or perhaps use a visibility observer. |
| 56 // NOTIMPLEMENTED(); | 47 // NOTIMPLEMENTED(); |
| 57 return false; | 48 return false; |
| 58 } | 49 } |
| 59 | 50 |
| 60 bool AppListPresenterMus::ConnectIfNeeded() { | 51 void AppListPresenterMus::ConnectIfNeeded() { |
| 61 if (HasConnection(&presenter_)) | 52 if (!connector_ || HasConnection(&presenter_)) |
| 62 return true; | 53 return; |
| 63 connector_->ConnectToInterface("exe:chrome", &presenter_); | 54 connector_->ConnectToInterface("exe:chrome", &presenter_); |
| 64 CHECK(HasConnection(&presenter_)) | 55 CHECK(HasConnection(&presenter_)) |
| 65 << "Could not connect to app_list::mojom::AppListPresenter."; | 56 << "Could not connect to app_list::mojom::AppListPresenter."; |
| 66 return true; | |
| 67 } | 57 } |
| 68 | 58 |
| 69 } // namespace ash | 59 } // namespace ash |
| OLD | NEW |