| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 9 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 10 | 10 |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 for (i = sorted_ids.begin(); | 500 for (i = sorted_ids.begin(); |
| 501 i != sorted_ids.end(); ++i) { | 501 i != sorted_ids.end(); ++i) { |
| 502 AppendExtensionItems(i->second, &index); | 502 AppendExtensionItems(i->second, &index); |
| 503 } | 503 } |
| 504 UMA_HISTOGRAM_TIMES("Extensions.ContextMenus_BuildTime", | 504 UMA_HISTOGRAM_TIMES("Extensions.ContextMenus_BuildTime", |
| 505 base::TimeTicks::Now() - begin); | 505 base::TimeTicks::Now() - begin); |
| 506 UMA_HISTOGRAM_COUNTS("Extensions.ContextMenus_ItemCount", index); | 506 UMA_HISTOGRAM_COUNTS("Extensions.ContextMenus_ItemCount", index); |
| 507 } | 507 } |
| 508 | 508 |
| 509 void RenderViewContextMenu::InitMenu() { | 509 void RenderViewContextMenu::InitMenu() { |
| 510 bool has_link = !params_.link_url.is_empty(); | 510 bool has_link = !params_.unfiltered_link_url.is_empty(); |
| 511 bool has_selection = !params_.selection_text.empty(); | 511 bool has_selection = !params_.selection_text.empty(); |
| 512 | 512 |
| 513 if (AppendCustomItems()) { | 513 if (AppendCustomItems()) { |
| 514 // If there's a selection, don't early return when there are custom items, | 514 // If there's a selection, don't early return when there are custom items, |
| 515 // but fall through to adding the normal ones after the custom ones. | 515 // but fall through to adding the normal ones after the custom ones. |
| 516 if (has_selection) { | 516 if (has_selection) { |
| 517 menu_model_.AddSeparator(); | 517 menu_model_.AddSeparator(); |
| 518 } else { | 518 } else { |
| 519 // Don't add items for Pepper menu. | 519 // Don't add items for Pepper menu. |
| 520 if (!params_.custom_context.is_pepper_menu) | 520 if (!params_.custom_context.is_pepper_menu) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 | 660 |
| 661 // In the DevTools popup menu, "developer items" is normally the only | 661 // In the DevTools popup menu, "developer items" is normally the only |
| 662 // section, so omit the separator there. | 662 // section, so omit the separator there. |
| 663 if (menu_model_.GetItemCount() > 0) | 663 if (menu_model_.GetItemCount() > 0) |
| 664 menu_model_.AddSeparator(); | 664 menu_model_.AddSeparator(); |
| 665 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTELEMENT, | 665 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTELEMENT, |
| 666 IDS_CONTENT_CONTEXT_INSPECTELEMENT); | 666 IDS_CONTENT_CONTEXT_INSPECTELEMENT); |
| 667 } | 667 } |
| 668 | 668 |
| 669 void RenderViewContextMenu::AppendLinkItems() { | 669 void RenderViewContextMenu::AppendLinkItems() { |
| 670 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, | 670 if (!params_.link_url.is_empty()) { |
| 671 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB); | 671 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, |
| 672 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, | 672 IDS_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| 673 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW); | 673 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, |
| 674 if (params_.link_url.is_valid()) { | 674 IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW); |
| 675 AppendProtocolHandlerSubMenu(); | 675 if (params_.link_url.is_valid()) { |
| 676 AppendProtocolHandlerSubMenu(); |
| 677 } |
| 678 |
| 679 if (!external_) { |
| 680 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, |
| 681 IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD); |
| 682 } |
| 683 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVELINKAS, |
| 684 IDS_CONTENT_CONTEXT_SAVELINKAS); |
| 676 } | 685 } |
| 677 if (!external_) { | |
| 678 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, | |
| 679 IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD); | |
| 680 } | |
| 681 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVELINKAS, | |
| 682 IDS_CONTENT_CONTEXT_SAVELINKAS); | |
| 683 | 686 |
| 684 menu_model_.AddItemWithStringId( | 687 menu_model_.AddItemWithStringId( |
| 685 IDC_CONTENT_CONTEXT_COPYLINKLOCATION, | 688 IDC_CONTENT_CONTEXT_COPYLINKLOCATION, |
| 686 params_.link_url.SchemeIs(chrome::kMailToScheme) ? | 689 params_.link_url.SchemeIs(chrome::kMailToScheme) ? |
| 687 IDS_CONTENT_CONTEXT_COPYEMAILADDRESS : | 690 IDS_CONTENT_CONTEXT_COPYEMAILADDRESS : |
| 688 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); | 691 IDS_CONTENT_CONTEXT_COPYLINKLOCATION); |
| 689 } | 692 } |
| 690 | 693 |
| 691 void RenderViewContextMenu::AppendImageItems() { | 694 void RenderViewContextMenu::AppendImageItems() { |
| 692 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, | 695 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 1840 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
| 1838 g_browser_process->clipboard()); | 1841 g_browser_process->clipboard()); |
| 1839 } | 1842 } |
| 1840 | 1843 |
| 1841 void RenderViewContextMenu::MediaPlayerActionAt( | 1844 void RenderViewContextMenu::MediaPlayerActionAt( |
| 1842 const gfx::Point& location, | 1845 const gfx::Point& location, |
| 1843 const WebMediaPlayerAction& action) { | 1846 const WebMediaPlayerAction& action) { |
| 1844 source_tab_contents_->render_view_host()-> | 1847 source_tab_contents_->render_view_host()-> |
| 1845 ExecuteMediaPlayerActionAtLocation(location, action); | 1848 ExecuteMediaPlayerActionAtLocation(location, action); |
| 1846 } | 1849 } |
| OLD | NEW |