summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 22:34:51 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 22:34:51 +0000
commit80d96fa5cd180d0fdda215f8ed52cfd39ef59423 (patch)
tree3f6f43b8d76a6d476f29a458b842aedf76d9306e /chrome/renderer
parent26ea6c409fedeabdabb53f41fcc80b79d2575cf9 (diff)
downloadchromium_src-80d96fa5cd180d0fdda215f8ed52cfd39ef59423.zip
chromium_src-80d96fa5cd180d0fdda215f8ed52cfd39ef59423.tar.gz
chromium_src-80d96fa5cd180d0fdda215f8ed52cfd39ef59423.tar.bz2
Do not allow URL drops on app windows to cause a navigation away
from the currently loaded site. We are careful in this patch to continue to allow dropping URLs in text fields within the app window, and behavior for normal browser windows remains as before. There is a slight glitch when dragging a to an app window on the border of the window. Even though it is very brief, it is still disturbing. BUG=7171 TEST=Open Chrome (1), load google.com. Open Chrome (2), load yahoo.com. Drag a link from 1 to 2 and a link from 2 to 1 (both allowed). Create an app shortcut from 1, drag a link from 1 to 2 (allowed) and a link from 2 to 1 (denied). Verify that link scan be dragged to the omnibox and to text fields. Patch by Chase Phillips <chase@chromium.org> via http://codereview.chromium.org/119298 Review URL: http://codereview.chromium.org/121003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18100 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_thread.cc6
-rw-r--r--chrome/renderer/render_thread.h2
-rw-r--r--chrome/renderer/render_view.cc24
-rw-r--r--chrome/renderer/render_view.h7
4 files changed, 33 insertions, 6 deletions
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index 3a0e739..2b919ac 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/shared_memory.h"
#include "base/stats_table.h"
+#include "chrome/browser/renderer_preferences.h"
#include "chrome/common/app_cache/app_cache_context_impl.h"
#include "chrome/common/app_cache/app_cache_dispatcher.h"
#include "chrome/common/chrome_switches.h"
@@ -241,6 +242,7 @@ void RenderThread::OnSetNextPageID(int32 next_page_id) {
void RenderThread::OnCreateNewView(gfx::NativeViewId parent_hwnd,
ModalDialogEvent modal_dialog_event,
+ const RendererPreferences& renderer_prefs,
const WebPreferences& webkit_prefs,
int32 view_id) {
EnsureWebKitInitialized();
@@ -256,8 +258,8 @@ void RenderThread::OnCreateNewView(gfx::NativeViewId parent_hwnd,
// TODO(darin): once we have a RenderThread per RenderView, this will need to
// change to assert that we are not creating more than one view.
RenderView::Create(
- this, parent_hwnd, waitable_event, MSG_ROUTING_NONE, webkit_prefs,
- new SharedRenderViewCounter(0), view_id);
+ this, parent_hwnd, waitable_event, MSG_ROUTING_NONE, renderer_prefs,
+ webkit_prefs, new SharedRenderViewCounter(0), view_id);
}
void RenderThread::OnSetCacheCapacities(size_t min_dead_capacity,
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index 7935a32..36cef3a 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -12,6 +12,7 @@
#include "base/shared_memory.h"
#include "base/task.h"
#include "build/build_config.h"
+#include "chrome/browser/renderer_preferences.h"
#include "chrome/common/child_thread.h"
#include "chrome/renderer/renderer_histogram_snapshots.h"
@@ -122,6 +123,7 @@ class RenderThread : public RenderThreadBase,
void OnSetNextPageID(int32 next_page_id);
void OnCreateNewView(gfx::NativeViewId parent_hwnd,
ModalDialogEvent modal_dialog_event,
+ const RendererPreferences& renderer_prefs,
const WebPreferences& webkit_prefs,
int32 view_id);
void OnTransferBitmap(const SkBitmap& bitmap, int resource_id);
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index d5db96e..13876ec 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -21,6 +21,7 @@
#include "base/string_piece.h"
#include "base/string_util.h"
#include "build/build_config.h"
+#include "chrome/browser/renderer_preferences.h"
#include "chrome/common/bindings_policy.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_constants.h"
@@ -193,7 +194,8 @@ RenderView::RenderView(RenderThreadBase* render_thread)
popup_notification_visible_(false),
delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync),
preferred_width_(0),
- send_preferred_width_changes_(false) {
+ send_preferred_width_changes_(false),
+ renderer_preferences_(*(new RendererPreferences)) {
}
RenderView::~RenderView() {
@@ -217,6 +219,7 @@ RenderView* RenderView::Create(
gfx::NativeViewId parent_hwnd,
base::WaitableEvent* modal_dialog_event,
int32 opener_id,
+ const RendererPreferences& renderer_prefs,
const WebPreferences& webkit_prefs,
SharedRenderViewCounter* counter,
int32 routing_id) {
@@ -225,6 +228,7 @@ RenderView* RenderView::Create(
view->Init(parent_hwnd,
modal_dialog_event,
opener_id,
+ renderer_prefs,
webkit_prefs,
counter,
routing_id); // adds reference
@@ -265,6 +269,7 @@ void RenderView::JSOutOfMemory() {
void RenderView::Init(gfx::NativeViewId parent_hwnd,
base::WaitableEvent* modal_dialog_event,
int32 opener_id,
+ const RendererPreferences& renderer_prefs,
const WebPreferences& webkit_prefs,
SharedRenderViewCounter* counter,
int32 routing_id) {
@@ -282,6 +287,8 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd,
decrement_shared_popup_at_destruction_ = false;
}
+ OnSetRendererPrefs(renderer_prefs);
+
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
bool dev_tools_enabled = !command_line.HasSwitch(
@@ -419,6 +426,7 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground)
IPC_MESSAGE_HANDLER(ViewMsg_EnableIntrinsicWidthChangedMode,
OnEnableIntrinsicWidthChangedMode)
+ IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs)
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message))
@@ -1003,6 +1011,10 @@ void RenderView::UpdateSessionHistory(WebFrame* frame) {
///////////////////////////////////////////////////////////////////////////////
// WebViewDelegate
+bool RenderView::CanAcceptLoadDrops() const {
+ return renderer_preferences_.can_accept_load_drops;
+}
+
void RenderView::DidStartLoading(WebView* webview) {
if (is_loading_) {
DLOG(WARNING) << "DidStartLoading called while loading";
@@ -1657,7 +1669,7 @@ WebView* RenderView::CreateWebView(WebView* webview,
}
// The WebView holds a reference to this new RenderView
- const WebPreferences& prefs = webview->GetPreferences();
+ const WebPreferences& web_prefs = webview->GetPreferences();
base::WaitableEvent* waitable_event = new base::WaitableEvent
#if defined(OS_WIN)
(modal_dialog_event.event);
@@ -1666,8 +1678,8 @@ WebView* RenderView::CreateWebView(WebView* webview,
#endif
RenderView* view = RenderView::Create(render_thread_,
NULL, waitable_event, routing_id_,
- prefs, shared_popup_counter_,
- routing_id);
+ renderer_preferences_, web_prefs,
+ shared_popup_counter_, routing_id);
view->opened_by_user_gesture_ = user_gesture;
view->creator_url_ = creator_url;
@@ -2518,6 +2530,10 @@ void RenderView::OnEnableIntrinsicWidthChangedMode() {
send_preferred_width_changes_ = true;
}
+void RenderView::OnSetRendererPrefs(const RendererPreferences& renderer_prefs) {
+ renderer_preferences_ = renderer_prefs;
+}
+
void RenderView::OnUpdateBackForwardListCount(int back_list_count,
int forward_list_count) {
history_back_list_count_ = back_list_count;
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index a0dd47a..f661b02 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -18,6 +18,7 @@
#include "base/timer.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "chrome/browser/renderer_preferences.h"
#include "chrome/renderer/automation/dom_automation_controller.h"
#include "chrome/renderer/dom_ui_bindings.h"
#include "chrome/renderer/extensions/extension_process_bindings.h"
@@ -113,6 +114,7 @@ class RenderView : public RenderWidget,
gfx::NativeViewId parent_hwnd,
base::WaitableEvent* modal_dialog_event, // takes ownership
int32 opener_id,
+ const RendererPreferences& renderer_prefs,
const WebPreferences& webkit_prefs,
SharedRenderViewCounter* counter,
int32 routing_id);
@@ -137,6 +139,7 @@ class RenderView : public RenderWidget,
virtual void OnMessageReceived(const IPC::Message& msg);
// WebViewDelegate
+ virtual bool CanAcceptLoadDrops() const;
virtual void ShowModalHTMLDialog(const GURL& url, int width, int height,
const std::string& json_arguments,
std::string* json_retval);
@@ -410,6 +413,7 @@ class RenderView : public RenderWidget,
void Init(gfx::NativeViewId parent,
base::WaitableEvent* modal_dialog_event, // takes ownership
int32 opener_id,
+ const RendererPreferences& renderer_prefs,
const WebPreferences& webkit_prefs,
SharedRenderViewCounter* counter,
int32 routing_id);
@@ -540,6 +544,7 @@ class RenderView : public RenderWidget,
void OnFileChooserResponse(const std::vector<FilePath>& file_names);
void OnEnableViewSourceMode();
void OnEnableIntrinsicWidthChangedMode();
+ void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
void OnUpdateBackForwardListCount(int back_list_count,
int forward_list_count);
void OnGetAccessibilityInfo(
@@ -799,6 +804,8 @@ class RenderView : public RenderWidget,
// Need for printing
scoped_ptr<PrintWebViewHelper> print_render_view_;
+ RendererPreferences renderer_preferences_;
+
DISALLOW_COPY_AND_ASSIGN(RenderView);
};