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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm

Issue 7880003: content: Move constrained window code from TabContents to TabContentsWrapper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac regression now that shutdown timing was changed for views. Created 9 years, 2 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) 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 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 24 matching lines...) Expand all
35 #import "chrome/browser/ui/cocoa/image_button_cell.h" 35 #import "chrome/browser/ui/cocoa/image_button_cell.h"
36 #import "chrome/browser/ui/cocoa/new_tab_button.h" 36 #import "chrome/browser/ui/cocoa/new_tab_button.h"
37 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" 37 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h"
38 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" 38 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h"
39 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" 39 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h"
40 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" 40 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h"
41 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 41 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
42 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 42 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
43 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" 43 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h"
44 #import "chrome/browser/ui/cocoa/tracking_area.h" 44 #import "chrome/browser/ui/cocoa/tracking_area.h"
45 #include "chrome/browser/ui/constrained_window_tab_helper.h"
45 #include "chrome/browser/ui/find_bar/find_bar.h" 46 #include "chrome/browser/ui/find_bar/find_bar.h"
46 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 47 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
47 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 48 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
48 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 49 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
49 #include "chrome/browser/ui/tabs/tab_menu_model.h" 50 #include "chrome/browser/ui/tabs/tab_menu_model.h"
50 #include "chrome/common/chrome_switches.h" 51 #include "chrome/common/chrome_switches.h"
51 #include "chrome/common/pref_names.h" 52 #include "chrome/common/pref_names.h"
52 #include "content/browser/tab_contents/navigation_controller.h" 53 #include "content/browser/tab_contents/navigation_controller.h"
53 #include "content/browser/tab_contents/navigation_entry.h" 54 #include "content/browser/tab_contents/navigation_entry.h"
54 #include "content/browser/tab_contents/tab_contents.h" 55 #include "content/browser/tab_contents/tab_contents.h"
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 // Tell per-tab sheet manager about currently selected tab. 506 // Tell per-tab sheet manager about currently selected tab.
506 if (sheetController_.get()) { 507 if (sheetController_.get()) {
507 [sheetController_ setActiveView:newView]; 508 [sheetController_ setActiveView:newView];
508 } 509 }
509 510
510 // Make sure the new tabs's sheets are visible (necessary when a background 511 // Make sure the new tabs's sheets are visible (necessary when a background
511 // tab opened a sheet while it was in the background and now becomes active). 512 // tab opened a sheet while it was in the background and now becomes active).
512 TabContentsWrapper* newTab = tabStripModel_->GetTabContentsAt(modelIndex); 513 TabContentsWrapper* newTab = tabStripModel_->GetTabContentsAt(modelIndex);
513 DCHECK(newTab); 514 DCHECK(newTab);
514 if (newTab) { 515 if (newTab) {
515 TabContents::ConstrainedWindowList::iterator it, end; 516 ConstrainedWindowTabHelper::ConstrainedWindowList::iterator it, end;
516 end = newTab->tab_contents()->constrained_window_end(); 517 end = newTab->constrained_window_tab_helper()->constrained_window_end();
517 NSWindowController* controller = [[newView window] windowController]; 518 NSWindowController* controller = [[newView window] windowController];
518 DCHECK([controller isKindOfClass:[BrowserWindowController class]]); 519 DCHECK([controller isKindOfClass:[BrowserWindowController class]]);
519 520
520 for (it = newTab->tab_contents()->constrained_window_begin(); 521 for (it = newTab->constrained_window_tab_helper()->
522 constrained_window_begin();
521 it != end; 523 it != end;
522 ++it) { 524 ++it) {
523 ConstrainedWindow* constrainedWindow = *it; 525 ConstrainedWindow* constrainedWindow = *it;
524 static_cast<ConstrainedWindowMac*>(constrainedWindow)->Realize( 526 static_cast<ConstrainedWindowMac*>(constrainedWindow)->Realize(
525 static_cast<BrowserWindowController*>(controller)); 527 static_cast<BrowserWindowController*>(controller));
526 } 528 }
527 } 529 }
528 } 530 }
529 531
530 // Create a new tab view and set its cell correctly so it draws the way we want 532 // Create a new tab view and set its cell correctly so it draws the way we want
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 // TODO(thakis, avi): Figure out how to make this work when tabs are dragged 1987 // TODO(thakis, avi): Figure out how to make this work when tabs are dragged
1986 // out or if fullscreen mode is toggled. 1988 // out or if fullscreen mode is toggled.
1987 1989
1988 // View hierarchy of the contents view: 1990 // View hierarchy of the contents view:
1989 // NSView -- switchView, same for all tabs 1991 // NSView -- switchView, same for all tabs
1990 // +- NSView -- TabContentsController's view 1992 // +- NSView -- TabContentsController's view
1991 // +- TabContentsViewCocoa 1993 // +- TabContentsViewCocoa
1992 // Changing it? Do not forget to modify removeConstrainedWindow too. 1994 // Changing it? Do not forget to modify removeConstrainedWindow too.
1993 // We use the TabContentsController's view in |swapInTabAtIndex|, so we have 1995 // We use the TabContentsController's view in |swapInTabAtIndex|, so we have
1994 // to pass it to the sheet controller here. 1996 // to pass it to the sheet controller here.
1995 NSView* tabContentsView = [window->owner()->GetNativeView() superview]; 1997 NSView* tabContentsView =
1998 [window->owner()->tab_contents()->GetNativeView() superview];
1996 window->delegate()->RunSheet([self sheetController], tabContentsView); 1999 window->delegate()->RunSheet([self sheetController], tabContentsView);
1997 2000
1998 // TODO(avi, thakis): GTMWindowSheetController has no api to move tabsheets 2001 // TODO(avi, thakis): GTMWindowSheetController has no api to move tabsheets
1999 // between windows. Until then, we have to prevent having to move a tabsheet 2002 // between windows. Until then, we have to prevent having to move a tabsheet
2000 // between windows, e.g. no tearing off of tabs. 2003 // between windows, e.g. no tearing off of tabs.
2001 NSInteger modelIndex = [self modelIndexForContentsView:tabContentsView]; 2004 NSInteger modelIndex = [self modelIndexForContentsView:tabContentsView];
2002 NSInteger index = [self indexFromModelIndex:modelIndex]; 2005 NSInteger index = [self indexFromModelIndex:modelIndex];
2003 BrowserWindowController* controller = 2006 BrowserWindowController* controller =
2004 (BrowserWindowController*)[[switchView_ window] windowController]; 2007 (BrowserWindowController*)[[switchView_ window] windowController];
2005 DCHECK(controller != nil); 2008 DCHECK(controller != nil);
2006 DCHECK(index >= 0); 2009 DCHECK(index >= 0);
2007 if (index >= 0) { 2010 if (index >= 0) {
2008 [controller setTab:[self viewAtIndex:index] isDraggable:NO]; 2011 [controller setTab:[self viewAtIndex:index] isDraggable:NO];
2009 } 2012 }
2010 } 2013 }
2011 2014
2012 - (void)removeConstrainedWindow:(ConstrainedWindowMac*)window { 2015 - (void)removeConstrainedWindow:(ConstrainedWindowMac*)window {
2013 NSView* tabContentsView = [window->owner()->GetNativeView() superview]; 2016 NSView* tabContentsView =
2017 [window->owner()->tab_contents()->GetNativeView() superview];
2014 2018
2015 // TODO(avi, thakis): GTMWindowSheetController has no api to move tabsheets 2019 // TODO(avi, thakis): GTMWindowSheetController has no api to move tabsheets
2016 // between windows. Until then, we have to prevent having to move a tabsheet 2020 // between windows. Until then, we have to prevent having to move a tabsheet
2017 // between windows, e.g. no tearing off of tabs. 2021 // between windows, e.g. no tearing off of tabs.
2018 NSInteger modelIndex = [self modelIndexForContentsView:tabContentsView]; 2022 NSInteger modelIndex = [self modelIndexForContentsView:tabContentsView];
2023 if (modelIndex < 0) {
2024 // This can happen during shutdown where the tab contents view has already
2025 // removed itself.
2026 return;
2027 }
2019 NSInteger index = [self indexFromModelIndex:modelIndex]; 2028 NSInteger index = [self indexFromModelIndex:modelIndex];
2020 BrowserWindowController* controller = 2029 BrowserWindowController* controller =
2021 (BrowserWindowController*)[[switchView_ window] windowController]; 2030 (BrowserWindowController*)[[switchView_ window] windowController];
2022 DCHECK(index >= 0); 2031 DCHECK(index >= 0);
2023 if (index >= 0) { 2032 if (index >= 0) {
2024 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; 2033 [controller setTab:[self viewAtIndex:index] isDraggable:YES];
2025 } 2034 }
2026 } 2035 }
2027 2036
2028 @end 2037 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698