OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "apps/app_shim/app_shim_handler_mac.h" | 5 #include "apps/app_shim/app_shim_handler_mac.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/memory/scoped_nsobject.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 public apps::AppShimHandler { | 43 public apps::AppShimHandler { |
44 public: | 44 public: |
45 virtual ~AppListServiceMac() {} | 45 virtual ~AppListServiceMac() {} |
46 | 46 |
47 static AppListServiceMac* GetInstance() { | 47 static AppListServiceMac* GetInstance() { |
48 return Singleton<AppListServiceMac, | 48 return Singleton<AppListServiceMac, |
49 LeakySingletonTraits<AppListServiceMac> >::get(); | 49 LeakySingletonTraits<AppListServiceMac> >::get(); |
50 } | 50 } |
51 | 51 |
52 void CreateAppList(Profile* profile); | 52 void CreateAppList(Profile* profile); |
53 NSWindow* GetNativeWindow(); | |
54 void ShowWindowNearDock(); | 53 void ShowWindowNearDock(); |
55 | 54 |
56 // AppListService overrides: | 55 // AppListService overrides: |
57 virtual void Init(Profile* initial_profile) OVERRIDE; | 56 virtual void Init(Profile* initial_profile) OVERRIDE; |
58 virtual void ShowAppList(Profile* requested_profile) OVERRIDE; | 57 virtual void ShowAppList(Profile* requested_profile) OVERRIDE; |
59 virtual void DismissAppList() OVERRIDE; | 58 virtual void DismissAppList() OVERRIDE; |
60 virtual bool IsAppListVisible() const OVERRIDE; | 59 virtual bool IsAppListVisible() const OVERRIDE; |
61 virtual void EnableAppList() OVERRIDE; | 60 virtual void EnableAppList() OVERRIDE; |
| 61 virtual gfx::NativeWindow GetAppListWindow() OVERRIDE; |
62 | 62 |
63 // AppShimHandler overrides: | 63 // AppShimHandler overrides: |
64 virtual bool OnShimLaunch(apps::AppShimHandler::Host* host) OVERRIDE; | 64 virtual bool OnShimLaunch(apps::AppShimHandler::Host* host) OVERRIDE; |
65 virtual void OnShimClose(apps::AppShimHandler::Host* host) OVERRIDE; | 65 virtual void OnShimClose(apps::AppShimHandler::Host* host) OVERRIDE; |
66 virtual void OnShimFocus(apps::AppShimHandler::Host* host) OVERRIDE; | 66 virtual void OnShimFocus(apps::AppShimHandler::Host* host) OVERRIDE; |
67 | 67 |
68 private: | 68 private: |
69 friend struct DefaultSingletonTraits<AppListServiceMac>; | 69 friend struct DefaultSingletonTraits<AppListServiceMac>; |
70 | 70 |
71 AppListServiceMac() {} | 71 AppListServiceMac() {} |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 AppListControllerDelegateCocoa::AppListControllerDelegateCocoa() {} | 162 AppListControllerDelegateCocoa::AppListControllerDelegateCocoa() {} |
163 | 163 |
164 AppListControllerDelegateCocoa::~AppListControllerDelegateCocoa() {} | 164 AppListControllerDelegateCocoa::~AppListControllerDelegateCocoa() {} |
165 | 165 |
166 void AppListControllerDelegateCocoa::DismissView() { | 166 void AppListControllerDelegateCocoa::DismissView() { |
167 AppListServiceMac::GetInstance()->DismissAppList(); | 167 AppListServiceMac::GetInstance()->DismissAppList(); |
168 } | 168 } |
169 | 169 |
170 gfx::NativeWindow AppListControllerDelegateCocoa::GetAppListWindow() { | 170 gfx::NativeWindow AppListControllerDelegateCocoa::GetAppListWindow() { |
171 return AppListServiceMac::GetInstance()->GetNativeWindow(); | 171 return AppListServiceMac::GetInstance()->GetAppListWindow(); |
172 } | 172 } |
173 | 173 |
174 bool AppListControllerDelegateCocoa::CanPin() { | 174 bool AppListControllerDelegateCocoa::CanPin() { |
175 return false; | 175 return false; |
176 } | 176 } |
177 | 177 |
178 bool AppListControllerDelegateCocoa::CanShowCreateShortcutsDialog() { | 178 bool AppListControllerDelegateCocoa::CanShowCreateShortcutsDialog() { |
179 // TODO(tapted): Return true when create shortcuts menu is tested on mac. | 179 // TODO(tapted): Return true when create shortcuts menu is tested on mac. |
180 return false; | 180 return false; |
181 } | 181 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } | 260 } |
261 | 261 |
262 bool AppListServiceMac::IsAppListVisible() const { | 262 bool AppListServiceMac::IsAppListVisible() const { |
263 return [[window_controller_ window] isVisible]; | 263 return [[window_controller_ window] isVisible]; |
264 } | 264 } |
265 | 265 |
266 void AppListServiceMac::EnableAppList() { | 266 void AppListServiceMac::EnableAppList() { |
267 // TODO(tapted): Implement enable logic here for OSX. | 267 // TODO(tapted): Implement enable logic here for OSX. |
268 } | 268 } |
269 | 269 |
270 NSWindow* AppListServiceMac::GetNativeWindow() { | 270 NSWindow* AppListServiceMac::GetAppListWindow() { |
271 return [window_controller_ window]; | 271 return [window_controller_ window]; |
272 } | 272 } |
273 | 273 |
274 bool AppListServiceMac::OnShimLaunch(apps::AppShimHandler::Host* host) { | 274 bool AppListServiceMac::OnShimLaunch(apps::AppShimHandler::Host* host) { |
275 ShowForSavedProfile(); | 275 ShowForSavedProfile(); |
276 observers_.AddObserver(host); | 276 observers_.AddObserver(host); |
277 return true; | 277 return true; |
278 } | 278 } |
279 | 279 |
280 void AppListServiceMac::OnShimClose(apps::AppShimHandler::Host* host) { | 280 void AppListServiceMac::OnShimClose(apps::AppShimHandler::Host* host) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 default: | 347 default: |
348 NOTREACHED(); | 348 NOTREACHED(); |
349 } | 349 } |
350 | 350 |
351 return NSMakePoint( | 351 return NSMakePoint( |
352 anchor.x() - window_size.width / 2, | 352 anchor.x() - window_size.width / 2, |
353 max_y - anchor.y() - window_size.height / 2); | 353 max_y - anchor.y() - window_size.height / 2); |
354 } | 354 } |
355 | 355 |
356 void AppListServiceMac::ShowWindowNearDock() { | 356 void AppListServiceMac::ShowWindowNearDock() { |
357 NSWindow* window = GetNativeWindow(); | 357 NSWindow* window = GetAppListWindow(); |
358 DCHECK(window); | 358 DCHECK(window); |
359 [window setFrameOrigin:GetAppListWindowOrigin(window)]; | 359 [window setFrameOrigin:GetAppListWindowOrigin(window)]; |
360 [window makeKeyAndOrderFront:nil]; | 360 [window makeKeyAndOrderFront:nil]; |
361 [NSApp activateIgnoringOtherApps:YES]; | 361 [NSApp activateIgnoringOtherApps:YES]; |
362 } | 362 } |
363 | 363 |
364 } // namespace | 364 } // namespace |
365 | 365 |
366 // static | 366 // static |
367 AppListService* AppListService::Get() { | 367 AppListService* AppListService::Get() { |
368 return AppListServiceMac::GetInstance(); | 368 return AppListServiceMac::GetInstance(); |
369 } | 369 } |
370 | 370 |
371 // static | 371 // static |
372 void AppListService::InitAll(Profile* initial_profile) { | 372 void AppListService::InitAll(Profile* initial_profile) { |
373 Get()->Init(initial_profile); | 373 Get()->Init(initial_profile); |
374 } | 374 } |
OLD | NEW |