Update To 11.40.268.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 "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"
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 namespace test {
27 class AppListServiceMacTestApi;
28 }
29
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 {
34  public:
35   ~AppListServiceMac() override;
36
37   static AppListServiceMac* GetInstance();
38
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);
54
55   void ShowWindowNearDock();
56   void WindowAnimationDidEnd();
57
58   // AppListService overrides:
59   void Init(Profile* initial_profile) override;
60   void ShowForProfile(Profile* requested_profile) override;
61   void DismissAppList() override;
62   bool IsAppListVisible() const override;
63   void EnableAppList(Profile* initial_profile,
64                      AppListEnableSource enable_source) override;
65   gfx::NativeWindow GetAppListWindow() override;
66   AppListControllerDelegate* GetControllerDelegate() override;
67   Profile* GetCurrentAppListProfile() override;
68   void CreateShortcut() override;
69
70   // AppListServiceImpl overrides:
71   void CreateForProfile(Profile* requested_profile) override;
72   void DestroyAppList() override;
73
74   // AppShimHandler overrides:
75   void OnShimLaunch(apps::AppShimHandler::Host* host,
76                     apps::AppShimLaunchType launch_type,
77                     const std::vector<base::FilePath>& files) override;
78   void OnShimClose(apps::AppShimHandler::Host* host) override;
79   void OnShimFocus(apps::AppShimHandler::Host* host,
80                    apps::AppShimFocusType focus_type,
81                    const std::vector<base::FilePath>& files) override;
82   void OnShimSetHidden(apps::AppShimHandler::Host* host, bool hidden) override;
83   void OnShimQuit(apps::AppShimHandler::Host* host) override;
84
85  private:
86   friend class test::AppListServiceMacTestApi;
87   friend struct DefaultSingletonTraits<AppListServiceMac>;
88
89   AppListServiceMac();
90
91   base::scoped_nsobject<AppListWindowController> window_controller_;
92   base::scoped_nsobject<AppListAnimationController> animation_controller_;
93   base::scoped_nsobject<NSRunningApplication> previously_active_application_;
94   NSPoint last_start_origin_;
95   Profile* profile_;
96   scoped_ptr<AppListControllerDelegateImpl> controller_delegate_;
97
98   DISALLOW_COPY_AND_ASSIGN(AppListServiceMac);
99 };
100
101 #endif  // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_MAC_H_