Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / app_list / app_list_service_mac.h
blob6440dc99a6d3b3de0ca8516a6353fb35d2f697fc
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;
21 namespace gfx {
22 class Display;
23 class Point;
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();
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) OVERRIDE;
61 virtual gfx::NativeWindow GetAppListWindow() OVERRIDE;
62 virtual AppListControllerDelegate* GetControllerDelegate() OVERRIDE;
63 virtual Profile* GetCurrentAppListProfile() OVERRIDE;
65 // AppListServiceImpl overrides:
66 virtual void CreateShortcut() OVERRIDE;
68 // AppShimHandler overrides:
69 virtual void OnShimLaunch(apps::AppShimHandler::Host* host,
70 apps::AppShimLaunchType launch_type,
71 const std::vector<base::FilePath>& files) OVERRIDE;
72 virtual void OnShimClose(apps::AppShimHandler::Host* host) OVERRIDE;
73 virtual void OnShimFocus(apps::AppShimHandler::Host* host,
74 apps::AppShimFocusType focus_type,
75 const std::vector<base::FilePath>& files) OVERRIDE;
76 virtual void OnShimSetHidden(apps::AppShimHandler::Host* host,
77 bool hidden) OVERRIDE;
78 virtual void OnShimQuit(apps::AppShimHandler::Host* host) OVERRIDE;
80 private:
81 friend struct DefaultSingletonTraits<AppListServiceMac>;
83 AppListServiceMac();
85 base::scoped_nsobject<AppListWindowController> window_controller_;
86 base::scoped_nsobject<AppListAnimationController> animation_controller_;
87 base::scoped_nsobject<NSRunningApplication> previously_active_application_;
88 NSPoint last_start_origin_;
89 Profile* profile_;
90 scoped_ptr<AppListControllerDelegateImpl> controller_delegate_;
92 DISALLOW_COPY_AND_ASSIGN(AppListServiceMac);
95 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SERVICE_MAC_H_