diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 23:58:41 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 23:58:41 +0000 |
commit | df28fc8f2d514e86cf39adb62053ab73134f2034 (patch) | |
tree | e0dc4f31739c3456c9088eec5dd347b32530a836 /chrome/browser/cocoa | |
parent | 6debdd4b159057619e9b53b975b335796aa163a5 (diff) | |
download | chromium_src-df28fc8f2d514e86cf39adb62053ab73134f2034.zip chromium_src-df28fc8f2d514e86cf39adb62053ab73134f2034.tar.gz chromium_src-df28fc8f2d514e86cf39adb62053ab73134f2034.tar.bz2 |
Add "copy" to context menu on bookmark button.
BUG=http://crbug.com/16941
TEST=Right-click on bookmark button; pick copy.
Go to any other app and paste. Make sure you got URL.
Review URL: http://codereview.chromium.org/249048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27690 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.mm | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.h b/chrome/browser/cocoa/bookmark_bar_controller.h index cecdb3b..1efcc92 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.h +++ b/chrome/browser/cocoa/bookmark_bar_controller.h @@ -104,6 +104,7 @@ class PrefService; - (IBAction)openBookmarkInNewWindow:(id)sender; - (IBAction)openBookmarkInIncognitoWindow:(id)sender; - (IBAction)editBookmark:(id)sender; +- (IBAction)copyBookmark:(id)sender; - (IBAction)deleteBookmark:(id)sender; // From a context menu over the bar, ... - (IBAction)openAllBookmarks:(id)sender; diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index 32c718d..da36bc1 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -25,6 +25,7 @@ #include "chrome/common/pref_service.h" #include "grit/generated_resources.h" #include "skia/ext/skia_utils_mac.h" +#import "third_party/mozilla/include/NSPasteboard+Utils.h" // Specialization of NSButton that responds to middle-clicks. By default, // NSButton ignores them. @@ -388,6 +389,17 @@ const CGFloat kBookmarkHorizontalPadding = 1.0; nil); } +- (IBAction)copyBookmark:(id)sender { + BookmarkNode* node = [self nodeFromMenuItem:sender]; + const std::string spec = node->GetURL().spec(); + NSString* url = base::SysUTF8ToNSString(spec); + NSString* title = base::SysWideToNSString(node->GetTitle()); + NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; + [pasteboard declareURLPasteboardWithAdditionalTypes:[NSArray array] + owner:nil]; + [pasteboard setDataForURL:url title:title]; +} + - (IBAction)deleteBookmark:(id)sender { BookmarkNode* node = [self nodeFromMenuItem:sender]; bookmarkModel_->Remove(node->GetParent(), |