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

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
« no previous file with comments | « ash/mus/app_list_presenter_mus.h ('k') | ash/mus/manifest.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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::mojom::AppListPresenter* app_list_presenter =
27 presenter_->Show(display_id); 18 WmShell::Get()->app_list()->GetAppListPresenter();
19 if (app_list_presenter)
20 app_list_presenter->Show(display_id);
28 } 21 }
29 22
30 void AppListPresenterMus::Dismiss() { 23 void AppListPresenterMus::Dismiss() {
31 ConnectIfNeeded(); 24 app_list::mojom::AppListPresenter* app_list_presenter =
32 presenter_->Dismiss(); 25 WmShell::Get()->app_list()->GetAppListPresenter();
26 if (app_list_presenter)
27 app_list_presenter->Dismiss();
33 } 28 }
34 29
35 void AppListPresenterMus::ToggleAppList(int64_t display_id) { 30 void AppListPresenterMus::ToggleAppList(int64_t display_id) {
36 ConnectIfNeeded(); 31 app_list::mojom::AppListPresenter* app_list_presenter =
37 presenter_->ToggleAppList(display_id); 32 WmShell::Get()->app_list()->GetAppListPresenter();
33 if (app_list_presenter)
34 app_list_presenter->ToggleAppList(display_id);
38 } 35 }
39 36
40 bool AppListPresenterMus::IsVisible() const { 37 bool AppListPresenterMus::IsVisible() const {
41 return false; 38 return false;
42 } 39 }
43 40
44 bool AppListPresenterMus::GetTargetVisibility() const { 41 bool AppListPresenterMus::GetTargetVisibility() const {
45 // TODO(mfomitchev): we have GetTargetVisibility() in mojom, but this 42 // TODO(mfomitchev): we have GetTargetVisibility() in mojom, but this
46 // shouldn't be a synchronous method. We should go through the call sites and 43 // 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. 44 // either teach them to use a callback, or perhaps use a visibility observer.
48 // NOTIMPLEMENTED(); 45 // NOTIMPLEMENTED();
49 return false; 46 return false;
50 } 47 }
51 48
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 49 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/app_list_presenter_mus.h ('k') | ash/mus/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698