| 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/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_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/ui/tab_contents/tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 16 #include "ui/base/dragdrop/os_exchange_data.h" | 16 #include "ui/base/dragdrop/os_exchange_data.h" |
| 17 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 17 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
| 18 #include "webkit/glue/webdropdata.h" | 18 #include "webkit/glue/webdropdata.h" |
| 19 | 19 |
| 20 using content::WebContents; | 20 using content::WebContents; |
| 21 | 21 |
| 22 WebDragBookmarkHandlerWin::WebDragBookmarkHandlerWin() | 22 WebDragBookmarkHandlerWin::WebDragBookmarkHandlerWin() |
| 23 : tab_(NULL) { | 23 : tab_(NULL) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 WebDragBookmarkHandlerWin::~WebDragBookmarkHandlerWin() { | 26 WebDragBookmarkHandlerWin::~WebDragBookmarkHandlerWin() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 void WebDragBookmarkHandlerWin::DragInitialize(WebContents* contents) { | 29 void WebDragBookmarkHandlerWin::DragInitialize(WebContents* contents) { |
| 30 // Ideally we would want to initialize the the TabContentsWrapper member in | 30 // Ideally we would want to initialize the the TabContents member in |
| 31 // the constructor. We cannot do that as the WebDragTargetWin object is | 31 // the constructor. We cannot do that as the WebDragTargetWin object is |
| 32 // created during the construction of the WebContents object. The | 32 // created during the construction of the WebContents object. The |
| 33 // TabContentsWrapper is created much later. | 33 // TabContents is created much later. |
| 34 DCHECK(tab_ ? (tab_->web_contents() == contents) : true); | 34 DCHECK(tab_ ? (tab_->web_contents() == contents) : true); |
| 35 if (!tab_) | 35 if (!tab_) |
| 36 tab_ = TabContentsWrapper::GetCurrentWrapperForContents(contents); | 36 tab_ = TabContents::FromWebContents(contents); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void WebDragBookmarkHandlerWin::OnDragOver(IDataObject* data_object) { | 39 void WebDragBookmarkHandlerWin::OnDragOver(IDataObject* data_object) { |
| 40 if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) { | 40 if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) { |
| 41 ui::OSExchangeData os_exchange_data( | 41 ui::OSExchangeData os_exchange_data( |
| 42 new ui::OSExchangeDataProviderWin(data_object)); | 42 new ui::OSExchangeDataProviderWin(data_object)); |
| 43 BookmarkNodeData bookmark_drag_data; | 43 BookmarkNodeData bookmark_drag_data; |
| 44 if (bookmark_drag_data.Read(os_exchange_data)) | 44 if (bookmark_drag_data.Read(os_exchange_data)) |
| 45 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragOver( | 45 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragOver( |
| 46 bookmark_drag_data); | 46 bookmark_drag_data); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 BookmarkNodeData bm_drag_data; | 110 BookmarkNodeData bm_drag_data; |
| 111 bm_drag_data.elements.push_back(bm_elt); | 111 bm_drag_data.elements.push_back(bm_elt); |
| 112 | 112 |
| 113 // Pass in NULL as the profile so that the bookmark always adds the url | 113 // Pass in NULL as the profile so that the bookmark always adds the url |
| 114 // rather than trying to move an existing url. | 114 // rather than trying to move an existing url. |
| 115 bm_drag_data.Write(NULL, data); | 115 bm_drag_data.Write(NULL, data); |
| 116 | 116 |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| OLD | NEW |