app_list_service.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
15e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org// Copyright 2013 The Chromium Authors. All rights reserved.
25e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org// Use of this source code is governed by a BSD-style license that can be
35e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org// found in the LICENSE file.
45e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org
55e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org#ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_
65e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org#define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_
75e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org
85e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org#include <string>
95e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org
105e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org#include "base/basictypes.h"
115e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org#include "base/compiler_specific.h"
125e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org#include "chrome/browser/ui/host_desktop.h"
135e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org#include "ui/gfx/native_widget_types.h"
145e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org
155e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.orgclass AppListControllerDelegate;
165e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.orgclass PrefRegistrySimple;
175e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.orgclass Profile;
185e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org
195e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.orgnamespace base {
205e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.orgclass CommandLine;
215e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.orgclass FilePath;
225e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org}
235e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org
245e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.orgnamespace gfx {
255e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.orgclass ImageSkia;
265e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org}
270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass AppListService {
290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public:
300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Source that triggers the app launcher being enabled. This is used for UMA
310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // to track discoverability of the app lancher shortcut after install. Also
320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // used to provide custom install behavior (e.g. "always" enable).
330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  enum AppListEnableSource {
340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    ENABLE_NOT_RECORDED,        // Indicates app launcher not recently enabled.
35cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org    ENABLE_FOR_APP_INSTALL,     // Triggered by a webstore packaged app install.
360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    ENABLE_VIA_WEBSTORE_LINK,   // Triggered by webstore explicitly via API.
372a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org    ENABLE_VIA_COMMAND_LINE,    // Triggered by --enable-app-list.
380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    ENABLE_ON_REINSTALL,        // Triggered by Chrome reinstall finding pref.
390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    ENABLE_SHOWN_UNDISCOVERED,  // This overrides a prior ENABLE_FOR_APP_INSTALL
400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                                // when the launcher is auto-shown without
410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                                // being "discovered" beforehand.
420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    ENABLE_NUM_ENABLE_SOURCES
430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  };
440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Get the AppListService for the current platform and specified
462a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  // |desktop_type|.
472a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  static AppListService* Get(chrome::HostDesktopType desktop_type);
480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Call Init for all AppListService instances on this platform.
500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static void InitAll(Profile* initial_profile);
510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static void RegisterPrefs(PrefRegistrySimple* registry);
530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static void RecordShowTimings(const base::CommandLine& command_line);
550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Indicates that |callback| should be called next time the app list is
572a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  // painted.
585c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org  virtual void SetAppListNextPaintCallback(void (*callback)()) = 0;
590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
602a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  // Perform Chrome first run logic. This is executed before Chrome's threads
610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // have been created.
620e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual void HandleFirstRun() = 0;
630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual base::FilePath GetProfilePath(
655e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org      const base::FilePath& user_data_dir) = 0;
665e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org  virtual void SetProfilePath(const base::FilePath& profile_path) = 0;
675e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org
684318280f56990bbbd758f6f5e49b5719100f9951buildbot@webrtc.org  // Show the app list for the profile configured in the user data dir for the
695e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org  // current browser process.
704318280f56990bbbd758f6f5e49b5719100f9951buildbot@webrtc.org  virtual void Show() = 0;
714318280f56990bbbd758f6f5e49b5719100f9951buildbot@webrtc.org
724318280f56990bbbd758f6f5e49b5719100f9951buildbot@webrtc.org  // Create the app list UI, and maintain its state, but do not show it.
735e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org  virtual void CreateForProfile(Profile* requested_profile) = 0;
745e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org
755e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org  // Show the app list for the given profile. If it differs from the profile the
765e89dbd355e720d82139013c5e56d005208d51c8guoweis@webrtc.org  // app list is currently showing, repopulate the app list and save the new
770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // profile to local prefs as the default app list profile.
780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual void ShowForProfile(Profile* requested_profile) = 0;
790e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Show the app list due to a trigger which was not an explicit user action
810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // to show the app list. E.g. the auto-show when installing an app. This
820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // permits UMA to distinguish between a user discovering the app list shortcut
830e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // themselves versus having it shown for them automatically.
840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual void AutoShowForProfile(Profile* requested_profile) = 0;
850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
860e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Dismiss the app list.
870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual void DismissAppList() = 0;
880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Get the profile the app list is currently showing.
900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual Profile* GetCurrentAppListProfile() = 0;
910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Returns true if the app list is visible.
930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual bool IsAppListVisible() const = 0;
940e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
950e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Enable the app list. What this does specifically will depend on the host
960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // operating system and shell.
970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual void EnableAppList(Profile* initial_profile,
980e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                             AppListEnableSource enable_source) = 0;
990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1000e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Get the window the app list is in, or NULL if the app list isn't visible.
1012a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  virtual gfx::NativeWindow GetAppListWindow() = 0;
1022a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org
1032a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  // Returns a pointer to the platform specific AppListControllerDelegate.
1042a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  virtual AppListControllerDelegate* GetControllerDelegate() = 0;
1050e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1060e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org protected:
1070e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  AppListService() {}
1080e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual ~AppListService() {}
1090e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Do any once off initialization needed for the app list.
1112a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  virtual void Init(Profile* initial_profile) = 0;
1122a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org
1130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org private:
1140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  DISALLOW_COPY_AND_ASSIGN(AppListService);
1152a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org};
1160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#endif  // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_
1180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org