OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/tab_contents/web_drag_bookmark_handler_win.h" | 5 #include "chrome/browser/ui/views/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_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
11 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 11 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/drop_data.h" |
15 #include "ui/base/dragdrop/os_exchange_data.h" | 16 #include "ui/base/dragdrop/os_exchange_data.h" |
16 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 17 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
17 #include "webkit/common/webdropdata.h" | |
18 | 18 |
19 using content::WebContents; | 19 using content::WebContents; |
20 | 20 |
21 WebDragBookmarkHandlerWin::WebDragBookmarkHandlerWin() | 21 WebDragBookmarkHandlerWin::WebDragBookmarkHandlerWin() |
22 : bookmark_tab_helper_(NULL), | 22 : bookmark_tab_helper_(NULL), |
23 web_contents_(NULL) { | 23 web_contents_(NULL) { |
24 } | 24 } |
25 | 25 |
26 WebDragBookmarkHandlerWin::~WebDragBookmarkHandlerWin() { | 26 WebDragBookmarkHandlerWin::~WebDragBookmarkHandlerWin() { |
27 } | 27 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) { | 85 if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) { |
86 ui::OSExchangeData os_exchange_data( | 86 ui::OSExchangeData os_exchange_data( |
87 new ui::OSExchangeDataProviderWin(data_object)); | 87 new ui::OSExchangeDataProviderWin(data_object)); |
88 BookmarkNodeData bookmark_drag_data; | 88 BookmarkNodeData bookmark_drag_data; |
89 if (bookmark_drag_data.Read(os_exchange_data)) | 89 if (bookmark_drag_data.Read(os_exchange_data)) |
90 bookmark_tab_helper_->bookmark_drag_delegate()->OnDragLeave( | 90 bookmark_tab_helper_->bookmark_drag_delegate()->OnDragLeave( |
91 bookmark_drag_data); | 91 bookmark_drag_data); |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 bool WebDragBookmarkHandlerWin::AddDragData(const WebDropData& drop_data, | 95 bool WebDragBookmarkHandlerWin::AddDragData(const content::DropData& drop_data, |
96 ui::OSExchangeData* data) { | 96 ui::OSExchangeData* data) { |
97 if (!drop_data.url.SchemeIs(chrome::kJavaScriptScheme)) | 97 if (!drop_data.url.SchemeIs(chrome::kJavaScriptScheme)) |
98 return false; | 98 return false; |
99 | 99 |
100 // We don't want to allow javascript URLs to be dragged to the desktop, | 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 | 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 | 102 // (bookmarklets). So we create a fake bookmark entry (BookmarkNodeData |
103 // object) which explorer.exe cannot handle, and write the entry to data. | 103 // object) which explorer.exe cannot handle, and write the entry to data. |
104 BookmarkNodeData::Element bm_elt; | 104 BookmarkNodeData::Element bm_elt; |
105 bm_elt.is_url = true; | 105 bm_elt.is_url = true; |
106 bm_elt.url = drop_data.url; | 106 bm_elt.url = drop_data.url; |
107 bm_elt.title = drop_data.url_title; | 107 bm_elt.title = drop_data.url_title; |
108 | 108 |
109 BookmarkNodeData bm_drag_data; | 109 BookmarkNodeData bm_drag_data; |
110 bm_drag_data.elements.push_back(bm_elt); | 110 bm_drag_data.elements.push_back(bm_elt); |
111 | 111 |
112 // Pass in NULL as the profile so that the bookmark always adds the url | 112 // Pass in NULL as the profile so that the bookmark always adds the url |
113 // rather than trying to move an existing url. | 113 // rather than trying to move an existing url. |
114 bm_drag_data.Write(NULL, data); | 114 bm_drag_data.Write(NULL, data); |
115 | 115 |
116 return true; | 116 return true; |
117 } | 117 } |
OLD | NEW |