OLD | NEW |
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 |
11 #include "base/memory/scoped_nsobject.h" | 11 #include "base/memory/scoped_nsobject.h" |
12 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
13 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 16 #include "grit/ui_resources_standard.h" |
| 17 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/gfx/mac/nsimage_cache.h" | 18 #include "ui/gfx/mac/nsimage_cache.h" |
17 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 19 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
18 | 20 |
19 NSString* const kBookmarkDictionaryListPboardType = | 21 NSString* const kBookmarkDictionaryListPboardType = |
20 @"BookmarkDictionaryListPboardType"; | 22 @"BookmarkDictionaryListPboardType"; |
21 | 23 |
22 namespace { | 24 namespace { |
23 | 25 |
24 // An unofficial standard pasteboard title type to be provided alongside the | 26 // An unofficial standard pasteboard title type to be provided alongside the |
25 // |NSURLPboardType|. | 27 // |NSURLPboardType|. |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 NSArray* availableTypes = | 343 NSArray* availableTypes = |
342 [NSArray arrayWithObjects:kBookmarkDictionaryListPboardType, | 344 [NSArray arrayWithObjects:kBookmarkDictionaryListPboardType, |
343 kCrWebURLsWithTitlesPboardType, | 345 kCrWebURLsWithTitlesPboardType, |
344 NSURLPboardType, | 346 NSURLPboardType, |
345 nil]; | 347 nil]; |
346 return [pb availableTypeFromArray:availableTypes] != nil; | 348 return [pb availableTypeFromArray:availableTypes] != nil; |
347 } | 349 } |
348 | 350 |
349 NSImage* DragImageForBookmark(NSImage* favicon, const string16& title) { | 351 NSImage* DragImageForBookmark(NSImage* favicon, const string16& title) { |
350 // If no favicon, use a default. | 352 // If no favicon, use a default. |
351 if (!favicon) | 353 if (!favicon) { |
352 favicon = gfx::GetCachedImageWithName(@"nav.pdf"); | 354 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 355 favicon = rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON); |
| 356 } |
353 | 357 |
354 // If no title, just use icon. | 358 // If no title, just use icon. |
355 if (title.empty()) | 359 if (title.empty()) |
356 return favicon; | 360 return favicon; |
357 NSString* ns_title = base::SysUTF16ToNSString(title); | 361 NSString* ns_title = base::SysUTF16ToNSString(title); |
358 | 362 |
359 // Set the look of the title. | 363 // Set the look of the title. |
360 NSDictionary* attrs = | 364 NSDictionary* attrs = |
361 [NSDictionary dictionaryWithObject:[NSFont systemFontOfSize: | 365 [NSDictionary dictionaryWithObject:[NSFont systemFontOfSize: |
362 [NSFont smallSystemFontSize]] | 366 [NSFont smallSystemFontSize]] |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 [window dragImage:drag_image | 429 [window dragImage:drag_image |
426 at:position | 430 at:position |
427 offset:NSZeroSize | 431 offset:NSZeroSize |
428 event:drag_event | 432 event:drag_event |
429 pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard] | 433 pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard] |
430 source:nil | 434 source:nil |
431 slideBack:YES]; | 435 slideBack:YES]; |
432 } | 436 } |
433 | 437 |
434 } // namespace bookmark_pasteboard_helper_mac | 438 } // namespace bookmark_pasteboard_helper_mac |
OLD | NEW |