| OLD | NEW |
| 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/webui/constrained_html_ui.h" | 5 #include "chrome/browser/ui/webui/constrained_html_ui.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/memory/scoped_nsobject.h" | 9 #include "base/memory/scoped_nsobject.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" | 11 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" |
| 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 12 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 13 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 13 #include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" | 14 #include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" |
| 14 #include "content/browser/tab_contents/tab_contents.h" | 15 #include "content/browser/tab_contents/tab_contents.h" |
| 15 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
| 16 | 17 |
| 17 class ConstrainedHtmlDelegateMac : | 18 class ConstrainedHtmlDelegateMac : |
| 18 public ConstrainedWindowMacDelegateCustomSheet, | 19 public ConstrainedWindowMacDelegateCustomSheet, |
| 19 public HtmlDialogTabContentsDelegate, | 20 public HtmlDialogTabContentsDelegate, |
| 20 public ConstrainedHtmlUIDelegate { | 21 public ConstrainedHtmlUIDelegate { |
| 21 | 22 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 closed_via_webui_ = true; | 126 closed_via_webui_ = true; |
| 126 DCHECK(constrained_window_); | 127 DCHECK(constrained_window_); |
| 127 if (constrained_window_) | 128 if (constrained_window_) |
| 128 constrained_window_->CloseConstrainedWindow(); | 129 constrained_window_->CloseConstrainedWindow(); |
| 129 } | 130 } |
| 130 | 131 |
| 131 // static | 132 // static |
| 132 ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( | 133 ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( |
| 133 Profile* profile, | 134 Profile* profile, |
| 134 HtmlDialogUIDelegate* delegate, | 135 HtmlDialogUIDelegate* delegate, |
| 135 TabContents* overshadowed) { | 136 TabContentsWrapper* wrapper) { |
| 136 // Deleted when ConstrainedHtmlDelegateMac::DeleteDelegate() runs. | 137 // Deleted when ConstrainedHtmlDelegateMac::DeleteDelegate() runs. |
| 137 ConstrainedHtmlDelegateMac* constrained_delegate = | 138 ConstrainedHtmlDelegateMac* constrained_delegate = |
| 138 new ConstrainedHtmlDelegateMac(profile, delegate); | 139 new ConstrainedHtmlDelegateMac(profile, delegate); |
| 139 // Deleted when ConstrainedHtmlDelegateMac::OnDialogCloseFromWebUI() runs. | 140 // Deleted when ConstrainedHtmlDelegateMac::OnDialogCloseFromWebUI() runs. |
| 140 ConstrainedWindow* constrained_window = | 141 ConstrainedWindow* constrained_window = |
| 141 new ConstrainedWindowMac(overshadowed, constrained_delegate); | 142 new ConstrainedWindowMac(wrapper->tab_contents(), constrained_delegate); |
| 142 constrained_delegate->set_window(constrained_window); | 143 constrained_delegate->set_window(constrained_window); |
| 143 return constrained_window; | 144 return constrained_window; |
| 144 } | 145 } |
| 145 | 146 |
| 146 @implementation ConstrainedHtmlDialogSheetCocoa | 147 @implementation ConstrainedHtmlDialogSheetCocoa |
| 147 | 148 |
| 148 - (id)initWithConstrainedHtmlDelegateMac: | 149 - (id)initWithConstrainedHtmlDelegateMac: |
| 149 (ConstrainedHtmlDelegateMac*)ConstrainedHtmlDelegateMac { | 150 (ConstrainedHtmlDelegateMac*)ConstrainedHtmlDelegateMac { |
| 150 if ((self = [super init])) | 151 if ((self = [super init])) |
| 151 constrainedHtmlDelegate_ = ConstrainedHtmlDelegateMac; | 152 constrainedHtmlDelegate_ = ConstrainedHtmlDelegateMac; |
| 152 return self; | 153 return self; |
| 153 } | 154 } |
| 154 | 155 |
| 155 - (void)sheetDidEnd:(NSWindow*)sheet | 156 - (void)sheetDidEnd:(NSWindow*)sheet |
| 156 returnCode:(int)returnCode | 157 returnCode:(int)returnCode |
| 157 contextInfo:(void *)contextInfo { | 158 contextInfo:(void *)contextInfo { |
| 158 [sheet orderOut:self]; | 159 [sheet orderOut:self]; |
| 159 } | 160 } |
| 160 | 161 |
| 161 @end | 162 @end |
| OLD | NEW |