1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/app_list/linux/app_list_service_linux.h"
7 #include "base/memory/singleton.h"
8 #include "base/thread_task_runner_handle.h"
9 #include "chrome/browser/shell_integration.h"
10 #include "chrome/browser/shell_integration_linux.h"
11 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
12 #include "chrome/browser/ui/app_list/app_list_controller_delegate_views.h"
13 #include "chrome/browser/ui/app_list/app_list_shower_views.h"
14 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
15 #include "chrome/browser/ui/app_list/scoped_keep_alive.h"
16 #include "chrome/browser/ui/ash/app_list/app_list_service_ash.h"
17 #include "chrome/browser/ui/views/app_list/linux/app_list_linux.h"
18 #include "content/public/browser/browser_thread.h"
19 #include "grit/chromium_strings.h"
20 #include "grit/google_chrome_strings.h"
21 #include "ui/app_list/app_list_constants.h"
22 #include "ui/app_list/views/app_list_view.h"
23 #include "ui/base/l10n/l10n_util.h"
27 void CreateShortcuts() {
28 std::string app_list_title =
29 l10n_util::GetStringUTF8(IDS_APP_LIST_SHORTCUT_NAME);
31 if (!shell_integration_linux::CreateAppListDesktopShortcut(
32 app_list::kAppListWMClass,
34 LOG(WARNING) << "Unable to create App Launcher shortcut.";
40 AppListServiceLinux::~AppListServiceLinux() {}
43 AppListServiceLinux* AppListServiceLinux::GetInstance() {
44 return Singleton<AppListServiceLinux,
45 LeakySingletonTraits<AppListServiceLinux> >::get();
48 void AppListServiceLinux::CreateShortcut() {
49 content::BrowserThread::PostTask(
50 content::BrowserThread::FILE, FROM_HERE, base::Bind(&CreateShortcuts));
53 void AppListServiceLinux::OnActivationChanged(views::Widget* /*widget*/,
58 // Dismiss the app list asynchronously. This must be done asynchronously
59 // or our caller will crash, as it expects the app list to remain alive.
60 base::ThreadTaskRunnerHandle::Get()->PostTask(
62 base::Bind(&AppListServiceLinux::DismissAppList, base::Unretained(this)));
65 AppListServiceLinux::AppListServiceLinux()
66 : AppListServiceViews(scoped_ptr<AppListControllerDelegate>(
67 new AppListControllerDelegateViews(this))) {}
69 void AppListServiceLinux::OnViewCreated() {
70 shower().app_list()->AddObserver(this);
73 void AppListServiceLinux::OnViewBeingDestroyed() {
74 shower().app_list()->RemoveObserver(this);
75 AppListServiceViews::OnViewBeingDestroyed();
78 void AppListServiceLinux::OnViewDismissed() {
81 void AppListServiceLinux::MoveNearCursor(app_list::AppListView* view) {
82 AppListLinux::MoveNearCursor(view);
86 AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) {
87 if (desktop_type == chrome::HOST_DESKTOP_TYPE_ASH)
88 return AppListServiceAsh::GetInstance();
90 return AppListServiceLinux::GetInstance();
94 void AppListService::InitAll(Profile* initial_profile) {
95 AppListServiceAsh::GetInstance()->Init(initial_profile);
96 AppListServiceLinux::GetInstance()->Init(initial_profile);