Chromium Code Reviews| 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/common/wm_shell.h" | |
| 5 #include "ash/mus/app_list_presenter_mus.h" | 6 #include "ash/mus/app_list_presenter_mus.h" |
|
James Cook
2016/12/10 00:50:08
nit: goes at top of file
msw
2016/12/10 01:08:12
Done.
| |
| 6 | 7 #include "ui/app_list/presenter/app_list.h" |
| 7 #include "content/public/common/service_names.mojom.h" | |
| 8 #include "services/service_manager/public/cpp/connector.h" | |
| 9 | 8 |
| 10 namespace ash { | 9 namespace ash { |
| 11 | 10 |
| 12 namespace { | 11 AppListPresenterMus::AppListPresenterMus() {} |
| 13 | |
| 14 bool HasConnection(app_list::mojom::AppListPresenterPtr* interface_ptr) { | |
| 15 return interface_ptr->is_bound() && !interface_ptr->encountered_error(); | |
| 16 } | |
| 17 | |
| 18 } // namespace | |
| 19 | |
| 20 AppListPresenterMus::AppListPresenterMus(service_manager::Connector* connector) | |
| 21 : connector_(connector) {} | |
| 22 | 12 |
| 23 AppListPresenterMus::~AppListPresenterMus() {} | 13 AppListPresenterMus::~AppListPresenterMus() {} |
| 24 | 14 |
| 25 void AppListPresenterMus::Show(int64_t display_id) { | 15 void AppListPresenterMus::Show(int64_t display_id) { |
| 26 ConnectIfNeeded(); | 16 if (WmShell::Get()->app_list()->GetAppListPresenter()) |
|
James Cook
2016/12/10 00:50:08
nit: cache either the result of WmShell::Get() or
msw
2016/12/10 01:08:12
Done.
| |
| 27 presenter_->Show(display_id); | 17 WmShell::Get()->app_list()->GetAppListPresenter()->Show(display_id); |
| 28 } | 18 } |
| 29 | 19 |
| 30 void AppListPresenterMus::Dismiss() { | 20 void AppListPresenterMus::Dismiss() { |
| 31 ConnectIfNeeded(); | 21 if (WmShell::Get()->app_list()->GetAppListPresenter()) |
| 32 presenter_->Dismiss(); | 22 WmShell::Get()->app_list()->GetAppListPresenter()->Dismiss(); |
| 33 } | 23 } |
| 34 | 24 |
| 35 void AppListPresenterMus::ToggleAppList(int64_t display_id) { | 25 void AppListPresenterMus::ToggleAppList(int64_t display_id) { |
| 36 ConnectIfNeeded(); | 26 if (WmShell::Get()->app_list()->GetAppListPresenter()) { |
| 37 presenter_->ToggleAppList(display_id); | 27 WmShell::Get()->app_list()->GetAppListPresenter()->ToggleAppList( |
| 28 display_id); | |
| 29 } | |
| 38 } | 30 } |
| 39 | 31 |
| 40 bool AppListPresenterMus::IsVisible() const { | 32 bool AppListPresenterMus::IsVisible() const { |
| 41 return false; | 33 return false; |
| 42 } | 34 } |
| 43 | 35 |
| 44 bool AppListPresenterMus::GetTargetVisibility() const { | 36 bool AppListPresenterMus::GetTargetVisibility() const { |
| 45 // TODO(mfomitchev): we have GetTargetVisibility() in mojom, but this | 37 // TODO(mfomitchev): we have GetTargetVisibility() in mojom, but this |
| 46 // shouldn't be a synchronous method. We should go through the call sites and | 38 // shouldn't be a synchronous method. We should go through the call sites and |
| 47 // either teach them to use a callback, or perhaps use a visibility observer. | 39 // either teach them to use a callback, or perhaps use a visibility observer. |
| 48 // NOTIMPLEMENTED(); | 40 // NOTIMPLEMENTED(); |
| 49 return false; | 41 return false; |
| 50 } | 42 } |
| 51 | 43 |
| 52 void AppListPresenterMus::ConnectIfNeeded() { | |
| 53 if (!connector_ || HasConnection(&presenter_)) | |
| 54 return; | |
| 55 connector_->ConnectToInterface(content::mojom::kBrowserServiceName, | |
| 56 &presenter_); | |
| 57 CHECK(HasConnection(&presenter_)) | |
| 58 << "Could not connect to app_list::mojom::AppListPresenter."; | |
| 59 } | |
| 60 | |
| 61 } // namespace ash | 44 } // namespace ash |
| OLD | NEW |