| 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 "ui/app_list/cocoa/app_list_window_controller.h" | 5 #import "ui/app_list/cocoa/app_list_window_controller.h" |
| 6 | 6 |
| 7 #include "ui/app_list/app_list_view_delegate.h" | 7 #include "ui/app_list/app_list_view_delegate.h" |
| 8 #import "ui/app_list/cocoa/app_list_view_controller.h" |
| 8 #import "ui/app_list/cocoa/apps_grid_controller.h" | 9 #import "ui/app_list/cocoa/apps_grid_controller.h" |
| 10 #include "ui/base/cocoa/window_size_constants.h" |
| 9 | 11 |
| 10 @interface AppListWindow : NSWindow; | 12 @interface AppListWindow : NSWindow; |
| 11 @end | 13 @end |
| 12 | 14 |
| 13 @implementation AppListWindow | 15 @implementation AppListWindow |
| 14 | 16 |
| 15 // If we initialize a window with NSBorderlessWindowMask, it will not accept key | 17 // If we initialize a window with NSBorderlessWindowMask, it will not accept key |
| 16 // events (among other things) unless canBecomeKeyWindow is overridden. | 18 // events (among other things) unless canBecomeKeyWindow is overridden. |
| 17 - (BOOL)canBecomeKeyWindow { | 19 - (BOOL)canBecomeKeyWindow { |
| 18 return YES; | 20 return YES; |
| 19 } | 21 } |
| 20 | 22 |
| 21 @end | 23 @end |
| 22 | 24 |
| 23 @implementation AppListWindowController; | 25 @implementation AppListWindowController; |
| 24 | 26 |
| 25 - (id)initWithGridController:(AppsGridController*)gridController { | 27 - (id)init { |
| 26 scoped_nsobject<NSWindow> controlledWindow( | 28 scoped_nsobject<NSWindow> controlledWindow( |
| 27 [[AppListWindow alloc] initWithContentRect:[[gridController view] bounds] | 29 [[AppListWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater |
| 28 styleMask:NSBorderlessWindowMask | 30 styleMask:NSBorderlessWindowMask |
| 29 backing:NSBackingStoreBuffered | 31 backing:NSBackingStoreBuffered |
| 30 defer:NO]); | 32 defer:NO]); |
| 31 [controlledWindow setContentView:[gridController view]]; | |
| 32 [controlledWindow setReleasedWhenClosed:NO]; | 33 [controlledWindow setReleasedWhenClosed:NO]; |
| 33 [controlledWindow setBackgroundColor:[NSColor clearColor]]; | 34 [controlledWindow setBackgroundColor:[NSColor clearColor]]; |
| 34 [controlledWindow setOpaque:NO]; | 35 [controlledWindow setOpaque:NO]; |
| 35 [controlledWindow setHasShadow:NO]; | 36 [controlledWindow setHasShadow:NO]; |
| 37 [controlledWindow |
| 38 setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces]; |
| 36 | 39 |
| 37 if ((self = [super initWithWindow:controlledWindow])) { | 40 if ((self = [super initWithWindow:controlledWindow])) { |
| 38 appsGridController_.reset([gridController retain]); | 41 appListViewController_.reset([[AppListViewController alloc] init]); |
| 42 [[self window] setFrame:[[appListViewController_ view] bounds] |
| 43 display:NO]; |
| 44 [[self window] setContentView:[appListViewController_ view]]; |
| 39 [[self window] setDelegate:self]; | 45 [[self window] setDelegate:self]; |
| 40 [[self window] makeFirstResponder:[appsGridController_ | 46 [[self window] makeFirstResponder: |
| 41 collectionViewAtPageIndex:0]]; | 47 [[appListViewController_ appsGridController] |
| 48 collectionViewAtPageIndex:0]]; |
| 42 } | 49 } |
| 43 return self; | 50 return self; |
| 44 } | 51 } |
| 45 | 52 |
| 46 - (AppsGridController*)appsGridController { | 53 - (AppListViewController*)appListViewController { |
| 47 return appsGridController_; | 54 return appListViewController_; |
| 48 } | 55 } |
| 49 | 56 |
| 50 - (void)doCommandBySelector:(SEL)command { | 57 - (void)doCommandBySelector:(SEL)command { |
| 51 if (command == @selector(cancel:)) { | 58 if (command == @selector(cancel:)) { |
| 52 if ([appsGridController_ delegate]) | 59 if ([appListViewController_ delegate]) |
| 53 [appsGridController_ delegate]->Dismiss(); | 60 [appListViewController_ delegate]->Dismiss(); |
| 54 } else if (command == @selector(insertNewline:) || | 61 } else if (command == @selector(insertNewline:) || |
| 55 command == @selector(insertLineBreak:)) { | 62 command == @selector(insertLineBreak:)) { |
| 56 [appsGridController_ activateSelection]; | 63 [[appListViewController_ appsGridController] activateSelection]; |
| 57 } | 64 } |
| 58 } | 65 } |
| 59 | 66 |
| 60 @end | 67 @end |
| OLD | NEW |