12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_CONTROLLER_DELEGATE_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CHROME_BROWSER_UI_APP_LIST_APP_LIST_CONTROLLER_DELEGATE_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "chrome/common/extensions/extension_constants.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/native_widget_types.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Profile;
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)namespace base {
1668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)class FilePath;
1768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)}
1868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace extensions {
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Extension;
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class ExtensionSet;
220f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)class InstallTracker;
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace gfx {
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ImageSkia;
27cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class Rect;
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Interface to allow the view delegate to call out to whatever is controlling
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the app list. This will have different implementations for different
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// platforms.
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class AppListControllerDelegate {
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
3568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // Indicates the source of an app list activation, for tracking purposes.
3668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  enum AppListSource {
3768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)    LAUNCH_FROM_UNKNOWN,
3868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)    LAUNCH_FROM_APP_LIST,
3968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)    LAUNCH_FROM_APP_LIST_SEARCH
4068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  };
4168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
424e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // Whether apps can be pinned, and whether pinned apps are editable or fixed.
434e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  enum Pinnable {
444e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    NO_PIN,
454e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    PIN_EDITABLE,
464e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    PIN_FIXED
474e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  };
484e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~AppListControllerDelegate();
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
51f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // Whether to force the use of a native desktop widget when the app list
52f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // window is first created.
53f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual bool ForceNativeDesktop() const;
54f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Dismisses the view.
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void DismissView() = 0;
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Handle the view being closed.
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ViewClosing();
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Get app list window.
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual gfx::NativeWindow GetAppListWindow() = 0;
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
64cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // Get the content bounds of the app list in the screen. On platforms that
65cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // use views, this returns the bounds of the AppListView. Without views, this
66cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // returns a 0x0 rectangle.
67cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual gfx::Rect GetAppListBounds();
68cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Get the application icon to be used, if any, for the app list.
701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual gfx::ImageSkia GetWindowIcon() = 0;
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Control of pinning apps.
731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual bool IsAppPinned(const std::string& extension_id) = 0;
741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual void PinApp(const std::string& extension_id) = 0;
751e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual void UnpinApp(const std::string& extension_id) = 0;
764e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual Pinnable GetPinnable() = 0;
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
78cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // Called before and after a dialog opens in the app list. For example,
79cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // displays an overlay that disables the app list while the dialog is open.
80cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual void OnShowChildDialog();
81cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual void OnCloseChildDialog();
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
83eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // Whether the controller supports a Create Shortcuts flow.
841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual bool CanDoCreateShortcutsFlow() = 0;
858bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // Show the dialog to create shortcuts. Call only if
878bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // CanDoCreateShortcutsFlow() returns true.
881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual void DoCreateShortcutsFlow(Profile* profile,
891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                                     const std::string& extension_id) = 0;
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Whether the controller supports a Show App Info flow.
925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual bool CanDoShowAppInfoFlow();
935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Show the dialog with the application's information. Call only if
955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // CanDoShowAppInfoFlow() returns true.
965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void DoShowAppInfoFlow(Profile* profile,
975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                 const std::string& extension_id);
985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Handle the "create window" context menu items of Chrome App.
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |incognito| is true to create an incognito window.
1011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual void CreateNewWindow(Profile* profile, bool incognito) = 0;
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Show the app's most recent window, or launch it if it is not running.
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ActivateApp(Profile* profile,
1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                           const extensions::Extension* extension,
10668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)                           AppListSource source,
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           int event_flags) = 0;
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Launch the app.
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void LaunchApp(Profile* profile,
1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                         const extensions::Extension* extension,
11268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)                         AppListSource source,
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                         int event_flags) = 0;
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // Show the app list for the profile specified by |profile_path|.
11668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  virtual void ShowForProfileByPath(const base::FilePath& profile_path) = 0;
11768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Whether or not the icon indicating which user is logged in should be
1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // visible.
1201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual bool ShouldShowUserIcon() = 0;
12168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
12268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  static std::string AppListSourceToString(AppListSource source);
1231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // True if the user has permission to modify the given app's settings.
1251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  bool UserMayModifySettings(Profile* profile, const std::string& app_id);
1261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Uninstall the app identified by |app_id| from |profile|.
1281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void UninstallApp(Profile* profile, const std::string& app_id);
1291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // True if the app was installed from the web store.
1311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  bool IsAppFromWebStore(Profile* profile,
1321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                         const std::string& app_id);
1331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Shows the user the webstore site for the given app.
1351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void ShowAppInWebStore(Profile* profile,
1361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                         const std::string& app_id,
1371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                         bool is_search_result);
1381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // True if the given extension has an options page.
1401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  bool HasOptionsPage(Profile* profile, const std::string& app_id);
1411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Shows the user the options page for the app.
1431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void ShowOptionsPage(Profile* profile, const std::string& app_id);
1441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Gets/sets the launch type for an app.
1461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // The launch type specifies whether a hosted app should launch as a separate
1471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // window, fullscreened or as a tab.
148a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  extensions::LaunchType GetExtensionLaunchType(
1491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      Profile* profile, const std::string& app_id);
1501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual void SetExtensionLaunchType(
1511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      Profile* profile,
1521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      const std::string& extension_id,
153a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      extensions::LaunchType launch_type);
1541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1551e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Returns true if the given extension is installed.
1561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  bool IsExtensionInstalled(Profile* profile, const std::string& app_id);
1571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1580f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)  extensions::InstallTracker* GetInstallTrackerFor(Profile* profile);
1590f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
1600f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)  // Get the list of installed apps for the given profile.
1615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void GetApps(Profile* profile, extensions::ExtensionSet* out_apps);
162a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
163a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // Called when a search is started using the app list search box.
164a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  void OnSearchStarted();
1652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // CHROME_BROWSER_UI_APP_LIST_APP_LIST_CONTROLLER_DELEGATE_H_
168