diff options
author | erikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-05 22:00:05 +0000 |
---|---|---|
committer | erikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-05 22:00:05 +0000 |
commit | abf68099745ba6ac94a766ca948371a7f1d009d1 (patch) | |
tree | 36338257f61a472ed8636daa2eba368e823f3605 /chrome/browser/extensions/extension_host.cc | |
parent | b8d7cc09baa2fa0364df444ddd9b5d76085a4362 (diff) | |
download | chromium_src-abf68099745ba6ac94a766ca948371a7f1d009d1.zip chromium_src-abf68099745ba6ac94a766ca948371a7f1d009d1.tar.gz chromium_src-abf68099745ba6ac94a766ca948371a7f1d009d1.tar.bz2 |
Allow popups to close themselves with window.close().
This also fixes an issue where not all of the parts of WebPreferences were being serialized/deserialized across IPC.
BUG=23832
TEST=run set_page_color extension, when it sets the color, the popup
should close
Review URL: http://codereview.chromium.org/243096
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_host.cc')
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 3baa908..766a12e 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -31,9 +31,8 @@ #include "chrome/common/view_types.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" - #include "grit/browser_resources.h" - +#include "views/widget/widget.h" #include "webkit/glue/context_menu.h" using WebKit::WebDragOperation; @@ -339,10 +338,26 @@ void ExtensionHost::RunJavaScriptMessage(const std::wstring& message, render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, L""); } +void ExtensionHost::Close(RenderViewHost* render_view_host) { + if (extension_host_type_ == ViewType::EXTENSION_POPUP) { +#if defined(TOOLKIT_VIEWS) + // TODO(erikkay) This is a bit of a hack. By hiding the widget, we trigger + // a deactivation which will then bubble into ExtensionPopup and actually + // close the popup. Perhaps we should have a more explicit delegate to + // ExtensionHost. + view_->GetWidget()->Hide(); +#endif + } +} + WebPreferences ExtensionHost::GetWebkitPrefs() { PrefService* prefs = render_view_host()->process()->profile()->GetPrefs(); const bool kIsDomUI = true; - return RenderViewHostDelegateHelper::GetWebkitPrefs(prefs, kIsDomUI); + WebPreferences webkit_prefs = + RenderViewHostDelegateHelper::GetWebkitPrefs(prefs, kIsDomUI); + if (extension_host_type_ == ViewType::EXTENSION_POPUP) + webkit_prefs.allow_scripts_to_close_windows = true; + return webkit_prefs; } void ExtensionHost::ProcessDOMUIMessage(const std::string& message, |