Index: chrome/browser/ui/views/constrained_html_delegate_views.cc |
=================================================================== |
--- chrome/browser/ui/views/constrained_html_delegate_views.cc (revision 104824) |
+++ chrome/browser/ui/views/constrained_html_delegate_views.cc (working copy) |
@@ -25,9 +25,14 @@ |
HtmlDialogUIDelegate* delegate); |
~ConstrainedHtmlDelegateViews(); |
+ TabContentsWrapper* tab() { |
+ return html_tab_contents_.get(); |
+ } |
+ |
// ConstrainedHtmlUIDelegate interface. |
virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() OVERRIDE; |
virtual void OnDialogCloseFromWebUI() OVERRIDE; |
+ virtual void ReleaseTabContentsOnDialogClose() OVERRIDE; |
// views::WidgetDelegate interface. |
virtual bool CanResize() const OVERRIDE { return true; } |
@@ -64,7 +69,7 @@ |
views::View* child) OVERRIDE { |
TabContentsContainer::ViewHierarchyChanged(is_add, parent, child); |
if (is_add && child == this) { |
- ChangeTabContents(&html_tab_contents_); |
+ ChangeTabContents(html_tab_contents_->tab_contents()); |
} |
} |
@@ -73,7 +78,7 @@ |
} |
private: |
- TabContents html_tab_contents_; |
+ scoped_ptr<TabContentsWrapper> html_tab_contents_; |
HtmlDialogUIDelegate* html_delegate_; |
@@ -83,29 +88,37 @@ |
// 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_; |
}; |
ConstrainedHtmlDelegateViews::ConstrainedHtmlDelegateViews( |
Profile* profile, |
HtmlDialogUIDelegate* delegate) |
: HtmlDialogTabContentsDelegate(profile), |
- html_tab_contents_(profile, NULL, MSG_ROUTING_NONE, NULL, NULL), |
html_delegate_(delegate), |
window_(NULL), |
- closed_via_webui_(false) { |
+ closed_via_webui_(false), |
+ release_tab_on_close_(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()); |
+ html_tab_contents_->tab_contents()->property_bag(), this); |
+ tab_contents->controller().LoadURL(delegate->GetDialogContentURL(), |
+ GURL(), |
+ PageTransition::START_PAGE, |
+ std::string()); |
} |
ConstrainedHtmlDelegateViews::~ConstrainedHtmlDelegateViews() { |
+ if (release_tab_on_close_) |
+ ignore_result(html_tab_contents_.release()); |
} |
HtmlDialogUIDelegate* ConstrainedHtmlDelegateViews::GetHtmlDialogUIDelegate() { |
@@ -117,6 +130,10 @@ |
window_->CloseConstrainedWindow(); |
} |
+void ConstrainedHtmlDelegateViews::ReleaseTabContentsOnDialogClose() { |
+ release_tab_on_close_ = true; |
+} |
+ |
// static |
ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( |
Profile* profile, |
@@ -134,3 +151,19 @@ |
return constrained_window; |
#endif |
} |
+TabContentsWrapper* ConstrainedHtmlUI::CreateConstrainedPrintPreviewHtmlUI( |
+ Profile* profile, |
+ HtmlDialogUIDelegate* delegate, |
+ TabContentsWrapper* container) { |
+#if defined(USE_AURA) |
+ // TODO(saintlou): Another atrocious hack until we get PureView version. |
+ return NULL; |
+#else |
+ ConstrainedHtmlDelegateViews* constrained_delegate = |
+ new ConstrainedHtmlDelegateViews(profile, delegate); |
+ ConstrainedWindow* constrained_window = |
+ new ConstrainedWindowViews(container, constrained_delegate); |
+ constrained_delegate->set_window(constrained_window); |
+ return constrained_delegate->tab(); |
+#endif |
+} |