OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/bookmark_folder_target.h" | 5 #import "chrome/browser/cocoa/bookmark_folder_target.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
10 #import "chrome/browser/cocoa/bookmark_bar_folder_controller.h" | 10 #import "chrome/browser/cocoa/bookmark_bar_folder_controller.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if (node->is_folder()) { | 72 if (node->is_folder()) { |
73 // TODO(viettrungluu): I'm not sure what we should do, so just declare the | 73 // TODO(viettrungluu): I'm not sure what we should do, so just declare the |
74 // "additional" types we're given for now. Maybe we want to add a list of | 74 // "additional" types we're given for now. Maybe we want to add a list of |
75 // URLs? Would we then have to recurse if there were subfolders? | 75 // URLs? Would we then have to recurse if there were subfolders? |
76 // In the meanwhile, we *must* set it to a known state. (If this survives to | 76 // In the meanwhile, we *must* set it to a known state. (If this survives to |
77 // a 10.6-only release, it can be replaced with |-clearContents|.) | 77 // a 10.6-only release, it can be replaced with |-clearContents|.) |
78 [pboard declareTypes:[NSArray array] owner:nil]; | 78 [pboard declareTypes:[NSArray array] owner:nil]; |
79 } else { | 79 } else { |
80 const std::string spec = node->GetURL().spec(); | 80 const std::string spec = node->GetURL().spec(); |
81 NSString* url = base::SysUTF8ToNSString(spec); | 81 NSString* url = base::SysUTF8ToNSString(spec); |
82 NSString* title = base::SysWideToNSString(node->GetTitle()); | 82 NSString* title = base::SysUTF16ToNSString(node->GetTitleAsString16()); |
83 [pboard declareURLPasteboardWithAdditionalTypes:[NSArray array] | 83 [pboard declareURLPasteboardWithAdditionalTypes:[NSArray array] |
84 owner:nil]; | 84 owner:nil]; |
85 [pboard setDataForURL:url title:title]; | 85 [pboard setDataForURL:url title:title]; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 - (void)fillPasteboard:(NSPasteboard*)pboard | 89 - (void)fillPasteboard:(NSPasteboard*)pboard |
90 forDragOfButton:(BookmarkButton*)button { | 90 forDragOfButton:(BookmarkButton*)button { |
91 if (const BookmarkNode* node = [button bookmarkNode]) { | 91 if (const BookmarkNode* node = [button bookmarkNode]) { |
92 // Put the bookmark information into the pasteboard, and then write our own | 92 // Put the bookmark information into the pasteboard, and then write our own |
93 // data for |kBookmarkButtonDragType|. | 93 // data for |kBookmarkButtonDragType|. |
94 [self copyBookmarkNode:node toPasteboard:pboard]; | 94 [self copyBookmarkNode:node toPasteboard:pboard]; |
95 [pboard addTypes:[NSArray arrayWithObject:kBookmarkButtonDragType] | 95 [pboard addTypes:[NSArray arrayWithObject:kBookmarkButtonDragType] |
96 owner:nil]; | 96 owner:nil]; |
97 [pboard setData:[NSData dataWithBytes:&button length:sizeof(button)] | 97 [pboard setData:[NSData dataWithBytes:&button length:sizeof(button)] |
98 forType:kBookmarkButtonDragType]; | 98 forType:kBookmarkButtonDragType]; |
99 } else { | 99 } else { |
100 NOTREACHED(); | 100 NOTREACHED(); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 @end | 104 @end |
OLD | NEW |