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

Unified Diff: chrome/browser/ui/views/app_list/linux/app_list_service_linux.cc

Issue 262643003: Revert of Refactor views app list services to allow more code sharing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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/views/app_list/linux/app_list_service_linux.cc
diff --git a/chrome/browser/ui/views/app_list/linux/app_list_service_linux.cc b/chrome/browser/ui/views/app_list/linux/app_list_service_linux.cc
index d6e0f86659b17fcc79e0c76681ed38fef7a2e8d7..16b19ce958acd5d4ec41d1481ebb5766d8ca00e6 100644
--- a/chrome/browser/ui/views/app_list/linux/app_list_service_linux.cc
+++ b/chrome/browser/ui/views/app_list/linux/app_list_service_linux.cc
@@ -5,11 +5,14 @@
#include "chrome/browser/ui/views/app_list/linux/app_list_service_linux.h"
#include "base/memory/singleton.h"
-#include "base/thread_task_runner_handle.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/shell_integration_linux.h"
-#include "chrome/browser/ui/app_list/app_list_controller_delegate_views.h"
-#include "chrome/browser/ui/app_list/app_list_shower_views.h"
+#include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
+#include "chrome/browser/ui/app_list/app_list_factory.h"
+#include "chrome/browser/ui/app_list/app_list_shower.h"
+#include "chrome/browser/ui/app_list/app_list_view_delegate.h"
+#include "chrome/browser/ui/app_list/scoped_keep_alive.h"
+#include "chrome/browser/ui/views/app_list/linux/app_list_controller_delegate_linux.h"
#include "chrome/browser/ui/views/app_list/linux/app_list_linux.h"
#include "content/public/browser/browser_thread.h"
#include "grit/chromium_strings.h"
@@ -17,8 +20,41 @@
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/views/app_list_view.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/gfx/screen.h"
namespace {
+
+class AppListFactoryLinux : public AppListFactory {
+ public:
+ explicit AppListFactoryLinux(AppListServiceLinux* service)
+ : service_(service) {}
+ virtual ~AppListFactoryLinux() {}
+
+ virtual AppList* CreateAppList(
+ Profile* profile,
+ AppListService* service,
+ const base::Closure& on_should_dismiss) OVERRIDE {
+ // The view delegate will be owned by the app list view. The app list view
+ // manages it's own lifetime.
+ AppListViewDelegate* view_delegate = new AppListViewDelegate(
+ profile, service->GetControllerDelegate());
+ app_list::AppListView* view = new app_list::AppListView(view_delegate);
+ gfx::Point cursor = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
+ view->InitAsBubbleAtFixedLocation(NULL,
+ &pagination_model_,
+ cursor,
+ views::BubbleBorder::FLOAT,
+ false /* border_accepts_events */);
+ return new AppListLinux(view, on_should_dismiss);
+ }
+
+ private:
+ // PaginationModel that is shared across all views.
+ app_list::PaginationModel pagination_model_;
+ AppListServiceLinux* service_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppListFactoryLinux);
+};
void CreateShortcuts() {
std::string app_list_title =
@@ -41,40 +77,65 @@
LeakySingletonTraits<AppListServiceLinux> >::get();
}
+void AppListServiceLinux::set_can_close(bool can_close) {
+ shower_->set_can_close(can_close);
+}
+
+void AppListServiceLinux::OnViewBeingDestroyed() {
+ shower_->HandleViewBeingDestroyed();
+}
+
+void AppListServiceLinux::Init(Profile* initial_profile) {
+ PerformStartupChecks(initial_profile);
+}
+
+void AppListServiceLinux::CreateForProfile(Profile* requested_profile) {
+ shower_->CreateViewForProfile(requested_profile);
+}
+
+void AppListServiceLinux::ShowForProfile(Profile* requested_profile) {
+ DCHECK(requested_profile);
+ if (requested_profile->IsManaged())
+ return;
+
+ ScopedKeepAlive keep_alive;
+
+ InvalidatePendingProfileLoads();
+ SetProfilePath(requested_profile->GetPath());
+ shower_->ShowForProfile(requested_profile);
+ RecordAppListLaunch();
+}
+
+void AppListServiceLinux::DismissAppList() {
+ shower_->DismissAppList();
+}
+
+bool AppListServiceLinux::IsAppListVisible() const {
+ return shower_->IsAppListVisible();
+}
+
+gfx::NativeWindow AppListServiceLinux::GetAppListWindow() {
+ return shower_->GetWindow();
+}
+
+Profile* AppListServiceLinux::GetCurrentAppListProfile() {
+ return shower_->profile();
+}
+
+AppListControllerDelegate* AppListServiceLinux::GetControllerDelegate() {
+ return controller_delegate_.get();
+}
+
void AppListServiceLinux::CreateShortcut() {
content::BrowserThread::PostTask(
content::BrowserThread::FILE, FROM_HERE, base::Bind(&CreateShortcuts));
}
-void AppListServiceLinux::OnActivationChanged(views::Widget* /*widget*/,
- bool active) {
- if (active)
- return;
-
- // Dismiss the app list asynchronously. This must be done asynchronously
- // or our caller will crash, as it expects the app list to remain alive.
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&AppListServiceLinux::DismissAppList, base::Unretained(this)));
-}
-
AppListServiceLinux::AppListServiceLinux()
- : AppListServiceViews(scoped_ptr<AppListControllerDelegate>(
- new AppListControllerDelegateViews(this))) {}
-
-void AppListServiceLinux::OnViewCreated() {
- shower().app_list()->AddObserver(this);
-}
-
-void AppListServiceLinux::OnViewBeingDestroyed() {
- shower().app_list()->RemoveObserver(this);
-}
-
-void AppListServiceLinux::OnViewDismissed() {
-}
-
-void AppListServiceLinux::MoveNearCursor(app_list::AppListView* view) {
- AppListLinux::MoveNearCursor(view);
+ : shower_(new AppListShower(
+ scoped_ptr<AppListFactory>(new AppListFactoryLinux(this)),
+ this)),
+ controller_delegate_(new AppListControllerDelegateLinux(this)) {
}
// static

Powered by Google App Engine
This is Rietveld 408576698