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

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

Issue 9564034: Separate out the Windows bookmark handling code out of the core drag & drop target class. This matc… (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
Property Changes:
Added: svn:eol-style
+ LF
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_win.h"
6
7 #include "chrome/browser/bookmarks/bookmark_node_data.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_window.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 "content/public/browser/web_contents.h"
14 #include "ui/base/dragdrop/os_exchange_data.h"
15 #include "ui/base/dragdrop/os_exchange_data_provider_win.h"
16
17 using content::WebContents;
18
19 WebDragBookmarkHandlerWin::WebDragBookmarkHandlerWin()
20 : tab_(NULL) {
21 }
22
23 WebDragBookmarkHandlerWin::~WebDragBookmarkHandlerWin() {
24 }
25
26 void WebDragBookmarkHandlerWin::DragInitialize(WebContents* contents) {
27 // Ideally we would want to initialize the the TabContentsWrapper member in
28 // the constructor. We cannot do that as the WebDragTargetWin object is
29 // created during the construction of the TabContents object. The
30 // TabContentsWrapper is created much later.
31 DCHECK(tab_ ? (tab_->web_contents() == contents) : true);
32 if (!tab_)
33 tab_ = TabContentsWrapper::GetCurrentWrapperForContents(contents);
34 }
35
36 void WebDragBookmarkHandlerWin::OnDragOver(IDataObject* data_object) {
37 if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
38 ui::OSExchangeData os_exchange_data(
39 new ui::OSExchangeDataProviderWin(data_object));
40 BookmarkNodeData bookmark_drag_data;
41 if (bookmark_drag_data.Read(os_exchange_data))
42 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragOver(
43 bookmark_drag_data);
44 }
45 }
46
47 void WebDragBookmarkHandlerWin::OnDragEnter(IDataObject* data_object) {
48 // This is non-null if web_contents_ is showing an ExtensionWebUI with
49 // support for (at the moment experimental) drag and drop extensions.
50 if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
51 ui::OSExchangeData os_exchange_data(
52 new ui::OSExchangeDataProviderWin(data_object));
53 BookmarkNodeData bookmark_drag_data;
54 if (bookmark_drag_data.Read(os_exchange_data))
55 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragEnter(
56 bookmark_drag_data);
57 }
58 }
59
60 void WebDragBookmarkHandlerWin::OnDrop(IDataObject* data_object) {
61 // This is non-null if tab_contents_ is showing an ExtensionWebUI with
62 // support for (at the moment experimental) drag and drop extensions.
63 if (tab_) {
64 if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
65 ui::OSExchangeData os_exchange_data(
66 new ui::OSExchangeDataProviderWin(data_object));
67 BookmarkNodeData bookmark_drag_data;
68 if (bookmark_drag_data.Read(os_exchange_data)) {
69 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDrop(
70 bookmark_drag_data);
71 }
72 }
73
74 // Focus the target browser.
75 Browser* browser = Browser::GetBrowserForController(
76 &tab_->web_contents()->GetController(), NULL);
77 if (browser)
78 browser->window()->Show();
79 }
80 }
81
82 void WebDragBookmarkHandlerWin::OnDragLeave(IDataObject* data_object) {
83 if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
84 ui::OSExchangeData os_exchange_data(
85 new ui::OSExchangeDataProviderWin(data_object));
86 BookmarkNodeData bookmark_drag_data;
87 if (bookmark_drag_data.Read(os_exchange_data))
88 tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragLeave(
89 bookmark_drag_data);
90 }
91 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/web_drag_bookmark_handler_win.h ('k') | chrome/browser/tab_contents/web_drop_target_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698