| 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_gtk.h" | 5 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_finder.h" | 8 #include "chrome/browser/ui/browser_finder.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 10 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.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 "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "ui/base/dragdrop/gtk_dnd_util.h" | 15 #include "ui/base/dragdrop/gtk_dnd_util.h" |
| 16 | 16 |
| 17 using content::WebContents; | 17 using content::WebContents; |
| 18 | 18 |
| 19 WebDragBookmarkHandlerGtk::WebDragBookmarkHandlerGtk() | 19 WebDragBookmarkHandlerGtk::WebDragBookmarkHandlerGtk() |
| 20 : tab_(NULL) { | 20 : tab_(NULL) { |
| 21 } | 21 } |
| 22 | 22 |
| 23 WebDragBookmarkHandlerGtk::~WebDragBookmarkHandlerGtk() {} | 23 WebDragBookmarkHandlerGtk::~WebDragBookmarkHandlerGtk() {} |
| 24 | 24 |
| 25 void WebDragBookmarkHandlerGtk::DragInitialize(WebContents* contents) { | 25 void WebDragBookmarkHandlerGtk::DragInitialize(WebContents* contents) { |
| 26 bookmark_drag_data_.Clear(); | 26 bookmark_drag_data_.Clear(); |
| 27 | 27 |
| 28 // Ideally we would want to initialize the the TabContentsWrapper member in | 28 // Ideally we would want to initialize the the TabContents member in |
| 29 // the constructor. We cannot do that as the WebDragDestGtk object is | 29 // the constructor. We cannot do that as the WebDragDestGtk object is |
| 30 // created during the construction of the WebContents object. The | 30 // created during the construction of the WebContents object. The |
| 31 // TabContentsWrapper is created much later. | 31 // TabContents is created much later. |
| 32 DCHECK(tab_ ? (tab_->web_contents() == contents) : true); | 32 DCHECK(tab_ ? (tab_->web_contents() == contents) : true); |
| 33 if (!tab_) | 33 if (!tab_) |
| 34 tab_ = TabContentsWrapper::GetCurrentWrapperForContents(contents); | 34 tab_ = TabContents::FromWebContents(contents); |
| 35 } | 35 } |
| 36 | 36 |
| 37 GdkAtom WebDragBookmarkHandlerGtk::GetBookmarkTargetAtom() const { | 37 GdkAtom WebDragBookmarkHandlerGtk::GetBookmarkTargetAtom() const { |
| 38 // For GTK, bookmark drag data is encoded as pickle and associated with | 38 // For GTK, bookmark drag data is encoded as pickle and associated with |
| 39 // ui::CHROME_BOOKMARK_ITEM. See bookmark_utils::WriteBookmarksToSelection() | 39 // ui::CHROME_BOOKMARK_ITEM. See bookmark_utils::WriteBookmarksToSelection() |
| 40 // for details. | 40 // for details. |
| 41 return ui::GetAtomForTarget(ui::CHROME_BOOKMARK_ITEM); | 41 return ui::GetAtomForTarget(ui::CHROME_BOOKMARK_ITEM); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void WebDragBookmarkHandlerGtk::OnReceiveDataFromGtk(GtkSelectionData* data) { | 44 void WebDragBookmarkHandlerGtk::OnReceiveDataFromGtk(GtkSelectionData* data) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 browser->window()->Show(); | 90 browser->window()->Show(); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 void WebDragBookmarkHandlerGtk::OnDragLeave() { | 94 void WebDragBookmarkHandlerGtk::OnDragLeave() { |
| 95 if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) { | 95 if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) { |
| 96 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragLeave( | 96 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragLeave( |
| 97 bookmark_drag_data_); | 97 bookmark_drag_data_); |
| 98 } | 98 } |
| 99 } | 99 } |
| OLD | NEW |