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

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

Issue 10534093: TabContentsWrapper -> TabContents, part 37. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" 50 #import "chrome/browser/ui/cocoa/status_bubble_mac.h"
51 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h" 51 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h"
52 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" 52 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h"
53 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" 53 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
54 #import "chrome/browser/ui/cocoa/tabpose_window.h" 54 #import "chrome/browser/ui/cocoa/tabpose_window.h"
55 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 55 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
56 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 56 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
57 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 57 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
58 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 58 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
59 #include "chrome/browser/ui/omnibox/location_bar.h" 59 #include "chrome/browser/ui/omnibox/location_bar.h"
60 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 60 #include "chrome/browser/ui/tab_contents/tab_contents.h"
61 #include "chrome/browser/ui/tabs/dock_info.h" 61 #include "chrome/browser/ui/tabs/dock_info.h"
62 #include "chrome/browser/ui/tabs/tab_strip_model.h" 62 #include "chrome/browser/ui/tabs/tab_strip_model.h"
63 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 63 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
64 #include "chrome/browser/ui/window_sizer.h" 64 #include "chrome/browser/ui/window_sizer.h"
65 #include "chrome/common/chrome_switches.h" 65 #include "chrome/common/chrome_switches.h"
66 #include "chrome/common/url_constants.h" 66 #include "chrome/common/url_constants.h"
67 #include "content/public/browser/render_view_host.h" 67 #include "content/public/browser/render_view_host.h"
68 #include "content/public/browser/render_widget_host_view.h" 68 #include "content/public/browser/render_widget_host_view.h"
69 #include "content/public/browser/web_contents.h" 69 #include "content/public/browser/web_contents.h"
70 #include "grit/generated_resources.h" 70 #include "grit/generated_resources.h"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 586
587 // TODO(viettrungluu): For some reason, the above doesn't suffice. 587 // TODO(viettrungluu): For some reason, the above doesn't suffice.
588 if ([self isFullscreen]) 588 if ([self isFullscreen])
589 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil. 589 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil.
590 } 590 }
591 591
592 // Called when we are activated (when we gain focus). 592 // Called when we are activated (when we gain focus).
593 - (void)windowDidBecomeKey:(NSNotification*)notification { 593 - (void)windowDidBecomeKey:(NSNotification*)notification {
594 // We need to activate the controls (in the "WebView"). To do this, get the 594 // We need to activate the controls (in the "WebView"). To do this, get the
595 // selected WebContents's RenderWidgetHostView and tell it to activate. 595 // selected WebContents's RenderWidgetHostView and tell it to activate.
596 if (WebContents* contents = browser_->GetSelectedWebContents()) { 596 if (WebContents* contents = browser_->GetActiveWebContents()) {
597 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 597 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
598 rwhv->SetActive(true); 598 rwhv->SetActive(true);
599 } 599 }
600 } 600 }
601 601
602 // Called when we are deactivated (when we lose focus). 602 // Called when we are deactivated (when we lose focus).
603 - (void)windowDidResignKey:(NSNotification*)notification { 603 - (void)windowDidResignKey:(NSNotification*)notification {
604 // If our app is still active and we're still the key window, ignore this 604 // If our app is still active and we're still the key window, ignore this
605 // message, since it just means that a menu extra (on the "system status bar") 605 // message, since it just means that a menu extra (on the "system status bar")
606 // was activated; we'll get another |-windowDidResignKey| if we ever really 606 // was activated; we'll get another |-windowDidResignKey| if we ever really
607 // lose key window status. 607 // lose key window status.
608 if ([NSApp isActive] && ([NSApp keyWindow] == [self window])) 608 if ([NSApp isActive] && ([NSApp keyWindow] == [self window]))
609 return; 609 return;
610 610
611 // We need to deactivate the controls (in the "WebView"). To do this, get the 611 // We need to deactivate the controls (in the "WebView"). To do this, get the
612 // selected WebContents's RenderWidgetHostView and tell it to deactivate. 612 // selected WebContents's RenderWidgetHostView and tell it to deactivate.
613 if (WebContents* contents = browser_->GetSelectedWebContents()) { 613 if (WebContents* contents = browser_->GetActiveWebContents()) {
614 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 614 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
615 rwhv->SetActive(false); 615 rwhv->SetActive(false);
616 } 616 }
617 } 617 }
618 618
619 // Called when we have been minimized. 619 // Called when we have been minimized.
620 - (void)windowDidMiniaturize:(NSNotification *)notification { 620 - (void)windowDidMiniaturize:(NSNotification *)notification {
621 [self saveWindowPositionIfNeeded]; 621 [self saveWindowPositionIfNeeded];
622 622
623 // Let the selected RenderWidgetHostView know, so that it can tell plugins. 623 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
624 if (WebContents* contents = browser_->GetSelectedWebContents()) { 624 if (WebContents* contents = browser_->GetActiveWebContents()) {
625 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 625 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
626 rwhv->SetWindowVisibility(false); 626 rwhv->SetWindowVisibility(false);
627 } 627 }
628 } 628 }
629 629
630 // Called when we have been unminimized. 630 // Called when we have been unminimized.
631 - (void)windowDidDeminiaturize:(NSNotification *)notification { 631 - (void)windowDidDeminiaturize:(NSNotification *)notification {
632 // Let the selected RenderWidgetHostView know, so that it can tell plugins. 632 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
633 if (WebContents* contents = browser_->GetSelectedWebContents()) { 633 if (WebContents* contents = browser_->GetActiveWebContents()) {
634 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 634 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
635 rwhv->SetWindowVisibility(true); 635 rwhv->SetWindowVisibility(true);
636 } 636 }
637 } 637 }
638 638
639 // Called when the application has been hidden. 639 // Called when the application has been hidden.
640 - (void)applicationDidHide:(NSNotification *)notification { 640 - (void)applicationDidHide:(NSNotification *)notification {
641 // Let the selected RenderWidgetHostView know, so that it can tell plugins 641 // Let the selected RenderWidgetHostView know, so that it can tell plugins
642 // (unless we are minimized, in which case nothing has really changed). 642 // (unless we are minimized, in which case nothing has really changed).
643 if (![[self window] isMiniaturized]) { 643 if (![[self window] isMiniaturized]) {
644 if (WebContents* contents = browser_->GetSelectedWebContents()) { 644 if (WebContents* contents = browser_->GetActiveWebContents()) {
645 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 645 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
646 rwhv->SetWindowVisibility(false); 646 rwhv->SetWindowVisibility(false);
647 } 647 }
648 } 648 }
649 } 649 }
650 650
651 // Called when the application has been unhidden. 651 // Called when the application has been unhidden.
652 - (void)applicationDidUnhide:(NSNotification *)notification { 652 - (void)applicationDidUnhide:(NSNotification *)notification {
653 // Let the selected RenderWidgetHostView know, so that it can tell plugins 653 // Let the selected RenderWidgetHostView know, so that it can tell plugins
654 // (unless we are minimized, in which case nothing has really changed). 654 // (unless we are minimized, in which case nothing has really changed).
655 if (![[self window] isMiniaturized]) { 655 if (![[self window] isMiniaturized]) {
656 if (WebContents* contents = browser_->GetSelectedWebContents()) { 656 if (WebContents* contents = browser_->GetActiveWebContents()) {
657 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 657 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
658 rwhv->SetWindowVisibility(true); 658 rwhv->SetWindowVisibility(true);
659 } 659 }
660 } 660 }
661 } 661 }
662 662
663 // Called when the user clicks the zoom button (or selects it from the Window 663 // Called when the user clicks the zoom button (or selects it from the Window
664 // menu) to determine the "standard size" of the window, based on the content 664 // menu) to determine the "standard size" of the window, based on the content
665 // and other factors. If the current size/location differs nontrivally from the 665 // and other factors. If the current size/location differs nontrivally from the
666 // standard size, Cocoa resizes the window to the standard size, and saves the 666 // standard size, Cocoa resizes the window to the standard size, and saves the
(...skipping 24 matching lines...) Expand all
691 } 691 }
692 692
693 // To prevent strange results on portrait displays, the basic minimum zoomed 693 // To prevent strange results on portrait displays, the basic minimum zoomed
694 // width is the larger of: 60% of available width, 60% of available height 694 // width is the larger of: 60% of available width, 60% of available height
695 // (bounded by available width). 695 // (bounded by available width).
696 const CGFloat kProportion = 0.6; 696 const CGFloat kProportion = 0.6;
697 CGFloat zoomedWidth = 697 CGFloat zoomedWidth =
698 std::max(kProportion * NSWidth(frame), 698 std::max(kProportion * NSWidth(frame),
699 std::min(kProportion * NSHeight(frame), NSWidth(frame))); 699 std::min(kProportion * NSHeight(frame), NSWidth(frame)));
700 700
701 WebContents* contents = browser_->GetSelectedWebContents(); 701 WebContents* contents = browser_->GetActiveWebContents();
702 if (contents) { 702 if (contents) {
703 // If the intrinsic width is bigger, then make it the zoomed width. 703 // If the intrinsic width is bigger, then make it the zoomed width.
704 const int kScrollbarWidth = 16; // TODO(viettrungluu): ugh. 704 const int kScrollbarWidth = 16; // TODO(viettrungluu): ugh.
705 CGFloat intrinsicWidth = static_cast<CGFloat>( 705 CGFloat intrinsicWidth = static_cast<CGFloat>(
706 contents->GetPreferredSize().width() + kScrollbarWidth); 706 contents->GetPreferredSize().width() + kScrollbarWidth);
707 zoomedWidth = std::max(zoomedWidth, 707 zoomedWidth = std::max(zoomedWidth,
708 std::min(intrinsicWidth, NSWidth(frame))); 708 std::min(intrinsicWidth, NSWidth(frame)));
709 } 709 }
710 710
711 // Never shrink from the current size on zoom (see above). 711 // Never shrink from the current size on zoom (see above).
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 } 928 }
929 } 929 }
930 930
931 frame.size.height = height; 931 frame.size.height = height;
932 // TODO(rohitrao): Determine if calling setFrame: twice is bad. 932 // TODO(rohitrao): Determine if calling setFrame: twice is bad.
933 [view setFrame:frame]; 933 [view setFrame:frame];
934 [self layoutSubviews]; 934 [self layoutSubviews];
935 935
936 if (resizeRectDirty) { 936 if (resizeRectDirty) {
937 // Send new resize rect to foreground tab. 937 // Send new resize rect to foreground tab.
938 if (content::WebContents* contents = browser_->GetSelectedWebContents()) { 938 if (content::WebContents* contents = browser_->GetActiveWebContents()) {
939 if (content::RenderViewHost* rvh = contents->GetRenderViewHost()) { 939 if (content::RenderViewHost* rvh = contents->GetRenderViewHost()) {
940 rvh->ResizeRectChanged(windowShim_->GetRootWindowResizerRect()); 940 rvh->ResizeRectChanged(windowShim_->GetRootWindowResizerRect());
941 } 941 }
942 } 942 }
943 } 943 }
944 } 944 }
945 945
946 - (void)setAnimationInProgress:(BOOL)inProgress { 946 - (void)setAnimationInProgress:(BOOL)inProgress {
947 [[self tabContentArea] setFastResizeMode:inProgress]; 947 [[self tabContentArea] setFastResizeMode:inProgress];
948 } 948 }
(...skipping 19 matching lines...) Expand all
968 } 968 }
969 969
970 // Update the checked/Unchecked state of items in the encoding menu. 970 // Update the checked/Unchecked state of items in the encoding menu.
971 // On Windows, this logic is part of |EncodingMenuModel| in 971 // On Windows, this logic is part of |EncodingMenuModel| in
972 // browser/ui/views/toolbar_view.h. 972 // browser/ui/views/toolbar_view.h.
973 EncodingMenuController encoding_controller; 973 EncodingMenuController encoding_controller;
974 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) { 974 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) {
975 DCHECK(browser_.get()); 975 DCHECK(browser_.get());
976 Profile* profile = browser_->profile(); 976 Profile* profile = browser_->profile();
977 DCHECK(profile); 977 DCHECK(profile);
978 WebContents* current_tab = browser_->GetSelectedWebContents(); 978 WebContents* current_tab = browser_->GetActiveWebContents();
979 if (!current_tab) { 979 if (!current_tab) {
980 return; 980 return;
981 } 981 }
982 const std::string encoding = current_tab->GetEncoding(); 982 const std::string encoding = current_tab->GetEncoding();
983 983
984 bool toggled = encoding_controller.IsItemChecked(profile, encoding, tag); 984 bool toggled = encoding_controller.IsItemChecked(profile, encoding, tag);
985 NSInteger oldState = [item state]; 985 NSInteger oldState = [item state];
986 NSInteger newState = toggled ? NSOnState : NSOffState; 986 NSInteger newState = toggled ? NSOnState : NSOffState;
987 if (oldState != newState) 987 if (oldState != newState)
988 [item setState:newState]; 988 [item setState:newState];
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 fromController:(TabWindowController*)dragController { 1221 fromController:(TabWindowController*)dragController {
1222 if (dragController) { 1222 if (dragController) {
1223 // Moving between windows. Figure out the WebContents to drop into our tab 1223 // Moving between windows. Figure out the WebContents to drop into our tab
1224 // model from the source window's model. 1224 // model from the source window's model.
1225 BOOL isBrowser = 1225 BOOL isBrowser =
1226 [dragController isKindOfClass:[BrowserWindowController class]]; 1226 [dragController isKindOfClass:[BrowserWindowController class]];
1227 DCHECK(isBrowser); 1227 DCHECK(isBrowser);
1228 if (!isBrowser) return; 1228 if (!isBrowser) return;
1229 BrowserWindowController* dragBWC = (BrowserWindowController*)dragController; 1229 BrowserWindowController* dragBWC = (BrowserWindowController*)dragController;
1230 int index = [dragBWC->tabStripController_ modelIndexForTabView:view]; 1230 int index = [dragBWC->tabStripController_ modelIndexForTabView:view];
1231 TabContentsWrapper* contents = 1231 TabContents* contents = dragBWC->browser_->GetTabContentsAt(index);
1232 dragBWC->browser_->GetTabContentsWrapperAt(index);
1233 // The tab contents may have gone away if given a window.close() while it 1232 // The tab contents may have gone away if given a window.close() while it
1234 // is being dragged. If so, bail, we've got nothing to drop. 1233 // is being dragged. If so, bail, we've got nothing to drop.
1235 if (!contents) 1234 if (!contents)
1236 return; 1235 return;
1237 1236
1238 // Convert |view|'s frame (which starts in the source tab strip's coordinate 1237 // Convert |view|'s frame (which starts in the source tab strip's coordinate
1239 // system) to the coordinate system of the destination tab strip. This needs 1238 // system) to the coordinate system of the destination tab strip. This needs
1240 // to be done before being detached so the window transforms can be 1239 // to be done before being detached so the window transforms can be
1241 // performed. 1240 // performed.
1242 NSRect destinationFrame = [view frame]; 1241 NSRect destinationFrame = [view frame];
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 - (void)layoutTabs { 1299 - (void)layoutTabs {
1301 [tabStripController_ layoutTabs]; 1300 [tabStripController_ layoutTabs];
1302 } 1301 }
1303 1302
1304 - (TabWindowController*)detachTabToNewWindow:(TabView*)tabView { 1303 - (TabWindowController*)detachTabToNewWindow:(TabView*)tabView {
1305 // Disable screen updates so that this appears as a single visual change. 1304 // Disable screen updates so that this appears as a single visual change.
1306 gfx::ScopedNSDisableScreenUpdates disabler; 1305 gfx::ScopedNSDisableScreenUpdates disabler;
1307 1306
1308 // Fetch the tab contents for the tab being dragged. 1307 // Fetch the tab contents for the tab being dragged.
1309 int index = [tabStripController_ modelIndexForTabView:tabView]; 1308 int index = [tabStripController_ modelIndexForTabView:tabView];
1310 TabContentsWrapper* contents = browser_->GetTabContentsWrapperAt(index); 1309 TabContents* contents = browser_->GetTabContentsAt(index);
1311 1310
1312 // Set the window size. Need to do this before we detach the tab so it's 1311 // Set the window size. Need to do this before we detach the tab so it's
1313 // still in the window. We have to flip the coordinates as that's what 1312 // still in the window. We have to flip the coordinates as that's what
1314 // is expected by the Browser code. 1313 // is expected by the Browser code.
1315 NSWindow* sourceWindow = [tabView window]; 1314 NSWindow* sourceWindow = [tabView window];
1316 NSRect windowRect = [sourceWindow frame]; 1315 NSRect windowRect = [sourceWindow frame];
1317 NSScreen* screen = [sourceWindow screen]; 1316 NSScreen* screen = [sourceWindow screen];
1318 windowRect.origin.y = NSHeight([screen frame]) - NSMaxY(windowRect); 1317 windowRect.origin.y = NSHeight([screen frame]) - NSMaxY(windowRect);
1319 gfx::Rect browserRect(windowRect.origin.x, windowRect.origin.y, 1318 gfx::Rect browserRect(windowRect.origin.x, windowRect.origin.y,
1320 NSWidth(windowRect), NSHeight(windowRect)); 1319 NSWidth(windowRect), NSHeight(windowRect));
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 - (NSInteger)numberOfTabs { 1482 - (NSInteger)numberOfTabs {
1484 // count() includes pinned tabs. 1483 // count() includes pinned tabs.
1485 return browser_->tab_count(); 1484 return browser_->tab_count();
1486 } 1485 }
1487 1486
1488 - (BOOL)hasLiveTabs { 1487 - (BOOL)hasLiveTabs {
1489 return !browser_->tab_strip_model()->empty(); 1488 return !browser_->tab_strip_model()->empty();
1490 } 1489 }
1491 1490
1492 - (NSString*)activeTabTitle { 1491 - (NSString*)activeTabTitle {
1493 WebContents* contents = browser_->GetSelectedWebContents(); 1492 WebContents* contents = browser_->GetActiveWebContents();
1494 return base::SysUTF16ToNSString(contents->GetTitle()); 1493 return base::SysUTF16ToNSString(contents->GetTitle());
1495 } 1494 }
1496 1495
1497 - (NSRect)regularWindowFrame { 1496 - (NSRect)regularWindowFrame {
1498 return [self isFullscreen] ? savedRegularWindowFrame_ : 1497 return [self isFullscreen] ? savedRegularWindowFrame_ :
1499 [[self window] frame]; 1498 [[self window] frame];
1500 } 1499 }
1501 1500
1502 // (Override of |TabWindowController| method.) 1501 // (Override of |TabWindowController| method.)
1503 - (BOOL)hasTabStrip { 1502 - (BOOL)hasTabStrip {
(...skipping 11 matching lines...) Expand all
1515 [devToolsController_ updateDevToolsForWebContents:contents 1514 [devToolsController_ updateDevToolsForWebContents:contents
1516 withProfile:browser_->profile()]; 1515 withProfile:browser_->profile()];
1517 1516
1518 // Update the bookmark bar. 1517 // Update the bookmark bar.
1519 // Must do it after devtools updates, otherwise bookmark bar might 1518 // Must do it after devtools updates, otherwise bookmark bar might
1520 // call resizeView -> layoutSubviews and cause unnecessary relayout. 1519 // call resizeView -> layoutSubviews and cause unnecessary relayout.
1521 // TODO(viettrungluu): perhaps update to not terminate running animations (if 1520 // TODO(viettrungluu): perhaps update to not terminate running animations (if
1522 // applicable)? 1521 // applicable)?
1523 [self updateBookmarkBarVisibilityWithAnimation:NO]; 1522 [self updateBookmarkBarVisibilityWithAnimation:NO];
1524 1523
1525 TabContentsWrapper* wrapper = 1524 TabContents* tabContents = TabContents::FromWebContents(contents);
1526 TabContentsWrapper::GetCurrentWrapperForContents(contents);
1527 // Without the .get(), xcode fails. 1525 // Without the .get(), xcode fails.
1528 [infoBarContainerController_.get() changeTabContents:wrapper]; 1526 [infoBarContainerController_.get() changeTabContents:tabContents];
1529 } 1527 }
1530 1528
1531 - (void)onReplaceTabWithContents:(WebContents*)contents { 1529 - (void)onReplaceTabWithContents:(WebContents*)contents {
1532 // Simply remove the preview view if it exists; the tab strip 1530 // Simply remove the preview view if it exists; the tab strip
1533 // controller will reinstall the view as the active view. 1531 // controller will reinstall the view as the active view.
1534 [previewableContentsController_ hidePreview]; 1532 [previewableContentsController_ hidePreview];
1535 [self updateBookmarkBarVisibilityWithAnimation:NO]; 1533 [self updateBookmarkBarVisibilityWithAnimation:NO];
1536 } 1534 }
1537 1535
1538 - (void)onTabChanged:(TabStripModelObserver::TabChangeType)change 1536 - (void)onTabChanged:(TabStripModelObserver::TabChangeType)change
1539 withContents:(WebContents*)contents { 1537 withContents:(WebContents*)contents {
1540 // Update titles if this is the currently selected tab and if it isn't just 1538 // Update titles if this is the currently selected tab and if it isn't just
1541 // the loading state which changed. 1539 // the loading state which changed.
1542 if (change != TabStripModelObserver::LOADING_ONLY) 1540 if (change != TabStripModelObserver::LOADING_ONLY)
1543 windowShim_->UpdateTitleBar(); 1541 windowShim_->UpdateTitleBar();
1544 1542
1545 // Update the bookmark bar if this is the currently selected tab and if it 1543 // Update the bookmark bar if this is the currently selected tab and if it
1546 // isn't just the title which changed. This for transitions between the NTP 1544 // isn't just the title which changed. This for transitions between the NTP
1547 // (showing its floating bookmark bar) and normal web pages (showing no 1545 // (showing its floating bookmark bar) and normal web pages (showing no
1548 // bookmark bar). 1546 // bookmark bar).
1549 // TODO(viettrungluu): perhaps update to not terminate running animations? 1547 // TODO(viettrungluu): perhaps update to not terminate running animations?
1550 if (change != TabStripModelObserver::TITLE_NOT_LOADING) 1548 if (change != TabStripModelObserver::TITLE_NOT_LOADING)
1551 [self updateBookmarkBarVisibilityWithAnimation:NO]; 1549 [self updateBookmarkBarVisibilityWithAnimation:NO];
1552 } 1550 }
1553 1551
1554 - (void)onTabDetachedWithContents:(WebContents*)contents { 1552 - (void)onTabDetachedWithContents:(WebContents*)contents {
1555 TabContentsWrapper* wrapper = 1553 TabContents* tabContents = TabContents::FromWebContents(contents);
1556 TabContentsWrapper::GetCurrentWrapperForContents(contents); 1554 [infoBarContainerController_ tabDetachedWithContents:tabContents];
1557 [infoBarContainerController_ tabDetachedWithContents:wrapper];
1558 } 1555 }
1559 1556
1560 - (void)userChangedTheme { 1557 - (void)userChangedTheme {
1561 // TODO(dmaclach): Instead of redrawing the whole window, views that care 1558 // TODO(dmaclach): Instead of redrawing the whole window, views that care
1562 // about the active window state should be registering for notifications. 1559 // about the active window state should be registering for notifications.
1563 [[self window] setViewsNeedDisplay:YES]; 1560 [[self window] setViewsNeedDisplay:YES];
1564 } 1561 }
1565 1562
1566 - (ui::ThemeProvider*)themeProvider { 1563 - (ui::ThemeProvider*)themeProvider {
1567 return ThemeServiceFactory::GetForProfile(browser_->profile()); 1564 return ThemeServiceFactory::GetForProfile(browser_->profile());
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 - (void)windowDidResize:(NSNotification*)notification { 1750 - (void)windowDidResize:(NSNotification*)notification {
1754 [self saveWindowPositionIfNeeded]; 1751 [self saveWindowPositionIfNeeded];
1755 1752
1756 // Resize (and possibly move) the status bubble. Note that we may get called 1753 // Resize (and possibly move) the status bubble. Note that we may get called
1757 // when the status bubble does not exist. 1754 // when the status bubble does not exist.
1758 if (statusBubble_) { 1755 if (statusBubble_) {
1759 statusBubble_->UpdateSizeAndPosition(); 1756 statusBubble_->UpdateSizeAndPosition();
1760 } 1757 }
1761 1758
1762 // Let the selected RenderWidgetHostView know, so that it can tell plugins. 1759 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
1763 if (WebContents* contents = browser_->GetSelectedWebContents()) { 1760 if (WebContents* contents = browser_->GetActiveWebContents()) {
1764 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 1761 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
1765 rwhv->WindowFrameChanged(); 1762 rwhv->WindowFrameChanged();
1766 } 1763 }
1767 1764
1768 // The FindBar needs to know its own position to properly detect overlaps 1765 // The FindBar needs to know its own position to properly detect overlaps
1769 // with find results. The position changes whenever the window is resized, 1766 // with find results. The position changes whenever the window is resized,
1770 // and |layoutSubviews| computes the FindBar's position. 1767 // and |layoutSubviews| computes the FindBar's position.
1771 // TODO: calling |layoutSubviews| here is a waste, find a better way to 1768 // TODO: calling |layoutSubviews| here is a waste, find a better way to
1772 // do this. 1769 // do this.
1773 if ([findBarCocoaController_ isFindBarVisible]) 1770 if ([findBarCocoaController_ isFindBarVisible])
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 // |-windowWillMove| is called too early for us to apply our heuristic. (The 1804 // |-windowWillMove| is called too early for us to apply our heuristic. (The
1808 // heuristic we use for detecting window movement is that if |windowTopGrowth_ 1805 // heuristic we use for detecting window movement is that if |windowTopGrowth_
1809 // > 0|, then we should be at the bottom of the work area -- if we're not, 1806 // > 0|, then we should be at the bottom of the work area -- if we're not,
1810 // we've moved. Similarly for the other side.) 1807 // we've moved. Similarly for the other side.)
1811 if (!NSContainsRect(workarea, windowFrame) || 1808 if (!NSContainsRect(workarea, windowFrame) ||
1812 (windowTopGrowth_ > 0 && NSMinY(windowFrame) != NSMinY(workarea)) || 1809 (windowTopGrowth_ > 0 && NSMinY(windowFrame) != NSMinY(workarea)) ||
1813 (windowBottomGrowth_ > 0 && NSMaxY(windowFrame) != NSMaxY(workarea))) 1810 (windowBottomGrowth_ > 0 && NSMaxY(windowFrame) != NSMaxY(workarea)))
1814 [self resetWindowGrowthState]; 1811 [self resetWindowGrowthState];
1815 1812
1816 // Let the selected RenderWidgetHostView know, so that it can tell plugins. 1813 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
1817 if (WebContents* contents = browser_->GetSelectedWebContents()) { 1814 if (WebContents* contents = browser_->GetActiveWebContents()) {
1818 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 1815 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
1819 rwhv->WindowFrameChanged(); 1816 rwhv->WindowFrameChanged();
1820 } 1817 }
1821 } 1818 }
1822 1819
1823 // Delegate method called when window will be resized; not called for 1820 // Delegate method called when window will be resized; not called for
1824 // |-setFrame:display:|. 1821 // |-setFrame:display:|.
1825 - (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize { 1822 - (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize {
1826 [self resetWindowGrowthState]; 1823 [self resetWindowGrowthState];
1827 return frameSize; 1824 return frameSize;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 2217
2221 - (BOOL)supportsBookmarkBar { 2218 - (BOOL)supportsBookmarkBar {
2222 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2219 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2223 } 2220 }
2224 2221
2225 - (BOOL)isTabbedWindow { 2222 - (BOOL)isTabbedWindow {
2226 return browser_->is_type_tabbed(); 2223 return browser_->is_type_tabbed();
2227 } 2224 }
2228 2225
2229 @end // @implementation BrowserWindowController(WindowType) 2226 @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