| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 // Only add extension items from this extension. | 739 // Only add extension items from this extension. |
| 740 int index = 0; | 740 int index = 0; |
| 741 extension_items_.AppendExtensionItems(key, PrintableSelectionText(), &index, | 741 extension_items_.AppendExtensionItems(key, PrintableSelectionText(), &index, |
| 742 false /* is_action_menu */); | 742 false /* is_action_menu */); |
| 743 } | 743 } |
| 744 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 744 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 745 | 745 |
| 746 void RenderViewContextMenu::InitMenu() { | 746 void RenderViewContextMenu::InitMenu() { |
| 747 RenderViewContextMenuBase::InitMenu(); | 747 RenderViewContextMenuBase::InitMenu(); |
| 748 | 748 |
| 749 if (content_type_->SupportsGroup( |
| 750 ContextMenuContentType::ITEM_GROUP_PASSWORD)) { |
| 751 AppendPasswordItems(); |
| 752 } |
| 753 |
| 749 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE)) | 754 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE)) |
| 750 AppendPageItems(); | 755 AppendPageItems(); |
| 751 | 756 |
| 752 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK)) { | 757 if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK)) { |
| 753 AppendLinkItems(); | 758 AppendLinkItems(); |
| 754 if (params_.media_type != WebContextMenuData::MediaTypeNone) | 759 if (params_.media_type != WebContextMenuData::MediaTypeNone) |
| 755 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | 760 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
| 756 } | 761 } |
| 757 | 762 |
| 758 if (content_type_->SupportsGroup( | 763 if (content_type_->SupportsGroup( |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 | 847 |
| 843 if (content_type_->SupportsGroup( | 848 if (content_type_->SupportsGroup( |
| 844 ContextMenuContentType::ITEM_GROUP_DEVTOOLS_UNPACKED_EXT)) { | 849 ContextMenuContentType::ITEM_GROUP_DEVTOOLS_UNPACKED_EXT)) { |
| 845 AppendDevtoolsForUnpackedExtensions(); | 850 AppendDevtoolsForUnpackedExtensions(); |
| 846 } | 851 } |
| 847 | 852 |
| 848 if (content_type_->SupportsGroup( | 853 if (content_type_->SupportsGroup( |
| 849 ContextMenuContentType::ITEM_GROUP_PRINT_PREVIEW)) { | 854 ContextMenuContentType::ITEM_GROUP_PRINT_PREVIEW)) { |
| 850 AppendPrintPreviewItems(); | 855 AppendPrintPreviewItems(); |
| 851 } | 856 } |
| 852 | |
| 853 if (content_type_->SupportsGroup( | |
| 854 ContextMenuContentType::ITEM_GROUP_PASSWORD)) { | |
| 855 AppendPasswordItems(); | |
| 856 } | |
| 857 } | 857 } |
| 858 | 858 |
| 859 Profile* RenderViewContextMenu::GetProfile() { | 859 Profile* RenderViewContextMenu::GetProfile() { |
| 860 return Profile::FromBrowserContext(browser_context_); | 860 return Profile::FromBrowserContext(browser_context_); |
| 861 } | 861 } |
| 862 | 862 |
| 863 void RenderViewContextMenu::RecordUsedItem(int id) { | 863 void RenderViewContextMenu::RecordUsedItem(int id) { |
| 864 int enum_id = FindUMAEnumValueForCommand(id, GENERAL_ENUM_ID); | 864 int enum_id = FindUMAEnumValueForCommand(id, GENERAL_ENUM_ID); |
| 865 if (enum_id != -1) { | 865 if (enum_id != -1) { |
| 866 const size_t kMappingSize = arraysize(kUmaEnumToControlId); | 866 const size_t kMappingSize = arraysize(kUmaEnumToControlId); |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS, | 1459 IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS, |
| 1460 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH_CONFIGURE)); | 1460 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH_CONFIGURE)); |
| 1461 | 1461 |
| 1462 menu_model_.AddSubMenu( | 1462 menu_model_.AddSubMenu( |
| 1463 IDC_CONTENT_CONTEXT_OPENLINKWITH, | 1463 IDC_CONTENT_CONTEXT_OPENLINKWITH, |
| 1464 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH), | 1464 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH), |
| 1465 &protocol_handler_submenu_model_); | 1465 &protocol_handler_submenu_model_); |
| 1466 } | 1466 } |
| 1467 | 1467 |
| 1468 void RenderViewContextMenu::AppendPasswordItems() { | 1468 void RenderViewContextMenu::AppendPasswordItems() { |
| 1469 bool separator_added = false; | 1469 bool add_separator = false; |
| 1470 if (password_manager::ForceSavingExperimentEnabled()) { | 1470 if (password_manager::ForceSavingExperimentEnabled()) { |
| 1471 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | |
| 1472 separator_added = true; | |
| 1473 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD, | 1471 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_FORCESAVEPASSWORD, |
| 1474 IDS_CONTENT_CONTEXT_FORCESAVEPASSWORD); | 1472 IDS_CONTENT_CONTEXT_FORCESAVEPASSWORD); |
| 1473 add_separator = true; |
| 1475 } | 1474 } |
| 1476 if (password_manager::ManualPasswordGenerationEnabled()) { | 1475 if (password_manager::ManualPasswordGenerationEnabled()) { |
| 1477 if (!separator_added) | |
| 1478 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); | |
| 1479 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_GENERATEPASSWORD, | 1476 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_GENERATEPASSWORD, |
| 1480 IDS_CONTENT_CONTEXT_GENERATEPASSWORD); | 1477 IDS_CONTENT_CONTEXT_GENERATEPASSWORD); |
| 1478 add_separator = true; |
| 1481 } | 1479 } |
| 1480 if (add_separator) |
| 1481 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); |
| 1482 } | 1482 } |
| 1483 | 1483 |
| 1484 // Menu delegate functions ----------------------------------------------------- | 1484 // Menu delegate functions ----------------------------------------------------- |
| 1485 | 1485 |
| 1486 bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { | 1486 bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { |
| 1487 { | 1487 { |
| 1488 bool enabled = false; | 1488 bool enabled = false; |
| 1489 if (RenderViewContextMenuBase::IsCommandIdKnown(id, &enabled)) | 1489 if (RenderViewContextMenuBase::IsCommandIdKnown(id, &enabled)) |
| 1490 return enabled; | 1490 return enabled; |
| 1491 } | 1491 } |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2524 void RenderViewContextMenu::PluginActionAt( | 2524 void RenderViewContextMenu::PluginActionAt( |
| 2525 const gfx::Point& location, | 2525 const gfx::Point& location, |
| 2526 const WebPluginAction& action) { | 2526 const WebPluginAction& action) { |
| 2527 source_web_contents_->GetRenderViewHost()-> | 2527 source_web_contents_->GetRenderViewHost()-> |
| 2528 ExecutePluginActionAtLocation(location, action); | 2528 ExecutePluginActionAtLocation(location, action); |
| 2529 } | 2529 } |
| 2530 | 2530 |
| 2531 Browser* RenderViewContextMenu::GetBrowser() const { | 2531 Browser* RenderViewContextMenu::GetBrowser() const { |
| 2532 return chrome::FindBrowserWithWebContents(embedder_web_contents_); | 2532 return chrome::FindBrowserWithWebContents(embedder_web_contents_); |
| 2533 } | 2533 } |
| OLD | NEW |