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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_win.h" 5 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_win.h"
6 6
7 #include "chrome/browser/bookmarks/bookmark_node_data.h" 7 #include "chrome/browser/bookmarks/bookmark_node_data.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_window.h" 9 #include "chrome/browser/ui/browser_window.h"
10 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 10 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/url_constants.h"
13 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
14 #include "ui/base/dragdrop/os_exchange_data.h" 15 #include "ui/base/dragdrop/os_exchange_data.h"
15 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" 16 #include "ui/base/dragdrop/os_exchange_data_provider_win.h"
17 #include "webkit/glue/webdropdata.h"
16 18
17 using content::WebContents; 19 using content::WebContents;
18 20
19 WebDragBookmarkHandlerWin::WebDragBookmarkHandlerWin() 21 WebDragBookmarkHandlerWin::WebDragBookmarkHandlerWin()
20 : tab_(NULL) { 22 : tab_(NULL) {
21 } 23 }
22 24
23 WebDragBookmarkHandlerWin::~WebDragBookmarkHandlerWin() { 25 WebDragBookmarkHandlerWin::~WebDragBookmarkHandlerWin() {
24 } 26 }
25 27
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 void WebDragBookmarkHandlerWin::OnDragLeave(IDataObject* data_object) { 84 void WebDragBookmarkHandlerWin::OnDragLeave(IDataObject* data_object) {
83 if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) { 85 if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
84 ui::OSExchangeData os_exchange_data( 86 ui::OSExchangeData os_exchange_data(
85 new ui::OSExchangeDataProviderWin(data_object)); 87 new ui::OSExchangeDataProviderWin(data_object));
86 BookmarkNodeData bookmark_drag_data; 88 BookmarkNodeData bookmark_drag_data;
87 if (bookmark_drag_data.Read(os_exchange_data)) 89 if (bookmark_drag_data.Read(os_exchange_data))
88 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragLeave( 90 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragLeave(
89 bookmark_drag_data); 91 bookmark_drag_data);
90 } 92 }
91 } 93 }
94
95 bool WebDragBookmarkHandlerWin::AddDragData(const WebDropData& drop_data,
96 ui::OSExchangeData* data) {
97 if (!drop_data.url.SchemeIs(chrome::kJavaScriptScheme))
98 return false;
99
100 // We don't want to allow javascript URLs to be dragged to the desktop,
101 // but we do want to allow them to be added to the bookmarks bar
102 // (bookmarklets). So we create a fake bookmark entry (BookmarkNodeData
103 // object) which explorer.exe cannot handle, and write the entry to data.
104 BookmarkNodeData::Element bm_elt;
105 bm_elt.is_url = true;
106 bm_elt.url = drop_data.url;
107 bm_elt.title = drop_data.url_title;
108
109 BookmarkNodeData bm_drag_data;
110 bm_drag_data.elements.push_back(bm_elt);
111
112 // Pass in NULL as the profile so that the bookmark always adds the url
113 // rather than trying to move an existing url.
114 bm_drag_data.Write(NULL, data);
115
116 return true;
117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698