| 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 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "grit/chrome_unscaled_resources.h" | 41 #include "grit/chrome_unscaled_resources.h" |
| 42 #include "net/base/url_util.h" | 42 #include "net/base/url_util.h" |
| 43 #import "ui/app_list/cocoa/app_list_view_controller.h" | 43 #import "ui/app_list/cocoa/app_list_view_controller.h" |
| 44 #import "ui/app_list/cocoa/app_list_window_controller.h" | 44 #import "ui/app_list/cocoa/app_list_window_controller.h" |
| 45 #include "ui/app_list/search_box_model.h" | 45 #include "ui/app_list/search_box_model.h" |
| 46 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
| 47 #include "ui/base/resource/resource_bundle.h" | 47 #include "ui/base/resource/resource_bundle.h" |
| 48 #include "ui/gfx/display.h" | 48 #include "ui/gfx/display.h" |
| 49 #include "ui/gfx/screen.h" | 49 #include "ui/gfx/screen.h" |
| 50 | 50 |
| 51 #include "chrome/browser/ui/app_list/app_list_service_views.h" |
| 52 #include "chrome/browser/ui/app_list/app_list_controller_delegate_views.h" |
| 53 |
| 51 namespace gfx { | 54 namespace gfx { |
| 52 class ImageSkia; | 55 class ImageSkia; |
| 53 } | 56 } |
| 54 | 57 |
| 55 // Controller for animations that show or hide the app list. | 58 // Controller for animations that show or hide the app list. |
| 56 @interface AppListAnimationController : NSObject<NSAnimationDelegate> { | 59 @interface AppListAnimationController : NSObject<NSAnimationDelegate> { |
| 57 @private | 60 @private |
| 58 // When closing, the window to close. Retained until the animation ends. | 61 // When closing, the window to close. Retained until the animation ends. |
| 59 base::scoped_nsobject<NSWindow> window_; | 62 base::scoped_nsobject<NSWindow> window_; |
| 60 // The animation started and owned by |self|. Reset when the animation ends. | 63 // The animation started and owned by |self|. Reset when the animation ends. |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 closing:NO]; | 525 closing:NO]; |
| 523 [window makeKeyAndOrderFront:nil]; | 526 [window makeKeyAndOrderFront:nil]; |
| 524 [NSApp activateIgnoringOtherApps:YES]; | 527 [NSApp activateIgnoringOtherApps:YES]; |
| 525 RecordAppListLaunch(); | 528 RecordAppListLaunch(); |
| 526 } | 529 } |
| 527 | 530 |
| 528 void AppListServiceMac::WindowAnimationDidEnd() { | 531 void AppListServiceMac::WindowAnimationDidEnd() { |
| 529 [animation_controller_ cleanupOnUIThread]; | 532 [animation_controller_ cleanupOnUIThread]; |
| 530 } | 533 } |
| 531 | 534 |
| 535 class AppListServiceMacViews : public AppListServiceViews { |
| 536 public: |
| 537 virtual ~AppListServiceMacViews() {} |
| 538 |
| 539 static AppListServiceMacViews* GetInstance() { |
| 540 return Singleton<AppListServiceMacViews, |
| 541 LeakySingletonTraits<AppListServiceMacViews> >::get(); |
| 542 } |
| 543 |
| 544 private: |
| 545 friend struct DefaultSingletonTraits<AppListServiceMacViews>; |
| 546 |
| 547 // AppListShowerDelegate overrides: |
| 548 virtual void OnViewCreated() OVERRIDE {} |
| 549 virtual void OnViewBeingDestroyed() OVERRIDE {} |
| 550 virtual void OnViewDismissed() OVERRIDE {} |
| 551 virtual void MoveNearCursor(app_list::AppListView* view) OVERRIDE {} |
| 552 |
| 553 AppListServiceMacViews() |
| 554 : AppListServiceViews(scoped_ptr<AppListControllerDelegate>( |
| 555 new AppListControllerDelegateViews(this))) {} |
| 556 |
| 557 DISALLOW_COPY_AND_ASSIGN(AppListServiceMacViews); |
| 558 }; |
| 559 |
| 532 // static | 560 // static |
| 533 AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) { | 561 AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) { |
| 534 return AppListServiceMac::GetInstance(); | 562 return AppListServiceMacViews::GetInstance(); |
| 563 //return AppListServiceMac::GetInstance(); |
| 535 } | 564 } |
| 536 | 565 |
| 537 // static | 566 // static |
| 538 void AppListService::InitAll(Profile* initial_profile) { | 567 void AppListService::InitAll(Profile* initial_profile) { |
| 539 AppListServiceMac::GetInstance()->Init(initial_profile); | 568 AppListServiceMacViews::GetInstance()->Init(initial_profile); |
| 569 //AppListServiceMac::GetInstance()->Init(initial_profile); |
| 540 } | 570 } |
| 541 | 571 |
| 542 @implementation AppListAnimationController | 572 @implementation AppListAnimationController |
| 543 | 573 |
| 544 - (BOOL)isClosing { | 574 - (BOOL)isClosing { |
| 545 return !!window_; | 575 return !!window_; |
| 546 } | 576 } |
| 547 | 577 |
| 548 - (void)animateWindow:(NSWindow*)window | 578 - (void)animateWindow:(NSWindow*)window |
| 549 targetOrigin:(NSPoint)targetOrigin | 579 targetOrigin:(NSPoint)targetOrigin |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 | 631 |
| 602 - (void)animationDidEnd:(NSAnimation*)animation { | 632 - (void)animationDidEnd:(NSAnimation*)animation { |
| 603 content::BrowserThread::PostTask( | 633 content::BrowserThread::PostTask( |
| 604 content::BrowserThread::UI, | 634 content::BrowserThread::UI, |
| 605 FROM_HERE, | 635 FROM_HERE, |
| 606 base::Bind(&AppListServiceMac::WindowAnimationDidEnd, | 636 base::Bind(&AppListServiceMac::WindowAnimationDidEnd, |
| 607 base::Unretained(AppListServiceMac::GetInstance()))); | 637 base::Unretained(AppListServiceMac::GetInstance()))); |
| 608 } | 638 } |
| 609 | 639 |
| 610 @end | 640 @end |
| OLD | NEW |