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

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

Issue 7880003: content: Move constrained window code from TabContents to TabContentsWrapper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Attempt to fix views merge part 2 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 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" 5 #include "chrome/browser/ui/cocoa/constrained_window_mac.h"
6 6
7 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 7 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
8 #include "chrome/browser/ui/constrained_window_tab_helper.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
8 #include "content/browser/tab_contents/tab_contents.h" 10 #include "content/browser/tab_contents/tab_contents.h"
9 #include "content/browser/tab_contents/tab_contents_view.h" 11 #include "content/browser/tab_contents/tab_contents_view.h"
10 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" 12 #import "third_party/GTM/AppKit/GTMWindowSheetController.h"
11 13
12 ConstrainedWindowMacDelegateSystemSheet:: 14 ConstrainedWindowMacDelegateSystemSheet::
13 ConstrainedWindowMacDelegateSystemSheet(id delegate, SEL didEndSelector) 15 ConstrainedWindowMacDelegateSystemSheet(id delegate, SEL didEndSelector)
14 : systemSheet_(nil), 16 : systemSheet_(nil),
15 delegate_([delegate retain]), 17 delegate_([delegate retain]),
16 didEndSelector_(didEndSelector) {} 18 didEndSelector_(didEndSelector) {}
17 19
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 GTMWindowSheetController* sheetController, 79 GTMWindowSheetController* sheetController,
78 NSView* view) { 80 NSView* view) {
79 [sheetController beginSheet:customSheet_.get() 81 [sheetController beginSheet:customSheet_.get()
80 modalForView:view 82 modalForView:view
81 modalDelegate:delegate_.get() 83 modalDelegate:delegate_.get()
82 didEndSelector:didEndSelector_ 84 didEndSelector:didEndSelector_
83 contextInfo:NULL]; 85 contextInfo:NULL];
84 } 86 }
85 87
86 ConstrainedWindowMac::ConstrainedWindowMac( 88 ConstrainedWindowMac::ConstrainedWindowMac(
87 TabContents* owner, ConstrainedWindowMacDelegate* delegate) 89 TabContentsWrapper* wrapper, ConstrainedWindowMacDelegate* delegate)
88 : owner_(owner), 90 : wrapper_(wrapper),
89 delegate_(delegate), 91 delegate_(delegate),
90 controller_(nil), 92 controller_(nil),
91 should_be_visible_(false), 93 should_be_visible_(false),
92 closing_(false) { 94 closing_(false) {
93 DCHECK(owner); 95 DCHECK(wrapper);
94 DCHECK(delegate); 96 DCHECK(delegate);
95 97
96 owner->AddConstrainedDialog(this); 98 wrapper->constrained_window_tab_helper()->AddConstrainedDialog(this);
97 } 99 }
98 100
99 ConstrainedWindowMac::~ConstrainedWindowMac() {} 101 ConstrainedWindowMac::~ConstrainedWindowMac() {}
100 102
101 void ConstrainedWindowMac::ShowConstrainedWindow() { 103 void ConstrainedWindowMac::ShowConstrainedWindow() {
102 should_be_visible_ = true; 104 should_be_visible_ = true;
103 // The TabContents only has a native window if it is currently visible. In 105 // The TabContents only has a native window if it is currently visible. In
104 // this case, open the sheet now. Else, Realize() will be called later, when 106 // this case, open the sheet now. Else, Realize() will be called later, when
105 // our tab becomes visible. 107 // our tab becomes visible.
106 NSWindow* browserWindow = owner_->view()->GetTopLevelNativeWindow(); 108 NSWindow* browserWindow = wrapper_->view()->GetTopLevelNativeWindow();
107 NSWindowController* controller = [browserWindow windowController]; 109 NSWindowController* controller = [browserWindow windowController];
108 if (controller != nil) { 110 if (controller != nil) {
109 DCHECK([controller isKindOfClass:[BrowserWindowController class]]); 111 DCHECK([controller isKindOfClass:[BrowserWindowController class]]);
110 BrowserWindowController* browser_controller = 112 BrowserWindowController* browser_controller =
111 static_cast<BrowserWindowController*>(controller); 113 static_cast<BrowserWindowController*>(controller);
112 if ([browser_controller canAttachConstrainedWindow]) 114 if ([browser_controller canAttachConstrainedWindow])
113 Realize(browser_controller); 115 Realize(browser_controller);
114 } 116 }
115 } 117 }
116 118
117 void ConstrainedWindowMac::CloseConstrainedWindow() { 119 void ConstrainedWindowMac::CloseConstrainedWindow() {
118 // Protection against reentrancy, which might otherwise become a problem if 120 // Protection against reentrancy, which might otherwise become a problem if
119 // DeleteDelegate forcibly closes a constrained window in a way that results 121 // DeleteDelegate forcibly closes a constrained window in a way that results
120 // in CloseConstrainedWindow being called again. 122 // in CloseConstrainedWindow being called again.
121 if (closing_) 123 if (closing_)
122 return; 124 return;
123 125
124 closing_ = true; 126 closing_ = true;
125 127
126 // Note: controller_ can be `nil` here if the sheet was never realized. That's 128 // Note: controller_ can be `nil` here if the sheet was never realized. That's
127 // ok. 129 // ok.
128 [controller_ removeConstrainedWindow:this]; 130 [controller_ removeConstrainedWindow:this];
129 delegate_->DeleteDelegate(); 131 delegate_->DeleteDelegate();
130 owner_->WillClose(this); 132 wrapper_->constrained_window_tab_helper()->WillClose(this);
131 133
132 delete this; 134 delete this;
133 } 135 }
134 136
135 void ConstrainedWindowMac::Realize(BrowserWindowController* controller) { 137 void ConstrainedWindowMac::Realize(BrowserWindowController* controller) {
136 if (!should_be_visible_) 138 if (!should_be_visible_)
137 return; 139 return;
138 140
139 if (controller_ != nil) { 141 if (controller_ != nil) {
140 DCHECK(controller_ == controller); 142 DCHECK(controller_ == controller);
141 return; 143 return;
142 } 144 }
143 DCHECK(controller != nil); 145 DCHECK(controller != nil);
144 146
145 // Remember the controller we're adding ourselves to, so that we can later 147 // Remember the controller we're adding ourselves to, so that we can later
146 // remove us from it. 148 // remove us from it.
147 controller_ = controller; 149 controller_ = controller;
148 [controller_ attachConstrainedWindow:this]; 150 [controller_ attachConstrainedWindow:this];
149 delegate_->set_sheet_open(true); 151 delegate_->set_sheet_open(true);
150 } 152 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698