diff options
-rw-r--r-- | chrome/browser/browser.cc | 6 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 6 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 2 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.h | 7 | ||||
-rw-r--r-- | chrome/browser/renderer_preferences.h | 25 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 7 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_delegate.h | 5 | ||||
-rw-r--r-- | chrome/chrome.gyp | 2 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 16 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 7 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 6 | ||||
-rw-r--r-- | chrome/renderer/render_thread.h | 2 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 24 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 7 | ||||
-rw-r--r-- | chrome/test/render_view_test.cc | 3 | ||||
-rw-r--r-- | webkit/glue/dragclient_impl.cc | 8 | ||||
-rw-r--r-- | webkit/glue/webview_delegate.h | 6 |
18 files changed, 132 insertions, 9 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_; }; diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index a6953cd..d9ea3ea 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1249,6 +1249,7 @@ 'browser/renderer_host/sync_resource_handler.h', 'browser/renderer_host/web_cache_manager.cc', 'browser/renderer_host/web_cache_manager.h', + 'browser/renderer_preferences.h', 'browser/rlz/rlz.cc', 'browser/rlz/rlz.h', 'browser/safe_browsing/bloom_filter.cc', @@ -2087,6 +2088,7 @@ # But app/ is the wrong directory for them. # Better is to remove the dep of *_tests on renderer, but in the # short term I'd like the build to work. + 'browser/renderer_preferences.h', 'renderer/automation/dom_automation_controller.cc', 'renderer/automation/dom_automation_controller.h', 'renderer/extensions/bindings_utils.cc', diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 50749cb..57cdcc8 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -14,6 +14,7 @@ #include "base/ref_counted.h" #include "base/shared_memory.h" #include "chrome/browser/renderer_host/resource_handler.h" +#include "chrome/browser/renderer_preferences.h" #include "chrome/common/filter_policy.h" #include "chrome/common/ipc_message_utils.h" #include "chrome/common/modal_dialog_event.h" @@ -1507,6 +1508,21 @@ struct ParamTraits<ViewHostMsg_DidPrintPage_Params> { } }; +// Traits for RendererPreferences structure to pack/unpack. +template <> +struct ParamTraits<RendererPreferences> { + typedef RendererPreferences param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.can_accept_load_drops); + } + static bool Read(const Message* m, void** iter, param_type* p) { + return ReadParam(m, iter, &p->can_accept_load_drops); + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"<RendererPreferences>"); + } +}; + // Traits for WebPreferences structure to pack/unpack. template <> struct ParamTraits<WebPreferences> { diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index d6d56bf..7984ebf 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -41,9 +41,10 @@ IPC_BEGIN_MESSAGES(View) // Tells the renderer to create a new view. // This message is slightly different, the view it takes is the view to // create, the message itself is sent as a non-view control message. - IPC_MESSAGE_CONTROL4(ViewMsg_New, + IPC_MESSAGE_CONTROL5(ViewMsg_New, gfx::NativeViewId, /* parent window */ ModalDialogEvent, /* model dialog box event */ + RendererPreferences, WebPreferences, int32 /* view id */) @@ -59,6 +60,10 @@ IPC_BEGIN_MESSAGES(View) IPC_MESSAGE_ROUTED1(ViewMsg_CreatingNew_ACK, gfx::NativeViewId /* parent_hwnd */) + // Sends updated preferences to the renderer. + IPC_MESSAGE_ROUTED1(ViewMsg_SetRendererPrefs, + RendererPreferences) + // Tells the render view to close. IPC_MESSAGE_ROUTED0(ViewMsg_Close) 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); }; diff --git a/chrome/test/render_view_test.cc b/chrome/test/render_view_test.cc index 20665f1..0ff6793 100644 --- a/chrome/test/render_view_test.cc +++ b/chrome/test/render_view_test.cc @@ -6,6 +6,7 @@ #include "chrome/common/native_web_keyboard_event.h" #include "chrome/common/render_messages.h" +#include "chrome/browser/renderer_preferences.h" #include "chrome/browser/extensions/extension_function_dispatcher.h" #include "chrome/renderer/extensions/event_bindings.h" #include "chrome/renderer/extensions/extension_process_bindings.h" @@ -85,7 +86,7 @@ void RenderViewTest::SetUp() { // This needs to pass the mock render thread to the view. view_ = RenderView::Create(&render_thread_, NULL, NULL, kOpenerId, - WebPreferences(), + RendererPreferences(), WebPreferences(), new SharedRenderViewCounter(0), kRouteId); // Attach a pseudo keyboard device to this object. diff --git a/webkit/glue/dragclient_impl.cc b/webkit/glue/dragclient_impl.cc index 6199fed..1a7d73d 100644 --- a/webkit/glue/dragclient_impl.cc +++ b/webkit/glue/dragclient_impl.cc @@ -44,7 +44,13 @@ void DragClientImpl::willPerformDragSourceAction( WebCore::DragDestinationAction DragClientImpl::actionMaskForDrag( WebCore::DragData*) { - return WebCore::DragDestinationActionAny; + if (webview_->delegate()->CanAcceptLoadDrops()) { + return WebCore::DragDestinationActionAny; + } else { + return static_cast<WebCore::DragDestinationAction> + (WebCore::DragDestinationActionDHTML | + WebCore::DragDestinationActionEdit); + } } WebCore::DragSourceAction DragClientImpl::dragSourceActionMaskForPoint( diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index a4b5061..7609eff 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -181,6 +181,12 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // FrameLoaderClient ------------------------------------------------------- + virtual bool CanAcceptLoadDrops() const { + // Always return true here so layout tests (which use the default WebView + // delegate) continue to pass. + return true; + } + // Notifies the delegate that a load has begun. virtual void DidStartLoading(WebView* webview) { } |