OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 NSView* contentView = [window contentView]; | 181 NSView* contentView = [window contentView]; |
182 [contentView setAutoresizesSubviews:NO]; | 182 [contentView setAutoresizesSubviews:NO]; |
183 | 183 |
184 // We grow the window from the bottom up to produce a 'reveal' animation. | 184 // We grow the window from the bottom up to produce a 'reveal' animation. |
185 NSRect startFrame = NSMakeRect(NSMinX(frame), NSMinY(frame), | 185 NSRect startFrame = NSMakeRect(NSMinX(frame), NSMinY(frame), |
186 NSWidth(frame), kMinimumWindowSize); | 186 NSWidth(frame), kMinimumWindowSize); |
187 [window setFrame:startFrame display:NO animate:NO]; | 187 [window setFrame:startFrame display:NO animate:NO]; |
188 // Shows the window without making it key, on top of its layer, even if | 188 // Shows the window without making it key, on top of its layer, even if |
189 // Chromium is not an active app. | 189 // Chromium is not an active app. |
190 [window orderFrontRegardless]; | 190 [window orderFrontRegardless]; |
| 191 // TODO(dcheng): Temporary hack to work around the fact that |
| 192 // orderFrontRegardless causes us to become the first responder. The usual |
| 193 // Chrome assumption is that becoming the first responder = you have focus, so |
| 194 // we always deactivate the controls here. If we're created as an active |
| 195 // panel, we'll get a NSWindowDidBecomeKeyNotification and reactivate the web |
| 196 // view properly. See crbug.com/97831 for more details. |
| 197 TabContents* tab_contents = |
| 198 windowShim_->panel()->browser()->GetSelectedTabContents(); |
| 199 // RWHV may be NULL in unit tests. |
| 200 if (tab_contents && tab_contents->GetRenderWidgetHostView()) |
| 201 tab_contents->GetRenderWidgetHostView()->SetActive(false); |
191 [window setFrame:frame display:YES animate:YES]; | 202 [window setFrame:frame display:YES animate:YES]; |
192 | 203 |
193 [contentView setAutoresizesSubviews:YES]; | 204 [contentView setAutoresizesSubviews:YES]; |
194 } | 205 } |
195 | 206 |
196 - (void)updateTitleBar { | 207 - (void)updateTitleBar { |
197 NSString* newTitle = base::SysUTF16ToNSString( | 208 NSString* newTitle = base::SysUTF16ToNSString( |
198 windowShim_->browser()->GetWindowTitleForCurrentTab()); | 209 windowShim_->browser()->GetWindowTitleForCurrentTab()); |
199 pendingWindowTitle_.reset( | 210 pendingWindowTitle_.reset( |
200 [BrowserWindowUtils scheduleReplaceOldTitle:pendingWindowTitle_.get() | 211 [BrowserWindowUtils scheduleReplaceOldTitle:pendingWindowTitle_.get() |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 - (BOOL)canBecomeKeyWindow { | 563 - (BOOL)canBecomeKeyWindow { |
553 // Panel can only gain focus if it is expanded. Minimized panels do not | 564 // Panel can only gain focus if it is expanded. Minimized panels do not |
554 // participate in Cmd-~ rotation. | 565 // participate in Cmd-~ rotation. |
555 // TODO(dimich): If it will be ever desired to expand/focus the Panel on | 566 // TODO(dimich): If it will be ever desired to expand/focus the Panel on |
556 // keyboard navigation or via main menu, the care should be taken to avoid | 567 // keyboard navigation or via main menu, the care should be taken to avoid |
557 // cases when minimized Panel is getting keyboard input, invisibly. | 568 // cases when minimized Panel is getting keyboard input, invisibly. |
558 return windowShim_->panel()->expansion_state() == Panel::EXPANDED; | 569 return windowShim_->panel()->expansion_state() == Panel::EXPANDED; |
559 } | 570 } |
560 | 571 |
561 @end | 572 @end |
OLD | NEW |