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

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: Compile on non-Windows OS 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 fe2ec8f9a13221c4a70a02fe3a583aad7412411d..7aae02a0babf8fe11b4050b085f4b6cb62dee93c 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -46,6 +46,7 @@
#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/common/chrome_constants.h"
@@ -359,8 +360,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)++;
@@ -510,6 +512,16 @@ void RenderViewContextMenu::InitMenu() {
bool has_link = !params_.link_url.is_empty();
bool has_selection = !params_.selection_text.empty();
+ Browser* active_browser = BrowserList::GetLastActive();
asargent_no_longer_on_chrome 2011/12/09 05:34:21 nit: it's probably better to use BrowserList::Find
benwells 2011/12/12 05:30:39 That's much better.
+ if (active_browser) {
+ const Extension* platform_app = active_browser->GetPlatformApp();
asargent_no_longer_on_chrome 2011/12/09 05:34:21 Instead of having the GetPlatformApp method on the
benwells 2011/12/12 05:30:39 To use the URL I would have to look at page_url, n
+ if (platform_app) {
+ int index = 0;
+ AppendExtensionItems(platform_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.

Powered by Google App Engine
This is Rietveld 408576698