summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 17:55:35 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 17:55:35 +0000
commit6d662cd0bf502ee83f09fc578799e3af1969b5b8 (patch)
treeedc27ec653b8e4f93876d1e6828da57b3d4677f1
parent2a86e6433a18113df7f763817adb647f19c5f71c (diff)
downloadchromium_src-6d662cd0bf502ee83f09fc578799e3af1969b5b8.zip
chromium_src-6d662cd0bf502ee83f09fc578799e3af1969b5b8.tar.gz
chromium_src-6d662cd0bf502ee83f09fc578799e3af1969b5b8.tar.bz2
Revert "Instead of passing down a switch to the renderer, storing a member, etc., just implement --disable-popup-blocking in the browser at the point where we make the final policy decision."
This reverts commit r14851. As it DID NOT PASS THE TRY BOTS. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14853 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc1
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc5
-rw-r--r--chrome/renderer/render_view.cc19
-rw-r--r--chrome/renderer/render_view.h6
4 files changed, 25 insertions, 6 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 885a086..c7c01f8 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -265,6 +265,7 @@ bool BrowserRenderProcessHost::Init() {
switches::kMessageLoopHistogrammer,
switches::kEnableDCHECK,
switches::kSilentDumpOnDCHECK,
+ switches::kDisablePopupBlocking,
switches::kUseLowFragHeapCrt,
switches::kEnableWebWorkers,
switches::kEnableStatsTable,
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index a835423..a74373d 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -35,7 +35,6 @@
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/browser/search_engines/template_url_fetcher.h"
#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/l10n_util.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
@@ -787,9 +786,7 @@ void TabContents::AddNewContents(TabContents* new_contents,
return;
#if defined(OS_WIN)
- if ((disposition == NEW_POPUP) && !user_gesture &&
- !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisablePopupBlocking)) {
+ if ((disposition == NEW_POPUP) && !user_gesture) {
// Unrequested popups from normal pages are constrained.
TabContents* popup_owner = this;
TabContents* our_owner = delegate_->GetConstrainingContents(this);
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 174408e..0f085dc 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -196,6 +196,7 @@ RenderView::RenderView(RenderThreadBase* render_thread)
devtools_client_(NULL),
history_back_list_count_(0),
history_forward_list_count_(0),
+ disable_popup_blocking_(false),
has_unload_listener_(false),
decrement_shared_popup_at_destruction_(false),
form_field_autofill_request_id_(0),
@@ -327,6 +328,8 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd,
if (command_line.HasSwitch(switches::kDomAutomationController))
enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION;
+ disable_popup_blocking_ =
+ command_line.HasSwitch(switches::kDisablePopupBlocking);
debug_message_handler_ = new DebugMessageHandler(this);
render_thread_->AddFilter(debug_message_handler_);
@@ -1957,8 +1960,9 @@ void RenderView::Show(WebWidget* webwidget, WindowOpenDisposition disposition) {
// NOTE: initial_pos_ may still have its default values at this point, but
// that's okay. It'll be ignored if disposition is not NEW_POPUP, or the
// browser process will impose a default position otherwise.
- Send(new ViewHostMsg_ShowView(opener_id_, routing_id_, disposition,
- initial_pos_, WasOpenedByUserGesture(NULL)));
+ Send(new ViewHostMsg_ShowView(
+ opener_id_, routing_id_, disposition, initial_pos_,
+ WasOpenedByUserGestureHelper()));
}
void RenderView::CloseWidgetSoon(WebWidget* webwidget) {
@@ -2289,6 +2293,17 @@ void RenderView::ReportFindInPageSelection(int request_id,
}
bool RenderView::WasOpenedByUserGesture(WebView* webview) const {
+ return WasOpenedByUserGestureHelper();
+}
+
+bool RenderView::WasOpenedByUserGestureHelper() const {
+ // If pop-up blocking has been disabled, then treat all new windows as if
+ // they were opened by a user gesture. This will prevent them from being
+ // blocked. This is a bit of a hack, there should be a more straightforward
+ // way to disable pop-up blocking.
+ if (disable_popup_blocking_)
+ return true;
+
return opened_by_user_gesture_;
}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 6db3a077..278fc7b 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -619,6 +619,9 @@ class RenderView : public RenderWidget,
// Decodes a data: URL image or returns an empty image in case of failure.
SkBitmap ImageFromDataUrl(const GURL&) const;
+ // A helper method used by WasOpenedByUserGesture.
+ bool WasOpenedByUserGestureHelper() const;
+
void DumpLoadHistograms() const;
// Bitwise-ORed set of extra bindings that have been enabled. See
@@ -738,6 +741,9 @@ class RenderView : public RenderWidget,
int history_back_list_count_;
int history_forward_list_count_;
+ // True if pop-up blocking is disabled. False by default.
+ bool disable_popup_blocking_;
+
// True if the page has any frame-level unload or beforeunload listeners.
bool has_unload_listener_;