diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 21:56:55 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 21:56:55 +0000 |
commit | 5835871a6f47c28ff022c9284e2aa1f0d1761ab3 (patch) | |
tree | 52eba6e7556400aa0b519216907844110bc8ce8a /chrome/browser/ui/webui | |
parent | bc6d23dc0d55aeda0be5ae9d799046ff6a43db14 (diff) | |
download | chromium_src-5835871a6f47c28ff022c9284e2aa1f0d1761ab3.zip chromium_src-5835871a6f47c28ff022c9284e2aa1f0d1761ab3.tar.gz chromium_src-5835871a6f47c28ff022c9284e2aa1f0d1761ab3.tar.bz2 |
Web-ify a bunch of these names. I am going to move some of the framework code here down to ui/web_dialogs in a future cl, hence the namespaces.
HtmlDialogUI->WebDialogUI
HtmlDialogUIDelegate->WebDialogDelegate
HtmlDialogTabContentsDelegate->WebDialogWebContentsDelegate
HtmlDialogView->WebDialogView
HtmlDialogController->WebDialogController
HtmlDialogGtk -> WebDialogGtk
BUG=none
TEST=none
TBR=sky
Review URL: https://chromiumcodereview.appspot.com/10214001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/webui')
33 files changed, 419 insertions, 409 deletions
diff --git a/chrome/browser/ui/webui/certificate_viewer_ui.cc b/chrome/browser/ui/webui/certificate_viewer_ui.cc index cd16522..9a08af0 100644 --- a/chrome/browser/ui/webui/certificate_viewer_ui.cc +++ b/chrome/browser/ui/webui/certificate_viewer_ui.cc @@ -15,7 +15,7 @@ #include "grit/generated_resources.h" CertificateViewerUI::CertificateViewerUI(content::WebUI* web_ui) - : ConstrainedHtmlUI(web_ui) { + : ConstrainedWebDialogUI(web_ui) { // Set up the chrome://view-cert source. ChromeWebUIDataSource* html_source = new ChromeWebUIDataSource(chrome::kChromeUICertificateViewerHost); diff --git a/chrome/browser/ui/webui/certificate_viewer_ui.h b/chrome/browser/ui/webui/certificate_viewer_ui.h index 1a895fc..c263840 100644 --- a/chrome/browser/ui/webui/certificate_viewer_ui.h +++ b/chrome/browser/ui/webui/certificate_viewer_ui.h @@ -6,10 +6,10 @@ #define CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_UI_H_ #pragma once -#include "chrome/browser/ui/webui/constrained_html_ui.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" // The WebUI for chrome://view-cert -class CertificateViewerUI : public ConstrainedHtmlUI { +class CertificateViewerUI : public ConstrainedWebDialogUI { public: explicit CertificateViewerUI(content::WebUI* web_ui); virtual ~CertificateViewerUI(); diff --git a/chrome/browser/ui/webui/certificate_viewer_webui.cc b/chrome/browser/ui/webui/certificate_viewer_webui.cc index af09b6f..e9d94cd 100644 --- a/chrome/browser/ui/webui/certificate_viewer_webui.cc +++ b/chrome/browser/ui/webui/certificate_viewer_webui.cc @@ -19,7 +19,7 @@ #include "chrome/browser/ui/certificate_dialogs.h" #include "chrome/browser/ui/dialog_style.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/constrained_web_dialog_ui.h" #include "chrome/common/net/x509_certificate_model.h" #include "chrome/common/url_constants.h" #include "content/public/browser/web_contents.h" @@ -72,8 +72,8 @@ void CertificateViewerDialog::Show(gfx::NativeWindow parent) { TabContentsWrapper* current_wrapper = browser->GetSelectedTabContentsWrapper(); // TODO(bshe): UI tweaks needed for AURA html Dialog, such as add padding on - // title for AURA ConstrainedHtmlDialog. - window_ = ConstrainedHtmlUI::CreateConstrainedHtmlDialog( + // title for AURA ConstrainedWebDialogUI. + window_ = ConstrainedWebDialogUI::CreateConstrainedWebDialog( current_wrapper->profile(), this, NULL, diff --git a/chrome/browser/ui/webui/certificate_viewer_webui.h b/chrome/browser/ui/webui/certificate_viewer_webui.h index f6f6e4e..0eeed20 100644 --- a/chrome/browser/ui/webui/certificate_viewer_webui.h +++ b/chrome/browser/ui/webui/certificate_viewer_webui.h @@ -11,7 +11,7 @@ #include "base/compiler_specific.h" #include "base/values.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "content/public/browser/web_ui_message_handler.h" #include "net/base/x509_certificate.h" #include "ui/gfx/native_widget_types.h" @@ -25,7 +25,7 @@ void ShowCertificateViewer(gfx::NativeWindow parent, // and chromeos builds to display detailed information in a floating dialog when // the user clicks on "Certificate Information" from the lock icon of a web site // or "View" from the Certificate Manager. -class CertificateViewerDialog : private HtmlDialogUIDelegate { +class CertificateViewerDialog : private WebDialogDelegate { public: // Shows the certificate viewer dialog for the passed in certificate. static void ShowDialog(gfx::NativeWindow parent, @@ -41,7 +41,7 @@ class CertificateViewerDialog : private HtmlDialogUIDelegate { // Show the dialog using the given parent window. void Show(gfx::NativeWindow parent); - // Overridden from HtmlDialogUI::Delegate: + // Overridden from WebDialogDelegate: virtual ui::ModalType GetDialogModalType() const OVERRIDE; virtual string16 GetDialogTitle() const OVERRIDE; virtual GURL GetDialogContentURL() const OVERRIDE; diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index 31eacba..cf4e6fb 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -17,7 +17,7 @@ #include "chrome/browser/ui/webui/help/help_ui.h" #include "chrome/browser/ui/webui/about_ui.h" #include "chrome/browser/ui/webui/bookmarks_ui.h" -#include "chrome/browser/ui/webui/constrained_html_ui.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" #include "chrome/browser/ui/webui/crashes_ui.h" #include "chrome/browser/ui/webui/devtools_ui.h" #include "chrome/browser/ui/webui/downloads_ui.h" @@ -30,7 +30,7 @@ #include "chrome/browser/ui/webui/generic_handler.h" #include "chrome/browser/ui/webui/gpu_internals_ui.h" #include "chrome/browser/ui/webui/history_ui.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "chrome/browser/ui/webui/inspect_ui.h" #include "chrome/browser/ui/webui/media/media_internals_ui.h" #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" @@ -167,17 +167,17 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, // dialog as backup. It's just that on Chrome OS, it's the only // print dialog. if (url.host() == chrome::kChromeUICloudPrintResourcesHost) - return &NewWebUI<ExternalHtmlDialogUI>; + return &NewWebUI<ExternalWebDialogUI>; if (url.host() == chrome::kChromeUICloudPrintSetupHost) - return &NewWebUI<HtmlDialogUI>; + return &NewWebUI<WebDialogUI>; if (url.spec() == chrome::kChromeUIConstrainedHTMLTestURL) - return &NewWebUI<ConstrainedHtmlUI>; + return &NewWebUI<ConstrainedWebDialogUI>; if (url.host() == chrome::kChromeUICrashesHost) return &NewWebUI<CrashesUI>; if (url.host() == chrome::kChromeUIDevToolsHost) return &NewWebUI<DevToolsUI>; if (url.host() == chrome::kChromeUIDialogHost) - return &NewWebUI<ConstrainedHtmlUI>; + return &NewWebUI<ConstrainedWebDialogUI>; if (url.host() == chrome::kChromeUIExtensionsFrameHost) return &NewWebUI<ExtensionsUI>; if (url.host() == chrome::kChromeUIFlashHost) @@ -203,7 +203,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, if (url.host() == chrome::kChromeUISyncInternalsHost) return &NewWebUI<SyncInternalsUI>; if (url.host() == chrome::kChromeUISyncResourcesHost) - return &NewWebUI<HtmlDialogUI>; + return &NewWebUI<WebDialogUI>; if (url.host() == chrome::kChromeUITracingHost) return &NewWebUI<TracingUI>; if (url.host() == chrome::kChromeUIUberFrameHost) @@ -291,7 +291,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, if (url.host() == chrome::kChromeUICollectedCookiesHost || url.host() == chrome::kChromeUIHttpAuthHost || url.host() == chrome::kChromeUITabModalConfirmDialogHost) { - return &NewWebUI<ConstrainedHtmlUI>; + return &NewWebUI<ConstrainedWebDialogUI>; } #endif diff --git a/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc b/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc index f8f93dc..0fe8484 100644 --- a/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc +++ b/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc @@ -310,7 +310,7 @@ void KeyboardOverlayHandler::OpenLearnMorePage(const ListValue* args) { //////////////////////////////////////////////////////////////////////////////// KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) - : HtmlDialogUI(web_ui) { + : WebDialogUI(web_ui) { Profile* profile = Profile::FromWebUI(web_ui); KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); web_ui->AddMessageHandler(handler); diff --git a/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h b/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h index 48fe717..094ad7f 100644 --- a/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h +++ b/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h @@ -6,9 +6,9 @@ #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_KEYBOARD_OVERLAY_UI_H_ #pragma once -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" -class KeyboardOverlayUI : public HtmlDialogUI { +class KeyboardOverlayUI : public WebDialogUI { public: explicit KeyboardOverlayUI(content::WebUI* web_ui); diff --git a/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc b/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc index 57b6f65..e771a28 100644 --- a/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc +++ b/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc @@ -12,7 +12,7 @@ #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/dialog_style.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "chrome/common/url_constants.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -21,7 +21,7 @@ using content::BrowserThread; using content::WebContents; using content::WebUIMessageHandler; -class MobileSetupDialogDelegate : public HtmlDialogUIDelegate { +class MobileSetupDialogDelegate : public WebDialogDelegate { public: static MobileSetupDialogDelegate* GetInstance(); void ShowDialog(); @@ -34,7 +34,7 @@ class MobileSetupDialogDelegate : public HtmlDialogUIDelegate { void OnCloseDialog(); - // HtmlDialogUIDelegate overrides. + // WebDialogDelegate overrides. virtual ui::ModalType GetDialogModalType() const OVERRIDE; virtual string16 GetDialogTitle() const OVERRIDE; virtual GURL GetDialogContentURL() const OVERRIDE; @@ -76,7 +76,7 @@ void MobileSetupDialogDelegate::ShowDialog() { Browser* browser = BrowserList::GetLastActive(); if (!browser) return; - browser->BrowserShowHtmlDialog(this, NULL, STYLE_GENERIC); + browser->BrowserShowWebDialog(this, NULL, STYLE_GENERIC); } ui::ModalType MobileSetupDialogDelegate::GetDialogModalType() const { diff --git a/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h b/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h index 172d291..f51e11d 100644 --- a/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h +++ b/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h @@ -9,7 +9,7 @@ #include <vector> #include "base/memory/singleton.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" class MobileSetupDialog { public: diff --git a/chrome/browser/ui/webui/constrained_html_ui_delegate_impl.h b/chrome/browser/ui/webui/constrained_html_ui_delegate_impl.h deleted file mode 100644 index 5e072b28..0000000 --- a/chrome/browser/ui/webui/constrained_html_ui_delegate_impl.h +++ /dev/null @@ -1,62 +0,0 @@ -// 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. - -#ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_DELEGATE_IMPL_H_ -#define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_DELEGATE_IMPL_H_ -#pragma once - -#include "base/memory/scoped_ptr.h" -#include "chrome/browser/ui/webui/constrained_html_ui.h" -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" - -// Platform-agnostic base implementation of ConstrainedHtmlUIDelegate. -class ConstrainedHtmlUIDelegateImpl : public ConstrainedHtmlUIDelegate, - public HtmlDialogTabContentsDelegate { - public: - ConstrainedHtmlUIDelegateImpl(Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate); - virtual ~ConstrainedHtmlUIDelegateImpl(); - - void set_window(ConstrainedWindow* window); - bool closed_via_webui() const; - - // ConstrainedHtmlUIDelegate interface. - virtual const HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() const OVERRIDE; - virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() OVERRIDE; - virtual void OnDialogCloseFromWebUI() OVERRIDE; - virtual void ReleaseTabContentsOnDialogClose() OVERRIDE; - virtual ConstrainedWindow* window() OVERRIDE; - virtual TabContentsWrapper* tab() OVERRIDE; - - // HtmlDialogTabContentsDelegate interface. - virtual void HandleKeyboardEvent( - const NativeWebKeyboardEvent& event) OVERRIDE; - - protected: - void set_override_tab_delegate( - HtmlDialogTabContentsDelegate* override_tab_delegate); - - private: - HtmlDialogUIDelegate* html_delegate_; - - // The constrained window that owns |this|. Saved so we can close it later. - ConstrainedWindow* window_; - - // Holds the HTML to display in the constrained dialog. - scoped_ptr<TabContentsWrapper> tab_; - - // 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_; - - scoped_ptr<HtmlDialogTabContentsDelegate> override_tab_delegate_; - - DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUIDelegateImpl); -}; - -#endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_DELEGATE_IMPL_H_ diff --git a/chrome/browser/ui/webui/constrained_html_ui_delegate_impl.cc b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc index a68dc76..ada3058 100644 --- a/chrome/browser/ui/webui/constrained_html_ui_delegate_impl.cc +++ b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/constrained_html_ui_delegate_impl.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h" #include <string> @@ -10,18 +10,18 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/constrained_window.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.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/web_dialog_web_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "content/public/browser/web_contents.h" using content::WebContents; -ConstrainedHtmlUIDelegateImpl::ConstrainedHtmlUIDelegateImpl( +ConstrainedWebDialogDelegateBase::ConstrainedWebDialogDelegateBase( Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate) - : HtmlDialogTabContentsDelegate(profile), - html_delegate_(delegate), + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate) + : WebDialogWebContentsDelegate(profile), + web_dialog_delegate_(delegate), window_(NULL), closed_via_webui_(false), release_tab_on_close_(false) { @@ -35,8 +35,8 @@ ConstrainedHtmlUIDelegateImpl::ConstrainedHtmlUIDelegateImpl( } else { web_contents->SetDelegate(this); } - // Set |this| as a property so the ConstrainedHtmlUI can retrieve it. - ConstrainedHtmlUI::GetPropertyAccessor().SetProperty( + // Set |this| as a property so the ConstrainedWebDialogUI can retrieve it. + ConstrainedWebDialogUI::GetPropertyAccessor().SetProperty( web_contents->GetPropertyBag(), this); web_contents->GetController().LoadURL(delegate->GetDialogContentURL(), @@ -45,51 +45,51 @@ ConstrainedHtmlUIDelegateImpl::ConstrainedHtmlUIDelegateImpl( std::string()); } -ConstrainedHtmlUIDelegateImpl::~ConstrainedHtmlUIDelegateImpl() { +ConstrainedWebDialogDelegateBase::~ConstrainedWebDialogDelegateBase() { if (release_tab_on_close_) ignore_result(tab_.release()); } -const HtmlDialogUIDelegate* -ConstrainedHtmlUIDelegateImpl::GetHtmlDialogUIDelegate() const { - return html_delegate_; +const WebDialogDelegate* + ConstrainedWebDialogDelegateBase::GetWebDialogDelegate() const { + return web_dialog_delegate_; } -HtmlDialogUIDelegate* -ConstrainedHtmlUIDelegateImpl::GetHtmlDialogUIDelegate() { - return html_delegate_; +WebDialogDelegate* + ConstrainedWebDialogDelegateBase::GetWebDialogDelegate() { + return web_dialog_delegate_; } -void ConstrainedHtmlUIDelegateImpl::OnDialogCloseFromWebUI() { +void ConstrainedWebDialogDelegateBase::OnDialogCloseFromWebUI() { closed_via_webui_ = true; window_->CloseConstrainedWindow(); } -void ConstrainedHtmlUIDelegateImpl::set_window(ConstrainedWindow* window) { +void ConstrainedWebDialogDelegateBase::set_window(ConstrainedWindow* window) { window_ = window; } -void ConstrainedHtmlUIDelegateImpl::set_override_tab_delegate( - HtmlDialogTabContentsDelegate* override_tab_delegate) { +void ConstrainedWebDialogDelegateBase::set_override_tab_delegate( + WebDialogWebContentsDelegate* override_tab_delegate) { override_tab_delegate_.reset(override_tab_delegate); } -bool ConstrainedHtmlUIDelegateImpl::closed_via_webui() const { +bool ConstrainedWebDialogDelegateBase::closed_via_webui() const { return closed_via_webui_; } -void ConstrainedHtmlUIDelegateImpl::ReleaseTabContentsOnDialogClose() { +void ConstrainedWebDialogDelegateBase::ReleaseTabContentsOnDialogClose() { release_tab_on_close_ = true; } -ConstrainedWindow* ConstrainedHtmlUIDelegateImpl::window() { +ConstrainedWindow* ConstrainedWebDialogDelegateBase::window() { return window_; } -TabContentsWrapper* ConstrainedHtmlUIDelegateImpl::tab() { +TabContentsWrapper* ConstrainedWebDialogDelegateBase::tab() { return tab_.get(); } -void ConstrainedHtmlUIDelegateImpl::HandleKeyboardEvent( +void ConstrainedWebDialogDelegateBase::HandleKeyboardEvent( const NativeWebKeyboardEvent& event) { } diff --git a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h new file mode 100644 index 0000000..7855bbc --- /dev/null +++ b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h @@ -0,0 +1,67 @@ +// 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. + +#ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ +#define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ +#pragma once + +#include "base/memory/scoped_ptr.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" + +// Platform-agnostic base implementation of ConstrainedWebDialogDelegate. +class ConstrainedWebDialogDelegateBase + : public ConstrainedWebDialogDelegate, + public WebDialogWebContentsDelegate { + public: + ConstrainedWebDialogDelegateBase( + Profile* profile, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate); + virtual ~ConstrainedWebDialogDelegateBase(); + + void set_window(ConstrainedWindow* window); + bool closed_via_webui() const; + + // ConstrainedWebDialogDelegate interface. + virtual const WebDialogDelegate* + GetWebDialogDelegate() const OVERRIDE; + virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE; + virtual void OnDialogCloseFromWebUI() OVERRIDE; + virtual void ReleaseTabContentsOnDialogClose() OVERRIDE; + virtual ConstrainedWindow* window() OVERRIDE; + virtual TabContentsWrapper* tab() OVERRIDE; + + // WebDialogWebContentsDelegate interface. + virtual void HandleKeyboardEvent( + const NativeWebKeyboardEvent& event) OVERRIDE; + + protected: + void set_override_tab_delegate( + WebDialogWebContentsDelegate* override_tab_delegate); + + private: + WebDialogDelegate* web_dialog_delegate_; + + // The constrained window that owns |this|. Saved so we can close it later. + ConstrainedWindow* window_; + + // Holds the HTML to display in the constrained dialog. + scoped_ptr<TabContentsWrapper> tab_; + + // Was the dialog closed from WebUI (in which case |web_dialog_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_; + + scoped_ptr<WebDialogWebContentsDelegate> override_tab_delegate_; + + DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateBase); +}; + +#endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ diff --git a/chrome/browser/ui/webui/constrained_html_ui.cc b/chrome/browser/ui/webui/constrained_web_dialog_ui.cc index c862123..2a4c5c5 100644 --- a/chrome/browser/ui/webui/constrained_html_ui.cc +++ b/chrome/browser/ui/webui/constrained_web_dialog_ui.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/constrained_html_ui.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" #include <string> #include <vector> @@ -12,7 +12,7 @@ #include "base/lazy_instance.h" #include "base/property_bag.h" #include "base/values.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "chrome/common/chrome_notification_types.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/render_view_host.h" @@ -23,22 +23,23 @@ using content::RenderViewHost; using content::WebContents; using content::WebUIMessageHandler; -static base::LazyInstance<base::PropertyAccessor<ConstrainedHtmlUIDelegate*> > - g_constrained_html_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance<base::PropertyAccessor<ConstrainedWebDialogDelegate*> > + g_constrained_web_dialog_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; -ConstrainedHtmlUI::ConstrainedHtmlUI(content::WebUI* web_ui) +ConstrainedWebDialogUI::ConstrainedWebDialogUI(content::WebUI* web_ui) : WebUIController(web_ui) { } -ConstrainedHtmlUI::~ConstrainedHtmlUI() { +ConstrainedWebDialogUI::~ConstrainedWebDialogUI() { } -void ConstrainedHtmlUI::RenderViewCreated(RenderViewHost* render_view_host) { - ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); +void ConstrainedWebDialogUI::RenderViewCreated( + RenderViewHost* render_view_host) { + ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); if (!delegate) return; - HtmlDialogUIDelegate* dialog_delegate = delegate->GetHtmlDialogUIDelegate(); + WebDialogDelegate* dialog_delegate = delegate->GetWebDialogDelegate(); std::vector<WebUIMessageHandler*> handlers; dialog_delegate->GetWebUIMessageHandlers(&handlers); render_view_host->SetWebUIProperty("dialogArguments", @@ -50,7 +51,7 @@ void ConstrainedHtmlUI::RenderViewCreated(RenderViewHost* render_view_host) { // Add a "DialogClose" callback which matches HTMLDialogUI behavior. web_ui()->RegisterMessageCallback("DialogClose", - base::Bind(&ConstrainedHtmlUI::OnDialogCloseMessage, + base::Bind(&ConstrainedWebDialogUI::OnDialogCloseMessage, base::Unretained(this))); content::NotificationService::current()->Notify( @@ -59,26 +60,26 @@ void ConstrainedHtmlUI::RenderViewCreated(RenderViewHost* render_view_host) { content::Details<RenderViewHost>(render_view_host)); } -void ConstrainedHtmlUI::OnDialogCloseMessage(const ListValue* args) { - ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); +void ConstrainedWebDialogUI::OnDialogCloseMessage(const ListValue* args) { + ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); if (!delegate) return; std::string json_retval; if (!args->empty() && !args->GetString(0, &json_retval)) NOTREACHED() << "Could not read JSON argument"; - delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(json_retval); + delegate->GetWebDialogDelegate()->OnDialogClosed(json_retval); delegate->OnDialogCloseFromWebUI(); } -ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::GetConstrainedDelegate() { - ConstrainedHtmlUIDelegate** property = GetPropertyAccessor().GetProperty( +ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() { + ConstrainedWebDialogDelegate** property = GetPropertyAccessor().GetProperty( web_ui()->GetWebContents()->GetPropertyBag()); return property ? *property : NULL; } // static -base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& - ConstrainedHtmlUI::GetPropertyAccessor() { - return g_constrained_html_ui_property_accessor.Get(); +base::PropertyAccessor<ConstrainedWebDialogDelegate*>& + ConstrainedWebDialogUI::GetPropertyAccessor() { + return g_constrained_web_dialog_ui_property_accessor.Get(); } diff --git a/chrome/browser/ui/webui/constrained_html_ui.h b/chrome/browser/ui/webui/constrained_web_dialog_ui.h index dc1efd2..96b68af 100644 --- a/chrome/browser/ui/webui/constrained_html_ui.h +++ b/chrome/browser/ui/webui/constrained_web_dialog_ui.h @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ #pragma once #include "base/compiler_specific.h" #include "content/public/browser/web_ui_controller.h" class ConstrainedWindow; -class HtmlDialogTabContentsDelegate; -class HtmlDialogUIDelegate; class Profile; class TabContentsWrapper; +class WebDialogDelegate; +class WebDialogWebContentsDelegate; namespace base { template<class T> class PropertyAccessor; @@ -23,10 +23,10 @@ namespace content { class RenderViewHost; } -class ConstrainedHtmlUIDelegate { +class ConstrainedWebDialogDelegate { public: - virtual const HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() const = 0; - virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() = 0; + virtual const WebDialogDelegate* GetWebDialogDelegate() const = 0; + virtual WebDialogDelegate* GetWebDialogDelegate() = 0; // Called when the dialog is being closed in response to a "DialogClose" // message from WebUI. @@ -44,57 +44,57 @@ class ConstrainedHtmlUIDelegate { virtual TabContentsWrapper* tab() = 0; protected: - virtual ~ConstrainedHtmlUIDelegate() {} + virtual ~ConstrainedWebDialogDelegate() {} }; -// ConstrainedHtmlUI is a facility to show HTML WebUI content +// ConstrainedWebDialogUI is a facility to show HTML WebUI content // in a tab-modal constrained dialog. It is implemented as an adapter -// between an HtmlDialogUI object and a ConstrainedWindow object. +// between an WebDialogUI object and a ConstrainedWindow object. // // 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 { +class ConstrainedWebDialogUI : public content::WebUIController { public: - explicit ConstrainedHtmlUI(content::WebUI* web_ui); - virtual ~ConstrainedHtmlUI(); + explicit ConstrainedWebDialogUI(content::WebUI* web_ui); + virtual ~ConstrainedWebDialogUI(); // WebUIController implementation: virtual void RenderViewCreated( content::RenderViewHost* render_view_host) OVERRIDE; // Create a constrained HTML dialog. The actual object that gets created - // is a ConstrainedHtmlUIDelegate, which later triggers construction of a - // ConstrainedHtmlUI object. + // is a ConstrainedWebDialogDelegate, which later triggers construction of a + // ConstrainedWebDialogUI 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 + // WebDialogWebContentsDelegate 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( + static ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate, TabContentsWrapper* overshadowed); // Returns a property accessor that can be used to set the - // ConstrainedHtmlUIDelegate property on a WebContents. - static base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& + // ConstrainedWebDialogDelegate property on a WebContents. + static base::PropertyAccessor<ConstrainedWebDialogDelegate*>& GetPropertyAccessor(); protected: - // Returns the WebContents' PropertyBag's ConstrainedHtmlUIDelegate. + // Returns the WebContents' PropertyBag's ConstrainedWebDialogDelegate. // Returns NULL if that property is not set. - ConstrainedHtmlUIDelegate* GetConstrainedDelegate(); + ConstrainedWebDialogDelegate* GetConstrainedDelegate(); private: // JS Message Handler void OnDialogCloseMessage(const base::ListValue* args); - DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUI); + DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogUI); }; -#endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ +#endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ diff --git a/chrome/browser/ui/webui/constrained_html_ui_browsertest.cc b/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc index 32594e1..c5d3648 100644 --- a/chrome/browser/ui/webui/constrained_html_ui_browsertest.cc +++ b/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc @@ -8,8 +8,8 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/constrained_window_tab_helper.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/test_html_dialog_ui_delegate.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" +#include "chrome/browser/ui/webui/test_web_dialog_delegate.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" @@ -20,14 +20,14 @@ using content::WebContents; namespace { -class ConstrainedHtmlDialogBrowserTestObserver +class ConstrainedWebDialogBrowserTestObserver : public content::WebContentsObserver { public: - explicit ConstrainedHtmlDialogBrowserTestObserver(WebContents* contents) + explicit ConstrainedWebDialogBrowserTestObserver(WebContents* contents) : content::WebContentsObserver(contents), tab_destroyed_(false) { } - virtual ~ConstrainedHtmlDialogBrowserTestObserver() {} + virtual ~ConstrainedWebDialogBrowserTestObserver() {} bool tab_destroyed() { return tab_destroyed_; } @@ -41,9 +41,9 @@ class ConstrainedHtmlDialogBrowserTestObserver } // namespace -class ConstrainedHtmlDialogBrowserTest : public InProcessBrowserTest { +class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest { public: - ConstrainedHtmlDialogBrowserTest() {} + ConstrainedWebDialogBrowserTest() {} protected: size_t GetConstrainedWindowCount(TabContentsWrapper* wrapper) const { @@ -52,45 +52,45 @@ class ConstrainedHtmlDialogBrowserTest : public InProcessBrowserTest { }; // Tests that opening/closing the constrained window won't crash it. -IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, BasicTest) { +IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) { // The delegate deletes itself. - HtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate( + WebDialogDelegate* delegate = new test::TestWebDialogDelegate( GURL(chrome::kChromeUIConstrainedHTMLTestURL)); TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(wrapper); - ConstrainedHtmlUIDelegate* html_ui_delegate = - ConstrainedHtmlUI::CreateConstrainedHtmlDialog(browser()->profile(), - delegate, - NULL, - wrapper); - ASSERT_TRUE(html_ui_delegate); - EXPECT_TRUE(html_ui_delegate->window()); + ConstrainedWebDialogDelegate* dialog_delegate = + ConstrainedWebDialogUI::CreateConstrainedWebDialog(browser()->profile(), + delegate, + NULL, + wrapper); + ASSERT_TRUE(dialog_delegate); + EXPECT_TRUE(dialog_delegate->window()); EXPECT_EQ(1U, GetConstrainedWindowCount(wrapper)); } // Tests that ReleaseTabContentsOnDialogClose() works. -IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, +IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, ReleaseTabContentsOnDialogClose) { // The delegate deletes itself. - HtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate( + WebDialogDelegate* delegate = new test::TestWebDialogDelegate( GURL(chrome::kChromeUIConstrainedHTMLTestURL)); TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(wrapper); - 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()); + ConstrainedWebDialogDelegate* dialog_delegate = + ConstrainedWebDialogUI::CreateConstrainedWebDialog(browser()->profile(), + delegate, + NULL, + wrapper); + ASSERT_TRUE(dialog_delegate); + scoped_ptr<TabContentsWrapper> new_tab(dialog_delegate->tab()); ASSERT_TRUE(new_tab.get()); ASSERT_EQ(1U, GetConstrainedWindowCount(wrapper)); - ConstrainedHtmlDialogBrowserTestObserver observer(new_tab->web_contents()); - html_ui_delegate->ReleaseTabContentsOnDialogClose(); - html_ui_delegate->OnDialogCloseFromWebUI(); + ConstrainedWebDialogBrowserTestObserver observer(new_tab->web_contents()); + dialog_delegate->ReleaseTabContentsOnDialogClose(); + dialog_delegate->OnDialogCloseFromWebUI(); ASSERT_FALSE(observer.tab_destroyed()); EXPECT_EQ(0U, GetConstrainedWindowCount(wrapper)); diff --git a/chrome/browser/ui/webui/feedback_ui.cc b/chrome/browser/ui/webui/feedback_ui.cc index a939c0f..9843ec1 100644 --- a/chrome/browser/ui/webui/feedback_ui.cc +++ b/chrome/browser/ui/webui/feedback_ui.cc @@ -134,9 +134,9 @@ int GetIndexOfFeedbackTab(Browser* browser) { namespace browser { -void ShowHtmlFeedbackView(Browser* browser, - const std::string& description_template, - const std::string& category_tag) { +void ShowWebFeedbackView(Browser* browser, + const std::string& description_template, + const std::string& category_tag) { #if defined(OS_CHROMEOS) // Grab the timestamp before we do anything else - this is crucial to help // diagnose some hardware issues. @@ -577,7 +577,8 @@ void FeedbackHandler::CloseFeedbackTab() { // FeedbackUI // //////////////////////////////////////////////////////////////////////////////// -FeedbackUI::FeedbackUI(content::WebUI* web_ui) : HtmlDialogUI(web_ui) { +FeedbackUI::FeedbackUI(content::WebUI* web_ui) + : WebDialogUI(web_ui) { FeedbackHandler* handler = new FeedbackHandler(web_ui->GetWebContents()); web_ui->AddMessageHandler(handler); diff --git a/chrome/browser/ui/webui/feedback_ui.h b/chrome/browser/ui/webui/feedback_ui.h index 9caab27..37bdbf7 100644 --- a/chrome/browser/ui/webui/feedback_ui.h +++ b/chrome/browser/ui/webui/feedback_ui.h @@ -7,17 +7,17 @@ #include <string> -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" class Browser; namespace browser { -void ShowHtmlFeedbackView(Browser* browser, - const std::string& description_template, - const std::string& category_tag); +void ShowWebFeedbackView(Browser* browser, + const std::string& description_template, + const std::string& category_tag); } // namespace browser -class FeedbackUI : public HtmlDialogUI { +class FeedbackUI : public WebDialogUI { public: explicit FeedbackUI(content::WebUI* web_ui); diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc index 9173aa4..6c51012 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc @@ -19,7 +19,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "chrome/browser/ui/webui/print_preview/print_preview_data_source.h" #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" #include "chrome/common/print_messages.h" @@ -76,7 +76,7 @@ base::LazyInstance<PrintPreviewRequestIdMapWithLock> } // namespace PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) - : ConstrainedHtmlUI(web_ui), + : ConstrainedWebDialogUI(web_ui), initial_preview_start_time_(base::TimeTicks::Now()), handler_(NULL), source_is_modifiable_(true), @@ -308,7 +308,7 @@ void PrintPreviewUI::OnHidePreviewTab() { if (background_printing_manager->HasPrintPreviewTab(preview_tab)) return; - ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); + ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); if (!delegate) return; delegate->ReleaseTabContentsOnDialogClose(); @@ -320,10 +320,10 @@ void PrintPreviewUI::OnClosePrintPreviewTab() { if (tab_closed_) return; tab_closed_ = true; - ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); + ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); if (!delegate) return; - delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(""); + delegate->GetWebDialogDelegate()->OnDialogClosed(""); delegate->OnDialogCloseFromWebUI(); } diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.h b/chrome/browser/ui/webui/print_preview/print_preview_ui.h index 1f5b071..bc113a8 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_ui.h +++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.h @@ -12,7 +12,7 @@ #include "base/memory/ref_counted.h" #include "base/time.h" #include "chrome/browser/printing/print_preview_data_service.h" -#include "chrome/browser/ui/webui/constrained_html_ui.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" class PrintPreviewDataService; class PrintPreviewHandler; @@ -30,7 +30,7 @@ namespace printing { struct PageSizeMargins; } -class PrintPreviewUI : public ConstrainedHtmlUI { +class PrintPreviewUI : public ConstrainedWebDialogUI { public: explicit PrintPreviewUI(content::WebUI* web_ui); virtual ~PrintPreviewUI(); 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 fe2b56c..ddb0762 100644 --- a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc +++ b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc @@ -20,7 +20,7 @@ #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" -#include "chrome/browser/ui/webui/constrained_html_ui.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/url_constants.h" #include "grit/browser_resources.h" @@ -55,12 +55,12 @@ TabModalConfirmDialogWebUI::TabModalConfirmDialogWebUI( data_source->set_default_resource(IDR_TAB_MODAL_CONFIRM_DIALOG_HTML); ChromeURLDataManager::AddDataSource(profile, data_source); - constrained_html_ui_delegate_ = - ConstrainedHtmlUI::CreateConstrainedHtmlDialog(profile, - this, - NULL, - wrapper); - delegate_->set_window(constrained_html_ui_delegate_->window()); + constrained_web_dialog_delegate_ = + ConstrainedWebDialogUI::CreateConstrainedWebDialog(profile, + this, + NULL, + wrapper); + delegate_->set_window(constrained_web_dialog_delegate_->window()); } TabModalConfirmDialogWebUI::~TabModalConfirmDialogWebUI() {} diff --git a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h index d21f09b..6f18a46 100644 --- a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h +++ b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h @@ -12,9 +12,9 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" -class ConstrainedHtmlUIDelegate; +class ConstrainedWebDialogDelegate; class TabContentsWrapper; class TabModalConfirmDialogDelegate; @@ -23,13 +23,13 @@ class TabModalConfirmDialogDelegate; // To display the dialog, allocate this object on the heap. It will open the // dialog from its constructor and then delete itself when the user dismisses // the dialog. -class TabModalConfirmDialogWebUI : public HtmlDialogUIDelegate { +class TabModalConfirmDialogWebUI : public WebDialogDelegate { public: TabModalConfirmDialogWebUI( TabModalConfirmDialogDelegate* dialog_delegate, TabContentsWrapper* wrapper); - // HtmlDialogUIDelegate implementation. + // WebDialogDelegate implementation. virtual ui::ModalType GetDialogModalType() const OVERRIDE; virtual string16 GetDialogTitle() const OVERRIDE; virtual GURL GetDialogContentURL() const OVERRIDE; @@ -42,8 +42,8 @@ class TabModalConfirmDialogWebUI : public HtmlDialogUIDelegate { bool* out_close_dialog) OVERRIDE; virtual bool ShouldShowDialogTitle() const OVERRIDE; - ConstrainedHtmlUIDelegate* constrained_html_ui_delegate() { - return constrained_html_ui_delegate_; + ConstrainedWebDialogDelegate* constrained_web_dialog_delegate() { + return constrained_web_dialog_delegate_; } private: @@ -52,7 +52,7 @@ class TabModalConfirmDialogWebUI : public HtmlDialogUIDelegate { scoped_ptr<TabModalConfirmDialogDelegate> delegate_; // Deletes itself. - ConstrainedHtmlUIDelegate* constrained_html_ui_delegate_; + ConstrainedWebDialogDelegate* constrained_web_dialog_delegate_; DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogWebUI); }; diff --git a/chrome/browser/ui/webui/task_manager/task_manager_dialog.cc b/chrome/browser/ui/webui/task_manager/task_manager_dialog.cc index 2a085f9..60a44c94 100644 --- a/chrome/browser/ui/webui/task_manager/task_manager_dialog.cc +++ b/chrome/browser/ui/webui/task_manager/task_manager_dialog.cc @@ -22,7 +22,7 @@ #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/dialog_style.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -45,7 +45,7 @@ using content::BrowserThread; using content::WebContents; using content::WebUIMessageHandler; -class TaskManagerDialogImpl : public HtmlDialogUIDelegate { +class TaskManagerDialogImpl : public WebDialogDelegate { public: TaskManagerDialogImpl(); @@ -58,7 +58,7 @@ class TaskManagerDialogImpl : public HtmlDialogUIDelegate { void OnCloseDialog(); - // Overridden from HtmlDialogUIDelegate: + // Overridden from WebDialogDelegate: virtual ui::ModalType GetDialogModalType() const OVERRIDE { return ui::MODAL_TYPE_NONE; } @@ -136,7 +136,7 @@ class TaskManagerDialogImpl : public HtmlDialogUIDelegate { private: void ShowDialog(bool is_background_page_mode); - void OpenHtmlDialog(); + void OpenWebDialog(); int show_count_; @@ -183,7 +183,7 @@ void TaskManagerDialogImpl::ShowDialog(bool is_background_page_mode) { #endif } is_background_page_mode_ = is_background_page_mode; - OpenHtmlDialog(); + OpenWebDialog(); ++show_count_; } @@ -192,14 +192,14 @@ void TaskManagerDialogImpl::OnCloseDialog() { --show_count_; } -void TaskManagerDialogImpl::OpenHtmlDialog() { +void TaskManagerDialogImpl::OpenWebDialog() { Browser* browser = BrowserList::GetLastActive(); DCHECK(browser); - window_ = browser::ShowHtmlDialog(NULL, - browser->profile()->GetOriginalProfile(), - NULL, - this, - STYLE_GENERIC); + window_ = browser::ShowWebDialog(NULL, + browser->profile()->GetOriginalProfile(), + NULL, + this, + STYLE_GENERIC); } // **************************************************** diff --git a/chrome/browser/ui/webui/test_html_dialog_ui_delegate.cc b/chrome/browser/ui/webui/test_html_dialog_ui_delegate.cc deleted file mode 100644 index a933585..0000000 --- a/chrome/browser/ui/webui/test_html_dialog_ui_delegate.cc +++ /dev/null @@ -1,59 +0,0 @@ -// 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. - -#include "chrome/browser/ui/webui/test_html_dialog_ui_delegate.h" - -#include "base/utf_string_conversions.h" - -using content::WebContents; -using content::WebUIMessageHandler; - -namespace test { - -TestHtmlDialogUIDelegate::TestHtmlDialogUIDelegate(const GURL& url) - : url_(url), - size_(400, 400) { -} - -TestHtmlDialogUIDelegate::~TestHtmlDialogUIDelegate() { -} - -ui::ModalType TestHtmlDialogUIDelegate::GetDialogModalType() const { - return ui::MODAL_TYPE_WINDOW; -} - -string16 TestHtmlDialogUIDelegate::GetDialogTitle() const { - return UTF8ToUTF16("Test"); -} - -GURL TestHtmlDialogUIDelegate::GetDialogContentURL() const { - return url_; -} - -void TestHtmlDialogUIDelegate::GetWebUIMessageHandlers( - std::vector<WebUIMessageHandler*>* handlers) const { -} - -void TestHtmlDialogUIDelegate::GetDialogSize(gfx::Size* size) const { - *size = size_; -} - -std::string TestHtmlDialogUIDelegate::GetDialogArgs() const { - return std::string(); -} - -void TestHtmlDialogUIDelegate::OnDialogClosed(const std::string& json_retval) { -} - -void TestHtmlDialogUIDelegate::OnCloseContents(WebContents* source, - bool* out_close_dialog) { - if (out_close_dialog) - *out_close_dialog = true; -} - -bool TestHtmlDialogUIDelegate::ShouldShowDialogTitle() const { - return true; -} - -} // namespace test diff --git a/chrome/browser/ui/webui/test_web_dialog_delegate.cc b/chrome/browser/ui/webui/test_web_dialog_delegate.cc new file mode 100644 index 0000000..1a07b3b --- /dev/null +++ b/chrome/browser/ui/webui/test_web_dialog_delegate.cc @@ -0,0 +1,59 @@ +// 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. + +#include "chrome/browser/ui/webui/test_web_dialog_delegate.h" + +#include "base/utf_string_conversions.h" + +using content::WebContents; +using content::WebUIMessageHandler; + +namespace test { + +TestWebDialogDelegate::TestWebDialogDelegate(const GURL& url) + : url_(url), + size_(400, 400) { +} + +TestWebDialogDelegate::~TestWebDialogDelegate() { +} + +ui::ModalType TestWebDialogDelegate::GetDialogModalType() const { + return ui::MODAL_TYPE_WINDOW; +} + +string16 TestWebDialogDelegate::GetDialogTitle() const { + return UTF8ToUTF16("Test"); +} + +GURL TestWebDialogDelegate::GetDialogContentURL() const { + return url_; +} + +void TestWebDialogDelegate::GetWebUIMessageHandlers( + std::vector<WebUIMessageHandler*>* handlers) const { +} + +void TestWebDialogDelegate::GetDialogSize(gfx::Size* size) const { + *size = size_; +} + +std::string TestWebDialogDelegate::GetDialogArgs() const { + return std::string(); +} + +void TestWebDialogDelegate::OnDialogClosed(const std::string& json_retval) { +} + +void TestWebDialogDelegate::OnCloseContents(WebContents* source, + bool* out_close_dialog) { + if (out_close_dialog) + *out_close_dialog = true; +} + +bool TestWebDialogDelegate::ShouldShowDialogTitle() const { + return true; +} + +} // namespace test diff --git a/chrome/browser/ui/webui/test_html_dialog_ui_delegate.h b/chrome/browser/ui/webui/test_web_dialog_delegate.h index 4a55900..4e92b03 100644 --- a/chrome/browser/ui/webui/test_html_dialog_ui_delegate.h +++ b/chrome/browser/ui/webui/test_web_dialog_delegate.h @@ -2,28 +2,28 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_TEST_HTML_DIALOG_UI_DELEGATE_H_ -#define CHROME_BROWSER_UI_WEBUI_TEST_HTML_DIALOG_UI_DELEGATE_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_TEST_WEB_DIALOG_DELEGATE_H_ +#define CHROME_BROWSER_UI_WEBUI_TEST_WEB_DIALOG_DELEGATE_H_ #pragma once #include <string> #include "base/compiler_specific.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "ui/gfx/size.h" namespace test { -class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { +class TestWebDialogDelegate : public WebDialogDelegate { public: - explicit TestHtmlDialogUIDelegate(const GURL& url); - virtual ~TestHtmlDialogUIDelegate(); + explicit TestWebDialogDelegate(const GURL& url); + virtual ~TestWebDialogDelegate(); void set_size(int width, int height) { size_.SetSize(width, height); } - // HTMLDialogUIDelegate implementation: + // WebDialogDelegate implementation: virtual ui::ModalType GetDialogModalType() const OVERRIDE; virtual string16 GetDialogTitle() const OVERRIDE; virtual GURL GetDialogContentURL() const OVERRIDE; @@ -40,9 +40,9 @@ class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { const GURL url_; gfx::Size size_; - DISALLOW_COPY_AND_ASSIGN(TestHtmlDialogUIDelegate); + DISALLOW_COPY_AND_ASSIGN(TestWebDialogDelegate); }; } // namespace test -#endif // CHROME_BROWSER_UI_WEBUI_TEST_HTML_DIALOG_UI_DELEGATE_H_ +#endif // CHROME_BROWSER_UI_WEBUI_TEST_WEB_DIALOG_DELEGATE_H_ diff --git a/chrome/browser/ui/webui/html_dialog_controller.cc b/chrome/browser/ui/webui/web_dialog_controller.cc index c31f2c7..51ba4d7 100644 --- a/chrome/browser/ui/webui/html_dialog_controller.cc +++ b/chrome/browser/ui/webui/web_dialog_controller.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/html_dialog_controller.h" +#include "chrome/browser/ui/webui/web_dialog_controller.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" @@ -10,9 +10,10 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" -HtmlDialogController::HtmlDialogController(HtmlDialogUIDelegate* delegate, - Profile* profile, - Browser* browser) +WebDialogController::WebDialogController( + WebDialogDelegate* delegate, + Profile* profile, + Browser* browser) : dialog_delegate_(delegate) { // It's only safe to show an off the record profile under one of two // circumstances: @@ -32,7 +33,7 @@ HtmlDialogController::HtmlDialogController(HtmlDialogUIDelegate* delegate, } // content::NotificationObserver implementation: -void HtmlDialogController::Observe( +void WebDialogController::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { diff --git a/chrome/browser/ui/webui/html_dialog_controller.h b/chrome/browser/ui/webui/web_dialog_controller.h index 6786475..ef36111 100644 --- a/chrome/browser/ui/webui/html_dialog_controller.h +++ b/chrome/browser/ui/webui/web_dialog_controller.h @@ -2,23 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_CONTROLLER_H_ -#define CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_CONTROLLER_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_CONTROLLER_H_ +#define CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_CONTROLLER_H_ #pragma once -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" class Browser; class Profile; -// This provides the common functionality for HtmlDialogs of notifying the +// This provides the common functionality for WebDialogs of notifying the // dialog that it should close when the browser that created it has closed to // avoid using an old Profile object. -class HtmlDialogController : public content::NotificationObserver { +class WebDialogController : public content::NotificationObserver { public: - HtmlDialogController(HtmlDialogUIDelegate* delegate, + WebDialogController(WebDialogDelegate* delegate, Profile* profile, Browser* browser); @@ -30,12 +30,12 @@ class HtmlDialogController : public content::NotificationObserver { private: // The delegate controlled by this instance. This class is owned by the // delegate. - HtmlDialogUIDelegate* dialog_delegate_; + WebDialogDelegate* dialog_delegate_; // Used for notification of parent browser closing. content::NotificationRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(HtmlDialogController); + DISALLOW_COPY_AND_ASSIGN(WebDialogController); }; -#endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_CONTROLLER_H_ +#endif // CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_CONTROLLER_H_ diff --git a/chrome/browser/ui/webui/html_dialog_controller_browsertest.cc b/chrome/browser/ui/webui/web_dialog_controller_browsertest.cc index 1fadb62..aa68d87 100644 --- a/chrome/browser/ui/webui/html_dialog_controller_browsertest.cc +++ b/chrome/browser/ui/webui/web_dialog_controller_browsertest.cc @@ -4,7 +4,7 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/webui/test_html_dialog_ui_delegate.h" +#include "chrome/browser/ui/webui/test_web_dialog_delegate.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" @@ -13,47 +13,46 @@ namespace { -class TestDialogClosedDelegate : public test::TestHtmlDialogUIDelegate { +class TestDialogClosedDelegate : public test::TestWebDialogDelegate { public: TestDialogClosedDelegate() - : test::TestHtmlDialogUIDelegate(GURL(chrome::kChromeUIChromeURLsURL)), + : test::TestWebDialogDelegate( + GURL(chrome::kChromeUIChromeURLsURL)), dialog_closed_(false) { } - // Overridden from HtmlDialogUIDelegate: + bool dialog_closed() const { return dialog_closed_; } + + // Overridden from WebDialogDelegate: virtual ui::ModalType GetDialogModalType() const OVERRIDE { return ui::MODAL_TYPE_NONE; } - - // Overridden from HtmlDialogUIDelegate: virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { dialog_closed_ = true; } - bool dialog_closed() { - return dialog_closed_; - } - private: bool dialog_closed_; + + DISALLOW_COPY_AND_ASSIGN(TestDialogClosedDelegate); }; } // namespace -class HtmlDialogControllerBrowserTest : public InProcessBrowserTest { +class WebDialogControllerBrowserTest : public InProcessBrowserTest { public: - HtmlDialogControllerBrowserTest() {} + WebDialogControllerBrowserTest() {} }; -// Tests that an HtmlDialog can be shown for an incognito browser and that when +// Tests that a WebDialog can be shown for an incognito browser and that when // that browser is closed the dialog created by that browser is closed. -IN_PROC_BROWSER_TEST_F(HtmlDialogControllerBrowserTest, IncognitoBrowser) { +IN_PROC_BROWSER_TEST_F(WebDialogControllerBrowserTest, IncognitoBrowser) { Browser* browser = CreateIncognitoBrowser(); scoped_ptr<TestDialogClosedDelegate> delegate(new TestDialogClosedDelegate()); // Create the dialog and make sure the initial "closed" state is what we // expect. - browser->BrowserShowHtmlDialog(delegate.get(), NULL, STYLE_GENERIC); + browser->BrowserShowWebDialog(delegate.get(), NULL, STYLE_GENERIC); ui_test_utils::RunAllPendingInMessageLoop(); ASSERT_FALSE(delegate->dialog_closed()); diff --git a/chrome/browser/ui/webui/html_dialog_ui.cc b/chrome/browser/ui/webui/web_dialog_ui.cc index 1b0dcf6..39e819a 100644 --- a/chrome/browser/ui/webui/html_dialog_ui.cc +++ b/chrome/browser/ui/webui/web_dialog_ui.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "base/bind.h" #include "base/bind_helpers.h" @@ -20,14 +20,14 @@ using content::RenderViewHost; using content::WebUIMessageHandler; -static base::LazyInstance<base::PropertyAccessor<HtmlDialogUIDelegate*> > - g_html_dialog_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance<base::PropertyAccessor<WebDialogDelegate*> > + g_web_dialog_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; -HtmlDialogUI::HtmlDialogUI(content::WebUI* web_ui) +WebDialogUI::WebDialogUI(content::WebUI* web_ui) : WebUIController(web_ui) { } -HtmlDialogUI::~HtmlDialogUI() { +WebDialogUI::~WebDialogUI() { // Don't unregister our property. During the teardown of the WebContents, // this will be deleted, but the WebContents will already be destroyed. // @@ -38,29 +38,28 @@ HtmlDialogUI::~HtmlDialogUI() { // and the HTML dialogs won't swap WebUIs anyway since they don't navigate. } -void HtmlDialogUI::CloseDialog(const base::ListValue* args) { +void WebDialogUI::CloseDialog(const base::ListValue* args) { OnDialogClosed(args); } // static -base::PropertyAccessor<HtmlDialogUIDelegate*>& - HtmlDialogUI::GetPropertyAccessor() { - return g_html_dialog_ui_property_accessor.Get(); +base::PropertyAccessor<WebDialogDelegate*>& WebDialogUI::GetPropertyAccessor() { + return g_web_dialog_ui_property_accessor.Get(); } //////////////////////////////////////////////////////////////////////////////// // Private: -void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { +void WebDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { // Hook up the javascript function calls, also known as chrome.send("foo") // calls in the HTML, to the actual C++ functions. web_ui()->RegisterMessageCallback("DialogClose", - base::Bind(&HtmlDialogUI::OnDialogClosed, base::Unretained(this))); + base::Bind(&WebDialogUI::OnDialogClosed, base::Unretained(this))); // Pass the arguments to the renderer supplied by the delegate. std::string dialog_args; std::vector<WebUIMessageHandler*> handlers; - HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( + WebDialogDelegate** delegate = GetPropertyAccessor().GetProperty( web_ui()->GetWebContents()->GetPropertyBag()); if (delegate) { dialog_args = (*delegate)->GetDialogArgs(); @@ -80,8 +79,8 @@ void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { content::Details<RenderViewHost>(render_view_host)); } -void HtmlDialogUI::OnDialogClosed(const ListValue* args) { - HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( +void WebDialogUI::OnDialogClosed(const ListValue* args) { + WebDialogDelegate** delegate = GetPropertyAccessor().GetProperty( web_ui()->GetWebContents()->GetPropertyBag()); if (delegate) { std::string json_retval; @@ -92,8 +91,8 @@ void HtmlDialogUI::OnDialogClosed(const ListValue* args) { } } -ExternalHtmlDialogUI::ExternalHtmlDialogUI(content::WebUI* web_ui) - : HtmlDialogUI(web_ui) { +ExternalWebDialogUI::ExternalWebDialogUI(content::WebUI* web_ui) + : WebDialogUI(web_ui) { // Non-file based UI needs to not have access to the Web UI bindings // for security reasons. The code hosting the dialog should provide // dialog specific functionality through other bindings and methods @@ -101,30 +100,30 @@ ExternalHtmlDialogUI::ExternalHtmlDialogUI(content::WebUI* web_ui) web_ui->SetBindings(web_ui->GetBindings() & ~content::BINDINGS_POLICY_WEB_UI); } -ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { +ExternalWebDialogUI::~ExternalWebDialogUI() { } -std::string HtmlDialogUIDelegate::GetDialogName() const { +std::string WebDialogDelegate::GetDialogName() const { return std::string(); } -void HtmlDialogUIDelegate::GetMinimumDialogSize(gfx::Size* size) const { +void WebDialogDelegate::GetMinimumDialogSize(gfx::Size* size) const { GetDialogSize(size); } -bool HtmlDialogUIDelegate::HandleContextMenu( +bool WebDialogDelegate::HandleContextMenu( const content::ContextMenuParams& params) { return false; } -bool HtmlDialogUIDelegate::HandleOpenURLFromTab( +bool WebDialogDelegate::HandleOpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params, content::WebContents** out_new_contents) { return false; } -bool HtmlDialogUIDelegate::HandleAddNewContents( +bool WebDialogDelegate::HandleAddNewContents( content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, diff --git a/chrome/browser/ui/webui/html_dialog_ui.h b/chrome/browser/ui/webui/web_dialog_ui.h index 21dc9ab..43f1e5b 100644 --- a/chrome/browser/ui/webui/html_dialog_ui.h +++ b/chrome/browser/ui/webui/web_dialog_ui.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_UI_H_ #pragma once #include <string> @@ -33,7 +33,7 @@ class Size; } // Implement this class to receive notifications. -class HtmlDialogUIDelegate { +class WebDialogDelegate { public: // Returns true if the contents needs to be run in a modal dialog. virtual ui::ModalType GetDialogModalType() const = 0; @@ -113,10 +113,10 @@ class HtmlDialogUIDelegate { virtual void StoreDialogSize(const gfx::Size& dialog_size) {} protected: - virtual ~HtmlDialogUIDelegate() {} + virtual ~WebDialogDelegate() {} }; -// Displays file URL contents inside a modal HTML dialog. +// Displays file URL contents inside a modal web dialog. // // This application really should not use WebContents + WebUI. It should instead // just embed a RenderView in a dialog and be done with it. @@ -126,9 +126,9 @@ class HtmlDialogUIDelegate { // there and call it back. This is a bit of a hack to allow the dialog to pass // its delegate to the Web UI without having nasty accessors on the WebContents. // The correct design using RVH directly would avoid all of this. -class HtmlDialogUI : public content::WebUIController { +class WebDialogUI : public content::WebUIController { public: - struct HtmlDialogParams { + struct WebDialogParams { // The URL for the content that will be loaded in the dialog. GURL url; // Width of the dialog. @@ -140,15 +140,15 @@ class HtmlDialogUI : public content::WebUIController { }; // When created, the property should already be set on the WebContents. - explicit HtmlDialogUI(content::WebUI* web_ui); - virtual ~HtmlDialogUI(); + explicit WebDialogUI(content::WebUI* web_ui); + virtual ~WebDialogUI(); // Close the dialog, passing the specified arguments to the close handler. void CloseDialog(const base::ListValue* args); // Returns the PropertyBag accessor object used to write the delegate pointer // into the WebContents (see class-level comment above). - static base::PropertyAccessor<HtmlDialogUIDelegate*>& GetPropertyAccessor(); + static base::PropertyAccessor<WebDialogDelegate*>& GetPropertyAccessor(); private: // WebUIController @@ -158,18 +158,18 @@ class HtmlDialogUI : public content::WebUIController { // JS message handler. void OnDialogClosed(const base::ListValue* args); - DISALLOW_COPY_AND_ASSIGN(HtmlDialogUI); + DISALLOW_COPY_AND_ASSIGN(WebDialogUI); }; -// Displays external URL contents inside a modal HTML dialog. +// Displays external URL contents inside a modal web dialog. // // Intended to be the place to collect the settings and lockdowns // necessary for running external UI components securely (e.g., the // cloud print dialog). -class ExternalHtmlDialogUI : public HtmlDialogUI { +class ExternalWebDialogUI : public WebDialogUI { public: - explicit ExternalHtmlDialogUI(content::WebUI* web_ui); - virtual ~ExternalHtmlDialogUI(); + explicit ExternalWebDialogUI(content::WebUI* web_ui); + virtual ~ExternalWebDialogUI(); }; -#endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ +#endif // CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_UI_H_ diff --git a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate.cc b/chrome/browser/ui/webui/web_dialog_web_contents_delegate.cc index b75942c..21ffe08 100644 --- a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate.cc +++ b/chrome/browser/ui/webui/web_dialog_web_contents_delegate.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tabs/tab_strip_model.h" @@ -20,18 +20,20 @@ using content::WebContents; // TODO(akalin): Should we make it so that we have a default incognito // profile that's long-lived? Of course, we'd still have to clear it out // when all incognito browsers close. -HtmlDialogTabContentsDelegate::HtmlDialogTabContentsDelegate(Profile* profile) - : profile_(profile) {} +WebDialogWebContentsDelegate::WebDialogWebContentsDelegate(Profile* profile) + : profile_(profile) { +} -HtmlDialogTabContentsDelegate::~HtmlDialogTabContentsDelegate() {} +WebDialogWebContentsDelegate::~WebDialogWebContentsDelegate() { +} -Profile* HtmlDialogTabContentsDelegate::profile() const { return profile_; } +Profile* WebDialogWebContentsDelegate::profile() const { return profile_; } -void HtmlDialogTabContentsDelegate::Detach() { +void WebDialogWebContentsDelegate::Detach() { profile_ = NULL; } -WebContents* HtmlDialogTabContentsDelegate::OpenURLFromTab( +WebContents* WebDialogWebContentsDelegate::OpenURLFromTab( WebContents* source, const OpenURLParams& params) { WebContents* new_contents = NULL; StaticOpenURLFromTab(profile_, source, params, &new_contents); @@ -39,7 +41,7 @@ WebContents* HtmlDialogTabContentsDelegate::OpenURLFromTab( } // static -Browser* HtmlDialogTabContentsDelegate::StaticOpenURLFromTab( +Browser* WebDialogWebContentsDelegate::StaticOpenURLFromTab( Profile* profile, WebContents* source, const OpenURLParams& params, WebContents** out_new_contents) { if (!profile) @@ -66,7 +68,7 @@ Browser* HtmlDialogTabContentsDelegate::StaticOpenURLFromTab( return nav_params.browser; } -void HtmlDialogTabContentsDelegate::AddNewContents( +void WebDialogWebContentsDelegate::AddNewContents( WebContents* source, WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture) { @@ -75,7 +77,7 @@ void HtmlDialogTabContentsDelegate::AddNewContents( } // static -Browser* HtmlDialogTabContentsDelegate::StaticAddNewContents( +Browser* WebDialogWebContentsDelegate::StaticAddNewContents( Profile* profile, WebContents* source, WebContents* new_contents, @@ -103,14 +105,14 @@ Browser* HtmlDialogTabContentsDelegate::StaticAddNewContents( return params.browser; } -bool HtmlDialogTabContentsDelegate::IsPopupOrPanel( +bool WebDialogWebContentsDelegate::IsPopupOrPanel( const WebContents* source) const { // This needs to return true so that we are allowed to be resized by our // contents. return true; } -bool HtmlDialogTabContentsDelegate::ShouldAddNavigationToHistory( +bool WebDialogWebContentsDelegate::ShouldAddNavigationToHistory( const history::HistoryAddPageArgs& add_page_args, content::NavigationType navigation_type) { return false; diff --git a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h b/chrome/browser/ui/webui/web_dialog_web_contents_delegate.h index e0cd210..eea5268 100644 --- a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h +++ b/chrome/browser/ui/webui/web_dialog_web_contents_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_TAB_CONTENTS_DELEGATE_H_ -#define CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_TAB_CONTENTS_DELEGATE_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ +#define CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ #pragma once #include "base/compiler_specific.h" @@ -13,11 +13,11 @@ class Browser; class Profile; // This class implements (and mostly ignores) most of -// content::WebContentsDelegate for use in an HTML dialog. Subclasses need only +// content::WebContentsDelegate for use in a Web dialog. Subclasses need only // override a few methods instead of the everything from // content::WebContentsDelegate; this way, implementations on all platforms // behave consistently. -class HtmlDialogTabContentsDelegate : public content::WebContentsDelegate { +class WebDialogWebContentsDelegate : public content::WebContentsDelegate { public: // Opens a new URL inside |source| (if source is NULL open in the current // front-most tab). |profile| is the profile that the browser should be owened @@ -43,9 +43,9 @@ class HtmlDialogTabContentsDelegate : public content::WebContentsDelegate { bool user_gesture); // Profile must be non-NULL. - explicit HtmlDialogTabContentsDelegate(Profile* profile); + explicit WebDialogWebContentsDelegate(Profile* profile); - virtual ~HtmlDialogTabContentsDelegate(); + virtual ~WebDialogWebContentsDelegate(); // The returned profile is guaranteed to be original if non-NULL. Profile* profile() const; @@ -73,6 +73,8 @@ class HtmlDialogTabContentsDelegate : public content::WebContentsDelegate { private: Profile* profile_; // Weak pointer. Always an original profile. + + DISALLOW_COPY_AND_ASSIGN(WebDialogWebContentsDelegate); }; -#endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_TAB_CONTENTS_DELEGATE_H_ +#endif // CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ diff --git a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc b/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc index cc07b5c..45d13f4 100644 --- a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc +++ b/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" #include <vector> @@ -29,55 +29,55 @@ using content::WebContentsTester; namespace { -class TestTabContentsDelegate : public HtmlDialogTabContentsDelegate { +class TestWebContentsDelegate : public WebDialogWebContentsDelegate { public: - explicit TestTabContentsDelegate(Profile* profile) - : HtmlDialogTabContentsDelegate(profile) {} - - virtual ~TestTabContentsDelegate() { + explicit TestWebContentsDelegate(Profile* profile) + : WebDialogWebContentsDelegate(profile) { + } + virtual ~TestWebContentsDelegate() { } private: - DISALLOW_COPY_AND_ASSIGN(TestTabContentsDelegate); + DISALLOW_COPY_AND_ASSIGN(TestWebContentsDelegate); }; -class HtmlDialogTabContentsDelegateTest : public BrowserWithTestWindowTest { +class WebDialogWebContentsDelegateTest : public BrowserWithTestWindowTest { public: virtual void SetUp() { BrowserWithTestWindowTest::SetUp(); - test_tab_contents_delegate_.reset(new TestTabContentsDelegate(profile())); + test_web_contents_delegate_.reset(new TestWebContentsDelegate(profile())); } virtual void TearDown() { - test_tab_contents_delegate_.reset(NULL); + test_web_contents_delegate_.reset(NULL); BrowserWithTestWindowTest::TearDown(); } protected: - scoped_ptr<TestTabContentsDelegate> test_tab_contents_delegate_; + scoped_ptr<TestWebContentsDelegate> test_web_contents_delegate_; }; -TEST_F(HtmlDialogTabContentsDelegateTest, DoNothingMethodsTest) { +TEST_F(WebDialogWebContentsDelegateTest, DoNothingMethodsTest) { // None of the following calls should do anything. - EXPECT_TRUE(test_tab_contents_delegate_->IsPopupOrPanel(NULL)); + EXPECT_TRUE(test_web_contents_delegate_->IsPopupOrPanel(NULL)); scoped_refptr<history::HistoryAddPageArgs> should_add_args( new history::HistoryAddPageArgs( GURL(), base::Time::Now(), 0, 0, GURL(), history::RedirectList(), content::PAGE_TRANSITION_TYPED, history::SOURCE_SYNCED, false)); - EXPECT_FALSE(test_tab_contents_delegate_->ShouldAddNavigationToHistory( + EXPECT_FALSE(test_web_contents_delegate_->ShouldAddNavigationToHistory( *should_add_args, content::NAVIGATION_TYPE_NEW_PAGE)); - test_tab_contents_delegate_->NavigationStateChanged(NULL, 0); - test_tab_contents_delegate_->ActivateContents(NULL); - test_tab_contents_delegate_->LoadingStateChanged(NULL); - test_tab_contents_delegate_->CloseContents(NULL); - test_tab_contents_delegate_->UpdateTargetURL(NULL, 0, GURL()); - test_tab_contents_delegate_->MoveContents(NULL, gfx::Rect()); + test_web_contents_delegate_->NavigationStateChanged(NULL, 0); + test_web_contents_delegate_->ActivateContents(NULL); + test_web_contents_delegate_->LoadingStateChanged(NULL); + test_web_contents_delegate_->CloseContents(NULL); + test_web_contents_delegate_->UpdateTargetURL(NULL, 0, GURL()); + test_web_contents_delegate_->MoveContents(NULL, gfx::Rect()); EXPECT_EQ(0, browser()->tab_count()); EXPECT_EQ(1U, BrowserList::size()); } -TEST_F(HtmlDialogTabContentsDelegateTest, OpenURLFromTabTest) { - test_tab_contents_delegate_->OpenURLFromTab( +TEST_F(WebDialogWebContentsDelegateTest, OpenURLFromTabTest) { + test_web_contents_delegate_->OpenURLFromTab( NULL, OpenURLParams(GURL(chrome::kAboutBlankURL), Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); // This should create a new foreground tab in the existing browser. @@ -85,25 +85,25 @@ TEST_F(HtmlDialogTabContentsDelegateTest, OpenURLFromTabTest) { EXPECT_EQ(1U, BrowserList::size()); } -TEST_F(HtmlDialogTabContentsDelegateTest, AddNewContentsForegroundTabTest) { +TEST_F(WebDialogWebContentsDelegateTest, AddNewContentsForegroundTabTest) { WebContents* contents = WebContentsTester::CreateTestWebContents(profile(), NULL); - test_tab_contents_delegate_->AddNewContents( + test_web_contents_delegate_->AddNewContents( NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), false); // This should create a new foreground tab in the existing browser. EXPECT_EQ(1, browser()->tab_count()); EXPECT_EQ(1U, BrowserList::size()); } -TEST_F(HtmlDialogTabContentsDelegateTest, DetachTest) { - EXPECT_EQ(profile(), test_tab_contents_delegate_->profile()); - test_tab_contents_delegate_->Detach(); - EXPECT_EQ(NULL, test_tab_contents_delegate_->profile()); +TEST_F(WebDialogWebContentsDelegateTest, DetachTest) { + EXPECT_EQ(profile(), test_web_contents_delegate_->profile()); + test_web_contents_delegate_->Detach(); + EXPECT_EQ(NULL, test_web_contents_delegate_->profile()); // Now, none of the following calls should do anything. - test_tab_contents_delegate_->OpenURLFromTab( + test_web_contents_delegate_->OpenURLFromTab( NULL, OpenURLParams(GURL(chrome::kAboutBlankURL), Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); - test_tab_contents_delegate_->AddNewContents(NULL, NULL, NEW_FOREGROUND_TAB, + test_web_contents_delegate_->AddNewContents(NULL, NULL, NEW_FOREGROUND_TAB, gfx::Rect(), false); EXPECT_EQ(0, browser()->tab_count()); EXPECT_EQ(1U, BrowserList::size()); |