| 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 #import "chrome/browser/ui/app_list/app_list_service_mac.h" | 5 #import "chrome/browser/ui/app_list/app_list_service_mac.h" |
| 6 | 6 |
| 7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 NSMaxY([[[NSScreen screens] firstObject] frame]); | 259 NSMaxY([[[NSScreen screens] firstObject] frame]); |
| 260 AppListServiceMac::FindAnchorPoint(window_size, | 260 AppListServiceMac::FindAnchorPoint(window_size, |
| 261 display, | 261 display, |
| 262 primary_display_height, | 262 primary_display_height, |
| 263 cursor_is_visible, | 263 cursor_is_visible, |
| 264 cursor, | 264 cursor, |
| 265 target_origin, | 265 target_origin, |
| 266 start_origin); | 266 start_origin); |
| 267 } | 267 } |
| 268 | 268 |
| 269 AppListServiceMac* GetActiveInstance() { | |
| 270 if (app_list::switches::IsMacViewsAppListEnabled()) { | |
| 271 #if defined(TOOLKIT_VIEWS) | |
| 272 // TODO(tapted): Return AppListServiceViewsMac instance. | |
| 273 #else | |
| 274 NOTREACHED(); | |
| 275 #endif | |
| 276 } | |
| 277 return AppListServiceCocoaMac::GetInstance(); | |
| 278 } | |
| 279 | |
| 280 } // namespace | 269 } // namespace |
| 281 | 270 |
| 282 AppListServiceMac::AppListServiceMac() { | 271 AppListServiceMac::AppListServiceMac() { |
| 283 animation_controller_.reset([[AppListAnimationController alloc] init]); | 272 animation_controller_.reset([[AppListAnimationController alloc] init]); |
| 284 } | 273 } |
| 285 | 274 |
| 286 AppListServiceMac::~AppListServiceMac() {} | 275 AppListServiceMac::~AppListServiceMac() {} |
| 287 | 276 |
| 288 // static | 277 // static |
| 289 void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size, | 278 void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size, |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 [NSApp activateIgnoringOtherApps:YES]; | 494 [NSApp activateIgnoringOtherApps:YES]; |
| 506 RecordAppListLaunch(); | 495 RecordAppListLaunch(); |
| 507 } | 496 } |
| 508 | 497 |
| 509 void AppListServiceMac::WindowAnimationDidEnd() { | 498 void AppListServiceMac::WindowAnimationDidEnd() { |
| 510 [animation_controller_ cleanupOnUIThread]; | 499 [animation_controller_ cleanupOnUIThread]; |
| 511 } | 500 } |
| 512 | 501 |
| 513 // static | 502 // static |
| 514 AppListService* AppListService::Get() { | 503 AppListService* AppListService::Get() { |
| 515 return GetActiveInstance(); | 504 return AppListServiceCocoaMac::GetInstance(); |
| 516 } | 505 } |
| 517 | 506 |
| 518 // static | 507 // static |
| 519 void AppListService::InitAll(Profile* initial_profile, | 508 void AppListService::InitAll(Profile* initial_profile, |
| 520 const base::FilePath& profile_path) { | 509 const base::FilePath& profile_path) { |
| 521 GetActiveInstance()->InitWithProfilePath(initial_profile, profile_path); | 510 AppListServiceCocoaMac::GetInstance()->InitWithProfilePath(initial_profile, |
| 511 profile_path); |
| 522 } | 512 } |
| 523 | 513 |
| 524 @implementation AppListAnimationController | 514 @implementation AppListAnimationController |
| 525 | 515 |
| 526 - (BOOL)isClosing { | 516 - (BOOL)isClosing { |
| 527 return !!window_; | 517 return !!window_; |
| 528 } | 518 } |
| 529 | 519 |
| 530 - (void)animateWindow:(NSWindow*)window | 520 - (void)animateWindow:(NSWindow*)window |
| 531 targetOrigin:(NSPoint)targetOrigin | 521 targetOrigin:(NSPoint)targetOrigin |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 [window_ close]; | 566 [window_ close]; |
| 577 window_.reset(); | 567 window_.reset(); |
| 578 animation_.reset(); | 568 animation_.reset(); |
| 579 | 569 |
| 580 if (closing) | 570 if (closing) |
| 581 apps::AppShimHandler::MaybeTerminate(); | 571 apps::AppShimHandler::MaybeTerminate(); |
| 582 } | 572 } |
| 583 | 573 |
| 584 - (void)animationDidEnd:(NSAnimation*)animation { | 574 - (void)animationDidEnd:(NSAnimation*)animation { |
| 585 content::BrowserThread::PostTask( | 575 content::BrowserThread::PostTask( |
| 586 content::BrowserThread::UI, | 576 content::BrowserThread::UI, FROM_HERE, |
| 587 FROM_HERE, | |
| 588 base::Bind(&AppListServiceMac::WindowAnimationDidEnd, | 577 base::Bind(&AppListServiceMac::WindowAnimationDidEnd, |
| 589 base::Unretained(GetActiveInstance()))); | 578 base::Unretained(AppListServiceCocoaMac::GetInstance()))); |
| 590 } | 579 } |
| 591 | 580 |
| 592 @end | 581 @end |
| OLD | NEW |