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

Side by Side Diff: chrome/browser/cocoa/web_drop_target.mm

Issue 1029004: GTK: implement extension bookmark manager drag api.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
« no previous file with comments | « chrome/browser/bookmarks/bookmark_utils.cc ('k') | chrome/browser/download/download_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #import "chrome/browser/cocoa/web_drop_target.h" 5 #import "chrome/browser/cocoa/web_drop_target.h"
6 6
7 #include "base/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "chrome/browser/bookmarks/bookmark_drag_data.h"
8 #include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h" 9 #include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h"
9 #include "chrome/browser/renderer_host/render_view_host.h" 10 #include "chrome/browser/renderer_host/render_view_host.h"
10 #include "chrome/browser/tab_contents/tab_contents.h" 11 #include "chrome/browser/tab_contents/tab_contents.h"
11 #import "third_party/mozilla/include/NSPasteboard+Utils.h" 12 #import "third_party/mozilla/include/NSPasteboard+Utils.h"
12 #include "webkit/glue/webdropdata.h" 13 #include "webkit/glue/webdropdata.h"
13 #include "webkit/glue/window_open_disposition.h" 14 #include "webkit/glue/window_open_disposition.h"
14 15
15 using WebKit::WebDragOperationsMask; 16 using WebKit::WebDragOperationsMask;
16 17
17 @implementation WebDropTarget 18 @implementation WebDropTarget
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 76
76 if ([self onlyAllowsNavigation]) { 77 if ([self onlyAllowsNavigation]) {
77 if ([[info draggingPasteboard] containsURLData]) 78 if ([[info draggingPasteboard] containsURLData])
78 return NSDragOperationCopy; 79 return NSDragOperationCopy;
79 return NSDragOperationNone; 80 return NSDragOperationNone;
80 } 81 }
81 82
82 // If the tab is showing the boomark manager, send BookmarkDrag events 83 // If the tab is showing the boomark manager, send BookmarkDrag events
83 RenderViewHostDelegate::BookmarkDrag* dragDelegate = 84 RenderViewHostDelegate::BookmarkDrag* dragDelegate =
84 tabContents_->GetBookmarkDragDelegate(); 85 tabContents_->GetBookmarkDragDelegate();
85 if(dragDelegate) 86 BookmarkDragData dragData;
86 dragDelegate->OnDragEnter(NULL); 87 if(dragDelegate && dragData.ReadFromDragClipboard())
88 dragDelegate->OnDragEnter(dragData);
87 89
88 // Fill out a WebDropData from pasteboard. 90 // Fill out a WebDropData from pasteboard.
89 WebDropData data; 91 WebDropData data;
90 [self populateWebDropData:&data fromPasteboard:[info draggingPasteboard]]; 92 [self populateWebDropData:&data fromPasteboard:[info draggingPasteboard]];
91 93
92 // Create the appropriate mouse locations for WebCore. The draggingLocation 94 // Create the appropriate mouse locations for WebCore. The draggingLocation
93 // is in window coordinates. Both need to be flipped. 95 // is in window coordinates. Both need to be flipped.
94 NSPoint windowPoint = [info draggingLocation]; 96 NSPoint windowPoint = [info draggingLocation];
95 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; 97 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view];
96 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; 98 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view];
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; 137 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view];
136 NSDragOperation mask = [info draggingSourceOperationMask]; 138 NSDragOperation mask = [info draggingSourceOperationMask];
137 tabContents_->render_view_host()->DragTargetDragOver( 139 tabContents_->render_view_host()->DragTargetDragOver(
138 gfx::Point(viewPoint.x, viewPoint.y), 140 gfx::Point(viewPoint.x, viewPoint.y),
139 gfx::Point(screenPoint.x, screenPoint.y), 141 gfx::Point(screenPoint.x, screenPoint.y),
140 static_cast<WebDragOperationsMask>(mask)); 142 static_cast<WebDragOperationsMask>(mask));
141 143
142 // If the tab is showing the boomark manager, send BookmarkDrag events 144 // If the tab is showing the boomark manager, send BookmarkDrag events
143 RenderViewHostDelegate::BookmarkDrag* dragDelegate = 145 RenderViewHostDelegate::BookmarkDrag* dragDelegate =
144 tabContents_->GetBookmarkDragDelegate(); 146 tabContents_->GetBookmarkDragDelegate();
145 if(dragDelegate) 147 BookmarkDragData dragData;
146 dragDelegate->OnDragOver(NULL); 148 if(dragDelegate && dragData.ReadFromDragClipboard())
149 dragDelegate->OnDragOver(dragData);
147 return current_operation_; 150 return current_operation_;
148 } 151 }
149 152
150 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info 153 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info
151 view:(NSView*)view { 154 view:(NSView*)view {
152 if (currentRVH_ != tabContents_->render_view_host()) 155 if (currentRVH_ != tabContents_->render_view_host())
153 [self draggingEntered:info view:view]; 156 [self draggingEntered:info view:view];
154 157
155 // Check if we only allow navigation and navigate to a url on the pasteboard. 158 // Check if we only allow navigation and navigate to a url on the pasteboard.
156 if ([self onlyAllowsNavigation]) { 159 if ([self onlyAllowsNavigation]) {
157 NSPasteboard* pboard = [info draggingPasteboard]; 160 NSPasteboard* pboard = [info draggingPasteboard];
158 if ([pboard containsURLData]) { 161 if ([pboard containsURLData]) {
159 WebDropData data; 162 WebDropData data;
160 [self populateURLAndTitle:&data fromPasteboard:pboard]; 163 [self populateURLAndTitle:&data fromPasteboard:pboard];
161 tabContents_->OpenURL(data.url, GURL(), CURRENT_TAB, 164 tabContents_->OpenURL(data.url, GURL(), CURRENT_TAB,
162 PageTransition::AUTO_BOOKMARK); 165 PageTransition::AUTO_BOOKMARK);
163 return YES; 166 return YES;
164 } 167 }
165 return NO; 168 return NO;
166 } 169 }
167 170
168 // If the tab is showing the boomark manager, send BookmarkDrag events 171 // If the tab is showing the boomark manager, send BookmarkDrag events
169 RenderViewHostDelegate::BookmarkDrag* dragDelegate = 172 RenderViewHostDelegate::BookmarkDrag* dragDelegate =
170 tabContents_->GetBookmarkDragDelegate(); 173 tabContents_->GetBookmarkDragDelegate();
171 if(dragDelegate) 174 BookmarkDragData dragData;
172 dragDelegate->OnDrop(NULL); 175 if(dragDelegate && dragData.ReadFromDragClipboard())
176 dragDelegate->OnDrop(dragData);
173 177
174 currentRVH_ = NULL; 178 currentRVH_ = NULL;
175 179
176 // Create the appropriate mouse locations for WebCore. The draggingLocation 180 // Create the appropriate mouse locations for WebCore. The draggingLocation
177 // is in window coordinates. Both need to be flipped. 181 // is in window coordinates. Both need to be flipped.
178 NSPoint windowPoint = [info draggingLocation]; 182 NSPoint windowPoint = [info draggingLocation];
179 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view]; 183 NSPoint viewPoint = [self flipWindowPointToView:windowPoint view:view];
180 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view]; 184 NSPoint screenPoint = [self flipWindowPointToScreen:windowPoint view:view];
181 tabContents_->render_view_host()->DragTargetDrop( 185 tabContents_->render_view_host()->DragTargetDrop(
182 gfx::Point(viewPoint.x, viewPoint.y), 186 gfx::Point(viewPoint.x, viewPoint.y),
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 if (exists && !isDir) 265 if (exists && !isDir)
262 data->filenames.push_back(base::SysNSStringToUTF16(filename)); 266 data->filenames.push_back(base::SysNSStringToUTF16(filename));
263 } 267 }
264 } 268 }
265 } 269 }
266 270
267 // TODO(pinkerton): Get file contents. http://crbug.com/34661 271 // TODO(pinkerton): Get file contents. http://crbug.com/34661
268 } 272 }
269 273
270 @end 274 @end
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_utils.cc ('k') | chrome/browser/download/download_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698