| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |