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

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

Issue 2219173002: Re-land "Disable Print in the context menu when a modal dialog is shown" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create the GetBrowser() helper method Created 4 years, 4 months 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
« no previous file with comments | « chrome/browser/renderer_context_menu/render_view_context_menu.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_context_menu/render_view_context_menu.cc
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
index ad0e6d23320cdd46b025de9b0fe93644c54590a8..82ed3656f5b33dad2339b6b213938ff2decbc36d 100644
--- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc
+++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
@@ -56,7 +56,6 @@
#include "chrome/browser/tab_contents/retargeting_details.h"
#include "chrome/browser/translate/chrome_translate_client.h"
#include "chrome/browser/translate/translate_service.h"
-#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator_params.h"
@@ -1586,9 +1585,7 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const {
incognito_avail != IncognitoModePrefs::DISABLED;
case IDC_PRINT:
- return prefs->GetBoolean(prefs::kPrintingEnabled) &&
- (params_.media_type == WebContextMenuData::MediaTypeNone ||
- params_.media_flags & WebContextMenuData::MediaCanPrint);
+ return IsPrintPreviewEnabled();
case IDC_CONTENT_CONTEXT_SEARCHWEBFOR:
case IDC_CONTENT_CONTEXT_GOTOURL:
@@ -2087,6 +2084,16 @@ bool RenderViewContextMenu::IsPasteAndMatchStyleEnabled() const {
ui::CLIPBOARD_TYPE_COPY_PASTE);
}
+bool RenderViewContextMenu::IsPrintPreviewEnabled() const {
+ if (params_.media_type != WebContextMenuData::MediaTypeNone &&
+ !(params_.media_flags & WebContextMenuData::MediaCanPrint)) {
+ return false;
+ }
+
+ Browser* browser = GetBrowser();
+ return browser && chrome::CanPrint(browser);
+}
+
bool RenderViewContextMenu::IsRouteMediaEnabled() const {
if (!media_router::MediaRouterEnabled(browser_context_))
return false;
@@ -2449,3 +2456,7 @@ void RenderViewContextMenu::PluginActionAt(
source_web_contents_->GetRenderViewHost()->
ExecutePluginActionAtLocation(location, action);
}
+
+Browser* RenderViewContextMenu::GetBrowser() const {
+ return chrome::FindBrowserWithWebContents(embedder_web_contents_);
+}
« no previous file with comments | « chrome/browser/renderer_context_menu/render_view_context_menu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698