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 16b19ce958acd5d4ec41d1481ebb5766d8ca00e6..d6e0f86659b17fcc79e0c76681ed38fef7a2e8d7 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,14 +5,11 @@ |
#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.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/app_list/app_list_controller_delegate_views.h" |
+#include "chrome/browser/ui/app_list/app_list_shower_views.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" |
@@ -20,42 +17,9 @@ |
#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 = |
l10n_util::GetStringUTF8(IDS_APP_LIST_SHORTCUT_NAME); |
@@ -77,65 +41,40 @@ AppListServiceLinux* AppListServiceLinux::GetInstance() { |
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::CreateShortcut() { |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::FILE, FROM_HERE, base::Bind(&CreateShortcuts)); |
} |
-void AppListServiceLinux::ShowForProfile(Profile* requested_profile) { |
- DCHECK(requested_profile); |
- if (requested_profile->IsManaged()) |
+void AppListServiceLinux::OnActivationChanged(views::Widget* /*widget*/, |
+ bool active) { |
+ if (active) |
return; |
- ScopedKeepAlive keep_alive; |
- |
- InvalidatePendingProfileLoads(); |
- SetProfilePath(requested_profile->GetPath()); |
- shower_->ShowForProfile(requested_profile); |
- RecordAppListLaunch(); |
-} |
- |
-void AppListServiceLinux::DismissAppList() { |
- shower_->DismissAppList(); |
+ // 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))); |
} |
-bool AppListServiceLinux::IsAppListVisible() const { |
- return shower_->IsAppListVisible(); |
-} |
- |
-gfx::NativeWindow AppListServiceLinux::GetAppListWindow() { |
- return shower_->GetWindow(); |
-} |
+AppListServiceLinux::AppListServiceLinux() |
+ : AppListServiceViews(scoped_ptr<AppListControllerDelegate>( |
+ new AppListControllerDelegateViews(this))) {} |
-Profile* AppListServiceLinux::GetCurrentAppListProfile() { |
- return shower_->profile(); |
+void AppListServiceLinux::OnViewCreated() { |
+ shower().app_list()->AddObserver(this); |
} |
-AppListControllerDelegate* AppListServiceLinux::GetControllerDelegate() { |
- return controller_delegate_.get(); |
+void AppListServiceLinux::OnViewBeingDestroyed() { |
+ shower().app_list()->RemoveObserver(this); |
} |
-void AppListServiceLinux::CreateShortcut() { |
- content::BrowserThread::PostTask( |
- content::BrowserThread::FILE, FROM_HERE, base::Bind(&CreateShortcuts)); |
+void AppListServiceLinux::OnViewDismissed() { |
} |
-AppListServiceLinux::AppListServiceLinux() |
- : shower_(new AppListShower( |
- scoped_ptr<AppListFactory>(new AppListFactoryLinux(this)), |
- this)), |
- controller_delegate_(new AppListControllerDelegateLinux(this)) { |
+void AppListServiceLinux::MoveNearCursor(app_list::AppListView* view) { |
+ AppListLinux::MoveNearCursor(view); |
} |
// static |