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

Side by Side Diff: chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.mm

Issue 9692020: mac: Don't use kWebURLsWithTitlesPboardType from third_party/mozilla (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/url_drop_target.mm » ('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) 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/bookmarks/bookmark_pasteboard_helper_mac.h" 5 #include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 21 matching lines...) Expand all
32 NSString* const kChromiumProfilePathPboardType = 32 NSString* const kChromiumProfilePathPboardType =
33 @"ChromiumProfilePathPboardType"; 33 @"ChromiumProfilePathPboardType";
34 34
35 // Internal bookmark ID for a bookmark node. Used only when moving inside 35 // Internal bookmark ID for a bookmark node. Used only when moving inside
36 // of one profile. 36 // of one profile.
37 NSString* const kChromiumBookmarkId = 37 NSString* const kChromiumBookmarkId =
38 @"ChromiumBookmarkId"; 38 @"ChromiumBookmarkId";
39 39
40 // Mac WebKit uses this type, declared in 40 // Mac WebKit uses this type, declared in
41 // WebKit/mac/History/WebURLsWithTitles.h. 41 // WebKit/mac/History/WebURLsWithTitles.h.
42 NSString* const kWebURLsWithTitlesPboardType = 42 NSString* const kCrWebURLsWithTitlesPboardType =
43 @"WebURLsWithTitlesPboardType"; 43 @"WebURLsWithTitlesPboardType";
44 44
45 // Keys for the type of node in BookmarkDictionaryListPboardType. 45 // Keys for the type of node in BookmarkDictionaryListPboardType.
46 NSString* const kWebBookmarkType = 46 NSString* const kWebBookmarkType =
47 @"WebBookmarkType"; 47 @"WebBookmarkType";
48 48
49 NSString* const kWebBookmarkTypeList = 49 NSString* const kWebBookmarkTypeList =
50 @"WebBookmarkTypeList"; 50 @"WebBookmarkTypeList";
51 51
52 NSString* const kWebBookmarkTypeLeaf = 52 NSString* const kWebBookmarkTypeLeaf =
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 if (!bookmarks) 92 if (!bookmarks)
93 return false; 93 return false;
94 ConvertPlistToElements(bookmarks, elements); 94 ConvertPlistToElements(bookmarks, elements);
95 return true; 95 return true;
96 } 96 }
97 97
98 bool ReadWebURLsWithTitlesPboardType( 98 bool ReadWebURLsWithTitlesPboardType(
99 NSPasteboard* pb, 99 NSPasteboard* pb,
100 std::vector<BookmarkNodeData::Element>& elements) { 100 std::vector<BookmarkNodeData::Element>& elements) {
101 NSArray* bookmarkPairs = 101 NSArray* bookmarkPairs =
102 [pb propertyListForType:kWebURLsWithTitlesPboardType]; 102 [pb propertyListForType:kCrWebURLsWithTitlesPboardType];
103 if (![bookmarkPairs isKindOfClass:[NSArray class]]) 103 if (![bookmarkPairs isKindOfClass:[NSArray class]])
104 return false; 104 return false;
105 105
106 NSArray* urlsArr = [bookmarkPairs objectAtIndex:0]; 106 NSArray* urlsArr = [bookmarkPairs objectAtIndex:0];
107 NSArray* titlesArr = [bookmarkPairs objectAtIndex:1]; 107 NSArray* titlesArr = [bookmarkPairs objectAtIndex:1];
108 if ([urlsArr count] < 1) 108 if ([urlsArr count] < 1)
109 return false; 109 return false;
110 if ([urlsArr count] != [titlesArr count]) 110 if ([urlsArr count] != [titlesArr count])
111 return false; 111 return false;
112 112
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 NSMutableArray* titles = [NSMutableArray array]; 208 NSMutableArray* titles = [NSMutableArray array];
209 NSMutableArray* urls = [NSMutableArray array]; 209 NSMutableArray* urls = [NSMutableArray array];
210 FillFlattenedArraysForBookmarks(elements, titles, urls); 210 FillFlattenedArraysForBookmarks(elements, titles, urls);
211 211
212 // These bookmark types only act on urls, not folders. 212 // These bookmark types only act on urls, not folders.
213 if ([urls count] < 1) 213 if ([urls count] < 1)
214 return; 214 return;
215 215
216 // Write WebURLsWithTitlesPboardType. 216 // Write WebURLsWithTitlesPboardType.
217 [pb setPropertyList:[NSArray arrayWithObjects:urls, titles, nil] 217 [pb setPropertyList:[NSArray arrayWithObjects:urls, titles, nil]
218 forType:kWebURLsWithTitlesPboardType]; 218 forType:kCrWebURLsWithTitlesPboardType];
219 219
220 // Write NSStringPboardType. 220 // Write NSStringPboardType.
221 [pb setString:[urls componentsJoinedByString:@"\n"] 221 [pb setString:[urls componentsJoinedByString:@"\n"]
222 forType:NSStringPboardType]; 222 forType:NSStringPboardType];
223 223
224 // Write NSURLPboardType (with title). 224 // Write NSURLPboardType (with title).
225 NSURL* url = [NSURL URLWithString:[urls objectAtIndex:0]]; 225 NSURL* url = [NSURL URLWithString:[urls objectAtIndex:0]];
226 [url writeToPasteboard:pb]; 226 [url writeToPasteboard:pb];
227 NSString* titleString = [titles objectAtIndex:0]; 227 NSString* titleString = [titles objectAtIndex:0];
228 [pb setString:titleString forType:kNSURLTitlePboardType]; 228 [pb setString:titleString forType:kNSURLTitlePboardType];
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 void WriteToPasteboard(PasteboardType type, 302 void WriteToPasteboard(PasteboardType type,
303 const std::vector<BookmarkNodeData::Element>& elements, 303 const std::vector<BookmarkNodeData::Element>& elements,
304 FilePath::StringType profile_path) { 304 FilePath::StringType profile_path) {
305 if (elements.empty()) 305 if (elements.empty())
306 return; 306 return;
307 307
308 NSPasteboard* pb = PasteboardFromType(type); 308 NSPasteboard* pb = PasteboardFromType(type);
309 309
310 NSArray* types = [NSArray arrayWithObjects:kBookmarkDictionaryListPboardType, 310 NSArray* types = [NSArray arrayWithObjects:kBookmarkDictionaryListPboardType,
311 kWebURLsWithTitlesPboardType, 311 kCrWebURLsWithTitlesPboardType,
312 NSStringPboardType, 312 NSStringPboardType,
313 NSURLPboardType, 313 NSURLPboardType,
314 kNSURLTitlePboardType, 314 kNSURLTitlePboardType,
315 kChromiumProfilePathPboardType, 315 kChromiumProfilePathPboardType,
316 nil]; 316 nil];
317 [pb declareTypes:types owner:nil]; 317 [pb declareTypes:types owner:nil];
318 [pb setString:base::SysUTF8ToNSString(profile_path) 318 [pb setString:base::SysUTF8ToNSString(profile_path)
319 forType:kChromiumProfilePathPboardType]; 319 forType:kChromiumProfilePathPboardType];
320 WriteBookmarkDictionaryListPboardType(pb, elements); 320 WriteBookmarkDictionaryListPboardType(pb, elements);
321 WriteSimplifiedBookmarkTypes(pb, elements); 321 WriteSimplifiedBookmarkTypes(pb, elements);
(...skipping 10 matching lines...) Expand all
332 return ReadBookmarkDictionaryListPboardType(pb, elements) || 332 return ReadBookmarkDictionaryListPboardType(pb, elements) ||
333 ReadWebURLsWithTitlesPboardType(pb, elements) || 333 ReadWebURLsWithTitlesPboardType(pb, elements) ||
334 ReadNSURLPboardType(pb, elements); 334 ReadNSURLPboardType(pb, elements);
335 } 335 }
336 336
337 bool PasteboardContainsBookmarks(PasteboardType type) { 337 bool PasteboardContainsBookmarks(PasteboardType type) {
338 NSPasteboard* pb = PasteboardFromType(type); 338 NSPasteboard* pb = PasteboardFromType(type);
339 339
340 NSArray* availableTypes = 340 NSArray* availableTypes =
341 [NSArray arrayWithObjects:kBookmarkDictionaryListPboardType, 341 [NSArray arrayWithObjects:kBookmarkDictionaryListPboardType,
342 kWebURLsWithTitlesPboardType, 342 kCrWebURLsWithTitlesPboardType,
343 NSURLPboardType, 343 NSURLPboardType,
344 nil]; 344 nil];
345 return [pb availableTypeFromArray:availableTypes] != nil; 345 return [pb availableTypeFromArray:availableTypes] != nil;
346 } 346 }
347 347
348 NSImage* DragImageForBookmark(NSImage* favicon, const string16& title) { 348 NSImage* DragImageForBookmark(NSImage* favicon, const string16& title) {
349 // If no favicon, use a default. 349 // If no favicon, use a default.
350 if (!favicon) 350 if (!favicon)
351 favicon = gfx::GetCachedImageWithName(@"nav.pdf"); 351 favicon = gfx::GetCachedImageWithName(@"nav.pdf");
352 352
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 [window dragImage:drag_image 424 [window dragImage:drag_image
425 at:position 425 at:position
426 offset:NSZeroSize 426 offset:NSZeroSize
427 event:drag_event 427 event:drag_event
428 pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard] 428 pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard]
429 source:nil 429 source:nil
430 slideBack:YES]; 430 slideBack:YES];
431 } 431 }
432 432
433 } // namespace bookmark_pasteboard_helper_mac 433 } // namespace bookmark_pasteboard_helper_mac
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/url_drop_target.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698