diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-31 00:33:57 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-31 00:33:57 +0000 |
commit | b0b053d415e9b7b3ad26774e721b10686dd28962 (patch) | |
tree | f324ececf88b02de407aae083bd6339c61f5f547 | |
parent | 7ae45d0506b2981d1884fda5281eee9e836a41a0 (diff) | |
download | chromium_src-b0b053d415e9b7b3ad26774e721b10686dd28962.zip chromium_src-b0b053d415e9b7b3ad26774e721b10686dd28962.tar.gz chromium_src-b0b053d415e9b7b3ad26774e721b10686dd28962.tar.bz2 |
Print Preview: Forward keyboard shortcuts to the browser.
BUG=104586
TEST=See bug.
Review URL: http://codereview.chromium.org/9169040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119781 0039d316-1c4b-4281-b951-d872f2087c98
13 files changed, 156 insertions, 44 deletions
diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc index 4037439..f74d546 100644 --- a/chrome/browser/printing/print_preview_tab_controller.cc +++ b/chrome/browser/printing/print_preview_tab_controller.cc @@ -19,8 +19,10 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_navigator.h" +#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/webui/constrained_html_ui.h" +#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" #include "chrome/browser/ui/webui/html_dialog_ui.h" #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" #include "chrome/common/chrome_content_client.h" @@ -53,6 +55,8 @@ void EnableInternalPDFPluginForTab(TabContentsWrapper* preview_tab) { ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); } +// HtmlDialogUIDelegate that specifies what the print preview dialog will look +// like. class PrintPreviewTabDelegate : public HtmlDialogUIDelegate { public: explicit PrintPreviewTabDelegate(TabContentsWrapper* initiator_tab); @@ -142,6 +146,46 @@ bool PrintPreviewTabDelegate::ShouldShowDialogTitle() const { return false; } +// WebContentsDelegate that forwards shortcut keys in the print preview +// renderer to the browser. +class PrintPreviewWebContentDelegate : public HtmlDialogTabContentsDelegate { + public: + PrintPreviewWebContentDelegate(Profile* profile, + TabContentsWrapper* initiator_tab); + virtual ~PrintPreviewWebContentDelegate(); + + virtual bool CanReloadContents(WebContents* source) const OVERRIDE; + virtual void HandleKeyboardEvent( + const NativeWebKeyboardEvent& event) OVERRIDE; + + private: + TabContentsWrapper* tab_; + + DISALLOW_COPY_AND_ASSIGN(PrintPreviewWebContentDelegate); +}; + +PrintPreviewWebContentDelegate::PrintPreviewWebContentDelegate( + Profile* profile, + TabContentsWrapper* initiator_tab) + : HtmlDialogTabContentsDelegate(profile), + tab_(initiator_tab) {} + +PrintPreviewWebContentDelegate::~PrintPreviewWebContentDelegate() {} + +bool PrintPreviewWebContentDelegate::CanReloadContents( + WebContents* source) const { + return false; +} + +void PrintPreviewWebContentDelegate::HandleKeyboardEvent( + const NativeWebKeyboardEvent& event) { + Browser* current_browser = + BrowserList::FindBrowserWithWebContents(tab_->web_contents()); + if (!current_browser) + return; + current_browser->window()->HandleKeyboardEvent(event); +} + } // namespace namespace printing { @@ -304,9 +348,6 @@ void PrintPreviewTabController::OnNavEntryCommitted( nav_type == content::NAVIGATION_TYPE_NEW_PAGE) { waiting_for_new_preview_page_ = false; SetInitiatorTabURLAndTitle(preview_tab); - - // Disabling the delegate will prevent all future navigation. - tab->web_contents()->SetDelegate(NULL); return; } @@ -379,12 +420,20 @@ TabContentsWrapper* PrintPreviewTabController::CreatePrintPreviewTab( } } - HtmlDialogUIDelegate* delegate = new PrintPreviewTabDelegate(initiator_tab); - ConstrainedHtmlUIDelegate* html_delegate = + // |html_dialog_ui_delegate| deletes itself in + // PrintPreviewTabDelegate::OnDialogClosed(). + HtmlDialogUIDelegate* html_dialog_ui_delegate = + new PrintPreviewTabDelegate(initiator_tab); + // |html_tab_content_delegate|'s owner is |constrained_html_ui_delegate|. + PrintPreviewWebContentDelegate* html_tab_content_delegate = + new PrintPreviewWebContentDelegate(current_browser->profile(), + initiator_tab); + ConstrainedHtmlUIDelegate* constrained_html_ui_delegate = ConstrainedHtmlUI::CreateConstrainedHtmlDialog(current_browser->profile(), - delegate, + html_dialog_ui_delegate, + html_tab_content_delegate, initiator_tab); - TabContentsWrapper* preview_tab = html_delegate->tab(); + TabContentsWrapper* preview_tab = constrained_html_ui_delegate->tab(); EnableInternalPDFPluginForTab(preview_tab); // Add an entry to the map. diff --git a/chrome/browser/ui/cocoa/constrained_html_delegate_mac.mm b/chrome/browser/ui/cocoa/constrained_html_delegate_mac.mm index f53b193..5dd94bad 100644 --- a/chrome/browser/ui/cocoa/constrained_html_delegate_mac.mm +++ b/chrome/browser/ui/cocoa/constrained_html_delegate_mac.mm @@ -25,7 +25,8 @@ class ConstrainedHtmlDelegateMac : public: ConstrainedHtmlDelegateMac(Profile* profile, - HtmlDialogUIDelegate* delegate); + HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate); ~ConstrainedHtmlDelegateMac() { if (release_tab_on_close_) ignore_result(tab_.release()); @@ -62,6 +63,7 @@ class ConstrainedHtmlDelegateMac : // Holds the HTML to be displayed in the sheet. scoped_ptr<TabContentsWrapper> tab_; HtmlDialogUIDelegate* html_delegate_; // weak. + scoped_ptr<HtmlDialogTabContentsDelegate> override_tab_delegate_; // The constrained window that owns |this|. Saved here because it needs to be // closed in response to the WebUI OnDialogClose callback. @@ -92,7 +94,8 @@ class ConstrainedHtmlDelegateMac : ConstrainedHtmlDelegateMac::ConstrainedHtmlDelegateMac( Profile* profile, - HtmlDialogUIDelegate* delegate) + HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate) : HtmlDialogTabContentsDelegate(profile), html_delegate_(delegate), constrained_window_(NULL), @@ -101,7 +104,12 @@ ConstrainedHtmlDelegateMac::ConstrainedHtmlDelegateMac( WebContents* web_contents = WebContents::Create( profile, NULL, MSG_ROUTING_NONE, NULL, NULL); tab_.reset(new TabContentsWrapper(web_contents)); - web_contents->SetDelegate(this); + if (tab_delegate) { + override_tab_delegate_.reset(tab_delegate); + web_contents->SetDelegate(tab_delegate); + } else { + web_contents->SetDelegate(this); + } // Set |this| as a property on the tab contents so that the ConstrainedHtmlUI // can get a reference to |this|. @@ -156,10 +164,11 @@ void ConstrainedHtmlDelegateMac::ReleaseTabContentsOnDialogClose() { ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( Profile* profile, HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate, TabContentsWrapper* wrapper) { // Deleted when ConstrainedHtmlDelegateMac::DeleteDelegate() runs. ConstrainedHtmlDelegateMac* constrained_delegate = - new ConstrainedHtmlDelegateMac(profile, delegate); + new ConstrainedHtmlDelegateMac(profile, delegate, tab_delegate); // Deleted when ConstrainedHtmlDelegateMac::OnDialogCloseFromWebUI() runs. ConstrainedWindow* constrained_window = new ConstrainedWindowMac(wrapper, constrained_delegate); diff --git a/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc b/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc index e77cceb..0da633c 100644 --- a/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc +++ b/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc @@ -24,7 +24,8 @@ class ConstrainedHtmlDelegateGtk : public ConstrainedWindowGtkDelegate, public ConstrainedHtmlUIDelegate { public: ConstrainedHtmlDelegateGtk(Profile* profile, - HtmlDialogUIDelegate* delegate); + HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate); virtual ~ConstrainedHtmlDelegateGtk() { if (release_tab_on_close_) @@ -79,6 +80,7 @@ class ConstrainedHtmlDelegateGtk : public ConstrainedWindowGtkDelegate, scoped_ptr<TabContentsWrapper> tab_; TabContentsContainerGtk tab_contents_container_; HtmlDialogUIDelegate* html_delegate_; + scoped_ptr<HtmlDialogTabContentsDelegate> override_tab_delegate_; // The constrained window that owns |this|. It's saved here because it needs // to be closed in response to the WebUI OnDialogClose callback. @@ -94,7 +96,8 @@ class ConstrainedHtmlDelegateGtk : public ConstrainedWindowGtkDelegate, ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( Profile* profile, - HtmlDialogUIDelegate* delegate) + HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate) : HtmlDialogTabContentsDelegate(profile), tab_contents_container_(NULL), html_delegate_(delegate), @@ -104,7 +107,12 @@ ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( WebContents* web_contents = WebContents::Create( profile, NULL, MSG_ROUTING_NONE, NULL, NULL); tab_.reset(new TabContentsWrapper(web_contents)); - web_contents->SetDelegate(this); + if (tab_delegate) { + override_tab_delegate_.reset(tab_delegate); + web_contents->SetDelegate(tab_delegate); + } else { + web_contents->SetDelegate(this); + } // Set |this| as a property on the tab contents so that the ConstrainedHtmlUI // can get a reference to |this|. @@ -130,9 +138,10 @@ ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( Profile* profile, HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate, TabContentsWrapper* overshadowed) { ConstrainedHtmlDelegateGtk* constrained_delegate = - new ConstrainedHtmlDelegateGtk(profile, delegate); + new ConstrainedHtmlDelegateGtk(profile, delegate, tab_delegate); ConstrainedWindow* constrained_window = new ConstrainedWindowGtk(overshadowed, constrained_delegate); constrained_delegate->set_window(constrained_window); diff --git a/chrome/browser/ui/login/login_prompt_ui.cc b/chrome/browser/ui/login/login_prompt_ui.cc index e233bfe..11ac0dd 100644 --- a/chrome/browser/ui/login/login_prompt_ui.cc +++ b/chrome/browser/ui/login/login_prompt_ui.cc @@ -263,7 +263,7 @@ void LoginHandlerHtml::BuildViewForPasswordManager( delegate_ = new LoginHandlerHtmlDelegate(this, explanation); ConstrainedWindow* dialog = ConstrainedHtmlUI::CreateConstrainedHtmlDialog( - profile, delegate_, wrapper)->window(); + profile, delegate_, NULL, wrapper)->window(); SetModel(manager); SetDialog(dialog); diff --git a/chrome/browser/ui/views/constrained_html_delegate_gtk.cc b/chrome/browser/ui/views/constrained_html_delegate_gtk.cc index 05235d3..055ddd3 100644 --- a/chrome/browser/ui/views/constrained_html_delegate_gtk.cc +++ b/chrome/browser/ui/views/constrained_html_delegate_gtk.cc @@ -26,7 +26,8 @@ class ConstrainedHtmlDelegateGtk : public views::NativeWidgetGtk, public HtmlDialogTabContentsDelegate { public: ConstrainedHtmlDelegateGtk(Profile* profile, - HtmlDialogUIDelegate* delegate); + HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate); ~ConstrainedHtmlDelegateGtk(); void set_window(ConstrainedWindow* window) { @@ -46,7 +47,6 @@ class ConstrainedHtmlDelegateGtk : public views::NativeWidgetGtk, return html_tab_contents_.get(); } - // ConstrainedWindowGtkDelegate implementation. virtual GtkWidget* GetWidgetRoot() OVERRIDE { return GetNativeView(); @@ -73,8 +73,8 @@ class ConstrainedHtmlDelegateGtk : public views::NativeWidgetGtk, private: scoped_ptr<TabContentsWrapper> html_tab_contents_; TabContentsContainer* tab_container_; - HtmlDialogUIDelegate* html_delegate_; + scoped_ptr<HtmlDialogTabContentsDelegate> override_tab_delegate_; // The constrained window that owns |this|. Saved so we can close it later. ConstrainedWindow* window_; @@ -89,7 +89,8 @@ class ConstrainedHtmlDelegateGtk : public views::NativeWidgetGtk, ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( Profile* profile, - HtmlDialogUIDelegate* delegate) + HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate) : views::NativeWidgetGtk(new views::Widget), HtmlDialogTabContentsDelegate(profile), tab_container_(NULL), @@ -101,7 +102,12 @@ ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( WebContents* web_contents = WebContents::Create(profile, NULL, MSG_ROUTING_NONE, NULL, NULL); html_tab_contents_.reset(new TabContentsWrapper(web_contents)); - web_contents->SetDelegate(this); + if (tab_delegate) { + override_tab_delegate_.reset(tab_delegate); + web_contents->SetDelegate(tab_delegate); + } else { + web_contents->SetDelegate(this); + } // Set |this| as a property so the ConstrainedHtmlUI can retrieve it. ConstrainedHtmlUI::GetPropertyAccessor().SetProperty( @@ -144,9 +150,10 @@ void ConstrainedHtmlDelegateGtk::OnDialogCloseFromWebUI() { ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( Profile* profile, HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate, TabContentsWrapper* wrapper) { ConstrainedHtmlDelegateGtk* constrained_delegate = - new ConstrainedHtmlDelegateGtk(profile, delegate); + new ConstrainedHtmlDelegateGtk(profile, delegate, tab_delegate); ConstrainedWindow* constrained_window = new ConstrainedWindowGtk(wrapper, constrained_delegate); constrained_delegate->set_window(constrained_window); diff --git a/chrome/browser/ui/views/constrained_html_delegate_views.cc b/chrome/browser/ui/views/constrained_html_delegate_views.cc index 3930212..aeb1b3b 100644 --- a/chrome/browser/ui/views/constrained_html_delegate_views.cc +++ b/chrome/browser/ui/views/constrained_html_delegate_views.cc @@ -25,7 +25,8 @@ class ConstrainedHtmlDelegateViews : public TabContentsContainer, public HtmlDialogTabContentsDelegate { public: ConstrainedHtmlDelegateViews(Profile* profile, - HtmlDialogUIDelegate* delegate); + HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate); ~ConstrainedHtmlDelegateViews(); void set_window(ConstrainedWindow* window) { @@ -88,8 +89,8 @@ class ConstrainedHtmlDelegateViews : public TabContentsContainer, private: scoped_ptr<TabContentsWrapper> html_tab_contents_; - HtmlDialogUIDelegate* html_delegate_; + scoped_ptr<HtmlDialogTabContentsDelegate> override_tab_delegate_; // The constrained window that owns |this|. Saved so we can close it later. ConstrainedWindow* window_; @@ -104,7 +105,8 @@ class ConstrainedHtmlDelegateViews : public TabContentsContainer, ConstrainedHtmlDelegateViews::ConstrainedHtmlDelegateViews( Profile* profile, - HtmlDialogUIDelegate* delegate) + HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate) : HtmlDialogTabContentsDelegate(profile), html_delegate_(delegate), window_(NULL), @@ -114,7 +116,12 @@ ConstrainedHtmlDelegateViews::ConstrainedHtmlDelegateViews( WebContents* web_contents = WebContents::Create(profile, NULL, MSG_ROUTING_NONE, NULL, NULL); html_tab_contents_.reset(new TabContentsWrapper(web_contents)); - web_contents->SetDelegate(this); + if (tab_delegate) { + override_tab_delegate_.reset(tab_delegate); + web_contents->SetDelegate(tab_delegate); + } else { + web_contents->SetDelegate(this); + } // Set |this| as a property so the ConstrainedHtmlUI can retrieve it. ConstrainedHtmlUI::GetPropertyAccessor().SetProperty( @@ -147,9 +154,10 @@ void ConstrainedHtmlDelegateViews::ReleaseTabContentsOnDialogClose() { ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( Profile* profile, HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate, TabContentsWrapper* container) { ConstrainedHtmlDelegateViews* constrained_delegate = - new ConstrainedHtmlDelegateViews(profile, delegate); + new ConstrainedHtmlDelegateViews(profile, delegate, tab_delegate); ConstrainedWindow* constrained_window = new ConstrainedWindowViews(container, constrained_delegate); constrained_delegate->set_window(constrained_window); diff --git a/chrome/browser/ui/webui/certificate_viewer_webui.cc b/chrome/browser/ui/webui/certificate_viewer_webui.cc index dc6b6bb..e97c3a5 100644 --- a/chrome/browser/ui/webui/certificate_viewer_webui.cc +++ b/chrome/browser/ui/webui/certificate_viewer_webui.cc @@ -10,7 +10,6 @@ #include "base/utf_string_conversions.h" #include "base/string_number_conversions.h" #include "chrome/browser/certificate_viewer.h" -#include "chrome/browser/ui/dialog_style.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_list.h" @@ -92,6 +91,7 @@ void CertificateViewerDialog::Show(gfx::NativeWindow parent) { window_ = ConstrainedHtmlUI::CreateConstrainedHtmlDialog( current_wrapper->profile(), this, + NULL, current_wrapper)->window()->GetNativeWindow(); #elif defined(OS_CHROMEOS) window_ = browser->BrowserShowHtmlDialog(this, parent, @@ -167,12 +167,8 @@ void CertificateViewerDialogHandler::RegisterMessages() { void CertificateViewerDialogHandler::ExportCertificate( const base::ListValue* args) { - int cert_index; - double val; - if (!(args->GetDouble(0, &val))) - return; - cert_index = (int)val; - if (cert_index < 0 || cert_index >= (int)cert_chain_.size()) + int cert_index = GetCertificateIndex(args); + if (cert_index < 0) return; ShowCertExportDialog(web_ui()->GetWebContents(), @@ -277,13 +273,10 @@ void CertificateViewerDialogHandler::RequestCertificateInfo( void CertificateViewerDialogHandler::RequestCertificateFields( const base::ListValue* args) { - int cert_index; - double val; - if (!(args->GetDouble(0, &val))) - return; - cert_index = (int)val; - if (cert_index < 0 || cert_index >= (int)cert_chain_.size()) + int cert_index = GetCertificateIndex(args); + if (cert_index < 0) return; + net::X509Certificate::OSCertHandle cert = cert_chain_[cert_index]; ListValue root_list; @@ -426,3 +419,15 @@ void CertificateViewerDialogHandler::RequestCertificateFields( web_ui()->CallJavascriptFunction("cert_viewer.getCertificateFields", root_list); } + +int CertificateViewerDialogHandler::GetCertificateIndex( + const base::ListValue* args) const { + int cert_index; + double val; + if (!(args->GetDouble(0, &val))) + return -1; + cert_index = static_cast<int>(val); + if (cert_index < 0 || cert_index >= static_cast<int>(cert_chain_.size())) + return -1; + return cert_index; +} diff --git a/chrome/browser/ui/webui/certificate_viewer_webui.h b/chrome/browser/ui/webui/certificate_viewer_webui.h index 35d0c85..a1553d1 100644 --- a/chrome/browser/ui/webui/certificate_viewer_webui.h +++ b/chrome/browser/ui/webui/certificate_viewer_webui.h @@ -6,6 +6,9 @@ #define CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_WEBUI_H_ #pragma once +#include <string> +#include <vector> + #include "base/compiler_specific.h" #include "base/values.h" #include "chrome/browser/ui/webui/html_dialog_ui.h" @@ -92,6 +95,10 @@ class CertificateViewerDialogHandler : public content::WebUIMessageHandler { // function cert_viewer.getCertificateInfo in a dictionary structure. void RequestCertificateInfo(const base::ListValue* args); + // Helper function to get the certificate index from |args|. Returns -1 if + // the index is out of range. + int GetCertificateIndex(const base::ListValue* args) const; + // The certificate being viewed. scoped_refptr<net::X509Certificate> cert_; diff --git a/chrome/browser/ui/webui/collected_cookies_ui_delegate.cc b/chrome/browser/ui/webui/collected_cookies_ui_delegate.cc index 11f82e6..fa3c2f1 100644 --- a/chrome/browser/ui/webui/collected_cookies_ui_delegate.cc +++ b/chrome/browser/ui/webui/collected_cookies_ui_delegate.cc @@ -149,6 +149,7 @@ void CollectedCookiesUIDelegate::Show(TabContentsWrapper* wrapper) { Profile* profile = wrapper->profile(); ConstrainedHtmlUI::CreateConstrainedHtmlDialog(profile, delegate, + NULL, wrapper); } diff --git a/chrome/browser/ui/webui/constrained_html_ui.h b/chrome/browser/ui/webui/constrained_html_ui.h index 4b21aff..ad2f806 100644 --- a/chrome/browser/ui/webui/constrained_html_ui.h +++ b/chrome/browser/ui/webui/constrained_html_ui.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,6 +10,7 @@ #include "content/public/browser/web_ui_controller.h" class ConstrainedWindow; +class HtmlDialogTabContentsDelegate; class HtmlDialogUIDelegate; class Profile; class RenderViewHost; @@ -48,6 +49,8 @@ class ConstrainedHtmlUIDelegate { // // Since ConstrainedWindow requires platform-specific delegate // implementations, this class is just a factory stub. +// TODO(thestig) Refactor the platform-independent code out of the +// platform-specific implementations. class ConstrainedHtmlUI : public content::WebUIController { public: explicit ConstrainedHtmlUI(content::WebUI* web_ui); @@ -59,9 +62,17 @@ class ConstrainedHtmlUI : public content::WebUIController { // Create a constrained HTML dialog. The actual object that gets created // is a ConstrainedHtmlUIDelegate, which later triggers construction of a // ConstrainedHtmlUI object. + // |profile| is used to construct the constrained HTML dialog's WebContents. + // |delegate| controls the behavior of the dialog. + // |tab_delegate| is optional, pass one in to use a custom + // HtmlDialogTabContentsDelegate with the dialog, or NULL to + // use the default one. The dialog takes ownership of + // |tab_delegate|. + // |overshadowed| is the tab being overshadowed by the dialog. static ConstrainedHtmlUIDelegate* CreateConstrainedHtmlDialog( Profile* profile, HtmlDialogUIDelegate* delegate, + HtmlDialogTabContentsDelegate* tab_delegate, TabContentsWrapper* overshadowed); // Returns a property accessor that can be used to set the diff --git a/chrome/browser/ui/webui/constrained_html_ui_browsertest.cc b/chrome/browser/ui/webui/constrained_html_ui_browsertest.cc index ed6dace..32594e1 100644 --- a/chrome/browser/ui/webui/constrained_html_ui_browsertest.cc +++ b/chrome/browser/ui/webui/constrained_html_ui_browsertest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -62,6 +62,7 @@ IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, BasicTest) { ConstrainedHtmlUIDelegate* html_ui_delegate = ConstrainedHtmlUI::CreateConstrainedHtmlDialog(browser()->profile(), delegate, + NULL, wrapper); ASSERT_TRUE(html_ui_delegate); EXPECT_TRUE(html_ui_delegate->window()); @@ -80,6 +81,7 @@ IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, ConstrainedHtmlUIDelegate* html_ui_delegate = ConstrainedHtmlUI::CreateConstrainedHtmlDialog(browser()->profile(), delegate, + NULL, wrapper); ASSERT_TRUE(html_ui_delegate); scoped_ptr<TabContentsWrapper> new_tab(html_ui_delegate->tab()); diff --git a/chrome/browser/ui/webui/ssl_client_certificate_selector_webui.cc b/chrome/browser/ui/webui/ssl_client_certificate_selector_webui.cc index b2c5313..1940a0c 100644 --- a/chrome/browser/ui/webui/ssl_client_certificate_selector_webui.cc +++ b/chrome/browser/ui/webui/ssl_client_certificate_selector_webui.cc @@ -122,7 +122,7 @@ void SSLClientCertificateSelectorWebUI::ShowDialog( cert_request_info, delegate); Profile* profile = wrapper->profile(); - ConstrainedHtmlUI::CreateConstrainedHtmlDialog(profile, ui, wrapper); + ConstrainedHtmlUI::CreateConstrainedHtmlDialog(profile, ui, NULL, wrapper); } SSLClientCertificateSelectorWebUI::SSLClientCertificateSelectorWebUI( diff --git a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc index 511b31a..6f955b7 100644 --- a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc +++ b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h" #include <string> +#include <vector> #include "base/basictypes.h" #include "base/json/json_reader.h" @@ -54,7 +55,10 @@ TabModalConfirmDialogWebUI::TabModalConfirmDialogWebUI( profile->GetChromeURLDataManager()->AddDataSource(data_source); constrained_html_ui_delegate_ = - ConstrainedHtmlUI::CreateConstrainedHtmlDialog(profile, this, wrapper); + ConstrainedHtmlUI::CreateConstrainedHtmlDialog(profile, + this, + NULL, + wrapper); delegate_->set_window(constrained_html_ui_delegate_->window()); } |