Chromium Code Reviews| 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 NOTREACHED(); | 405 NOTREACHED(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 bool RenderViewContextMenu::AppendCustomItems() { | 408 bool RenderViewContextMenu::AppendCustomItems() { |
| 409 std::vector<WebMenuItem>& custom_items = params_.custom_items; | 409 std::vector<WebMenuItem>& custom_items = params_.custom_items; |
| 410 for (size_t i = 0; i < custom_items.size(); ++i) { | 410 for (size_t i = 0; i < custom_items.size(); ++i) { |
| 411 DCHECK(IDC_CONTENT_CONTEXT_CUSTOM_FIRST + custom_items[i].action < | 411 DCHECK(IDC_CONTENT_CONTEXT_CUSTOM_FIRST + custom_items[i].action < |
| 412 IDC_CONTENT_CONTEXT_CUSTOM_LAST); | 412 IDC_CONTENT_CONTEXT_CUSTOM_LAST); |
| 413 if (custom_items[i].type == WebMenuItem::SEPARATOR) { | 413 if (custom_items[i].type == WebMenuItem::SEPARATOR) { |
| 414 menu_model_.AddSeparator(); | 414 menu_model_.AddSeparator(); |
| 415 } else if (custom_items[i].type == WebMenuItem::CHECKABLE_OPTION) { | |
| 416 menu_model_.AddCheckItem( | |
| 417 custom_items[i].action + IDC_CONTENT_CONTEXT_CUSTOM_FIRST, | |
| 418 custom_items[i].label); | |
| 415 } else { | 419 } else { |
| 416 menu_model_.AddItem( | 420 menu_model_.AddItem( |
| 417 custom_items[i].action + IDC_CONTENT_CONTEXT_CUSTOM_FIRST, | 421 custom_items[i].action + IDC_CONTENT_CONTEXT_CUSTOM_FIRST, |
| 418 custom_items[i].label); | 422 custom_items[i].label); |
| 419 } | 423 } |
| 420 } | 424 } |
| 421 return custom_items.size() > 0; | 425 return custom_items.size() > 0; |
| 422 } | 426 } |
| 423 | 427 |
| 424 void RenderViewContextMenu::AppendDeveloperItems() { | 428 void RenderViewContextMenu::AppendDeveloperItems() { |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 (id < IDC_CONTENT_CONTEXT_CUSTOM_LAST)) { | 745 (id < IDC_CONTENT_CONTEXT_CUSTOM_LAST)) { |
| 742 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; | 746 unsigned action = id - IDC_CONTENT_CONTEXT_CUSTOM_FIRST; |
| 743 for (size_t i = 0; i < params_.custom_items.size(); ++i) { | 747 for (size_t i = 0; i < params_.custom_items.size(); ++i) { |
| 744 if (params_.custom_items[i].action == action) | 748 if (params_.custom_items[i].action == action) |
| 745 return params_.custom_items[i].enabled; | 749 return params_.custom_items[i].enabled; |
| 746 } | 750 } |
| 747 NOTREACHED(); | 751 NOTREACHED(); |
| 748 return false; | 752 return false; |
| 749 } | 753 } |
| 750 | 754 |
| 755 // Custom WebKit items. | |
| 756 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && | |
| 757 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { | |
| 758 const std::vector<WebMenuItem>& custom_items = params_.custom_items; | |
| 759 for (size_t i = 0; i < custom_items.size(); ++i) { | |
| 760 int action_id = IDC_CONTENT_CONTEXT_CUSTOM_FIRST + custom_items[i].action; | |
| 761 if (action_id == id) | |
| 762 return custom_items[i].enabled; | |
| 763 } | |
|
yurys
2010/08/25 12:55:29
There should be ASSERT_NOT_REACHED();
| |
| 764 return true; | |
| 765 } | |
| 766 | |
| 751 // Extension items. | 767 // Extension items. |
| 752 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && | 768 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && |
| 753 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { | 769 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { |
| 754 // In the future we may add APIs for extensions to disable items, but for | 770 // In the future we may add APIs for extensions to disable items, but for |
| 755 // now all items are implicitly enabled. | 771 // now all items are implicitly enabled. |
| 756 return true; | 772 return true; |
| 757 } | 773 } |
| 758 | 774 |
| 759 switch (id) { | 775 switch (id) { |
| 760 case IDC_BACK: | 776 case IDC_BACK: |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 964 if (id == IDC_CONTENT_CONTEXT_LOOP) { | 980 if (id == IDC_CONTENT_CONTEXT_LOOP) { |
| 965 return (params_.media_flags & | 981 return (params_.media_flags & |
| 966 WebContextMenuData::MediaLoop) != 0; | 982 WebContextMenuData::MediaLoop) != 0; |
| 967 } | 983 } |
| 968 | 984 |
| 969 if (id == IDC_CONTENT_CONTEXT_CONTROLS) { | 985 if (id == IDC_CONTENT_CONTEXT_CONTROLS) { |
| 970 return (params_.media_flags & | 986 return (params_.media_flags & |
| 971 WebContextMenuData::MediaControls) != 0; | 987 WebContextMenuData::MediaControls) != 0; |
| 972 } | 988 } |
| 973 | 989 |
| 990 // Custom WebKit items. | |
| 991 if (id >= IDC_CONTENT_CONTEXT_CUSTOM_FIRST && | |
| 992 id <= IDC_CONTENT_CONTEXT_CUSTOM_LAST) { | |
| 993 const std::vector<WebMenuItem>& custom_items = params_.custom_items; | |
| 994 for (size_t i = 0; i < custom_items.size(); ++i) { | |
| 995 int action_id = IDC_CONTENT_CONTEXT_CUSTOM_FIRST + custom_items[i].action; | |
| 996 if (action_id == id) | |
| 997 return custom_items[i].checked; | |
| 998 } | |
| 999 return false; | |
|
yurys
2010/08/25 12:55:29
ditto.
| |
| 1000 } | |
| 1001 | |
| 1002 // Extension items. | |
| 974 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && | 1003 if (id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && |
| 975 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { | 1004 id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { |
| 976 ExtensionMenuItem* item = GetExtensionMenuItem(id); | 1005 ExtensionMenuItem* item = GetExtensionMenuItem(id); |
| 977 if (item) | 1006 if (item) |
| 978 return item->checked(); | 1007 return item->checked(); |
| 979 else | 1008 else |
| 980 return false; | 1009 return false; |
| 981 } | 1010 } |
| 982 | 1011 |
| 983 #if defined(OS_MACOSX) | 1012 #if defined(OS_MACOSX) |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1426 UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), | 1455 UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), |
| 1427 g_browser_process->clipboard()); | 1456 g_browser_process->clipboard()); |
| 1428 } | 1457 } |
| 1429 | 1458 |
| 1430 void RenderViewContextMenu::MediaPlayerActionAt( | 1459 void RenderViewContextMenu::MediaPlayerActionAt( |
| 1431 const gfx::Point& location, | 1460 const gfx::Point& location, |
| 1432 const WebMediaPlayerAction& action) { | 1461 const WebMediaPlayerAction& action) { |
| 1433 source_tab_contents_->render_view_host()->MediaPlayerActionAt( | 1462 source_tab_contents_->render_view_host()->MediaPlayerActionAt( |
| 1434 location, action); | 1463 location, action); |
| 1435 } | 1464 } |
| OLD | NEW |