app_list_service.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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) 52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_ 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_ 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <string> 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/basictypes.h" 112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/compiler_specific.h" 121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "chrome/browser/ui/host_desktop.h" 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/gfx/native_widget_types.h" 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class AppListControllerDelegate; 1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class CommandLine; 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class PrefRegistrySimple; 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Profile; 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace base { 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class FilePath; 222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace gfx { 252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ImageSkia; 262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 28a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)class AppListService { 292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public: 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Source that triggers the app launcher being enabled. This is used for UMA 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // to track discoverability of the app lancher shortcut after install. 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) enum AppListEnableSource { 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ENABLE_NOT_RECORDED, // Indicates app launcher not recently enabled. 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ENABLE_FOR_APP_INSTALL, // Triggered by a webstore packaged app install. 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ENABLE_VIA_WEBSTORE_LINK, // Triggered by webstore explicitly via API. 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ENABLE_VIA_COMMAND_LINE, // Triggered by --enable-app-list. 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ENABLE_ON_REINSTALL, // Triggered by Chrome reinstall finding pref. 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ENABLE_SHOWN_UNDISCOVERED, // This overrides a prior ENABLE_FOR_APP_INSTALL 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // when the launcher is auto-shown without 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // being "discovered" beforehand. 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ENABLE_NUM_ENABLE_SOURCES 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) }; 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Get the AppListService for the current platform and specified 451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // |desktop_type|. 461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) static AppListService* Get(chrome::HostDesktopType desktop_type); 472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Call Init for all AppListService instances on this platform. 492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static void InitAll(Profile* initial_profile); 502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static void RegisterPrefs(PrefRegistrySimple* registry); 522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 53ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch static void RecordShowTimings(const CommandLine& command_line); 54ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 553551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Indicates that |callback| should be called next time the app list is 563551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // painted. 57f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual void SetAppListNextPaintCallback(void (*callback)()) = 0; 583551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 59ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Perform Chrome first run logic. This is executed before Chrome's threads 60ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // have been created. 61ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch virtual void HandleFirstRun() = 0; 62ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch 6390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual base::FilePath GetProfilePath( 64a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const base::FilePath& user_data_dir) = 0; 65ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch virtual void SetProfilePath(const base::FilePath& profile_path) = 0; 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 67ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Show the app list for the profile configured in the user data dir for the 68ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // current browser process. 69ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch virtual void Show() = 0; 7090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 71ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch // Create the app list UI, and maintain its state, but do not show it. 72ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch virtual void CreateForProfile(Profile* requested_profile) = 0; 73ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 74ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Show the app list for the given profile. If it differs from the profile the 75ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // app list is currently showing, repopulate the app list and save the new 76ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // profile to local prefs as the default app list profile. 77ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch virtual void ShowForProfile(Profile* requested_profile) = 0; 782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Show the app list due to a trigger which was not an explicit user action 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // to show the app list. E.g. the auto-show when installing an app. This 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // permits UMA to distinguish between a user discovering the app list shortcut 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // themselves versus having it shown for them automatically. 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void AutoShowForProfile(Profile* requested_profile) = 0; 845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Dismiss the app list. 86a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual void DismissAppList() = 0; 87a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Get the profile the app list is currently showing. 89a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual Profile* GetCurrentAppListProfile() = 0; 902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Returns true if the app list is visible. 92a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual bool IsAppListVisible() const = 0; 932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 94c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Enable the app list. What this does specifically will depend on the host 95c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // operating system and shell. 965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void EnableAppList(Profile* initial_profile, 975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AppListEnableSource enable_source) = 0; 982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 99868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Get the window the app list is in, or NULL if the app list isn't visible. 100868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual gfx::NativeWindow GetAppListWindow() = 0; 101868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 102f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Returns a pointer to the platform specific AppListControllerDelegate. 103f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual AppListControllerDelegate* GetControllerDelegate() = 0; 104a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) protected: 1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) AppListService() {} 1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual ~AppListService() {} 1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Do any once off initialization needed for the app list. 110a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual void Init(Profile* initial_profile) = 0; 1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private: 1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(AppListService); 1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_H_ 117