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 "apps/app_shim/app_shim_handler_mac.h"
11 #include "base/mac/scoped_nsobject.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/ui/app_list/app_list_service_impl.h"
15 class AppListControllerDelegateImpl
;
17 @
class AppListAnimationController
;
18 @
class AppListWindowController
;
19 template <typename T
> struct DefaultSingletonTraits
;
26 // AppListServiceMac manages global resources needed for the app list to
27 // operate, and controls when the app list is opened and closed.
28 class AppListServiceMac
: public AppListServiceImpl
,
29 public apps::AppShimHandler
{
31 virtual ~AppListServiceMac();
33 static AppListServiceMac
* GetInstance();
35 // Finds the position for a window to anchor it to the dock. This chooses the
36 // most appropriate position for the window based on whether the dock exists,
37 // the position of the dock (calculated by the difference between the display
38 // bounds and display work area), whether the mouse cursor is visible and its
39 // position. Sets |target_origin| to the coordinates for the window to appear
40 // at, and |start_origin| to the coordinates the window should begin animating
41 // from. Coordinates are for the bottom-left coordinate of the window, in
42 // AppKit space (Y positive is up).
43 static void FindAnchorPoint(const gfx::Size
& window_size
,
44 const gfx::Display
& display
,
45 int primary_display_height
,
46 bool cursor_is_visible
,
47 const gfx::Point
& cursor
,
48 NSPoint
* target_origin
,
49 NSPoint
* start_origin
);
51 void ShowWindowNearDock();
52 void WindowAnimationDidEnd();
54 // AppListService overrides:
55 virtual void Init(Profile
* initial_profile
) OVERRIDE
;
56 virtual void CreateForProfile(Profile
* requested_profile
) OVERRIDE
;
57 virtual void ShowForProfile(Profile
* requested_profile
) OVERRIDE
;
58 virtual void DismissAppList() OVERRIDE
;
59 virtual bool IsAppListVisible() const OVERRIDE
;
60 virtual void EnableAppList(Profile
* initial_profile
,
61 AppListEnableSource enable_source
) OVERRIDE
;
62 virtual gfx::NativeWindow
GetAppListWindow() OVERRIDE
;
63 virtual AppListControllerDelegate
* GetControllerDelegate() OVERRIDE
;
64 virtual Profile
* GetCurrentAppListProfile() OVERRIDE
;
66 // AppListServiceImpl overrides:
67 virtual void CreateShortcut() OVERRIDE
;
69 // AppShimHandler overrides:
70 virtual void OnShimLaunch(apps::AppShimHandler::Host
* host
,
71 apps::AppShimLaunchType launch_type
,
72 const std::vector
<base::FilePath
>& files
) OVERRIDE
;
73 virtual void OnShimClose(apps::AppShimHandler::Host
* host
) OVERRIDE
;
74 virtual void OnShimFocus(apps::AppShimHandler::Host
* host
,
75 apps::AppShimFocusType focus_type
,
76 const std::vector
<base::FilePath
>& files
) OVERRIDE
;
77 virtual void OnShimSetHidden(apps::AppShimHandler::Host
* host
,
78 bool hidden
) OVERRIDE
;
79 virtual void OnShimQuit(apps::AppShimHandler::Host
* host
) OVERRIDE
;
82 friend struct DefaultSingletonTraits
<AppListServiceMac
>;
86 base::scoped_nsobject
<AppListWindowController
> window_controller_
;
87 base::scoped_nsobject
<AppListAnimationController
> animation_controller_
;
88 base::scoped_nsobject
<NSRunningApplication
> previously_active_application_
;
89 NSPoint last_start_origin_
;
91 scoped_ptr
<AppListControllerDelegateImpl
> controller_delegate_
;
93 DISALLOW_COPY_AND_ASSIGN(AppListServiceMac
);
96 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_MAC_H_