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.
5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_MAC_H_
6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_MAC_H_
8 #import <Cocoa/Cocoa.h>
10 #include "base/mac/scoped_nsobject.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/apps/app_shim/app_shim_handler_mac.h"
13 #include "chrome/browser/ui/app_list/app_list_service_impl.h"
15 @
class AppListAnimationController
;
22 // AppListServiceMac manages global resources needed for the app list to
23 // operate, and controls when and how the app list is opened and closed.
24 class AppListServiceMac
: public AppListServiceImpl
,
25 public apps::AppShimHandler
{
27 ~AppListServiceMac() override
;
29 // Finds the position for a window to anchor it to the dock. This chooses the
30 // most appropriate position for the window based on whether the dock exists,
31 // the position of the dock (calculated by the difference between the display
32 // bounds and display work area), whether the mouse cursor is visible and its
33 // position. Sets |target_origin| to the coordinates for the window to appear
34 // at, and |start_origin| to the coordinates the window should begin animating
35 // from. Coordinates are for the bottom-left coordinate of the window, in
36 // AppKit space (Y positive is up).
37 static void FindAnchorPoint(const gfx::Size
& window_size
,
38 const gfx::Display
& display
,
39 int primary_display_height
,
40 bool cursor_is_visible
,
41 const gfx::Point
& cursor
,
42 NSPoint
* target_origin
,
43 NSPoint
* start_origin
);
45 void ShowWindowNearDock();
46 void WindowAnimationDidEnd();
47 void InitWithProfilePath(Profile
* initial_profile
,
48 const base::FilePath
& profile_path
);
50 // AppListService overrides:
51 void Init(Profile
* initial_profile
) override
;
52 void DismissAppList() override
;
53 void ShowForCustomLauncherPage(Profile
* profile
) override
;
54 void HideCustomLauncherPage() override
;
55 bool IsAppListVisible() const override
;
56 void EnableAppList(Profile
* initial_profile
,
57 AppListEnableSource enable_source
) override
;
58 gfx::NativeWindow
GetAppListWindow() override
;
59 void CreateShortcut() override
;
61 // AppShimHandler overrides:
62 void OnShimLaunch(apps::AppShimHandler::Host
* host
,
63 apps::AppShimLaunchType launch_type
,
64 const std::vector
<base::FilePath
>& files
) override
;
65 void OnShimClose(apps::AppShimHandler::Host
* host
) override
;
66 void OnShimFocus(apps::AppShimHandler::Host
* host
,
67 apps::AppShimFocusType focus_type
,
68 const std::vector
<base::FilePath
>& files
) override
;
69 void OnShimSetHidden(apps::AppShimHandler::Host
* host
, bool hidden
) override
;
70 void OnShimQuit(apps::AppShimHandler::Host
* host
) override
;
75 // Returns the native window for the app list, or nil if can't be shown yet.
76 // Note that, unlike GetAppListWindow(), this does not return null when the
77 // app list is loaded, but not visible.
78 virtual NSWindow
* GetNativeWindow() const = 0;
80 // If the app list is loaded, return true. Otherwise, if supported,
81 // synchronously prepare an unpopulated app list window to begin showing on
82 // screen and return true. If that's not supported, return false.
83 virtual bool ReadyToShow() = 0;
86 base::scoped_nsobject
<AppListAnimationController
> animation_controller_
;
87 base::scoped_nsobject
<NSRunningApplication
> previously_active_application_
;
88 NSPoint last_start_origin_
;
90 DISALLOW_COPY_AND_ASSIGN(AppListServiceMac
);
93 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_MAC_H_