summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_host.cc21
-rw-r--r--chrome/browser/extensions/extension_host.h1
-rw-r--r--chrome/browser/views/browser_bubble_win.cc14
-rw-r--r--chrome/common/render_messages.h16
-rwxr-xr-xchrome/test/data/extensions/samples/set_page_color/popup.html1
5 files changed, 45 insertions, 8 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,
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index 9a0f23e..c5aeeba 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -112,6 +112,7 @@ class ExtensionHost : public RenderViewHostDelegate,
const int flags,
IPC::Message* reply_msg,
bool* did_suppress_message);
+ virtual void Close(RenderViewHost* render_view_host);
// RenderViewHostDelegate::View
virtual void CreateNewWindow(int route_id);
diff --git a/chrome/browser/views/browser_bubble_win.cc b/chrome/browser/views/browser_bubble_win.cc
index 8cae2da..17ab8ca 100644
--- a/chrome/browser/views/browser_bubble_win.cc
+++ b/chrome/browser/views/browser_bubble_win.cc
@@ -27,9 +27,23 @@ public:
if (closed_)
return;
closed_ = true;
+ if (IsActive()) {
+ BrowserBubble::Delegate* delegate = bubble_->delegate();
+ if (delegate)
+ delegate->BubbleLostFocus(bubble_);
+ }
views::WidgetWin::Close();
}
+ void Hide() {
+ if (IsActive()) {
+ BrowserBubble::Delegate* delegate = bubble_->delegate();
+ if (delegate)
+ delegate->BubbleLostFocus(bubble_);
+ }
+ views::WidgetWin::Hide();
+ }
+
void OnActivate(UINT action, BOOL minimized, HWND window) {
BrowserBubble::Delegate* delegate = bubble_->delegate();
if (!delegate)
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index bd1b676..8ae3408 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -1641,8 +1641,7 @@ struct ParamTraits<WebPreferences> {
WriteParam(m, p.uses_universal_detector);
WriteParam(m, p.text_areas_are_resizable);
WriteParam(m, p.java_enabled);
- WriteParam(m, p.user_style_sheet_enabled);
- WriteParam(m, p.user_style_sheet_location);
+ WriteParam(m, p.allow_scripts_to_close_windows);
WriteParam(m, p.uses_page_cache);
WriteParam(m, p.remote_fonts_enabled);
WriteParam(m, p.xss_auditor_enabled);
@@ -1650,6 +1649,10 @@ struct ParamTraits<WebPreferences> {
WriteParam(m, p.databases_enabled);
WriteParam(m, p.session_storage_enabled);
WriteParam(m, p.application_cache_enabled);
+ WriteParam(m, p.tabs_to_links);
+ WriteParam(m, p.user_style_sheet_enabled);
+ WriteParam(m, p.user_style_sheet_location);
+ WriteParam(m, p.allow_universal_access_from_file_urls);
WriteParam(m, p.experimental_webgl_enabled);
WriteParam(m, p.experimental_notifications_enabled);
}
@@ -1678,8 +1681,7 @@ struct ParamTraits<WebPreferences> {
ReadParam(m, iter, &p->uses_universal_detector) &&
ReadParam(m, iter, &p->text_areas_are_resizable) &&
ReadParam(m, iter, &p->java_enabled) &&
- ReadParam(m, iter, &p->user_style_sheet_enabled) &&
- ReadParam(m, iter, &p->user_style_sheet_location) &&
+ ReadParam(m, iter, &p->allow_scripts_to_close_windows) &&
ReadParam(m, iter, &p->uses_page_cache) &&
ReadParam(m, iter, &p->remote_fonts_enabled) &&
ReadParam(m, iter, &p->xss_auditor_enabled) &&
@@ -1687,7 +1689,11 @@ struct ParamTraits<WebPreferences> {
ReadParam(m, iter, &p->databases_enabled) &&
ReadParam(m, iter, &p->session_storage_enabled) &&
ReadParam(m, iter, &p->application_cache_enabled) &&
- ReadParam(m, iter, &p->experimental_webgl_enabled) &&
+ ReadParam(m, iter, &p->tabs_to_links) &&
+ ReadParam(m, iter, &p->user_style_sheet_enabled) &&
+ ReadParam(m, iter, &p->user_style_sheet_location) &&
+ ReadParam(m, iter, &p->allow_universal_access_from_file_urls) &&
+ ReadParam(m, iter, &p->experimental_webgl_enabled);
ReadParam(m, iter, &p->experimental_notifications_enabled);
}
static void Log(const param_type& p, std::wstring* l) {
diff --git a/chrome/test/data/extensions/samples/set_page_color/popup.html b/chrome/test/data/extensions/samples/set_page_color/popup.html
index e781b9b..3de4f36 100755
--- a/chrome/test/data/extensions/samples/set_page_color/popup.html
+++ b/chrome/test/data/extensions/samples/set_page_color/popup.html
@@ -37,6 +37,7 @@ div:hover {
function click(color) {
chrome.tabs.executeScript(null,
{code:"document.body.bgColor='" + color.id + "'"});
+ window.close();
}
</script>
<div onclick="click(this)" id="red">red</div>