| 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" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 13 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
| 12 #include "chrome/browser/ui/panels/panel.h" | 14 #include "chrome/browser/ui/panels/panel.h" |
| 13 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" | 15 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" |
| 14 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" | 16 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" |
| 15 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
| 16 | 18 |
| 17 const int kMinimumWindowSize = 1; | 19 const int kMinimumWindowSize = 1; |
| 18 | 20 |
| 19 @implementation PanelWindowControllerCocoa | 21 @implementation PanelWindowControllerCocoa |
| 20 | 22 |
| 21 - (id)initWithBrowserWindow:(PanelBrowserWindowCocoa*)window { | 23 - (id)initWithBrowserWindow:(PanelBrowserWindowCocoa*)window { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 [window setFrame:startFrame display:NO animate:NO]; | 80 [window setFrame:startFrame display:NO animate:NO]; |
| 79 // Shows the window without making it key, on top of its layer, even if | 81 // Shows the window without making it key, on top of its layer, even if |
| 80 // Chromium is not an active app. | 82 // Chromium is not an active app. |
| 81 [window orderFrontRegardless]; | 83 [window orderFrontRegardless]; |
| 82 [window setFrame:frame display:YES animate:YES]; | 84 [window setFrame:frame display:YES animate:YES]; |
| 83 | 85 |
| 84 // Resume auto-resizing of the TabContents view. | 86 // Resume auto-resizing of the TabContents view. |
| 85 [self enableTabContentsViewAutosizing]; | 87 [self enableTabContentsViewAutosizing]; |
| 86 } | 88 } |
| 87 | 89 |
| 90 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { |
| 91 // Shouldn't call addFindBar twice. |
| 92 DCHECK(!findBarCocoaController_.get()); |
| 93 |
| 94 // Create a controller for the findbar. |
| 95 findBarCocoaController_.reset([findBarCocoaController retain]); |
| 96 NSView* contentView = [[self window] contentView]; |
| 97 [contentView addSubview:[findBarCocoaController_ view] |
| 98 positioned:NSWindowBelow |
| 99 relativeTo:titlebar_view_]; |
| 100 |
| 101 // Place the find bar immediately below the title bar. |
| 102 CGFloat maxY = NSMinY([titlebar_view_ frame]); |
| 103 CGFloat maxWidth = NSWidth([contentView frame]); |
| 104 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; |
| 105 } |
| 106 |
| 88 - (void)closePanel { | 107 - (void)closePanel { |
| 89 windowShim_->panel()->Close(); | 108 windowShim_->panel()->Close(); |
| 90 } | 109 } |
| 91 | 110 |
| 92 - (void)windowWillClose:(NSNotification*)notification { | 111 - (void)windowWillClose:(NSNotification*)notification { |
| 93 [self autorelease]; | 112 [self autorelease]; |
| 94 } | 113 } |
| 95 | 114 |
| 96 - (NSView*)tabContentsView { | 115 - (NSView*)tabContentsView { |
| 97 TabContents* contents = windowShim_->browser()->GetSelectedTabContents(); | 116 TabContents* contents = windowShim_->browser()->GetSelectedTabContents(); |
| 98 CHECK(contents); | 117 CHECK(contents); |
| 99 NSView* tabContentView = contents->GetNativeView(); | 118 NSView* tabContentView = contents->GetNativeView(); |
| 100 CHECK(tabContentView); | 119 CHECK(tabContentView); |
| 101 return tabContentView; | 120 return tabContentView; |
| 102 } | 121 } |
| 103 | 122 |
| 104 - (PanelTitlebarViewCocoa*)titlebarView { | 123 - (PanelTitlebarViewCocoa*)titlebarView { |
| 105 return titlebar_view_; | 124 return titlebar_view_; |
| 106 } | 125 } |
| 107 @end | 126 @end |
| OLD | NEW |