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

Unified Diff: chrome/browser/tab_contents/render_view_context_menu_mac.mm

Issue 3139007: Added "Look Up in Dictionary" item to context menu for Mac. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: morrita@google.com Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/render_view_context_menu_mac.mm
diff --git a/chrome/browser/tab_contents/render_view_context_menu_mac.mm b/chrome/browser/tab_contents/render_view_context_menu_mac.mm
index 42fe061a4c2851320e7ec56644b7be5bfc11c2ff..582f8addedf652528b0b828769a98caec45ff92d 100644
--- a/chrome/browser/tab_contents/render_view_context_menu_mac.mm
+++ b/chrome/browser/tab_contents/render_view_context_menu_mac.mm
@@ -7,7 +7,10 @@
#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "base/scoped_nsobject.h"
+#include "base/sys_string_conversions.h"
+#include "chrome/app/chrome_dll_resource.h"
#import "chrome/browser/cocoa/menu_controller.h"
+#include "grit/generated_resources.h"
// Obj-C bridge class that is the target of all items in the context menu.
// Relies on the tag being set to the command id.
@@ -24,6 +27,7 @@ RenderViewContextMenuMac::~RenderViewContextMenuMac() {
}
void RenderViewContextMenuMac::PlatformInit() {
+ InitPlatformMenu();
menuController_.reset(
[[MenuController alloc] initWithModel:&menu_model_
useWithPopUpButtonCell:NO]);
@@ -54,3 +58,26 @@ void RenderViewContextMenuMac::PlatformInit() {
forView:parent_view_];
}
}
+
+void RenderViewContextMenuMac::InitPlatformMenu() {
+ bool has_selection = !params_.selection_text.empty();
+
+ if (has_selection) {
+ menu_model_.AddSeparator();
+ menu_model_.AddItemWithStringId(
+ IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY,
+ IDS_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY);
+ }
+
+}
+
+void RenderViewContextMenuMac::LookUpInDictionary() {
+ // TODO(morrita): On Safari, A dictionary panel could be shown
+ // based on a preference setting of Dictionary.app. We currently
+ // don't support it: http://crbug.com/17951
+ NSString* text = base::SysWideToNSString(params_.selection_text);
+ NSPasteboard* pboard = [NSPasteboard pasteboardWithUniqueName];
+ BOOL ok = [pboard setString:text forType:NSStringPboardType];
+ if (ok)
+ NSPerformService(@"Look Up in Dictionary", pboard);
+}
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698