| Index: trunk/src/chrome/browser/ui/views/app_list/linux/app_list_service_linux.cc
|
| ===================================================================
|
| --- trunk/src/chrome/browser/ui/views/app_list/linux/app_list_service_linux.cc (revision 267382)
|
| +++ trunk/src/chrome/browser/ui/views/app_list/linux/app_list_service_linux.cc (working copy)
|
| @@ -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,9 +20,42 @@
|
| #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);
|
| @@ -41,42 +77,67 @@
|
| LeakySingletonTraits<AppListServiceLinux> >::get();
|
| }
|
|
|
| -void AppListServiceLinux::CreateShortcut() {
|
| - content::BrowserThread::PostTask(
|
| - content::BrowserThread::FILE, FROM_HERE, base::Bind(&CreateShortcuts));
|
| +void AppListServiceLinux::set_can_close(bool can_close) {
|
| + shower_->set_can_close(can_close);
|
| }
|
|
|
| -void AppListServiceLinux::OnActivationChanged(views::Widget* /*widget*/,
|
| - bool active) {
|
| - if (active)
|
| +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;
|
|
|
| - // 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)));
|
| + ScopedKeepAlive keep_alive;
|
| +
|
| + InvalidatePendingProfileLoads();
|
| + SetProfilePath(requested_profile->GetPath());
|
| + shower_->ShowForProfile(requested_profile);
|
| + RecordAppListLaunch();
|
| }
|
|
|
| -AppListServiceLinux::AppListServiceLinux()
|
| - : AppListServiceViews(scoped_ptr<AppListControllerDelegate>(
|
| - new AppListControllerDelegateViews(this))) {}
|
| +void AppListServiceLinux::DismissAppList() {
|
| + shower_->DismissAppList();
|
| +}
|
|
|
| -void AppListServiceLinux::OnViewCreated() {
|
| - shower().app_list()->AddObserver(this);
|
| +bool AppListServiceLinux::IsAppListVisible() const {
|
| + return shower_->IsAppListVisible();
|
| }
|
|
|
| -void AppListServiceLinux::OnViewBeingDestroyed() {
|
| - shower().app_list()->RemoveObserver(this);
|
| +gfx::NativeWindow AppListServiceLinux::GetAppListWindow() {
|
| + return shower_->GetWindow();
|
| }
|
|
|
| -void AppListServiceLinux::OnViewDismissed() {
|
| +Profile* AppListServiceLinux::GetCurrentAppListProfile() {
|
| + return shower_->profile();
|
| }
|
|
|
| -void AppListServiceLinux::MoveNearCursor(app_list::AppListView* view) {
|
| - AppListLinux::MoveNearCursor(view);
|
| +AppListControllerDelegate* AppListServiceLinux::GetControllerDelegate() {
|
| + return controller_delegate_.get();
|
| }
|
|
|
| +void AppListServiceLinux::CreateShortcut() {
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::FILE, FROM_HERE, base::Bind(&CreateShortcuts));
|
| +}
|
| +
|
| +AppListServiceLinux::AppListServiceLinux()
|
| + : shower_(new AppListShower(
|
| + scoped_ptr<AppListFactory>(new AppListFactoryLinux(this)),
|
| + this)),
|
| + controller_delegate_(new AppListControllerDelegateLinux(this)) {
|
| +}
|
| +
|
| // static
|
| AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) {
|
| return AppListServiceLinux::GetInstance();
|
|
|