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