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

Unified Diff: chrome/browser/ui/ash/app_list/app_list_service_ash.cc

Issue 1874063002: Reland of AppListController refactoring part 3: Switching over to use AppListShower in Ash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mus_chrome_delegates_ash_impl
Patch Set: Created 4 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/app_list/app_list_service_ash.cc
diff --git a/chrome/browser/ui/ash/app_list/app_list_service_ash.cc b/chrome/browser/ui/ash/app_list/app_list_service_ash.cc
index fb76d99edba1ce83e081a4f641fd4c7831af9779..b420c882993b1a57bd44b94d2e8b1b2ffb87d0de 100644
--- a/chrome/browser/ui/ash/app_list/app_list_service_ash.cc
+++ b/chrome/browser/ui/ash/app_list/app_list_service_ash.cc
@@ -4,18 +4,48 @@
#include "chrome/browser/ui/ash/app_list/app_list_service_ash.h"
+#include "ash/app_list/app_list_shower_delegate.h"
+#include "ash/app_list/app_list_shower_delegate_factory.h"
+#include "ash/app_list/app_list_view_delegate_factory.h"
#include "ash/shell.h"
#include "base/files/file_path.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/singleton.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/app_list/app_list_view_delegate.h"
#include "chrome/browser/ui/app_list/start_page_service.h"
#include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
+#include "chrome/browser/ui/ash/session_util.h"
#include "ui/app_list/app_list_switches.h"
+#include "ui/app_list/shower/app_list_shower_delegate_factory.h"
+#include "ui/app_list/shower/app_list_shower_impl.h"
#include "ui/app_list/views/app_list_main_view.h"
#include "ui/app_list/views/app_list_view.h"
#include "ui/app_list/views/contents_view.h"
+
+namespace {
+
+class ViewDelegateFactoryImpl : public ash::AppListViewDelegateFactory {
+ public:
+ explicit ViewDelegateFactoryImpl(AppListServiceImpl* factory)
+ : factory_(factory) {}
+ ~ViewDelegateFactoryImpl() override {}
+
+ // app_list::AppListViewDelegateFactory:
+ app_list::AppListViewDelegate* GetDelegate() override {
+ return factory_->GetViewDelegate(
+ Profile::FromBrowserContext(GetActiveBrowserContext()));
+ }
+
+ private:
+ AppListServiceImpl* factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ViewDelegateFactoryImpl);
+};
+
+} // namespace
// static
AppListServiceAsh* AppListServiceAsh::GetInstance() {
@@ -24,33 +54,19 @@
}
AppListServiceAsh::AppListServiceAsh()
- : controller_delegate_(new AppListControllerDelegateAsh()) {
+ : shower_delegate_factory_(new ash::AppListShowerDelegateFactory(
+ base::WrapUnique(new ViewDelegateFactoryImpl(this)))) {
+ app_list_shower_.reset(
+ new app_list::AppListShowerImpl(shower_delegate_factory_.get()));
+ controller_delegate_.reset(
+ new AppListControllerDelegateAsh(app_list_shower_.get()));
}
AppListServiceAsh::~AppListServiceAsh() {
}
-void AppListServiceAsh::ShowAndSwitchToState(
- app_list::AppListModel::State state) {
- bool app_list_was_open = true;
- app_list::AppListView* app_list_view =
- ash::Shell::GetInstance()->GetAppListView();
- if (!app_list_view) {
- // TODO(calamity): This may cause the app list to show briefly before the
- // state change. If this becomes an issue, add the ability to ash::Shell to
- // load the app list without showing it.
- ash::Shell::GetInstance()->ShowAppList(NULL);
- app_list_was_open = false;
- app_list_view = ash::Shell::GetInstance()->GetAppListView();
- DCHECK(app_list_view);
- }
-
- if (state == app_list::AppListModel::INVALID_STATE)
- return;
-
- app_list::ContentsView* contents_view =
- app_list_view->app_list_main_view()->contents_view();
- contents_view->SetActiveState(state, app_list_was_open /* animate */);
+app_list::AppListShower* AppListServiceAsh::GetAppListShower() {
+ return app_list_shower_.get();
}
void AppListServiceAsh::Init(Profile* initial_profile) {
@@ -63,7 +79,28 @@
}
void AppListServiceAsh::OnProfileWillBeRemoved(
- const base::FilePath& profile_path) {
+ const base::FilePath& profile_path) {}
+
+void AppListServiceAsh::ShowAndSwitchToState(
+ app_list::AppListModel::State state) {
+ bool app_list_was_open = true;
+ app_list::AppListView* app_list_view = app_list_shower_->GetView();
+ if (!app_list_view) {
+ // TODO(calamity): This may cause the app list to show briefly before the
+ // state change. If this becomes an issue, add the ability to ash::Shell to
+ // load the app list without showing it.
+ app_list_shower_->Show(ash::Shell::GetTargetRootWindow());
+ app_list_was_open = false;
+ app_list_view = app_list_shower_->GetView();
+ DCHECK(app_list_view);
+ }
+
+ if (state == app_list::AppListModel::INVALID_STATE)
+ return;
+
+ app_list::ContentsView* contents_view =
+ app_list_view->app_list_main_view()->contents_view();
+ contents_view->SetActiveState(state, app_list_was_open /* animate */);
}
base::FilePath AppListServiceAsh::GetProfilePath(
@@ -75,7 +112,7 @@
// This may not work correctly if the profile passed in is different from the
// one the ash Shell is currently using.
// TODO(ananta): Handle profile changes correctly when !defined(OS_CHROMEOS).
- ash::Shell::GetInstance()->ShowAppList(NULL);
+ app_list_shower_->Show(ash::Shell::GetTargetRootWindow());
}
void AppListServiceAsh::ShowForAppInstall(Profile* profile,
@@ -93,8 +130,7 @@
}
void AppListServiceAsh::HideCustomLauncherPage() {
- app_list::AppListView* app_list_view =
- ash::Shell::GetInstance()->GetAppListView();
+ app_list::AppListView* app_list_view = app_list_shower_->GetView();
if (!app_list_view)
return;
@@ -107,20 +143,18 @@
}
bool AppListServiceAsh::IsAppListVisible() const {
- return ash::Shell::GetInstance()->GetAppListTargetVisibility();
+ return app_list_shower_->GetTargetVisibility();
}
void AppListServiceAsh::DismissAppList() {
- ash::Shell::GetInstance()->DismissAppList();
+ app_list_shower_->Dismiss();
}
void AppListServiceAsh::EnableAppList(Profile* initial_profile,
AppListEnableSource enable_source) {}
gfx::NativeWindow AppListServiceAsh::GetAppListWindow() {
- if (ash::Shell::HasInstance())
- return ash::Shell::GetInstance()->GetAppListWindow();
- return NULL;
+ return app_list_shower_->GetWindow();
}
Profile* AppListServiceAsh::GetCurrentAppListProfile() {

Powered by Google App Engine
This is Rietveld 408576698