Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: chrome/browser/tab_contents/render_view_context_menu.cc

Issue 8834008: Hide default context menu for platform apps. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moved code out of Browser Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/tab_contents/render_view_context_menu.cc
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index caf3684562fbf306dbeffff35ffd86d076a75c4a..b25ae666f9948282445000e0e13a6eca6dd768e1 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()) {
Mihai Parparita -not on Chrome 2011/12/13 01:12:45 It seems like you would also want to do another is
+ 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.
« no previous file with comments | « chrome/browser/extensions/platform_app_browsertest.cc ('k') | chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698