OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/ash/app_list/app_list_service_ash.h" | 5 #include "chrome/browser/ui/ash/app_list/app_list_service_ash.h" |
6 | 6 |
7 #include "ash/app_list/app_list_shower_delegate.h" | 7 #include "ash/app_list/app_list_presenter_delegate.h" |
8 #include "ash/app_list/app_list_shower_delegate_factory.h" | 8 #include "ash/app_list/app_list_presenter_delegate_factory.h" |
9 #include "ash/app_list/app_list_view_delegate_factory.h" | 9 #include "ash/app_list/app_list_view_delegate_factory.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" | 16 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" |
17 #include "chrome/browser/ui/app_list/start_page_service.h" | 17 #include "chrome/browser/ui/app_list/start_page_service.h" |
18 #include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h" | 18 #include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h" |
19 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 19 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
20 #include "chrome/browser/ui/ash/session_util.h" | 20 #include "chrome/browser/ui/ash/session_util.h" |
21 #include "ui/app_list/app_list_switches.h" | 21 #include "ui/app_list/app_list_switches.h" |
22 #include "ui/app_list/shower/app_list_shower_delegate_factory.h" | 22 #include "ui/app_list/presenter/app_list_presenter_delegate_factory.h" |
23 #include "ui/app_list/shower/app_list_shower_impl.h" | 23 #include "ui/app_list/presenter/app_list_presenter_impl.h" |
24 #include "ui/app_list/views/app_list_main_view.h" | 24 #include "ui/app_list/views/app_list_main_view.h" |
25 #include "ui/app_list/views/app_list_view.h" | 25 #include "ui/app_list/views/app_list_view.h" |
26 #include "ui/app_list/views/contents_view.h" | 26 #include "ui/app_list/views/contents_view.h" |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 class ViewDelegateFactoryImpl : public ash::AppListViewDelegateFactory { | 30 class ViewDelegateFactoryImpl : public ash::AppListViewDelegateFactory { |
31 public: | 31 public: |
32 explicit ViewDelegateFactoryImpl(AppListServiceImpl* factory) | 32 explicit ViewDelegateFactoryImpl(AppListServiceImpl* factory) |
33 : factory_(factory) {} | 33 : factory_(factory) {} |
(...skipping 13 matching lines...) Expand all Loading... |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 // static | 50 // static |
51 AppListServiceAsh* AppListServiceAsh::GetInstance() { | 51 AppListServiceAsh* AppListServiceAsh::GetInstance() { |
52 return base::Singleton<AppListServiceAsh, | 52 return base::Singleton<AppListServiceAsh, |
53 base::LeakySingletonTraits<AppListServiceAsh>>::get(); | 53 base::LeakySingletonTraits<AppListServiceAsh>>::get(); |
54 } | 54 } |
55 | 55 |
56 AppListServiceAsh::AppListServiceAsh() | 56 AppListServiceAsh::AppListServiceAsh() |
57 : shower_delegate_factory_(new ash::AppListShowerDelegateFactory( | 57 : presenter_delegate_factory_(new ash::AppListPresenterDelegateFactory( |
58 base::WrapUnique(new ViewDelegateFactoryImpl(this)))) { | 58 base::WrapUnique(new ViewDelegateFactoryImpl(this)))) { |
59 app_list_shower_.reset( | 59 app_list_presenter_.reset( |
60 new app_list::AppListShowerImpl(shower_delegate_factory_.get())); | 60 new app_list::AppListPresenterImpl(presenter_delegate_factory_.get())); |
61 controller_delegate_.reset( | 61 controller_delegate_.reset( |
62 new AppListControllerDelegateAsh(app_list_shower_.get())); | 62 new AppListControllerDelegateAsh(app_list_presenter_.get())); |
63 } | 63 } |
64 | 64 |
65 AppListServiceAsh::~AppListServiceAsh() { | 65 AppListServiceAsh::~AppListServiceAsh() { |
66 } | 66 } |
67 | 67 |
68 app_list::AppListShower* AppListServiceAsh::GetAppListShower() { | 68 app_list::AppListPresenter* AppListServiceAsh::GetAppListPresenter() { |
69 return app_list_shower_.get(); | 69 return app_list_presenter_.get(); |
70 } | 70 } |
71 | 71 |
72 void AppListServiceAsh::Init(Profile* initial_profile) { | 72 void AppListServiceAsh::Init(Profile* initial_profile) { |
73 // Ensure the StartPageService is created here. This early initialization is | 73 // Ensure the StartPageService is created here. This early initialization is |
74 // necessary to allow the WebContents to load before the app list is shown. | 74 // necessary to allow the WebContents to load before the app list is shown. |
75 app_list::StartPageService* service = | 75 app_list::StartPageService* service = |
76 app_list::StartPageService::Get(initial_profile); | 76 app_list::StartPageService::Get(initial_profile); |
77 if (service) | 77 if (service) |
78 service->Init(); | 78 service->Init(); |
79 } | 79 } |
80 | 80 |
81 void AppListServiceAsh::OnProfileWillBeRemoved( | 81 void AppListServiceAsh::OnProfileWillBeRemoved( |
82 const base::FilePath& profile_path) {} | 82 const base::FilePath& profile_path) {} |
83 | 83 |
84 void AppListServiceAsh::ShowAndSwitchToState( | 84 void AppListServiceAsh::ShowAndSwitchToState( |
85 app_list::AppListModel::State state) { | 85 app_list::AppListModel::State state) { |
86 bool app_list_was_open = true; | 86 bool app_list_was_open = true; |
87 app_list::AppListView* app_list_view = app_list_shower_->GetView(); | 87 app_list::AppListView* app_list_view = app_list_presenter_->GetView(); |
88 if (!app_list_view) { | 88 if (!app_list_view) { |
89 // TODO(calamity): This may cause the app list to show briefly before the | 89 // TODO(calamity): This may cause the app list to show briefly before the |
90 // state change. If this becomes an issue, add the ability to ash::Shell to | 90 // state change. If this becomes an issue, add the ability to ash::Shell to |
91 // load the app list without showing it. | 91 // load the app list without showing it. |
92 app_list_shower_->Show(ash::Shell::GetTargetRootWindow()); | 92 app_list_presenter_->Show(ash::Shell::GetTargetRootWindow()); |
93 app_list_was_open = false; | 93 app_list_was_open = false; |
94 app_list_view = app_list_shower_->GetView(); | 94 app_list_view = app_list_presenter_->GetView(); |
95 DCHECK(app_list_view); | 95 DCHECK(app_list_view); |
96 } | 96 } |
97 | 97 |
98 if (state == app_list::AppListModel::INVALID_STATE) | 98 if (state == app_list::AppListModel::INVALID_STATE) |
99 return; | 99 return; |
100 | 100 |
101 app_list::ContentsView* contents_view = | 101 app_list::ContentsView* contents_view = |
102 app_list_view->app_list_main_view()->contents_view(); | 102 app_list_view->app_list_main_view()->contents_view(); |
103 contents_view->SetActiveState(state, app_list_was_open /* animate */); | 103 contents_view->SetActiveState(state, app_list_was_open /* animate */); |
104 } | 104 } |
105 | 105 |
106 base::FilePath AppListServiceAsh::GetProfilePath( | 106 base::FilePath AppListServiceAsh::GetProfilePath( |
107 const base::FilePath& user_data_dir) { | 107 const base::FilePath& user_data_dir) { |
108 return ChromeLauncherController::instance()->profile()->GetPath(); | 108 return ChromeLauncherController::instance()->profile()->GetPath(); |
109 } | 109 } |
110 | 110 |
111 void AppListServiceAsh::ShowForProfile(Profile* /*default_profile*/) { | 111 void AppListServiceAsh::ShowForProfile(Profile* /*default_profile*/) { |
112 // This may not work correctly if the profile passed in is different from the | 112 // This may not work correctly if the profile passed in is different from the |
113 // one the ash Shell is currently using. | 113 // one the ash Shell is currently using. |
114 // TODO(ananta): Handle profile changes correctly when !defined(OS_CHROMEOS). | 114 // TODO(ananta): Handle profile changes correctly when !defined(OS_CHROMEOS). |
115 app_list_shower_->Show(ash::Shell::GetTargetRootWindow()); | 115 app_list_presenter_->Show(ash::Shell::GetTargetRootWindow()); |
116 } | 116 } |
117 | 117 |
118 void AppListServiceAsh::ShowForAppInstall(Profile* profile, | 118 void AppListServiceAsh::ShowForAppInstall(Profile* profile, |
119 const std::string& extension_id, | 119 const std::string& extension_id, |
120 bool start_discovery_tracking) { | 120 bool start_discovery_tracking) { |
121 if (app_list::switches::IsExperimentalAppListEnabled()) | 121 if (app_list::switches::IsExperimentalAppListEnabled()) |
122 ShowAndSwitchToState(app_list::AppListModel::STATE_APPS); | 122 ShowAndSwitchToState(app_list::AppListModel::STATE_APPS); |
123 | 123 |
124 AppListServiceImpl::ShowForAppInstall(profile, extension_id, | 124 AppListServiceImpl::ShowForAppInstall(profile, extension_id, |
125 start_discovery_tracking); | 125 start_discovery_tracking); |
126 } | 126 } |
127 | 127 |
128 void AppListServiceAsh::ShowForCustomLauncherPage(Profile* /*profile*/) { | 128 void AppListServiceAsh::ShowForCustomLauncherPage(Profile* /*profile*/) { |
129 ShowAndSwitchToState(app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE); | 129 ShowAndSwitchToState(app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE); |
130 } | 130 } |
131 | 131 |
132 void AppListServiceAsh::HideCustomLauncherPage() { | 132 void AppListServiceAsh::HideCustomLauncherPage() { |
133 app_list::AppListView* app_list_view = app_list_shower_->GetView(); | 133 app_list::AppListView* app_list_view = app_list_presenter_->GetView(); |
134 if (!app_list_view) | 134 if (!app_list_view) |
135 return; | 135 return; |
136 | 136 |
137 app_list::ContentsView* contents_view = | 137 app_list::ContentsView* contents_view = |
138 app_list_view->app_list_main_view()->contents_view(); | 138 app_list_view->app_list_main_view()->contents_view(); |
139 if (contents_view->IsStateActive( | 139 if (contents_view->IsStateActive( |
140 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)) { | 140 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)) { |
141 contents_view->SetActiveState(app_list::AppListModel::STATE_START, true); | 141 contents_view->SetActiveState(app_list::AppListModel::STATE_START, true); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 bool AppListServiceAsh::IsAppListVisible() const { | 145 bool AppListServiceAsh::IsAppListVisible() const { |
146 return app_list_shower_->GetTargetVisibility(); | 146 return app_list_presenter_->GetTargetVisibility(); |
147 } | 147 } |
148 | 148 |
149 void AppListServiceAsh::DismissAppList() { | 149 void AppListServiceAsh::DismissAppList() { |
150 app_list_shower_->Dismiss(); | 150 app_list_presenter_->Dismiss(); |
151 } | 151 } |
152 | 152 |
153 void AppListServiceAsh::EnableAppList(Profile* initial_profile, | 153 void AppListServiceAsh::EnableAppList(Profile* initial_profile, |
154 AppListEnableSource enable_source) {} | 154 AppListEnableSource enable_source) {} |
155 | 155 |
156 gfx::NativeWindow AppListServiceAsh::GetAppListWindow() { | 156 gfx::NativeWindow AppListServiceAsh::GetAppListWindow() { |
157 return app_list_shower_->GetWindow(); | 157 return app_list_presenter_->GetWindow(); |
158 } | 158 } |
159 | 159 |
160 Profile* AppListServiceAsh::GetCurrentAppListProfile() { | 160 Profile* AppListServiceAsh::GetCurrentAppListProfile() { |
161 return ChromeLauncherController::instance()->profile(); | 161 return ChromeLauncherController::instance()->profile(); |
162 } | 162 } |
163 | 163 |
164 AppListControllerDelegate* AppListServiceAsh::GetControllerDelegate() { | 164 AppListControllerDelegate* AppListServiceAsh::GetControllerDelegate() { |
165 return controller_delegate_.get(); | 165 return controller_delegate_.get(); |
166 } | 166 } |
167 | 167 |
(...skipping 15 matching lines...) Expand all Loading... |
183 return AppListServiceAsh::GetInstance(); | 183 return AppListServiceAsh::GetInstance(); |
184 } | 184 } |
185 | 185 |
186 // static | 186 // static |
187 void AppListService::InitAll(Profile* initial_profile, | 187 void AppListService::InitAll(Profile* initial_profile, |
188 const base::FilePath& profile_path) { | 188 const base::FilePath& profile_path) { |
189 AppListServiceAsh::GetInstance()->Init(initial_profile); | 189 AppListServiceAsh::GetInstance()->Init(initial_profile); |
190 } | 190 } |
191 | 191 |
192 #endif // !defined(OS_WIN) | 192 #endif // !defined(OS_WIN) |
OLD | NEW |