12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
50529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "chrome/browser/ui/ash/app_list/app_list_service_ash.h"
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/shell.h"
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/file_path.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/singleton.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/profiles/profile.h"
11424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
140529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch// static
150529e5d033099cbfc42635f6f6183833b09dff6eBen MurdochAppListServiceAsh* AppListServiceAsh::GetInstance() {
160529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  return Singleton<AppListServiceAsh,
170529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                   LeakySingletonTraits<AppListServiceAsh> >::get();
180529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch}
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
20f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)AppListServiceAsh::AppListServiceAsh()
21f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    : controller_delegate_(new AppListControllerDelegateAsh()) {
22f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)}
23f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
24f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)AppListServiceAsh::~AppListServiceAsh() {
25f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)}
26f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)base::FilePath AppListServiceAsh::GetProfilePath(
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const base::FilePath& user_data_dir) {
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return ChromeLauncherController::instance()->profile()->GetPath();
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
32ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdochvoid AppListServiceAsh::CreateForProfile(Profile* default_profile) {}
33ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch
34ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdochvoid AppListServiceAsh::ShowForProfile(Profile* default_profile) {
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // This may not work correctly if the profile passed in is different from the
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // one the ash Shell is currently using.
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // TODO(ananta): Handle profile changes correctly when !defined(OS_CHROMEOS).
386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  ash::Shell::GetInstance()->ShowAppList(NULL);
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool AppListServiceAsh::IsAppListVisible() const {
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return ash::Shell::GetInstance()->GetAppListTargetVisibility();
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void AppListServiceAsh::DismissAppList() {
466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  ash::Shell::GetInstance()->DismissAppList();
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void AppListServiceAsh::EnableAppList(Profile* initial_profile,
505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                      AppListEnableSource enable_source) {}
51a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)gfx::NativeWindow AppListServiceAsh::GetAppListWindow() {
53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  if (ash::Shell::HasInstance())
54868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    return ash::Shell::GetInstance()->GetAppListWindow();
55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  return NULL;
56868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)Profile* AppListServiceAsh::GetCurrentAppListProfile() {
591e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  return ChromeLauncherController::instance()->profile();
601e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}
611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
62f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)AppListControllerDelegate* AppListServiceAsh::GetControllerDelegate() {
63f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  return controller_delegate_.get();
64424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}
65424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid AppListServiceAsh::DestroyAppList() {
671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // On Ash, the app list is torn down whenever it is dismissed, so just ensure
681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // that it is dismissed.
691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  DismissAppList();
701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
72cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Windows and Linux Ash additionally supports a native UI. See
73cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// app_list_service_{win,linux}.cc.
74cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#if defined(OS_CHROMEOS)
75a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
76a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// static
771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) {
780529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  return AppListServiceAsh::GetInstance();
79a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)}
80a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
81a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// static
82a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)void AppListService::InitAll(Profile* initial_profile) {
831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  AppListServiceAsh::GetInstance()->Init(initial_profile);
84a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)}
85a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)
86a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#endif  // !defined(OS_WIN)
87