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

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

Issue 1770993002: wip: Refactoring Ash's AppListController, moving the bulk of the logic to chrome/browser/ui/ash/app… Base URL: https://chromium.googlesource.com/chromium/src.git@small_5_apps
Patch Set: Added a comment for PostTask in AppListServiceAsh. Created 4 years, 9 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..ac56053423e45026fc552d33e78f06121ae5d204 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,14 +4,16 @@
#include "chrome/browser/ui/ash/app_list/app_list_service_ash.h"
-#include "ash/shell.h"
#include "base/files/file_path.h"
#include "base/memory/singleton.h"
+#include "base/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.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/app_list/app_list_shower_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/views/app_list_main_view.h"
#include "ui/app_list/views/app_list_view.h"
@@ -24,24 +26,53 @@ AppListServiceAsh* AppListServiceAsh::GetInstance() {
}
AppListServiceAsh::AppListServiceAsh()
- : controller_delegate_(new AppListControllerDelegateAsh()) {
+ : app_list_shower_(new AppListShowerAsh()) {
+ controller_delegate_.reset(
+ new AppListControllerDelegateAsh(app_list_shower_.get()));
+ // The PostTask is necessary because getting AppListViewDelegate requires a
+ // Profile to be set on AppListViewDelegate, which requires the
+ // AppListService to be already created.
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&AppListServiceAsh::SetViewDelegateForShower,
+ base::Unretained(this)));
xiyuan 2016/03/11 18:36:00 We should figure out a way to get rid of this Post
mfomitchev 2016/03/24 17:47:29 Done.
}
AppListServiceAsh::~AppListServiceAsh() {
}
+app_list::AppListController* AppListServiceAsh::GetAppListController() {
+ return app_list_shower_.get();
+}
+
+void AppListServiceAsh::Init(Profile* initial_profile) {
+ // Ensure the StartPageService is created here. This early initialization is
+ // necessary to allow the WebContents to load before the app list is shown.
+ app_list::StartPageService* service =
+ app_list::StartPageService::Get(initial_profile);
+ if (service)
+ service->Init();
+}
+
+void AppListServiceAsh::OnProfileWillBeRemoved(
+ const base::FilePath& profile_path) {}
+
+void AppListServiceAsh::SetViewDelegateForShower() {
+ AppListViewDelegate* view_delegate =
+ GetViewDelegate(Profile::FromBrowserContext(GetActiveBrowserContext()));
+ app_list_shower_->set_view_delegate(view_delegate);
+}
+
void AppListServiceAsh::ShowAndSwitchToState(
app_list::AppListModel::State state) {
bool app_list_was_open = true;
- app_list::AppListView* app_list_view =
- ash::Shell::GetInstance()->GetAppListView();
+ 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.
- ash::Shell::GetInstance()->ShowAppList(NULL);
+ app_list_shower_->Show(NULL);
app_list_was_open = false;
- app_list_view = ash::Shell::GetInstance()->GetAppListView();
+ app_list_view = app_list_shower_->GetView();
DCHECK(app_list_view);
}
@@ -53,19 +84,6 @@ void AppListServiceAsh::ShowAndSwitchToState(
contents_view->SetActiveState(state, app_list_was_open /* animate */);
}
-void AppListServiceAsh::Init(Profile* initial_profile) {
- // Ensure the StartPageService is created here. This early initialization is
- // necessary to allow the WebContents to load before the app list is shown.
- app_list::StartPageService* service =
- app_list::StartPageService::Get(initial_profile);
- if (service)
- service->Init();
-}
-
-void AppListServiceAsh::OnProfileWillBeRemoved(
- const base::FilePath& profile_path) {
-}
-
base::FilePath AppListServiceAsh::GetProfilePath(
const base::FilePath& user_data_dir) {
return ChromeLauncherController::instance()->profile()->GetPath();
@@ -75,7 +93,7 @@ void AppListServiceAsh::ShowForProfile(Profile* /*default_profile*/) {
// 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(NULL);
}
void AppListServiceAsh::ShowForAppInstall(Profile* profile,
@@ -93,8 +111,7 @@ void AppListServiceAsh::ShowForCustomLauncherPage(Profile* /*profile*/) {
}
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 +124,18 @@ void AppListServiceAsh::HideCustomLauncherPage() {
}
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