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

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

Issue 10870094: Constrained window sheet controller (test patch) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename 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 12 matching lines...) Expand all
23 #include "chrome/browser/extensions/tab_helper.h" 23 #include "chrome/browser/extensions/tab_helper.h"
24 #include "chrome/browser/favicon/favicon_tab_helper.h" 24 #include "chrome/browser/favicon/favicon_tab_helper.h"
25 #include "chrome/browser/net/url_fixer_upper.h" 25 #include "chrome/browser/net/url_fixer_upper.h"
26 #include "chrome/browser/prefs/pref_service.h" 26 #include "chrome/browser/prefs/pref_service.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/profiles/profile_manager.h" 28 #include "chrome/browser/profiles/profile_manager.h"
29 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
30 #include "chrome/browser/ui/browser_navigator.h" 30 #include "chrome/browser/ui/browser_navigator.h"
31 #include "chrome/browser/ui/browser_tabstrip.h" 31 #include "chrome/browser/ui/browser_tabstrip.h"
32 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 32 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
33 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h"
33 #import "chrome/browser/ui/cocoa/constrained_window_mac.h" 34 #import "chrome/browser/ui/cocoa/constrained_window_mac.h"
34 #include "chrome/browser/ui/cocoa/drag_util.h" 35 #include "chrome/browser/ui/cocoa/drag_util.h"
35 #import "chrome/browser/ui/cocoa/image_button_cell.h" 36 #import "chrome/browser/ui/cocoa/image_button_cell.h"
36 #import "chrome/browser/ui/cocoa/new_tab_button.h" 37 #import "chrome/browser/ui/cocoa/new_tab_button.h"
37 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h" 38 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h"
38 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" 39 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
39 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" 40 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h"
40 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" 41 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h"
41 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" 42 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h"
42 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 43 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 [switchView_ addSubview:newView]; 545 [switchView_ addSubview:newView];
545 } 546 }
546 547
547 // New content is in place, delegate should adjust itself accordingly. 548 // New content is in place, delegate should adjust itself accordingly.
548 [delegate_ onActivateTabWithContents:[controller webContents]]; 549 [delegate_ onActivateTabWithContents:[controller webContents]];
549 550
550 // It also restores content autoresizing properties. 551 // It also restores content autoresizing properties.
551 [controller ensureContentsVisible]; 552 [controller ensureContentsVisible];
552 553
553 // Tell per-tab sheet manager about currently selected tab. 554 // Tell per-tab sheet manager about currently selected tab.
554 if (sheetController_.get()) { 555 if (sheetController_.get())
555 [sheetController_ setActiveView:newView]; 556 [sheetController_ setActiveView:newView];
556 } 557
558 NSWindow* parentWindow = [switchView_ window];
559 ConstrainedWindowSheetController* sheetController =
560 [ConstrainedWindowSheetController
561 controllerForParentWindow:parentWindow];
562 [sheetController parentViewDidBecomeActive:newView];
557 563
558 // Make sure the new tabs's sheets are visible (necessary when a background 564 // Make sure the new tabs's sheets are visible (necessary when a background
559 // tab opened a sheet while it was in the background and now becomes active). 565 // tab opened a sheet while it was in the background and now becomes active).
560 TabContents* newTab = tabStripModel_->GetTabContentsAt(modelIndex); 566 TabContents* newTab = tabStripModel_->GetTabContentsAt(modelIndex);
561 DCHECK(newTab); 567 DCHECK(newTab);
562 if (newTab) { 568 if (newTab && ![sheetController sheetCount]) {
563 ConstrainedWindowTabHelper::ConstrainedWindowList::iterator it, end; 569 ConstrainedWindowTabHelper::ConstrainedWindowList::iterator it, end;
564 end = newTab->constrained_window_tab_helper()->constrained_window_end(); 570 end = newTab->constrained_window_tab_helper()->constrained_window_end();
565 NSWindowController* controller = [[newView window] windowController]; 571 NSWindowController* controller = [[newView window] windowController];
566 DCHECK([controller isKindOfClass:[BrowserWindowController class]]); 572 DCHECK([controller isKindOfClass:[BrowserWindowController class]]);
567 573
568 for (it = newTab->constrained_window_tab_helper()-> 574 for (it = newTab->constrained_window_tab_helper()->
569 constrained_window_begin(); 575 constrained_window_begin();
570 it != end; 576 it != end;
571 ++it) { 577 ++it) {
572 ConstrainedWindow* constrainedWindow = *it; 578 ConstrainedWindow* constrainedWindow = *it;
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 // Raise window... 2075 // Raise window...
2070 [[switchView_ window] makeKeyAndOrderFront:self]; 2076 [[switchView_ window] makeKeyAndOrderFront:self];
2071 2077
2072 // ...and raise a tab with a sheet. 2078 // ...and raise a tab with a sheet.
2073 NSInteger index = [self modelIndexForContentsView:view]; 2079 NSInteger index = [self modelIndexForContentsView:view];
2074 DCHECK(index >= 0); 2080 DCHECK(index >= 0);
2075 if (index >= 0) 2081 if (index >= 0)
2076 tabStripModel_->ActivateTabAt(index, false /* not a user gesture */); 2082 tabStripModel_->ActivateTabAt(index, false /* not a user gesture */);
2077 } 2083 }
2078 2084
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
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 2085 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_controller.h ('k') | chrome/browser/ui/cocoa/tabs/tab_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698