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

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

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

Powered by Google App Engine
This is Rietveld 408576698