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

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

Issue 2174573002: [Constrained Web Dialogs] [Cocoa] Enable autoresizing immediately if intended. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/webui/constrained_web_dialog_delegate_base.h" 5 #include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 void RenderViewCreated(content::RenderViewHost* render_view_host) override { 142 void RenderViewCreated(content::RenderViewHost* render_view_host) override {
143 if (IsDialogAutoResizable()) 143 if (IsDialogAutoResizable())
144 EnableAutoResize(); 144 EnableAutoResize();
145 } 145 }
146 void RenderViewHostChanged(content::RenderViewHost* old_host, 146 void RenderViewHostChanged(content::RenderViewHost* old_host,
147 content::RenderViewHost* new_host) override { 147 content::RenderViewHost* new_host) override {
148 if (IsDialogAutoResizable()) 148 if (IsDialogAutoResizable())
149 EnableAutoResize(); 149 EnableAutoResize();
150 } 150 }
151 void DocumentOnLoadCompletedInMainFrame() override { 151 void DocumentOnLoadCompletedInMainFrame() override {
152 if (!IsDialogAutoResizable()) 152 if (IsDialogAutoResizable() && GetWebContents())
153 return;
154
155 EnableAutoResize();
156 if (GetWebContents())
157 constrained_window_->ShowWebContentsModalDialog(); 153 constrained_window_->ShowWebContentsModalDialog();
158 } 154 }
159 155
160 // ConstrainedWindowMacDelegate interface 156 // ConstrainedWindowMacDelegate interface
161 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { 157 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override {
162 if (!impl_->closed_via_webui()) 158 if (!impl_->closed_via_webui())
163 GetWebDialogDelegate()->OnDialogClosed(""); 159 GetWebDialogDelegate()->OnDialogClosed("");
164 delete this; 160 delete this;
165 } 161 }
166 162
(...skipping 28 matching lines...) Expand all
195 content::BrowserContext* browser_context, 191 content::BrowserContext* browser_context,
196 WebDialogDelegate* delegate, 192 WebDialogDelegate* delegate,
197 content::WebContents* web_contents, 193 content::WebContents* web_contents,
198 const gfx::Size& min_size, 194 const gfx::Size& min_size,
199 const gfx::Size& max_size) 195 const gfx::Size& max_size)
200 : content::WebContentsObserver(web_contents), 196 : content::WebContentsObserver(web_contents),
201 impl_(new ConstrainedWebDialogDelegateMac(browser_context, delegate, 197 impl_(new ConstrainedWebDialogDelegateMac(browser_context, delegate,
202 this)), 198 this)),
203 min_size_(min_size), 199 min_size_(min_size),
204 max_size_(max_size) { 200 max_size_(max_size) {
205 if (IsDialogAutoResizable()) 201 if (IsDialogAutoResizable()) {
206 Observe(GetWebContents()); 202 Observe(GetWebContents());
203 EnableAutoResize();
204 }
207 205
208 // Create a window to hold web_contents in the constrained sheet: 206 // Create a window to hold web_contents in the constrained sheet:
209 gfx::Size size; 207 gfx::Size size;
210 delegate->GetDialogSize(&size); 208 delegate->GetDialogSize(&size);
211 // The window size for autoresizing dialogs will be determined at a later 209 // The window size for autoresizing dialogs will be determined at a later
212 // time. 210 // time.
213 NSRect frame = IsDialogAutoResizable() ? ui::kWindowSizeDeterminedLater : 211 NSRect frame = IsDialogAutoResizable() ? ui::kWindowSizeDeterminedLater :
214 NSMakeRect(0, 0, size.width(), size.height()); 212 NSMakeRect(0, 0, size.width(), size.height());
215 213
216 window_.reset([[ConstrainedWindowCustomWindow alloc] 214 window_.reset([[ConstrainedWindowCustomWindow alloc]
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 const gfx::Size& max_size) { 253 const gfx::Size& max_size) {
256 DCHECK(!min_size.IsEmpty()); 254 DCHECK(!min_size.IsEmpty());
257 DCHECK(!max_size.IsEmpty()); 255 DCHECK(!max_size.IsEmpty());
258 // Deleted when the dialog closes. 256 // Deleted when the dialog closes.
259 ConstrainedWebDialogDelegateViewMac* constrained_delegate = 257 ConstrainedWebDialogDelegateViewMac* constrained_delegate =
260 new ConstrainedWebDialogDelegateViewMac( 258 new ConstrainedWebDialogDelegateViewMac(
261 browser_context, delegate, web_contents, 259 browser_context, delegate, web_contents,
262 min_size, max_size); 260 min_size, max_size);
263 return constrained_delegate; 261 return constrained_delegate;
264 } 262 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698