summaryrefslogtreecommitdiffstats
path: root/chrome/browser
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/browser
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/browser')
-rw-r--r--chrome/browser/browser.cc6
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc6
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h7
-rw-r--r--chrome/browser/renderer_preferences.h25
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc7
-rw-r--r--chrome/browser/tab_contents/tab_contents.h2
-rw-r--r--chrome/browser/tab_contents/tab_contents_delegate.h5
8 files changed, 60 insertions, 0 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 3f6b024..fe267cb 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -201,6 +201,8 @@ Browser::Browser(Type type, Profile* profile)
// Trim browser memory on idle for low & medium memory models.
if (g_browser_process->memory_model() < BrowserProcess::HIGH_MEMORY_MODEL)
idle_task_->Start();
+
+ renderer_preferences_.can_accept_load_drops = (this->type() == TYPE_NORMAL);
}
Browser::~Browser() {
@@ -321,6 +323,8 @@ void Browser::OpenApplicationWindow(Profile* profile, const GURL& url) {
Browser* browser = Browser::CreateForApp(app_name, profile, false);
browser->AddTabWithURL(url, GURL(), PageTransition::START_PAGE, true, -1,
false, NULL);
+ browser->GetSelectedTabContents()->render_view_host()->SetRendererPrefs(
+ browser->GetSelectedTabContents()->delegate()->GetRendererPrefs());
browser->window()->Show();
// TODO(jcampan): http://crbug.com/8123 we should not need to set the initial
// focus explicitly.
@@ -1859,6 +1863,8 @@ void Browser::ConvertContentsToApplication(TabContents* contents) {
DetachContents(contents);
Browser* browser = Browser::CreateForApp(app_name, profile_, false);
browser->tabstrip_model()->AppendTabContents(contents, true);
+ browser->GetSelectedTabContents()->render_view_host()->SetRendererPrefs(
+ browser->GetSelectedTabContents()->delegate()->GetRendererPrefs());
browser->window()->Show();
}
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 63ea4ae..5e4fd06 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -181,6 +181,7 @@ bool RenderViewHost::CreateRenderView() {
Send(new ViewMsg_New(GetNativeViewId(),
modal_dialog_event,
+ delegate_->GetRendererPrefs(),
delegate_->GetWebkitPrefs(),
routing_id()));
@@ -202,6 +203,11 @@ bool RenderViewHost::IsRenderViewLive() const {
return process()->channel() && renderer_initialized_;
}
+void RenderViewHost::SetRendererPrefs(
+ const RendererPreferences& renderer_prefs) {
+ Send(new ViewMsg_SetRendererPrefs(routing_id(), renderer_prefs));
+}
+
void RenderViewHost::NavigateToEntry(const NavigationEntry& entry,
bool is_reload) {
ViewMsg_Navigate_Params params;
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 14c03c1..efe3b39 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -102,6 +102,8 @@ class RenderViewHost : public RenderWidgetHost {
// Returns true if the RenderView is active and has not crashed.
virtual bool IsRenderViewLive() const;
+ virtual void SetRendererPrefs(const RendererPreferences& renderer_prefs);
+
// Load the specified entry, optionally reloading.
virtual void NavigateToEntry(const NavigationEntry& entry, bool is_reload);
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index c2488b2..abfaf86 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -12,6 +12,7 @@
#include "base/file_path.h"
#include "base/gfx/rect.h"
#include "base/logging.h"
+#include "chrome/browser/renderer_preferences.h"
#include "chrome/common/native_web_keyboard_event.h"
#include "net/base/load_states.h"
#include "webkit/glue/password_form.h"
@@ -366,6 +367,12 @@ class RenderViewHostDelegate {
return GURL();
}
+ // Return a dummy RendererPreferences object that will be used by the renderer
+ // associated with the owning RenderViewHost.
+ virtual RendererPreferences GetRendererPrefs() const {
+ return RendererPreferences();
+ }
+
// Returns a WebPreferences object that will be used by the renderer
// associated with the owning render view host.
virtual WebPreferences GetWebkitPrefs() {
diff --git a/chrome/browser/renderer_preferences.h b/chrome/browser/renderer_preferences.h
new file mode 100644
index 0000000..0a4b34f
--- /dev/null
+++ b/chrome/browser/renderer_preferences.h
@@ -0,0 +1,25 @@
+// Copyright (c) 2006-2008 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.
+//
+// A struct for managing browser's settings that apply to the renderer or its
+// webview. These differ from WebPreferences since they apply to Chromium's
+// glue layer rather than applying to just WebKit.
+//
+// Adding new values to this class probably involves updating
+// common/render_messages.h, browser/browser.cc, etc.
+
+#ifndef CHROME_BROWSER_RENDERER_PREFERENCES_H_
+#define CHROME_BROWSER_RENDERER_PREFERENCES_H_
+
+struct RendererPreferences {
+ // Whether the renderer's current browser context accept drops from the OS
+ // that result in navigations away from the current page.
+ bool can_accept_load_drops;
+
+ RendererPreferences()
+ : can_accept_load_drops(true) {
+ }
+};
+
+#endif // CHROME_BROWSER_RENDERER_PREFERENCES_H_
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index ad09bf6..297ed28 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -1482,6 +1482,13 @@ RenderViewHostDelegate::Save* TabContents::GetSaveDelegate() const {
return save_package_.get(); // May be NULL, but we can return NULL.
}
+RendererPreferences TabContents::GetRendererPrefs() const {
+ if (delegate())
+ return delegate()->GetRendererPrefs();
+ else
+ return RendererPreferences();
+}
+
ExtensionFunctionDispatcher* TabContents::CreateExtensionFunctionDispatcher(
RenderViewHost* render_view_host,
const std::string& extension_id) {
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 92a67bc..8bb35c9 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -23,6 +23,7 @@
#include "chrome/browser/find_notification_details.h"
#include "chrome/browser/shell_dialogs.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
+#include "chrome/browser/renderer_preferences.h"
#include "chrome/browser/tab_contents/constrained_window.h"
#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
@@ -710,6 +711,7 @@ class TabContents : public PageNavigator,
// RenderViewHostDelegate ----------------------------------------------------
+ virtual RendererPreferences GetRendererPrefs() const;
virtual RenderViewHostDelegate::View* GetViewDelegate() const;
virtual RenderViewHostDelegate::Save* GetSaveDelegate() const;
virtual ExtensionFunctionDispatcher *CreateExtensionFunctionDispatcher(
diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h
index da5bd60..43f5cc4 100644
--- a/chrome/browser/tab_contents/tab_contents_delegate.h
+++ b/chrome/browser/tab_contents/tab_contents_delegate.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/gfx/native_widget_types.h"
#include "base/gfx/rect.h"
+#include "chrome/browser/renderer_preferences.h"
#include "chrome/common/page_transition_types.h"
#include "webkit/glue/window_open_disposition.h"
@@ -179,8 +180,12 @@ class TabContentsDelegate {
virtual void OnStartDownload(DownloadItem* download) {
}
+ // Returns the renderer's current preferences settings.
+ RendererPreferences GetRendererPrefs() const { return renderer_preferences_; }
+
protected:
~TabContentsDelegate() {}
+ RendererPreferences renderer_preferences_;
};