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

Unified Diff: chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc

Issue 9581003: Get rid of chrome dependencies from tab_contents_drag_win.cc. After this I'll move it to content\br… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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
Index: chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc
===================================================================
--- chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc (revision 124607)
+++ chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc (working copy)
@@ -10,9 +10,11 @@
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/url_constants.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/dragdrop/os_exchange_data_provider_win.h"
+#include "webkit/glue/webdropdata.h"
using content::WebContents;
@@ -89,3 +91,27 @@
bookmark_drag_data);
}
}
+
+bool WebDragBookmarkHandlerWin::AddDragData(const WebDropData& drop_data,
+ ui::OSExchangeData* data) {
+ if (!drop_data.url.SchemeIs(chrome::kJavaScriptScheme))
+ return false;
+
+ // We don't want to allow javascript URLs to be dragged to the desktop,
+ // but we do want to allow them to be added to the bookmarks bar
+ // (bookmarklets). So we create a fake bookmark entry (BookmarkNodeData
+ // object) which explorer.exe cannot handle, and write the entry to data.
+ BookmarkNodeData::Element bm_elt;
+ bm_elt.is_url = true;
+ bm_elt.url = drop_data.url;
+ bm_elt.title = drop_data.url_title;
+
+ BookmarkNodeData bm_drag_data;
+ bm_drag_data.elements.push_back(bm_elt);
+
+ // Pass in NULL as the profile so that the bookmark always adds the url
+ // rather than trying to move an existing url.
+ bm_drag_data.Write(NULL, data);
+
+ return true;
+}

Powered by Google App Engine
This is Rietveld 408576698