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

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

Issue 12177009: Printing selection from context menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/tab_contents/render_view_context_menu.h ('k') | chrome/browser/ui/browser_commands.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3908e2a9c1b07ccc03fecf3aa9c868f1951ffccb..848c6bd71600ba79ca0aac1fc41736a2f81877c3 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -487,8 +487,10 @@ void RenderViewContextMenu::InitMenu() {
else if (has_selection)
AppendCopyItem();
- if (has_selection)
+ if (has_selection) {
+ AppendPrintItem();
AppendSearchProvider();
+ }
if (!IsDevToolsURL(params_.page_url))
AppendAllExtensionItems();
@@ -532,7 +534,7 @@ void RenderViewContextMenu::AppendPlatformAppItems() {
int index = 0;
extension_items_.AppendExtensionItems(platform_app->id(),
- PrintableSelectionText(), &index);
+ PrintableSelectionText(), &index);
// Add dev tools for unpacked extensions.
if (platform_app->location() == extensions::Manifest::LOAD ||
@@ -805,6 +807,14 @@ void RenderViewContextMenu::AppendCopyItem() {
IDS_CONTENT_CONTEXT_COPY);
}
+void RenderViewContextMenu::AppendPrintItem() {
+ if (profile_->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) &&
+ (params_.media_type == WebContextMenuData::MediaTypeNone ||
+ params_.media_flags & WebContextMenuData::MediaCanPrint)) {
+ menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT);
+ }
+}
+
void RenderViewContextMenu::AppendSearchProvider() {
DCHECK(profile_);
@@ -1563,7 +1573,7 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
if (profile_->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled)) {
print_view_manager->PrintNow();
} else {
- print_view_manager->PrintPreviewNow();
+ print_view_manager->PrintPreviewNow(!params_.selection_text.empty());
}
} else {
rvh->Send(new PrintMsg_PrintNodeUnderContextMenu(rvh->GetRoutingID()));
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.h ('k') | chrome/browser/ui/browser_commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698