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

Side by Side Diff: chrome/browser/cocoa/bookmark_bar_controller.mm

Issue 249048: Add "copy" to context menu on bookmark button.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | « chrome/browser/cocoa/bookmark_bar_controller.h ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/l10n_util_mac.h" 5 #include "app/l10n_util_mac.h"
6 #include "base/mac_util.h" 6 #include "base/mac_util.h"
7 #include "base/sys_string_conversions.h" 7 #include "base/sys_string_conversions.h"
8 #include "chrome/browser/bookmarks/bookmark_editor.h" 8 #include "chrome/browser/bookmarks/bookmark_editor.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h" 9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
11 #include "chrome/browser/browser_list.h" 11 #include "chrome/browser/browser_list.h"
12 #import "chrome/browser/cocoa/bookmark_bar_bridge.h" 12 #import "chrome/browser/cocoa/bookmark_bar_bridge.h"
13 #import "chrome/browser/cocoa/bookmark_bar_controller.h" 13 #import "chrome/browser/cocoa/bookmark_bar_controller.h"
14 #import "chrome/browser/cocoa/bookmark_bar_view.h" 14 #import "chrome/browser/cocoa/bookmark_bar_view.h"
15 #import "chrome/browser/cocoa/bookmark_button_cell.h" 15 #import "chrome/browser/cocoa/bookmark_button_cell.h"
16 #import "chrome/browser/cocoa/bookmark_editor_controller.h" 16 #import "chrome/browser/cocoa/bookmark_editor_controller.h"
17 #import "chrome/browser/cocoa/bookmark_name_folder_controller.h" 17 #import "chrome/browser/cocoa/bookmark_name_folder_controller.h"
18 #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" 18 #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h"
19 #import "chrome/browser/cocoa/event_utils.h" 19 #import "chrome/browser/cocoa/event_utils.h"
20 #import "chrome/browser/cocoa/menu_button.h" 20 #import "chrome/browser/cocoa/menu_button.h"
21 #import "chrome/browser/cocoa/view_resizer.h" 21 #import "chrome/browser/cocoa/view_resizer.h"
22 #include "chrome/browser/cocoa/nsimage_cache.h" 22 #include "chrome/browser/cocoa/nsimage_cache.h"
23 #include "chrome/browser/profile.h" 23 #include "chrome/browser/profile.h"
24 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
25 #include "chrome/common/pref_service.h" 25 #include "chrome/common/pref_service.h"
26 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
27 #include "skia/ext/skia_utils_mac.h" 27 #include "skia/ext/skia_utils_mac.h"
28 #import "third_party/mozilla/include/NSPasteboard+Utils.h"
28 29
29 // Specialization of NSButton that responds to middle-clicks. By default, 30 // Specialization of NSButton that responds to middle-clicks. By default,
30 // NSButton ignores them. 31 // NSButton ignores them.
31 @interface BookmarkButton : NSButton 32 @interface BookmarkButton : NSButton
32 @end 33 @end
33 34
34 @implementation BookmarkButton 35 @implementation BookmarkButton
35 - (void)otherMouseUp:(NSEvent*) event { 36 - (void)otherMouseUp:(NSEvent*) event {
36 [self performClick:self]; 37 [self performClick:self];
37 } 38 }
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // for the other platforms but can't find a way to trigger it in the 382 // for the other platforms but can't find a way to trigger it in the
382 // UI. 383 // UI.
383 BookmarkEditor::Show([[[self view] window] contentView], 384 BookmarkEditor::Show([[[self view] window] contentView],
384 profile_, 385 profile_,
385 node->GetParent(), 386 node->GetParent(),
386 node, 387 node,
387 BookmarkEditor::SHOW_TREE, 388 BookmarkEditor::SHOW_TREE,
388 nil); 389 nil);
389 } 390 }
390 391
392 - (IBAction)copyBookmark:(id)sender {
393 BookmarkNode* node = [self nodeFromMenuItem:sender];
394 const std::string spec = node->GetURL().spec();
395 NSString* url = base::SysUTF8ToNSString(spec);
396 NSString* title = base::SysWideToNSString(node->GetTitle());
397 NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
398 [pasteboard declareURLPasteboardWithAdditionalTypes:[NSArray array]
399 owner:nil];
400 [pasteboard setDataForURL:url title:title];
401 }
402
391 - (IBAction)deleteBookmark:(id)sender { 403 - (IBAction)deleteBookmark:(id)sender {
392 BookmarkNode* node = [self nodeFromMenuItem:sender]; 404 BookmarkNode* node = [self nodeFromMenuItem:sender];
393 bookmarkModel_->Remove(node->GetParent(), 405 bookmarkModel_->Remove(node->GetParent(),
394 node->GetParent()->IndexOfChild(node)); 406 node->GetParent()->IndexOfChild(node));
395 } 407 }
396 408
397 - (void)openBookmarkNodesRecursive:(BookmarkNode*)node { 409 - (void)openBookmarkNodesRecursive:(BookmarkNode*)node {
398 for (int i = 0; i < node->GetChildCount(); i++) { 410 for (int i = 0; i < node->GetChildCount(); i++) {
399 BookmarkNode* child = node->GetChild(i); 411 BookmarkNode* child = node->GetChild(i);
400 if (child->is_url()) 412 if (child->is_url())
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 686
675 - (void)setUrlDelegate:(id<BookmarkURLOpener>)urlDelegate { 687 - (void)setUrlDelegate:(id<BookmarkURLOpener>)urlDelegate {
676 urlDelegate_ = urlDelegate; 688 urlDelegate_ = urlDelegate;
677 } 689 }
678 690
679 - (NSArray*)buttons { 691 - (NSArray*)buttons {
680 return buttons_.get(); 692 return buttons_.get();
681 } 693 }
682 694
683 @end 695 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698