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

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

Issue 10871082: Constrained Windows Cocoa: Part 4 Refactor ConstrainedWindowSupport (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 8 years, 3 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/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 <cmath> 9 #include <cmath>
10 #include <limits> 10 #include <limits>
(...skipping 2058 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 // Raise window... 2069 // Raise window...
2070 [[switchView_ window] makeKeyAndOrderFront:self]; 2070 [[switchView_ window] makeKeyAndOrderFront:self];
2071 2071
2072 // ...and raise a tab with a sheet. 2072 // ...and raise a tab with a sheet.
2073 NSInteger index = [self modelIndexForContentsView:view]; 2073 NSInteger index = [self modelIndexForContentsView:view];
2074 DCHECK(index >= 0); 2074 DCHECK(index >= 0);
2075 if (index >= 0) 2075 if (index >= 0)
2076 tabStripModel_->ActivateTabAt(index, false /* not a user gesture */); 2076 tabStripModel_->ActivateTabAt(index, false /* not a user gesture */);
2077 } 2077 }
2078 2078
2079 - (void)attachConstrainedWindow:(ConstrainedWindowMac*)window {
2080 // TODO(thakis, avi): Figure out how to make this work when tabs are dragged
2081 // out or if fullscreen mode is toggled.
2082
2083 // View hierarchy of the contents view:
2084 // NSView -- switchView, same for all tabs
2085 // +- NSView -- TabContentsController's view
2086 // +- TabContentsViewCocoa
2087 // Changing it? Do not forget to modify removeConstrainedWindow too.
2088 // We use the TabContentsController's view in |swapInTabAtIndex|, so we have
Nico 2012/09/04 15:56:03 This comment is still true, right? Move it to the
sail 2012/09/04 17:04:22 Done. I view hierarchy related code into a helper
2089 // to pass it to the sheet controller here.
2090 NSView* tabContentsView =
2091 [window->owner()->web_contents()->GetNativeView() superview];
2092 window->delegate()->RunSheet([self sheetController], tabContentsView);
2093
2094 // TODO(avi, thakis): GTMWindowSheetController has no api to move tabsheets
2095 // between windows. Until then, we have to prevent having to move a tabsheet
2096 // between windows, e.g. no tearing off of tabs.
2097 NSInteger modelIndex = [self modelIndexForContentsView:tabContentsView];
2098 NSInteger index = [self indexFromModelIndex:modelIndex];
2099 BrowserWindowController* controller =
2100 (BrowserWindowController*)[[switchView_ window] windowController];
2101 DCHECK(controller != nil);
2102 DCHECK(index >= 0);
2103 if (index >= 0) {
2104 [controller setTab:[self viewAtIndex:index] isDraggable:NO];
2105 }
2106 }
2107
2108 - (void)removeConstrainedWindow:(ConstrainedWindowMac*)window {
2109 NSView* tabContentsView =
2110 [window->owner()->web_contents()->GetNativeView() superview];
2111
2112 // TODO(avi, thakis): GTMWindowSheetController has no api to move tabsheets
2113 // between windows. Until then, we have to prevent having to move a tabsheet
2114 // between windows, e.g. no tearing off of tabs.
2115 NSInteger modelIndex = [self modelIndexForContentsView:tabContentsView];
2116 if (modelIndex < 0) {
2117 // This can happen during shutdown where the tab contents view has already
2118 // removed itself.
2119 return;
2120 }
2121 NSInteger index = [self indexFromModelIndex:modelIndex];
2122 BrowserWindowController* controller =
2123 (BrowserWindowController*)[[switchView_ window] windowController];
2124 DCHECK(index >= 0);
2125 if (index >= 0) {
2126 [controller setTab:[self viewAtIndex:index] isDraggable:YES];
2127 }
2128 }
2129
2130 @end 2079 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698