| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 8 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 393 |
| 394 if (has_selection) | 394 if (has_selection) |
| 395 AppendSearchProvider(); | 395 AppendSearchProvider(); |
| 396 | 396 |
| 397 if (!is_devtools) | 397 if (!is_devtools) |
| 398 AppendAllExtensionItems(); | 398 AppendAllExtensionItems(); |
| 399 | 399 |
| 400 AppendDeveloperItems(); | 400 AppendDeveloperItems(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 void RenderViewContextMenu::LookUpInDictionary() { |
| 404 // Used only in the Mac port. |
| 405 NOTREACHED(); |
| 406 } |
| 407 |
| 403 bool RenderViewContextMenu::AppendCustomItems() { | 408 bool RenderViewContextMenu::AppendCustomItems() { |
| 404 std::vector<WebMenuItem>& custom_items = params_.custom_items; | 409 std::vector<WebMenuItem>& custom_items = params_.custom_items; |
| 405 for (size_t i = 0; i < custom_items.size(); ++i) { | 410 for (size_t i = 0; i < custom_items.size(); ++i) { |
| 406 DCHECK(IDC_CONTENT_CONTEXT_CUSTOM_FIRST + custom_items[i].action < | 411 DCHECK(IDC_CONTENT_CONTEXT_CUSTOM_FIRST + custom_items[i].action < |
| 407 IDC_CONTENT_CONTEXT_CUSTOM_LAST); | 412 IDC_CONTENT_CONTEXT_CUSTOM_LAST); |
| 408 if (custom_items[i].type == WebMenuItem::SEPARATOR) { | 413 if (custom_items[i].type == WebMenuItem::SEPARATOR) { |
| 409 menu_model_.AddSeparator(); | 414 menu_model_.AddSeparator(); |
| 410 } else { | 415 } else { |
| 411 menu_model_.AddItem( | 416 menu_model_.AddItem( |
| 412 custom_items[i].action + IDC_CONTENT_CONTEXT_CUSTOM_FIRST, | 417 custom_items[i].action + IDC_CONTENT_CONTEXT_CUSTOM_FIRST, |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 return params_.writing_direction_default & | 933 return params_.writing_direction_default & |
| 929 WebContextMenuData::CheckableMenuItemEnabled; | 934 WebContextMenuData::CheckableMenuItemEnabled; |
| 930 case IDC_WRITING_DIRECTION_RTL: | 935 case IDC_WRITING_DIRECTION_RTL: |
| 931 return params_.writing_direction_right_to_left & | 936 return params_.writing_direction_right_to_left & |
| 932 WebContextMenuData::CheckableMenuItemEnabled; | 937 WebContextMenuData::CheckableMenuItemEnabled; |
| 933 case IDC_WRITING_DIRECTION_LTR: | 938 case IDC_WRITING_DIRECTION_LTR: |
| 934 return params_.writing_direction_left_to_right & | 939 return params_.writing_direction_left_to_right & |
| 935 WebContextMenuData::CheckableMenuItemEnabled; | 940 WebContextMenuData::CheckableMenuItemEnabled; |
| 936 case IDC_WRITING_DIRECTION_MENU: | 941 case IDC_WRITING_DIRECTION_MENU: |
| 937 return true; | 942 return true; |
| 943 case IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY: |
| 944 // This is OK because the menu is not shown when it isn't |
| 945 // appropriate. |
| 946 return true; |
| 938 #elif defined(OS_POSIX) | 947 #elif defined(OS_POSIX) |
| 939 // TODO(suzhe): this should not be enabled for password fields. | 948 // TODO(suzhe): this should not be enabled for password fields. |
| 940 case IDC_INPUT_METHODS_MENU: | 949 case IDC_INPUT_METHODS_MENU: |
| 941 return true; | 950 return true; |
| 942 #endif | 951 #endif |
| 943 | 952 |
| 944 case IDC_SPELLCHECK_MENU: | 953 case IDC_SPELLCHECK_MENU: |
| 945 return true; | 954 return true; |
| 946 | 955 |
| 947 default: | 956 default: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 974 #if defined(OS_MACOSX) | 983 #if defined(OS_MACOSX) |
| 975 if (id == IDC_WRITING_DIRECTION_DEFAULT) | 984 if (id == IDC_WRITING_DIRECTION_DEFAULT) |
| 976 return params_.writing_direction_default & | 985 return params_.writing_direction_default & |
| 977 WebContextMenuData::CheckableMenuItemChecked; | 986 WebContextMenuData::CheckableMenuItemChecked; |
| 978 if (id == IDC_WRITING_DIRECTION_RTL) | 987 if (id == IDC_WRITING_DIRECTION_RTL) |
| 979 return params_.writing_direction_right_to_left & | 988 return params_.writing_direction_right_to_left & |
| 980 WebContextMenuData::CheckableMenuItemChecked; | 989 WebContextMenuData::CheckableMenuItemChecked; |
| 981 if (id == IDC_WRITING_DIRECTION_LTR) | 990 if (id == IDC_WRITING_DIRECTION_LTR) |
| 982 return params_.writing_direction_left_to_right & | 991 return params_.writing_direction_left_to_right & |
| 983 WebContextMenuData::CheckableMenuItemChecked; | 992 WebContextMenuData::CheckableMenuItemChecked; |
| 993 if (id == IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY) |
| 994 return false; |
| 984 #endif // OS_MACOSX | 995 #endif // OS_MACOSX |
| 985 | 996 |
| 986 // Check box for 'Check the Spelling of this field'. | 997 // Check box for 'Check the Spelling of this field'. |
| 987 if (id == IDC_CHECK_SPELLING_OF_THIS_FIELD) { | 998 if (id == IDC_CHECK_SPELLING_OF_THIS_FIELD) { |
| 988 return (params_.spellcheck_enabled && | 999 return (params_.spellcheck_enabled && |
| 989 profile_->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck)); | 1000 profile_->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck)); |
| 990 } | 1001 } |
| 991 | 1002 |
| 992 // Don't bother getting the display language vector if this isn't a spellcheck | 1003 // Don't bother getting the display language vector if this isn't a spellcheck |
| 993 // language. | 1004 // language. |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 break; | 1327 break; |
| 1317 case IDC_WRITING_DIRECTION_RTL: | 1328 case IDC_WRITING_DIRECTION_RTL: |
| 1318 case IDC_WRITING_DIRECTION_LTR: { | 1329 case IDC_WRITING_DIRECTION_LTR: { |
| 1319 WebKit::WebTextDirection dir = WebKit::WebTextDirectionLeftToRight; | 1330 WebKit::WebTextDirection dir = WebKit::WebTextDirectionLeftToRight; |
| 1320 if (id == IDC_WRITING_DIRECTION_RTL) | 1331 if (id == IDC_WRITING_DIRECTION_RTL) |
| 1321 dir = WebKit::WebTextDirectionRightToLeft; | 1332 dir = WebKit::WebTextDirectionRightToLeft; |
| 1322 source_tab_contents_->render_view_host()->UpdateTextDirection(dir); | 1333 source_tab_contents_->render_view_host()->UpdateTextDirection(dir); |
| 1323 source_tab_contents_->render_view_host()->NotifyTextDirection(); | 1334 source_tab_contents_->render_view_host()->NotifyTextDirection(); |
| 1324 break; | 1335 break; |
| 1325 } | 1336 } |
| 1337 case IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY: |
| 1338 LookUpInDictionary(); |
| 1339 break; |
| 1326 #endif // OS_MACOSX | 1340 #endif // OS_MACOSX |
| 1327 | 1341 |
| 1328 default: | 1342 default: |
| 1329 NOTREACHED(); | 1343 NOTREACHED(); |
| 1330 break; | 1344 break; |
| 1331 } | 1345 } |
| 1332 } | 1346 } |
| 1333 | 1347 |
| 1334 bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { | 1348 bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { |
| 1335 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1349 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), | 1426 UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), |
| 1413 g_browser_process->clipboard()); | 1427 g_browser_process->clipboard()); |
| 1414 } | 1428 } |
| 1415 | 1429 |
| 1416 void RenderViewContextMenu::MediaPlayerActionAt( | 1430 void RenderViewContextMenu::MediaPlayerActionAt( |
| 1417 const gfx::Point& location, | 1431 const gfx::Point& location, |
| 1418 const WebMediaPlayerAction& action) { | 1432 const WebMediaPlayerAction& action) { |
| 1419 source_tab_contents_->render_view_host()->MediaPlayerActionAt( | 1433 source_tab_contents_->render_view_host()->MediaPlayerActionAt( |
| 1420 location, action); | 1434 location, action); |
| 1421 } | 1435 } |
| OLD | NEW |