Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / app_list / app_list_service.h
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.
4
5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_
6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/ui/host_desktop.h"
13 #include "ui/gfx/native_widget_types.h"
14
15 class AppListControllerDelegate;
16 class PrefRegistrySimple;
17 class Profile;
18
19 namespace base {
20 class CommandLine;
21 class FilePath;
22 }
23
24 namespace gfx {
25 class ImageSkia;
26 }
27
28 class AppListService {
29  public:
30   // Source that triggers the app launcher being enabled. This is used for UMA
31   // to track discoverability of the app lancher shortcut after install. Also
32   // used to provide custom install behavior (e.g. "always" enable).
33   enum AppListEnableSource {
34     ENABLE_NOT_RECORDED,        // Indicates app launcher not recently enabled.
35     ENABLE_FOR_APP_INSTALL,     // Triggered by a webstore packaged app install.
36     ENABLE_VIA_WEBSTORE_LINK,   // Triggered by webstore explicitly via API.
37     ENABLE_VIA_COMMAND_LINE,    // Triggered by --enable-app-list.
38     ENABLE_ON_REINSTALL,        // Triggered by Chrome reinstall finding pref.
39     ENABLE_SHOWN_UNDISCOVERED,  // This overrides a prior ENABLE_FOR_APP_INSTALL
40                                 // when the launcher is auto-shown without
41                                 // being "discovered" beforehand.
42     ENABLE_NUM_ENABLE_SOURCES
43   };
44
45   // Get the AppListService for the current platform and specified
46   // |desktop_type|.
47   static AppListService* Get(chrome::HostDesktopType desktop_type);
48
49   // Call Init for all AppListService instances on this platform.
50   static void InitAll(Profile* initial_profile);
51
52   static void RegisterPrefs(PrefRegistrySimple* registry);
53
54   // Initializes the AppListService, and returns true if |command_line| is for
55   // showing the app list.
56   static bool HandleLaunchCommandLine(const base::CommandLine& command_line,
57                                       Profile* launch_profile);
58
59   // Indicates that |callback| should be called next time the app list is
60   // painted.
61   virtual void SetAppListNextPaintCallback(void (*callback)()) = 0;
62
63   // Perform Chrome first run logic. This is executed before Chrome's threads
64   // have been created.
65   virtual void HandleFirstRun() = 0;
66
67   virtual base::FilePath GetProfilePath(
68       const base::FilePath& user_data_dir) = 0;
69   virtual void SetProfilePath(const base::FilePath& profile_path) = 0;
70
71   // Show the app list for the profile configured in the user data dir for the
72   // current browser process.
73   virtual void Show() = 0;
74
75   // Show the app list for the given profile. If it differs from the profile the
76   // app list is currently showing, repopulate the app list and save the new
77   // profile to local prefs as the default app list profile.
78   virtual void ShowForProfile(Profile* requested_profile) = 0;
79
80   // Shows the app list, and jump to voice search. Used by always-on hotwording.
81   virtual void ShowForVoiceSearch(Profile* profile) = 0;
82
83   // Shows the app list, and reveals the page that contains |extension_id|. This
84   // should only be called for things that show in the app list, and only when
85   // they begin or complete installing. If |start_discovery_tracking| is set,
86   // the app launcher will not actually be shown, but will start tracking UMA
87   // for app launcher discovery.
88   virtual void ShowForAppInstall(Profile* profile,
89                                  const std::string& extension_id,
90                                  bool start_discovery_tracking) = 0;
91
92   // Dismiss the app list.
93   virtual void DismissAppList() = 0;
94
95   // Get the profile the app list is currently showing.
96   virtual Profile* GetCurrentAppListProfile() = 0;
97
98   // Returns true if the app list is visible.
99   virtual bool IsAppListVisible() const = 0;
100
101   // Enable the app list. What this does specifically will depend on the host
102   // operating system and shell.
103   virtual void EnableAppList(Profile* initial_profile,
104                              AppListEnableSource enable_source) = 0;
105
106   // Get the window the app list is in, or NULL if the app list isn't visible.
107   virtual gfx::NativeWindow GetAppListWindow() = 0;
108
109   // Returns a pointer to the platform specific AppListControllerDelegate.
110   virtual AppListControllerDelegate* GetControllerDelegate() = 0;
111
112   // Create a platform-specific shortcut for the app list.
113   virtual void CreateShortcut() = 0;
114
115  protected:
116   AppListService() {}
117   virtual ~AppListService() {}
118
119   // Do any once off initialization needed for the app list.
120   virtual void Init(Profile* initial_profile) = 0;
121
122  private:
123   DISALLOW_COPY_AND_ASSIGN(AppListService);
124 };
125
126 #endif  // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_