| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/cocoa/tab_strip_controller.h" | 5 #import "chrome/browser/cocoa/tab_strip_controller.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/mac_util.h" | 9 #include "base/mac_util.h" |
| 10 #include "base/nsimage_cache_mac.h" | 10 #include "base/nsimage_cache_mac.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 NSArray* subviews = [switchView_ subviews]; | 187 NSArray* subviews = [switchView_ subviews]; |
| 188 if ([subviews count]) { | 188 if ([subviews count]) { |
| 189 NSView* oldView = [subviews objectAtIndex:0]; | 189 NSView* oldView = [subviews objectAtIndex:0]; |
| 190 [switchView_ replaceSubview:oldView with:newView]; | 190 [switchView_ replaceSubview:oldView with:newView]; |
| 191 } else { | 191 } else { |
| 192 [switchView_ addSubview:newView]; | 192 [switchView_ addSubview:newView]; |
| 193 } | 193 } |
| 194 | 194 |
| 195 // Make sure the new tabs's sheets are visible (necessary when a background | 195 // Make sure the new tabs's sheets are visible (necessary when a background |
| 196 // tab opened a sheet while it was in the background and now becomes active). | 196 // tab opened a sheet while it was in the background and now becomes active). |
| 197 // TODO(viettrungluu@gmail.com): Directly iterating over the |TabContents|'s |
| 198 // (essentially internal, private) list isn't great -- I'd like to get rid of |
| 199 // this and somehow move it into |TabContents| itself (or provide a cleaner |
| 200 // interface). |
| 197 TabContents* newTab = tabModel_->GetTabContentsAt(index); | 201 TabContents* newTab = tabModel_->GetTabContentsAt(index); |
| 198 DCHECK(newTab); | 202 DCHECK(newTab); |
| 199 if (newTab) { | 203 if (newTab) { |
| 200 TabContents::ConstrainedWindowList::iterator it, end; | 204 TabContents::ConstrainedWindowList::iterator it, end; |
| 201 end = newTab->constrained_window_end(); | 205 end = newTab->constrained_window_end(); |
| 202 NSWindowController* controller = [[newView window] windowController]; | 206 NSWindowController* controller = [[newView window] windowController]; |
| 203 DCHECK([controller isKindOfClass:[BrowserWindowController class]]); | 207 DCHECK([controller isKindOfClass:[BrowserWindowController class]]); |
| 204 | 208 |
| 205 for (it = newTab->constrained_window_begin(); it != end; ++it) { | 209 for (it = newTab->constrained_window_begin(); it != end; ++it) { |
| 206 ConstrainedWindow* constrainedWindow = *it; | 210 ConstrainedWindow* constrainedWindow = *it; |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 | 956 |
| 953 // View hierarchy of the contents view: | 957 // View hierarchy of the contents view: |
| 954 // NSView -- switchView, same for all tabs | 958 // NSView -- switchView, same for all tabs |
| 955 // +- NSView -- TabContentsController's view | 959 // +- NSView -- TabContentsController's view |
| 956 // +- NSBox | 960 // +- NSBox |
| 957 // +- TabContentsViewCocoa | 961 // +- TabContentsViewCocoa |
| 958 // We use the TabContentsController's view in |swapInTabAtIndex|, so we have | 962 // We use the TabContentsController's view in |swapInTabAtIndex|, so we have |
| 959 // to pass it to the sheet controller here. | 963 // to pass it to the sheet controller here. |
| 960 NSView* tabContentsView = | 964 NSView* tabContentsView = |
| 961 [[window->owner()->GetNativeView() superview] superview]; | 965 [[window->owner()->GetNativeView() superview] superview]; |
| 962 window->delegate()->RunSheet([self sheetController], tabContentsView); | 966 SEL frameSelector = nil; |
| 967 SEL positionSelector = nil; |
| 968 if (window->delegate()->GetModalityLevel() >= |
| 969 ConstrainedWindow::kModalForTab) { |
| 970 frameSelector = @selector(frameWithBars); |
| 971 positionSelector = @selector(positionSheetBelowToolbar:usingRect:); |
| 972 } |
| 973 window->delegate()->RunSheet([self sheetController], |
| 974 tabContentsView, |
| 975 frameSelector, |
| 976 positionSelector); |
| 963 | 977 |
| 964 // TODO(avi, thakis): GTMWindowSheetController has no api to move tabsheets | 978 // TODO(avi, thakis): GTMWindowSheetController has no api to move tabsheets |
| 965 // between windows. Until then, we have to prevent having to move a tabsheet | 979 // between windows. Until then, we have to prevent having to move a tabsheet |
| 966 // between windows, e.g. no tearing off of tabs. | 980 // between windows, e.g. no tearing off of tabs. |
| 967 NSInteger index = [self indexForContentsView:tabContentsView]; | 981 NSInteger index = [self indexForContentsView:tabContentsView]; |
| 968 BrowserWindowController* controller = | 982 BrowserWindowController* controller = |
| 969 (BrowserWindowController*)[[switchView_ window] windowController]; | 983 (BrowserWindowController*)[[switchView_ window] windowController]; |
| 970 DCHECK(controller != nil); | 984 DCHECK(controller != nil); |
| 971 DCHECK(index >= 0); | 985 DCHECK(index >= 0); |
| 972 if (index >= 0) { | 986 if (index >= 0) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 985 BrowserWindowController* controller = | 999 BrowserWindowController* controller = |
| 986 (BrowserWindowController*)[[switchView_ window] windowController]; | 1000 (BrowserWindowController*)[[switchView_ window] windowController]; |
| 987 DCHECK(index >= 0); | 1001 DCHECK(index >= 0); |
| 988 if (index >= 0) { | 1002 if (index >= 0) { |
| 989 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; | 1003 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; |
| 990 } | 1004 } |
| 991 } | 1005 } |
| 992 | 1006 |
| 993 | 1007 |
| 994 @end | 1008 @end |
| OLD | NEW |