Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / app_list / app_list_service_mac.h
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.
4
5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_MAC_H_
6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_MAC_H_
7
8 #import <Cocoa/Cocoa.h>
9
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"
14
15 class AppListControllerDelegateImpl;
16
17 @class AppListAnimationController;
18 @class AppListWindowController;
19 template <typename T> struct DefaultSingletonTraits;
20
21 namespace gfx {
22 class Display;
23 class Point;
24 }
25
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 {
30  public:
31   virtual ~AppListServiceMac();
32
33   static AppListServiceMac* GetInstance();
34
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);
50
51   void ShowWindowNearDock();
52   void WindowAnimationDidEnd();
53
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;
65
66   // AppListServiceImpl overrides:
67   virtual void CreateShortcut() OVERRIDE;
68
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;
80
81  private:
82   friend struct DefaultSingletonTraits<AppListServiceMac>;
83
84   AppListServiceMac();
85
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_;
90   Profile* profile_;
91   scoped_ptr<AppListControllerDelegateImpl> controller_delegate_;
92
93   DISALLOW_COPY_AND_ASSIGN(AppListServiceMac);
94 };
95
96 #endif  // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_MAC_H_