Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1414)

Unified Diff: chrome/browser/guest_view/guest_view_base.cc

Issue 301303003: GuestView: Move Disable Drag and Drop Out to Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@change_browser_plugin_guest_delegate_lifetime
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/guest_view/guest_view_base.h ('k') | chrome/browser/guest_view/web_view/web_view_guest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/guest_view/guest_view_base.cc
diff --git a/chrome/browser/guest_view/guest_view_base.cc b/chrome/browser/guest_view/guest_view_base.cc
index 122833cd63eb067971eea24bf36f2e5e4e29af2c..884903de9223f399cb4db5493d9422455d8317f9 100644
--- a/chrome/browser/guest_view/guest_view_base.cc
+++ b/chrome/browser/guest_view/guest_view_base.cc
@@ -5,13 +5,16 @@
#include "chrome/browser/guest_view/guest_view_base.h"
#include "base/lazy_instance.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/guest_view/ad_view/ad_view_guest.h"
#include "chrome/browser/guest_view/guest_view_constants.h"
#include "chrome/browser/guest_view/guest_view_manager.h"
#include "chrome/browser/guest_view/web_view/web_view_guest.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/content_settings.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "extensions/browser/event_router.h"
@@ -223,6 +226,16 @@ void GuestViewBase::RegisterDestructionCallback(
destruction_callback_ = callback;
}
+void GuestViewBase::DidStopLoading(content::RenderViewHost* render_view_host) {
+ // Disable drag-and-drop by default. Derived classes that override this method
lazyboy 2014/05/30 00:30:52 Don't think this is a good way of doing this: "you
Fady Samuel 2014/05/30 01:53:21 You got the logic reversed. This disables DND by d
lazyboy 2014/05/30 03:11:40 Yeah I misread. But my concern is still the same,
+ // can avoid the script injection, thereby enabling drag-and-drop.
+ const char script[] = "window.addEventListener('dragstart', function() { "
+ " window.event.preventDefault(); "
+ "});";
+ render_view_host->GetMainFrame()->ExecuteJavaScript(
+ base::ASCIIToUTF16(script));
+}
+
void GuestViewBase::WebContentsDestroyed() {
delete this;
}
« no previous file with comments | « chrome/browser/guest_view/guest_view_base.h ('k') | chrome/browser/guest_view/web_view/web_view_guest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698