Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller.mm

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <numeric> 8 #include <numeric>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/profiles/profile_info_cache.h" 22 #include "chrome/browser/profiles/profile_info_cache.h"
23 #include "chrome/browser/profiles/profile_manager.h" 23 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/browser/sync/profile_sync_service.h" 24 #include "chrome/browser/sync/profile_sync_service.h"
25 #include "chrome/browser/sync/sync_ui_util_mac.h" 25 #include "chrome/browser/sync/sync_ui_util_mac.h"
26 #include "chrome/browser/themes/theme_service.h" 26 #include "chrome/browser/themes/theme_service.h"
27 #include "chrome/browser/themes/theme_service_factory.h" 27 #include "chrome/browser/themes/theme_service_factory.h"
28 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_command_controller.h" 29 #include "chrome/browser/ui/browser_command_controller.h"
30 #include "chrome/browser/ui/browser_commands.h" 30 #include "chrome/browser/ui/browser_commands.h"
31 #include "chrome/browser/ui/browser_list.h" 31 #include "chrome/browser/ui/browser_list.h"
32 #include "chrome/browser/ui/browser_tabstrip.h"
32 #include "chrome/browser/ui/browser_window_state.h" 33 #include "chrome/browser/ui/browser_window_state.h"
33 #import "chrome/browser/ui/cocoa/background_gradient_view.h" 34 #import "chrome/browser/ui/cocoa/background_gradient_view.h"
34 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 35 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
35 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" 36 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h"
36 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" 37 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h"
37 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" 38 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
38 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" 39 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
39 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 40 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
40 #import "chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.h" 41 #import "chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.h"
41 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" 42 #import "chrome/browser/ui/cocoa/dev_tools_controller.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 414 }
414 415
415 - (void)awakeFromNib { 416 - (void)awakeFromNib {
416 // Set different minimum sizes on tabbed windows vs non-tabbed, e.g. popups. 417 // Set different minimum sizes on tabbed windows vs non-tabbed, e.g. popups.
417 NSSize minSize = [self isTabbedWindow] ? 418 NSSize minSize = [self isTabbedWindow] ?
418 NSMakeSize(400, 272) : NSMakeSize(100, 122); 419 NSMakeSize(400, 272) : NSMakeSize(100, 122);
419 [[self window] setMinSize:minSize]; 420 [[self window] setMinSize:minSize];
420 } 421 }
421 422
422 - (void)dealloc { 423 - (void)dealloc {
423 browser_->CloseAllTabs(); 424 chrome::CloseAllTabs(browser_.get());
424 [downloadShelfController_ exiting]; 425 [downloadShelfController_ exiting];
425 426
426 // Explicitly release |presentationModeController_| here, as it may call back 427 // Explicitly release |presentationModeController_| here, as it may call back
427 // to this BWC in |-dealloc|. We are required to call |-exitPresentationMode| 428 // to this BWC in |-dealloc|. We are required to call |-exitPresentationMode|
428 // before releasing the controller. 429 // before releasing the controller.
429 [presentationModeController_ exitPresentationMode]; 430 [presentationModeController_ exitPresentationMode];
430 presentationModeController_.reset(); 431 presentationModeController_.reset();
431 432
432 // Under certain testing configurations we may not actually own the browser. 433 // Under certain testing configurations we may not actually own the browser.
433 if (ownsBrowser_ == NO) 434 if (ownsBrowser_ == NO)
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 592
592 // TODO(viettrungluu): For some reason, the above doesn't suffice. 593 // TODO(viettrungluu): For some reason, the above doesn't suffice.
593 if ([self isFullscreen]) 594 if ([self isFullscreen])
594 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil. 595 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil.
595 } 596 }
596 597
597 // Called when we are activated (when we gain focus). 598 // Called when we are activated (when we gain focus).
598 - (void)windowDidBecomeKey:(NSNotification*)notification { 599 - (void)windowDidBecomeKey:(NSNotification*)notification {
599 // We need to activate the controls (in the "WebView"). To do this, get the 600 // We need to activate the controls (in the "WebView"). To do this, get the
600 // selected WebContents's RenderWidgetHostView and tell it to activate. 601 // selected WebContents's RenderWidgetHostView and tell it to activate.
601 if (WebContents* contents = browser_->GetActiveWebContents()) { 602 if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) {
602 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 603 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
603 rwhv->SetActive(true); 604 rwhv->SetActive(true);
604 } 605 }
605 } 606 }
606 607
607 // Called when we are deactivated (when we lose focus). 608 // Called when we are deactivated (when we lose focus).
608 - (void)windowDidResignKey:(NSNotification*)notification { 609 - (void)windowDidResignKey:(NSNotification*)notification {
609 // If our app is still active and we're still the key window, ignore this 610 // If our app is still active and we're still the key window, ignore this
610 // message, since it just means that a menu extra (on the "system status bar") 611 // message, since it just means that a menu extra (on the "system status bar")
611 // was activated; we'll get another |-windowDidResignKey| if we ever really 612 // was activated; we'll get another |-windowDidResignKey| if we ever really
612 // lose key window status. 613 // lose key window status.
613 if ([NSApp isActive] && ([NSApp keyWindow] == [self window])) 614 if ([NSApp isActive] && ([NSApp keyWindow] == [self window]))
614 return; 615 return;
615 616
616 // We need to deactivate the controls (in the "WebView"). To do this, get the 617 // We need to deactivate the controls (in the "WebView"). To do this, get the
617 // selected WebContents's RenderWidgetHostView and tell it to deactivate. 618 // selected WebContents's RenderWidgetHostView and tell it to deactivate.
618 if (WebContents* contents = browser_->GetActiveWebContents()) { 619 if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) {
619 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 620 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
620 rwhv->SetActive(false); 621 rwhv->SetActive(false);
621 } 622 }
622 } 623 }
623 624
624 // Called when we have been minimized. 625 // Called when we have been minimized.
625 - (void)windowDidMiniaturize:(NSNotification *)notification { 626 - (void)windowDidMiniaturize:(NSNotification *)notification {
626 [self saveWindowPositionIfNeeded]; 627 [self saveWindowPositionIfNeeded];
627 628
628 // Let the selected RenderWidgetHostView know, so that it can tell plugins. 629 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
629 if (WebContents* contents = browser_->GetActiveWebContents()) { 630 if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) {
630 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 631 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
631 rwhv->SetWindowVisibility(false); 632 rwhv->SetWindowVisibility(false);
632 } 633 }
633 } 634 }
634 635
635 // Called when we have been unminimized. 636 // Called when we have been unminimized.
636 - (void)windowDidDeminiaturize:(NSNotification *)notification { 637 - (void)windowDidDeminiaturize:(NSNotification *)notification {
637 // Let the selected RenderWidgetHostView know, so that it can tell plugins. 638 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
638 if (WebContents* contents = browser_->GetActiveWebContents()) { 639 if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) {
639 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 640 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
640 rwhv->SetWindowVisibility(true); 641 rwhv->SetWindowVisibility(true);
641 } 642 }
642 } 643 }
643 644
644 // Called when the application has been hidden. 645 // Called when the application has been hidden.
645 - (void)applicationDidHide:(NSNotification *)notification { 646 - (void)applicationDidHide:(NSNotification *)notification {
646 // Let the selected RenderWidgetHostView know, so that it can tell plugins 647 // Let the selected RenderWidgetHostView know, so that it can tell plugins
647 // (unless we are minimized, in which case nothing has really changed). 648 // (unless we are minimized, in which case nothing has really changed).
648 if (![[self window] isMiniaturized]) { 649 if (![[self window] isMiniaturized]) {
649 if (WebContents* contents = browser_->GetActiveWebContents()) { 650 if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) {
650 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 651 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
651 rwhv->SetWindowVisibility(false); 652 rwhv->SetWindowVisibility(false);
652 } 653 }
653 } 654 }
654 } 655 }
655 656
656 // Called when the application has been unhidden. 657 // Called when the application has been unhidden.
657 - (void)applicationDidUnhide:(NSNotification *)notification { 658 - (void)applicationDidUnhide:(NSNotification *)notification {
658 // Let the selected RenderWidgetHostView know, so that it can tell plugins 659 // Let the selected RenderWidgetHostView know, so that it can tell plugins
659 // (unless we are minimized, in which case nothing has really changed). 660 // (unless we are minimized, in which case nothing has really changed).
660 if (![[self window] isMiniaturized]) { 661 if (![[self window] isMiniaturized]) {
661 if (WebContents* contents = browser_->GetActiveWebContents()) { 662 if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) {
662 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 663 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
663 rwhv->SetWindowVisibility(true); 664 rwhv->SetWindowVisibility(true);
664 } 665 }
665 } 666 }
666 } 667 }
667 668
668 // Called when the user clicks the zoom button (or selects it from the Window 669 // Called when the user clicks the zoom button (or selects it from the Window
669 // menu) to determine the "standard size" of the window, based on the content 670 // menu) to determine the "standard size" of the window, based on the content
670 // and other factors. If the current size/location differs nontrivally from the 671 // and other factors. If the current size/location differs nontrivally from the
671 // standard size, Cocoa resizes the window to the standard size, and saves the 672 // standard size, Cocoa resizes the window to the standard size, and saves the
(...skipping 24 matching lines...) Expand all
696 } 697 }
697 698
698 // To prevent strange results on portrait displays, the basic minimum zoomed 699 // To prevent strange results on portrait displays, the basic minimum zoomed
699 // width is the larger of: 60% of available width, 60% of available height 700 // width is the larger of: 60% of available width, 60% of available height
700 // (bounded by available width). 701 // (bounded by available width).
701 const CGFloat kProportion = 0.6; 702 const CGFloat kProportion = 0.6;
702 CGFloat zoomedWidth = 703 CGFloat zoomedWidth =
703 std::max(kProportion * NSWidth(frame), 704 std::max(kProportion * NSWidth(frame),
704 std::min(kProportion * NSHeight(frame), NSWidth(frame))); 705 std::min(kProportion * NSHeight(frame), NSWidth(frame)));
705 706
706 WebContents* contents = browser_->GetActiveWebContents(); 707 WebContents* contents = chrome::GetActiveWebContents(browser_.get());
707 if (contents) { 708 if (contents) {
708 // If the intrinsic width is bigger, then make it the zoomed width. 709 // If the intrinsic width is bigger, then make it the zoomed width.
709 const int kScrollbarWidth = 16; // TODO(viettrungluu): ugh. 710 const int kScrollbarWidth = 16; // TODO(viettrungluu): ugh.
710 CGFloat intrinsicWidth = static_cast<CGFloat>( 711 CGFloat intrinsicWidth = static_cast<CGFloat>(
711 contents->GetPreferredSize().width() + kScrollbarWidth); 712 contents->GetPreferredSize().width() + kScrollbarWidth);
712 zoomedWidth = std::max(zoomedWidth, 713 zoomedWidth = std::max(zoomedWidth,
713 std::min(intrinsicWidth, NSWidth(frame))); 714 std::min(intrinsicWidth, NSWidth(frame)));
714 } 715 }
715 716
716 // Never shrink from the current size on zoom (see above). 717 // Never shrink from the current size on zoom (see above).
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 } 934 }
934 } 935 }
935 936
936 frame.size.height = height; 937 frame.size.height = height;
937 // TODO(rohitrao): Determine if calling setFrame: twice is bad. 938 // TODO(rohitrao): Determine if calling setFrame: twice is bad.
938 [view setFrame:frame]; 939 [view setFrame:frame];
939 [self layoutSubviews]; 940 [self layoutSubviews];
940 941
941 if (resizeRectDirty) { 942 if (resizeRectDirty) {
942 // Send new resize rect to foreground tab. 943 // Send new resize rect to foreground tab.
943 if (content::WebContents* contents = browser_->GetActiveWebContents()) { 944 if (content::WebContents* contents =
945 chrome::GetActiveWebContents(browser_.get())) {
944 if (content::RenderViewHost* rvh = contents->GetRenderViewHost()) { 946 if (content::RenderViewHost* rvh = contents->GetRenderViewHost()) {
945 rvh->ResizeRectChanged(windowShim_->GetRootWindowResizerRect()); 947 rvh->ResizeRectChanged(windowShim_->GetRootWindowResizerRect());
946 } 948 }
947 } 949 }
948 } 950 }
949 } 951 }
950 952
951 - (void)setAnimationInProgress:(BOOL)inProgress { 953 - (void)setAnimationInProgress:(BOOL)inProgress {
952 [[self tabContentArea] setFastResizeMode:inProgress]; 954 [[self tabContentArea] setFastResizeMode:inProgress];
953 } 955 }
(...skipping 19 matching lines...) Expand all
973 } 975 }
974 976
975 // Update the checked/Unchecked state of items in the encoding menu. 977 // Update the checked/Unchecked state of items in the encoding menu.
976 // On Windows, this logic is part of |EncodingMenuModel| in 978 // On Windows, this logic is part of |EncodingMenuModel| in
977 // browser/ui/views/toolbar_view.h. 979 // browser/ui/views/toolbar_view.h.
978 EncodingMenuController encoding_controller; 980 EncodingMenuController encoding_controller;
979 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) { 981 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) {
980 DCHECK(browser_.get()); 982 DCHECK(browser_.get());
981 Profile* profile = browser_->profile(); 983 Profile* profile = browser_->profile();
982 DCHECK(profile); 984 DCHECK(profile);
983 WebContents* current_tab = browser_->GetActiveWebContents(); 985 WebContents* current_tab = chrome::GetActiveWebContents(browser_.get());
984 if (!current_tab) { 986 if (!current_tab) {
985 return; 987 return;
986 } 988 }
987 const std::string encoding = current_tab->GetEncoding(); 989 const std::string encoding = current_tab->GetEncoding();
988 990
989 bool toggled = encoding_controller.IsItemChecked(profile, encoding, tag); 991 bool toggled = encoding_controller.IsItemChecked(profile, encoding, tag);
990 NSInteger oldState = [item state]; 992 NSInteger oldState = [item state];
991 NSInteger newState = toggled ? NSOnState : NSOffState; 993 NSInteger newState = toggled ? NSOnState : NSOffState;
992 if (oldState != newState) 994 if (oldState != newState)
993 [item setState:newState]; 995 [item setState:newState];
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 fromController:(TabWindowController*)dragController { 1228 fromController:(TabWindowController*)dragController {
1227 if (dragController) { 1229 if (dragController) {
1228 // Moving between windows. Figure out the WebContents to drop into our tab 1230 // Moving between windows. Figure out the WebContents to drop into our tab
1229 // model from the source window's model. 1231 // model from the source window's model.
1230 BOOL isBrowser = 1232 BOOL isBrowser =
1231 [dragController isKindOfClass:[BrowserWindowController class]]; 1233 [dragController isKindOfClass:[BrowserWindowController class]];
1232 DCHECK(isBrowser); 1234 DCHECK(isBrowser);
1233 if (!isBrowser) return; 1235 if (!isBrowser) return;
1234 BrowserWindowController* dragBWC = (BrowserWindowController*)dragController; 1236 BrowserWindowController* dragBWC = (BrowserWindowController*)dragController;
1235 int index = [dragBWC->tabStripController_ modelIndexForTabView:view]; 1237 int index = [dragBWC->tabStripController_ modelIndexForTabView:view];
1236 TabContents* contents = dragBWC->browser_->GetTabContentsAt(index); 1238 TabContents* contents =
1239 chrome::GetTabContentsAt(dragBWC->browser_.get(), index);
1237 // The tab contents may have gone away if given a window.close() while it 1240 // The tab contents may have gone away if given a window.close() while it
1238 // is being dragged. If so, bail, we've got nothing to drop. 1241 // is being dragged. If so, bail, we've got nothing to drop.
1239 if (!contents) 1242 if (!contents)
1240 return; 1243 return;
1241 1244
1242 // Convert |view|'s frame (which starts in the source tab strip's coordinate 1245 // Convert |view|'s frame (which starts in the source tab strip's coordinate
1243 // system) to the coordinate system of the destination tab strip. This needs 1246 // system) to the coordinate system of the destination tab strip. This needs
1244 // to be done before being detached so the window transforms can be 1247 // to be done before being detached so the window transforms can be
1245 // performed. 1248 // performed.
1246 NSRect destinationFrame = [view frame]; 1249 NSRect destinationFrame = [view frame];
1247 NSPoint tabOrigin = destinationFrame.origin; 1250 NSPoint tabOrigin = destinationFrame.origin;
1248 tabOrigin = [[dragController tabStripView] convertPoint:tabOrigin 1251 tabOrigin = [[dragController tabStripView] convertPoint:tabOrigin
1249 toView:nil]; 1252 toView:nil];
1250 tabOrigin = [[view window] convertBaseToScreen:tabOrigin]; 1253 tabOrigin = [[view window] convertBaseToScreen:tabOrigin];
1251 tabOrigin = [[self window] convertScreenToBase:tabOrigin]; 1254 tabOrigin = [[self window] convertScreenToBase:tabOrigin];
1252 tabOrigin = [[self tabStripView] convertPoint:tabOrigin fromView:nil]; 1255 tabOrigin = [[self tabStripView] convertPoint:tabOrigin fromView:nil];
1253 destinationFrame.origin = tabOrigin; 1256 destinationFrame.origin = tabOrigin;
1254 1257
1255 // Before the tab is detached from its originating tab strip, store the 1258 // Before the tab is detached from its originating tab strip, store the
1256 // pinned state so that it can be maintained between the windows. 1259 // pinned state so that it can be maintained between the windows.
1257 bool isPinned = dragBWC->browser_->IsTabPinned(index); 1260 bool isPinned = dragBWC->browser_->tab_strip_model()->IsTabPinned(index);
1258 1261
1259 // Now that we have enough information about the tab, we can remove it from 1262 // Now that we have enough information about the tab, we can remove it from
1260 // the dragging window. We need to do this *before* we add it to the new 1263 // the dragging window. We need to do this *before* we add it to the new
1261 // window as this will remove the WebContents' delegate. 1264 // window as this will remove the WebContents' delegate.
1262 [dragController detachTabView:view]; 1265 [dragController detachTabView:view];
1263 1266
1264 // Deposit it into our model at the appropriate location (it already knows 1267 // Deposit it into our model at the appropriate location (it already knows
1265 // where it should go from tracking the drag). Doing this sets the tab's 1268 // where it should go from tracking the drag). Doing this sets the tab's
1266 // delegate to be the Browser. 1269 // delegate to be the Browser.
1267 [tabStripController_ dropTabContents:contents 1270 [tabStripController_ dropTabContents:contents
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 - (void)layoutTabs { 1307 - (void)layoutTabs {
1305 [tabStripController_ layoutTabs]; 1308 [tabStripController_ layoutTabs];
1306 } 1309 }
1307 1310
1308 - (TabWindowController*)detachTabToNewWindow:(TabView*)tabView { 1311 - (TabWindowController*)detachTabToNewWindow:(TabView*)tabView {
1309 // Disable screen updates so that this appears as a single visual change. 1312 // Disable screen updates so that this appears as a single visual change.
1310 gfx::ScopedNSDisableScreenUpdates disabler; 1313 gfx::ScopedNSDisableScreenUpdates disabler;
1311 1314
1312 // Fetch the tab contents for the tab being dragged. 1315 // Fetch the tab contents for the tab being dragged.
1313 int index = [tabStripController_ modelIndexForTabView:tabView]; 1316 int index = [tabStripController_ modelIndexForTabView:tabView];
1314 TabContents* contents = browser_->GetTabContentsAt(index); 1317 TabContents* contents = chrome::GetTabContentsAt(browser_.get(), index);
1315 1318
1316 // Set the window size. Need to do this before we detach the tab so it's 1319 // Set the window size. Need to do this before we detach the tab so it's
1317 // still in the window. We have to flip the coordinates as that's what 1320 // still in the window. We have to flip the coordinates as that's what
1318 // is expected by the Browser code. 1321 // is expected by the Browser code.
1319 NSWindow* sourceWindow = [tabView window]; 1322 NSWindow* sourceWindow = [tabView window];
1320 NSRect windowRect = [sourceWindow frame]; 1323 NSRect windowRect = [sourceWindow frame];
1321 NSScreen* screen = [sourceWindow screen]; 1324 NSScreen* screen = [sourceWindow screen];
1322 windowRect.origin.y = NSHeight([screen frame]) - NSMaxY(windowRect); 1325 windowRect.origin.y = NSHeight([screen frame]) - NSMaxY(windowRect);
1323 gfx::Rect browserRect(windowRect.origin.x, windowRect.origin.y, 1326 gfx::Rect browserRect(windowRect.origin.x, windowRect.origin.y,
1324 NSWidth(windowRect), NSHeight(windowRect)); 1327 NSWidth(windowRect), NSHeight(windowRect));
1325 1328
1326 NSRect sourceTabRect = [tabView frame]; 1329 NSRect sourceTabRect = [tabView frame];
1327 NSView* tabStrip = [self tabStripView]; 1330 NSView* tabStrip = [self tabStripView];
1328 1331
1329 // Pushes tabView's frame back inside the tabstrip. 1332 // Pushes tabView's frame back inside the tabstrip.
1330 NSSize tabOverflow = 1333 NSSize tabOverflow =
1331 [self overflowFrom:[tabStrip convertRect:sourceTabRect toView:nil] 1334 [self overflowFrom:[tabStrip convertRect:sourceTabRect toView:nil]
1332 to:[tabStrip frame]]; 1335 to:[tabStrip frame]];
1333 NSRect tabRect = NSOffsetRect(sourceTabRect, 1336 NSRect tabRect = NSOffsetRect(sourceTabRect,
1334 -tabOverflow.width, -tabOverflow.height); 1337 -tabOverflow.width, -tabOverflow.height);
1335 1338
1336 // Before detaching the tab, store the pinned state. 1339 // Before detaching the tab, store the pinned state.
1337 bool isPinned = browser_->IsTabPinned(index); 1340 bool isPinned = browser_->tab_strip_model()->IsTabPinned(index);
1338 1341
1339 // Detach it from the source window, which just updates the model without 1342 // Detach it from the source window, which just updates the model without
1340 // deleting the tab contents. This needs to come before creating the new 1343 // deleting the tab contents. This needs to come before creating the new
1341 // Browser because it clears the WebContents' delegate, which gets hooked 1344 // Browser because it clears the WebContents' delegate, which gets hooked
1342 // up during creation of the new window. 1345 // up during creation of the new window.
1343 browser_->tab_strip_model()->DetachTabContentsAt(index); 1346 browser_->tab_strip_model()->DetachTabContentsAt(index);
1344 1347
1345 // Create the new window with a single tab in its model, the one being 1348 // Create the new window with a single tab in its model, the one being
1346 // dragged. 1349 // dragged.
1347 DockInfo dockInfo; 1350 DockInfo dockInfo;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 - (NSInteger)numberOfTabs { 1490 - (NSInteger)numberOfTabs {
1488 // count() includes pinned tabs. 1491 // count() includes pinned tabs.
1489 return browser_->tab_count(); 1492 return browser_->tab_count();
1490 } 1493 }
1491 1494
1492 - (BOOL)hasLiveTabs { 1495 - (BOOL)hasLiveTabs {
1493 return !browser_->tab_strip_model()->empty(); 1496 return !browser_->tab_strip_model()->empty();
1494 } 1497 }
1495 1498
1496 - (NSString*)activeTabTitle { 1499 - (NSString*)activeTabTitle {
1497 WebContents* contents = browser_->GetActiveWebContents(); 1500 WebContents* contents = chrome::GetActiveWebContents(browser_.get());
1498 return base::SysUTF16ToNSString(contents->GetTitle()); 1501 return base::SysUTF16ToNSString(contents->GetTitle());
1499 } 1502 }
1500 1503
1501 - (NSRect)regularWindowFrame { 1504 - (NSRect)regularWindowFrame {
1502 return [self isFullscreen] ? savedRegularWindowFrame_ : 1505 return [self isFullscreen] ? savedRegularWindowFrame_ :
1503 [[self window] frame]; 1506 [[self window] frame];
1504 } 1507 }
1505 1508
1506 // (Override of |TabWindowController| method.) 1509 // (Override of |TabWindowController| method.)
1507 - (BOOL)hasTabStrip { 1510 - (BOOL)hasTabStrip {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 - (void)windowDidResize:(NSNotification*)notification { 1763 - (void)windowDidResize:(NSNotification*)notification {
1761 [self saveWindowPositionIfNeeded]; 1764 [self saveWindowPositionIfNeeded];
1762 1765
1763 // Resize (and possibly move) the status bubble. Note that we may get called 1766 // Resize (and possibly move) the status bubble. Note that we may get called
1764 // when the status bubble does not exist. 1767 // when the status bubble does not exist.
1765 if (statusBubble_) { 1768 if (statusBubble_) {
1766 statusBubble_->UpdateSizeAndPosition(); 1769 statusBubble_->UpdateSizeAndPosition();
1767 } 1770 }
1768 1771
1769 // Let the selected RenderWidgetHostView know, so that it can tell plugins. 1772 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
1770 if (WebContents* contents = browser_->GetActiveWebContents()) { 1773 if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) {
1771 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 1774 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
1772 rwhv->WindowFrameChanged(); 1775 rwhv->WindowFrameChanged();
1773 } 1776 }
1774 1777
1775 // The FindBar needs to know its own position to properly detect overlaps 1778 // The FindBar needs to know its own position to properly detect overlaps
1776 // with find results. The position changes whenever the window is resized, 1779 // with find results. The position changes whenever the window is resized,
1777 // and |layoutSubviews| computes the FindBar's position. 1780 // and |layoutSubviews| computes the FindBar's position.
1778 // TODO: calling |layoutSubviews| here is a waste, find a better way to 1781 // TODO: calling |layoutSubviews| here is a waste, find a better way to
1779 // do this. 1782 // do this.
1780 if ([findBarCocoaController_ isFindBarVisible]) 1783 if ([findBarCocoaController_ isFindBarVisible])
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 // |-windowWillMove| is called too early for us to apply our heuristic. (The 1817 // |-windowWillMove| is called too early for us to apply our heuristic. (The
1815 // heuristic we use for detecting window movement is that if |windowTopGrowth_ 1818 // heuristic we use for detecting window movement is that if |windowTopGrowth_
1816 // > 0|, then we should be at the bottom of the work area -- if we're not, 1819 // > 0|, then we should be at the bottom of the work area -- if we're not,
1817 // we've moved. Similarly for the other side.) 1820 // we've moved. Similarly for the other side.)
1818 if (!NSContainsRect(workarea, windowFrame) || 1821 if (!NSContainsRect(workarea, windowFrame) ||
1819 (windowTopGrowth_ > 0 && NSMinY(windowFrame) != NSMinY(workarea)) || 1822 (windowTopGrowth_ > 0 && NSMinY(windowFrame) != NSMinY(workarea)) ||
1820 (windowBottomGrowth_ > 0 && NSMaxY(windowFrame) != NSMaxY(workarea))) 1823 (windowBottomGrowth_ > 0 && NSMaxY(windowFrame) != NSMaxY(workarea)))
1821 [self resetWindowGrowthState]; 1824 [self resetWindowGrowthState];
1822 1825
1823 // Let the selected RenderWidgetHostView know, so that it can tell plugins. 1826 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
1824 if (WebContents* contents = browser_->GetActiveWebContents()) { 1827 if (WebContents* contents = chrome::GetActiveWebContents(browser_.get())) {
1825 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 1828 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
1826 rwhv->WindowFrameChanged(); 1829 rwhv->WindowFrameChanged();
1827 } 1830 }
1828 } 1831 }
1829 1832
1830 // Delegate method called when window will be resized; not called for 1833 // Delegate method called when window will be resized; not called for
1831 // |-setFrame:display:|. 1834 // |-setFrame:display:|.
1832 - (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize { 1835 - (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize {
1833 [self resetWindowGrowthState]; 1836 [self resetWindowGrowthState];
1834 return frameSize; 1837 return frameSize;
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 2214
2212 - (BOOL)supportsBookmarkBar { 2215 - (BOOL)supportsBookmarkBar {
2213 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2216 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2214 } 2217 }
2215 2218
2216 - (BOOL)isTabbedWindow { 2219 - (BOOL)isTabbedWindow {
2217 return browser_->is_type_tabbed(); 2220 return browser_->is_type_tabbed();
2218 } 2221 }
2219 2222
2220 @end // @implementation BrowserWindowController(WindowType) 2223 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_cocoa.mm ('k') | chrome/browser/ui/cocoa/browser_window_controller_private.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698