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

Side by Side Diff: chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc

Issue 8196001: content: Split web_drag_dest_gtk.cc into chrome/ and content/ parts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: :( Created 9 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.h"
6
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_window.h"
9 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h"
10 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "ui/base/dragdrop/gtk_dnd_util.h"
14
15 WebDragBookmarkHandlerGtk::WebDragBookmarkHandlerGtk()
16 : tab_(NULL) {
17 }
18
19 WebDragBookmarkHandlerGtk::~WebDragBookmarkHandlerGtk() {}
20
21 void WebDragBookmarkHandlerGtk::DragInitialize(TabContents* contents) {
22 bookmark_drag_data_.Clear();
23
24 // Ideally we would want to initialize the the TabContentsWrapper member in
25 // the constructor. We cannot do that as the WebDragDestGtk object is
26 // created during the construction of the TabContents object. The
27 // TabContentsWrapper is created much later.
28 if (!tab_)
29 tab_ = TabContentsWrapper::GetCurrentWrapperForContents(contents);
30 }
31
32 void WebDragBookmarkHandlerGtk::OnReceiveDataFromGtk(GtkSelectionData* data) {
33 if (tab_) {
34 Profile* profile = tab_->profile();
35 bookmark_drag_data_.ReadFromVector(
36 bookmark_utils::GetNodesFromSelection(
37 NULL, data,
38 ui::CHROME_BOOKMARK_ITEM,
39 profile, NULL, NULL));
40 bookmark_drag_data_.SetOriginatingProfile(profile);
41 }
42 }
43
44 void WebDragBookmarkHandlerGtk::OnReceiveProcessedData(const GURL& url,
45 const string16& title) {
46 bookmark_drag_data_.ReadFromTuple(url, title);
47 }
48
49 void WebDragBookmarkHandlerGtk::OnDragOver() {
50 if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate())
51 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragOver(
52 bookmark_drag_data_);
53 }
54
55 void WebDragBookmarkHandlerGtk::OnDragEnter() {
56 // This is non-null if tab_contents_ is showing an ExtensionWebUI with
57 // support for (at the moment experimental) drag and drop extensions.
58 if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate())
59 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragEnter(
60 bookmark_drag_data_);
61 }
62
63 void WebDragBookmarkHandlerGtk::OnDrop() {
64 // This is non-null if tab_contents_ is showing an ExtensionWebUI with
65 // support for (at the moment experimental) drag and drop extensions.
66 if (tab_) {
67 if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
68 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDrop(
69 bookmark_drag_data_);
70 }
71
72 // Focus the target browser.
73 Browser* browser = Browser::GetBrowserForController(
74 &tab_->controller(), NULL);
75 if (browser)
76 browser->window()->Show();
77 }
78 }
79
80 void WebDragBookmarkHandlerGtk::OnDragLeave() {
81 if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate())
82 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragLeave(
83 bookmark_drag_data_);
84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698