summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorbenwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-13 02:53:21 +0000
committerbenwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-13 02:53:21 +0000
commit375003a571b5858486e58b8b3a4a255d2fb0669f (patch)
treecbf738433533ccb6bfe27ed45d52bd687a115240 /chrome/browser/tab_contents
parent9f392190f2e0cd72dd44e90c9f430921bdcbc680 (diff)
downloadchromium_src-375003a571b5858486e58b8b3a4a255d2fb0669f.zip
chromium_src-375003a571b5858486e58b8b3a4a255d2fb0669f.tar.gz
chromium_src-375003a571b5858486e58b8b3a4a255d2fb0669f.tar.bz2
Hide default context menu for platform apps.
Platform apps can provide their own context menu by overriding the contextmenu event. If they don't override this event, the default Chrome menu should not be shown. BUG=106687 TEST=Manually tested, and new browser test cases added. Review URL: http://codereview.chromium.org/8834008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114162 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index caf3684..b25ae66 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -47,8 +47,10 @@
#include "chrome/browser/translate/translate_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -360,8 +362,9 @@ void RenderViewContextMenu::AppendExtensionItems(
if (items.empty())
return;
- // If this is the first extension-provided menu item, add a separator.
- if (*index == 0)
+ // If this is the first extension-provided menu item, and there are other
+ // items in the menu, add a separator.
+ if (*index == 0 && menu_model_.GetItemCount())
menu_model_.AddSeparator();
int menu_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + (*index)++;
@@ -511,6 +514,20 @@ void RenderViewContextMenu::InitMenu() {
bool has_link = !params_.unfiltered_link_url.is_empty();
bool has_selection = !params_.selection_text.empty();
+ Browser* active_browser = BrowserList::FindBrowserWithTabContents(
+ source_tab_contents_);
+ if (active_browser && active_browser->is_app()) {
+ const std::string ext_id = web_app::GetExtensionIdFromApplicationName(
+ active_browser->app_name());
+ const Extension* app =
+ profile_->GetExtensionService()->GetInstalledExtension(ext_id);
+ if (app && app->is_platform_app()) {
+ int index = 0;
+ AppendExtensionItems(app->id(), &index);
+ return;
+ }
+ }
+
if (AppendCustomItems()) {
// If there's a selection, don't early return when there are custom items,
// but fall through to adding the normal ones after the custom ones.