Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1019)

Side by Side Diff: ash/mus/app_list_presenter_mus.cc

Issue 2567523002: mash: Have chrome set itself as the app list presenter. (Closed)
Patch Set: Address comments. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/mus/app_list_presenter_mus.h" 5 #include "ash/mus/app_list_presenter_mus.h"
6 6
7 #include "content/public/common/service_names.mojom.h" 7 #include "ash/common/wm_shell.h"
8 #include "services/service_manager/public/cpp/connector.h" 8 #include "ui/app_list/presenter/app_list.h"
9 9
10 namespace ash { 10 namespace ash {
11 11
12 namespace { 12 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 13
23 AppListPresenterMus::~AppListPresenterMus() {} 14 AppListPresenterMus::~AppListPresenterMus() {}
24 15
25 void AppListPresenterMus::Show(int64_t display_id) { 16 void AppListPresenterMus::Show(int64_t display_id) {
26 ConnectIfNeeded(); 17 app_list::AppList* app_list = WmShell::Get()->app_list();
mfomitchev 2016/12/12 22:59:49 nit: why not do app_list_presenter = WmShell::Get
msw 2016/12/12 23:47:54 Done.
27 presenter_->Show(display_id); 18 if (app_list->GetAppListPresenter())
19 app_list->GetAppListPresenter()->Show(display_id);
28 } 20 }
29 21
30 void AppListPresenterMus::Dismiss() { 22 void AppListPresenterMus::Dismiss() {
31 ConnectIfNeeded(); 23 app_list::AppList* app_list = WmShell::Get()->app_list();
32 presenter_->Dismiss(); 24 if (app_list->GetAppListPresenter())
25 app_list->GetAppListPresenter()->Dismiss();
33 } 26 }
34 27
35 void AppListPresenterMus::ToggleAppList(int64_t display_id) { 28 void AppListPresenterMus::ToggleAppList(int64_t display_id) {
36 ConnectIfNeeded(); 29 app_list::AppList* app_list = WmShell::Get()->app_list();
37 presenter_->ToggleAppList(display_id); 30 if (app_list->GetAppListPresenter())
31 app_list->GetAppListPresenter()->ToggleAppList(display_id);
38 } 32 }
39 33
40 bool AppListPresenterMus::IsVisible() const { 34 bool AppListPresenterMus::IsVisible() const {
41 return false; 35 return false;
42 } 36 }
43 37
44 bool AppListPresenterMus::GetTargetVisibility() const { 38 bool AppListPresenterMus::GetTargetVisibility() const {
45 // TODO(mfomitchev): we have GetTargetVisibility() in mojom, but this 39 // TODO(mfomitchev): we have GetTargetVisibility() in mojom, but this
46 // shouldn't be a synchronous method. We should go through the call sites and 40 // 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. 41 // either teach them to use a callback, or perhaps use a visibility observer.
48 // NOTIMPLEMENTED(); 42 // NOTIMPLEMENTED();
49 return false; 43 return false;
50 } 44 }
51 45
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 46 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698