summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/chrome_dll_resource.h1
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc14
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.h1
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu_mac.h3
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu_mac.mm27
6 files changed, 49 insertions, 0 deletions
diff --git a/chrome/app/chrome_dll_resource.h b/chrome/app/chrome_dll_resource.h
index db4e0db..2c37401 100644
--- a/chrome/app/chrome_dll_resource.h
+++ b/chrome/app/chrome_dll_resource.h
@@ -311,6 +311,7 @@
#define IDC_CONTENT_CONTEXT_INSPECTELEMENT 50151
#define IDC_CONTENT_CONTEXT_VIEWPAGEINFO 50152
#define IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS 50153
+#define IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY 50154
// Frame items.
#define IDC_CONTENT_CONTEXT_RELOADFRAME 50160
#define IDC_CONTENT_CONTEXT_OPENFRAMENEWTAB 50161
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 9788c96..5bba2df 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -309,6 +309,9 @@ each locale. -->
<message name="IDS_CONTENT_CONTEXT_WRITING_DIRECTION_RTL" desc="The name of the 'Right to Left' item from the Writing Direction submenu in the content area context menu. To translate, launch /Applications/Textedit.app in an appropriately localized version of OS X, right-click on the text entry area and use the translation from there.">
Right to Left
</message>
+ <message name="IDS_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY" desc="The name of the 'Look Up in Dictionary' item in the content area context menu. To translate, launch /Applications/Textedit.app in an appropriately localized version of OS X, right-click on the text entry area and use the translation from there.">
+ Look Up in Dictionary
+ </message>
</if>
<if expr="not pp_ifdef('use_titlecase')">
<message name="IDS_CONTENT_CONTEXT_BACK" desc="The name of the Back command in the content area context menu">
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 3865f40..2fae258 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -400,6 +400,11 @@ void RenderViewContextMenu::InitMenu() {
AppendDeveloperItems();
}
+void RenderViewContextMenu::LookUpInDictionary() {
+ // Used only in the Mac port.
+ NOTREACHED();
+}
+
bool RenderViewContextMenu::AppendCustomItems() {
std::vector<WebMenuItem>& custom_items = params_.custom_items;
for (size_t i = 0; i < custom_items.size(); ++i) {
@@ -935,6 +940,10 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const {
WebContextMenuData::CheckableMenuItemEnabled;
case IDC_WRITING_DIRECTION_MENU:
return true;
+ case IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY:
+ // This is OK because the menu is not shown when it isn't
+ // appropriate.
+ return true;
#elif defined(OS_POSIX)
// TODO(suzhe): this should not be enabled for password fields.
case IDC_INPUT_METHODS_MENU:
@@ -981,6 +990,8 @@ bool RenderViewContextMenu::IsCommandIdChecked(int id) const {
if (id == IDC_WRITING_DIRECTION_LTR)
return params_.writing_direction_left_to_right &
WebContextMenuData::CheckableMenuItemChecked;
+ if (id == IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY)
+ return false;
#endif // OS_MACOSX
// Check box for 'Check the Spelling of this field'.
@@ -1323,6 +1334,9 @@ void RenderViewContextMenu::ExecuteCommand(int id) {
source_tab_contents_->render_view_host()->NotifyTextDirection();
break;
}
+ case IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY:
+ LookUpInDictionary();
+ break;
#endif // OS_MACOSX
default:
diff --git a/chrome/browser/tab_contents/render_view_context_menu.h b/chrome/browser/tab_contents/render_view_context_menu.h
index 73cdba8..9fd3108 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.h
+++ b/chrome/browser/tab_contents/render_view_context_menu.h
@@ -56,6 +56,7 @@ class RenderViewContextMenu : public menus::SimpleMenuModel::Delegate {
virtual bool GetAcceleratorForCommandId(
int command_id,
menus::Accelerator* accelerator) = 0;
+ virtual void LookUpInDictionary();
// Attempts to get an ExtensionMenuItem given the id of a context menu item.
ExtensionMenuItem* GetExtensionMenuItem(int id) const;
diff --git a/chrome/browser/tab_contents/render_view_context_menu_mac.h b/chrome/browser/tab_contents/render_view_context_menu_mac.h
index 71d1967..72f402c 100644
--- a/chrome/browser/tab_contents/render_view_context_menu_mac.h
+++ b/chrome/browser/tab_contents/render_view_context_menu_mac.h
@@ -33,6 +33,9 @@ class RenderViewContextMenuMac : public RenderViewContextMenu {
return false;
}
+ virtual void LookUpInDictionary();
+
+ void InitPlatformMenu();
private:
scoped_nsobject<MenuController> menuController_;
NSView* parent_view_; // parent view
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 42fe061..582f8ad 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);
+}