| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/panels/panel_window_controller_cocoa.h" | 5 #include "chrome/browser/ui/panels/panel_window_controller_cocoa.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 | 73 |
| 74 @implementation PanelWindowControllerCocoa | 74 @implementation PanelWindowControllerCocoa |
| 75 | 75 |
| 76 - (id)initWithBrowserWindow:(PanelBrowserWindowCocoa*)window { | 76 - (id)initWithBrowserWindow:(PanelBrowserWindowCocoa*)window { |
| 77 NSString* nibpath = | 77 NSString* nibpath = |
| 78 [base::mac::FrameworkBundle() pathForResource:@"Panel" ofType:@"nib"]; | 78 [base::mac::FrameworkBundle() pathForResource:@"Panel" ofType:@"nib"]; |
| 79 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { | 79 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { |
| 80 windowShim_.reset(window); | 80 windowShim_.reset(window); |
| 81 animateOnBoundsChange_ = YES; | 81 animateOnBoundsChange_ = YES; |
| 82 canBecomeKeyWindow_ = YES; |
| 82 } | 83 } |
| 83 contentsController_.reset( | 84 contentsController_.reset( |
| 84 [[TabContentsController alloc] initWithContents:nil]); | 85 [[TabContentsController alloc] initWithContents:nil]); |
| 85 return self; | 86 return self; |
| 86 } | 87 } |
| 87 | 88 |
| 88 - (void)dealloc { | 89 - (void)dealloc { |
| 89 if (windowTrackingArea_.get()) { | 90 if (windowTrackingArea_.get()) { |
| 90 [[[[self window] contentView] superview] | 91 [[[[self window] contentView] superview] |
| 91 removeTrackingArea:windowTrackingArea_.get()]; | 92 removeTrackingArea:windowTrackingArea_.get()]; |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 BrowserWindow* browser_window = | 617 BrowserWindow* browser_window = |
| 617 windowShim_->panel()->manager()->GetNextBrowserWindowToActivate( | 618 windowShim_->panel()->manager()->GetNextBrowserWindowToActivate( |
| 618 windowShim_->panel()); | 619 windowShim_->panel()); |
| 619 | 620 |
| 620 if (browser_window) | 621 if (browser_window) |
| 621 browser_window->Activate(); | 622 browser_window->Activate(); |
| 622 else | 623 else |
| 623 [NSApp deactivate]; | 624 [NSApp deactivate]; |
| 624 } | 625 } |
| 625 | 626 |
| 627 - (void)preventBecomingKeyWindow:(BOOL)prevent { |
| 628 canBecomeKeyWindow_ = !prevent; |
| 629 } |
| 630 |
| 626 - (void)fullScreenModeChanged:(bool)isFullScreen { | 631 - (void)fullScreenModeChanged:(bool)isFullScreen { |
| 627 NSWindow* window = [self window]; | 632 NSWindow* window = [self window]; |
| 628 [window setLevel:(isFullScreen ? NSNormalWindowLevel : NSStatusWindowLevel)]; | 633 [window setLevel:(isFullScreen ? NSNormalWindowLevel : NSStatusWindowLevel)]; |
| 629 } | 634 } |
| 630 | 635 |
| 631 - (BOOL)canBecomeKeyWindow { | 636 - (BOOL)canBecomeKeyWindow { |
| 632 // Panel can only gain focus if it is expanded. Minimized panels do not | 637 // Panel can only gain focus if it is expanded. Minimized panels do not |
| 633 // participate in Cmd-~ rotation. | 638 // participate in Cmd-~ rotation. |
| 634 // TODO(dimich): If it will be ever desired to expand/focus the Panel on | 639 // TODO(dimich): If it will be ever desired to expand/focus the Panel on |
| 635 // keyboard navigation or via main menu, the care should be taken to avoid | 640 // keyboard navigation or via main menu, the care should be taken to avoid |
| 636 // cases when minimized Panel is getting keyboard input, invisibly. | 641 // cases when minimized Panel is getting keyboard input, invisibly. |
| 637 return windowShim_->panel()->expansion_state() == Panel::EXPANDED; | 642 return canBecomeKeyWindow_; |
| 638 } | 643 } |
| 639 @end | 644 @end |
| OLD | NEW |