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

Side by Side Diff: chrome/browser/ui/app_list/app_list_service_views.cc

Issue 2582743002: Remove obsolete app_list Linux code. (Closed)
Patch Set: tapted 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
(Empty)
1 // Copyright 2014 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 "chrome/browser/ui/app_list/app_list_service_views.h"
6
7 #include <utility>
8
9 #include "chrome/browser/lifetime/keep_alive_types.h"
10 #include "chrome/browser/lifetime/scoped_keep_alive.h"
11 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
12 #include "ui/app_list/app_list_switches.h"
13 #include "ui/app_list/views/app_list_main_view.h"
14 #include "ui/app_list/views/app_list_view.h"
15 #include "ui/app_list/views/contents_view.h"
16
17 AppListServiceViews::AppListServiceViews(
18 std::unique_ptr<AppListControllerDelegate> controller_delegate)
19 : shower_(this),
20 can_dismiss_(true),
21 controller_delegate_(std::move(controller_delegate)) {}
22
23 AppListServiceViews::~AppListServiceViews() {}
24
25 void AppListServiceViews::OnViewBeingDestroyed() {
26 can_dismiss_ = true;
27 shower_.HandleViewBeingDestroyed();
28 }
29
30 void AppListServiceViews::Init(Profile* initial_profile) {
31 PerformStartupChecks(initial_profile);
32 }
33
34 void AppListServiceViews::ShowForProfile(Profile* requested_profile) {
35 // App list profiles should not be off-the-record.
36 DCHECK(!requested_profile->IsOffTheRecord());
37 DCHECK(!requested_profile->IsGuestSession());
38
39 ShowForProfileInternal(requested_profile,
40 app_list::AppListModel::INVALID_STATE);
41 }
42
43 void AppListServiceViews::ShowForAppInstall(Profile* profile,
44 const std::string& extension_id,
45 bool start_discovery_tracking) {
46 ShowForProfileInternal(profile, app_list::AppListModel::STATE_APPS);
47 AppListServiceImpl::ShowForAppInstall(profile, extension_id,
48 start_discovery_tracking);
49 }
50
51 void AppListServiceViews::ShowForCustomLauncherPage(Profile* profile) {
52 ShowForProfileInternal(profile,
53 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE);
54 }
55
56 void AppListServiceViews::HideCustomLauncherPage() {
57 if (!shower_.IsAppListVisible())
58 return;
59
60 app_list::ContentsView* contents_view =
61 shower_.app_list()->app_list_main_view()->contents_view();
62
63 if (contents_view->IsStateActive(
64 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)) {
65 contents_view->SetActiveState(app_list::AppListModel::STATE_START, true);
66 }
67 }
68
69 void AppListServiceViews::DismissAppList() {
70 if (!can_dismiss_)
71 return;
72
73 shower_.DismissAppList();
74 }
75
76 bool AppListServiceViews::IsAppListVisible() const {
77 return shower_.IsAppListVisible();
78 }
79
80 gfx::NativeWindow AppListServiceViews::GetAppListWindow() {
81 return shower_.GetWindow();
82 }
83
84 Profile* AppListServiceViews::GetCurrentAppListProfile() {
85 return shower_.profile();
86 }
87
88 AppListControllerDelegate* AppListServiceViews::GetControllerDelegate() {
89 return controller_delegate_.get();
90 }
91
92 void AppListServiceViews::CreateForProfile(Profile* requested_profile) {
93 DCHECK(requested_profile);
94 InvalidatePendingProfileLoads();
95 shower_.CreateViewForProfile(requested_profile);
96 SetProfilePath(shower_.profile()->GetPath());
97 }
98
99 void AppListServiceViews::DestroyAppList() {
100 if (!shower_.HasView())
101 return;
102
103 // Use CloseNow(). This can't be asynchronous because the profile will be
104 // deleted once this function returns.
105 shower_.app_list()->GetWidget()->CloseNow();
106 DCHECK(!shower_.HasView());
107 }
108
109 AppListViewDelegate* AppListServiceViews::GetViewDelegateForCreate() {
110 return GetViewDelegate(shower_.profile());
111 }
112
113 void AppListServiceViews::ShowForProfileInternal(
114 Profile* profile,
115 app_list::AppListModel::State state) {
116 DCHECK(profile);
117
118 ScopedKeepAlive keep_alive(KeepAliveOrigin::APP_LIST_SERVICE_VIEWS,
119 KeepAliveRestartOption::DISABLED);
120
121 CreateForProfile(profile);
122
123 if (state != app_list::AppListModel::INVALID_STATE) {
124 app_list::ContentsView* contents_view =
125 shower_.app_list()->app_list_main_view()->contents_view();
126 contents_view->SetActiveState(state,
127 shower_.IsAppListVisible() /* animate */);
128 }
129
130 shower_.ShowForCurrentProfile();
131 RecordAppListLaunch();
132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698