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

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

Issue 8418033: Push one function from the Mac drag/drop util code to ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/ui/cocoa/tab_contents/web_drop_target.h" 5 #import "chrome/browser/ui/cocoa/tab_contents/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_node_data.h" 8 #include "chrome/browser/bookmarks/bookmark_node_data.h"
9 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 9 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_window.h" 11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/cocoa/drag_util.h"
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
14 #include "content/browser/renderer_host/render_view_host.h" 13 #include "content/browser/renderer_host/render_view_host.h"
15 #include "content/browser/tab_contents/tab_contents.h" 14 #include "content/browser/tab_contents/tab_contents.h"
16 #import "third_party/mozilla/NSPasteboard+Utils.h" 15 #import "third_party/mozilla/NSPasteboard+Utils.h"
16 #import "ui/base/dragdrop/cocoa_dnd_util.h"
17 #include "webkit/glue/webdropdata.h" 17 #include "webkit/glue/webdropdata.h"
18 #include "webkit/glue/window_open_disposition.h" 18 #include "webkit/glue/window_open_disposition.h"
19 19
20 using WebKit::WebDragOperationsMask; 20 using WebKit::WebDragOperationsMask;
21 21
22 @implementation WebDropTarget 22 @implementation WebDropTarget
23 23
24 // |contents| is the TabContents representing this tab, used to communicate 24 // |contents| is the TabContents representing this tab, used to communicate
25 // drag&drop messages to WebCore and handle navigation on a successful drop 25 // drag&drop messages to WebCore and handle navigation on a successful drop
26 // (if necessary). 26 // (if necessary).
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info 160 - (BOOL)performDragOperation:(id<NSDraggingInfo>)info
161 view:(NSView*)view { 161 view:(NSView*)view {
162 if (currentRVH_ != tabContents_->render_view_host()) 162 if (currentRVH_ != tabContents_->render_view_host())
163 [self draggingEntered:info view:view]; 163 [self draggingEntered:info view:view];
164 164
165 // Check if we only allow navigation and navigate to a url on the pasteboard. 165 // Check if we only allow navigation and navigate to a url on the pasteboard.
166 if ([self onlyAllowsNavigation]) { 166 if ([self onlyAllowsNavigation]) {
167 NSPasteboard* pboard = [info draggingPasteboard]; 167 NSPasteboard* pboard = [info draggingPasteboard];
168 if ([pboard containsURLData]) { 168 if ([pboard containsURLData]) {
169 GURL url; 169 GURL url;
170 drag_util::PopulateURLAndTitleFromPasteBoard(&url, NULL, pboard, YES); 170 ui::PopulateURLAndTitleFromPasteboard(&url, NULL, pboard, YES);
171 tabContents_->OpenURL(url, GURL(), CURRENT_TAB, 171 tabContents_->OpenURL(url, GURL(), CURRENT_TAB,
172 content::PAGE_TRANSITION_AUTO_BOOKMARK); 172 content::PAGE_TRANSITION_AUTO_BOOKMARK);
173 return YES; 173 return YES;
174 } 174 }
175 return NO; 175 return NO;
176 } 176 }
177 177
178 // If the tab is showing the bookmark manager, send BookmarkDrag events 178 // If the tab is showing the bookmark manager, send BookmarkDrag events
179 BookmarkTabHelper::BookmarkDrag* dragDelegate = 179 BookmarkTabHelper::BookmarkDrag* dragDelegate =
180 tab_ ? tab_->bookmark_tab_helper()->GetBookmarkDragDelegate() : NULL; 180 tab_ ? tab_->bookmark_tab_helper()->GetBookmarkDragDelegate() : NULL;
(...skipping 24 matching lines...) Expand all
205 // Given |data|, which should not be nil, fill it in using the contents of the 205 // Given |data|, which should not be nil, fill it in using the contents of the
206 // given pasteboard. 206 // given pasteboard.
207 - (void)populateWebDropData:(WebDropData*)data 207 - (void)populateWebDropData:(WebDropData*)data
208 fromPasteboard:(NSPasteboard*)pboard { 208 fromPasteboard:(NSPasteboard*)pboard {
209 DCHECK(data); 209 DCHECK(data);
210 DCHECK(pboard); 210 DCHECK(pboard);
211 NSArray* types = [pboard types]; 211 NSArray* types = [pboard types];
212 212
213 // Get URL if possible. To avoid exposing file system paths to web content, 213 // Get URL if possible. To avoid exposing file system paths to web content,
214 // filenames in the drag are not converted to file URLs. 214 // filenames in the drag are not converted to file URLs.
215 drag_util::PopulateURLAndTitleFromPasteBoard(&data->url, 215 ui::PopulateURLAndTitleFromPasteboard(&data->url,
216 &data->url_title, 216 &data->url_title,
217 pboard, 217 pboard,
218 NO); 218 NO);
219 219
220 // Get plain text. 220 // Get plain text.
221 if ([types containsObject:NSStringPboardType]) { 221 if ([types containsObject:NSStringPboardType]) {
222 data->plain_text = 222 data->plain_text =
223 base::SysNSStringToUTF16([pboard stringForType:NSStringPboardType]); 223 base::SysNSStringToUTF16([pboard stringForType:NSStringPboardType]);
224 } 224 }
225 225
226 // Get HTML. If there's no HTML, try RTF. 226 // Get HTML. If there's no HTML, try RTF.
227 if ([types containsObject:NSHTMLPboardType]) { 227 if ([types containsObject:NSHTMLPboardType]) {
228 data->text_html = 228 data->text_html =
(...skipping 15 matching lines...) Expand all
244 if (exists && !isDir) 244 if (exists && !isDir)
245 data->filenames.push_back(base::SysNSStringToUTF16(filename)); 245 data->filenames.push_back(base::SysNSStringToUTF16(filename));
246 } 246 }
247 } 247 }
248 } 248 }
249 249
250 // TODO(pinkerton): Get file contents. http://crbug.com/34661 250 // TODO(pinkerton): Get file contents. http://crbug.com/34661
251 } 251 }
252 252
253 @end 253 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/drag_util.mm ('k') | chrome/browser/ui/cocoa/tab_contents/web_drop_target_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698