Index: chrome/browser/ui/views/constrained_html_delegate_gtk.cc |
=================================================================== |
--- chrome/browser/ui/views/constrained_html_delegate_gtk.cc (revision 104824) |
+++ chrome/browser/ui/views/constrained_html_delegate_gtk.cc (working copy) |
@@ -26,12 +26,15 @@ |
HtmlDialogUIDelegate* delegate); |
~ConstrainedHtmlDelegateGtk(); |
+ TabContentsWrapper* tab() { |
+ return html_tab_contents_.get(); |
+ } |
+ |
// ConstrainedHtmlUIDelegate interface. |
virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() OVERRIDE; |
virtual void OnDialogCloseFromWebUI() OVERRIDE; |
- virtual bool GetBackgroundColor(GdkColor* color) OVERRIDE { |
- *color = ui::kGdkWhite; |
- return true; |
+ virtual void ReleaseTabContentsOnDialogClose() OVERRIDE { |
+ release_tab_on_close_ = true; |
} |
// ConstrainedWindowGtkDelegate implementation. |
@@ -39,13 +42,17 @@ |
return GetNativeView(); |
} |
virtual GtkWidget* GetFocusWidget() OVERRIDE { |
- return html_tab_contents_.GetContentNativeView(); |
+ return html_tab_contents_->tab_contents()->GetContentNativeView(); |
} |
virtual void DeleteDelegate() OVERRIDE { |
if (!closed_via_webui_) |
html_delegate_->OnDialogClosed(""); |
tab_container_->ChangeTabContents(NULL); |
} |
+ virtual bool GetBackgroundColor(GdkColor* color) OVERRIDE { |
+ *color = ui::kGdkWhite; |
+ return true; |
+ } |
virtual bool ShouldHaveBorderPadding() const OVERRIDE { |
return false; |
} |
@@ -58,7 +65,7 @@ |
} |
private: |
- TabContents html_tab_contents_; |
+ scoped_ptr<TabContentsWrapper> html_tab_contents_; |
TabContentsContainer* tab_container_; |
HtmlDialogUIDelegate* html_delegate_; |
@@ -69,6 +76,9 @@ |
// Was the dialog closed from WebUI (in which case |html_delegate_|'s |
// OnDialogClosed() method has already been called)? |
bool closed_via_webui_; |
+ |
+ // If true, release |tab_| on close instead of destroying it. |
+ bool release_tab_on_close_; |
}; |
ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( |
@@ -76,21 +86,21 @@ |
HtmlDialogUIDelegate* delegate) |
: views::NativeWidgetGtk(new views::Widget), |
HtmlDialogTabContentsDelegate(profile), |
- html_tab_contents_(profile, NULL, MSG_ROUTING_NONE, NULL, NULL), |
tab_container_(NULL), |
html_delegate_(delegate), |
window_(NULL), |
closed_via_webui_(false) { |
CHECK(delegate); |
- html_tab_contents_.set_delegate(this); |
+ TabContents* tab_contents = |
+ new TabContents(profile, NULL, MSG_ROUTING_NONE, NULL, NULL); |
+ html_tab_contents_.reset(new TabContentsWrapper(tab_contents)); |
+ tab_contents->set_delegate(this); |
// Set |this| as a property so the ConstrainedHtmlUI can retrieve it. |
ConstrainedHtmlUI::GetPropertyAccessor().SetProperty( |
- html_tab_contents_.property_bag(), this); |
- html_tab_contents_.controller().LoadURL(delegate->GetDialogContentURL(), |
- GURL(), |
- PageTransition::START_PAGE, |
- std::string()); |
+ tab_contents->property_bag(), this); |
+ tab_contents->controller().LoadURL(delegate->GetDialogContentURL(), GURL(), |
+ PageTransition::START_PAGE, std::string()); |
views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); |
params.native_widget = this; |
@@ -98,7 +108,7 @@ |
tab_container_ = new TabContentsContainer; |
GetWidget()->SetContentsView(tab_container_); |
- tab_container_->ChangeTabContents(&html_tab_contents_); |
+ tab_container_->ChangeTabContents(html_tab_contents_->tab_contents()); |
gfx::Size dialog_size; |
html_delegate_->GetDialogSize(&dialog_size); |
@@ -131,3 +141,16 @@ |
constrained_delegate->set_window(constrained_window); |
return constrained_window; |
} |
+ |
+// static |
+TabContentsWrapper* ConstrainedHtmlUI::CreateConstrainedPrintPreviewHtmlUI( |
+ Profile* profile, |
+ HtmlDialogUIDelegate* delegate, |
+ TabContentsWrapper* wrapper) { |
+ ConstrainedHtmlDelegateGtk* constrained_delegate = |
+ new ConstrainedHtmlDelegateGtk(profile, delegate); |
+ ConstrainedWindow* constrained_window = |
+ new ConstrainedWindowGtk(wrapper, constrained_delegate); |
+ constrained_delegate->set_window(constrained_window); |
+ return constrained_delegate->tab(); |
+} |