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