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

Unified Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 1125343004: Add a "Simplify Page" option to the print preview dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update AUTHORS file to reflect the correct HP name used in the CLA Created 5 years, 7 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
Index: chrome/browser/ui/webui/print_preview/print_preview_handler.cc
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
index 237bba967a6013be8075d1ae87087d520386b79e..eb42f2507ed7b6fe6f67cc762389ad6269fd8f1e 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -30,6 +30,7 @@
#include "base/values.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/dom_distiller/tab_utils.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/printing/print_dialog_cloud.h"
#include "chrome/browser/printing/print_error_dialog.h"
@@ -57,6 +58,7 @@
#include "components/cloud_devices/common/cloud_device_description.h"
#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "components/cloud_devices/common/printer_description.h"
+#include "components/dom_distiller/core/url_utils.h"
#include "components/printing/common/print_messages.h"
#include "components/signin/core/browser/gaia_cookie_manager_service.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
@@ -165,6 +167,8 @@ const char kHidePrintWithSystemDialogLink[] = "hidePrintWithSystemDialogLink";
#endif
// Name of a dictionary field holding the state of selection for document.
const char kDocumentHasSelection[] = "documentHasSelection";
+// Dictionary field indicating whether to simplify the page.
+const char kPrintFriendlyEnabled[] = "printFriendlyEnabled";
// Id of the predefined PDF printer.
const char kLocalPdfPrinterId[] = "Save as PDF";
@@ -823,8 +827,24 @@ void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) {
}
VLOG(1) << "Print preview request start";
- RenderViewHost* rvh = initiator->GetRenderViewHost();
- rvh->Send(new PrintMsg_PrintPreview(rvh->GetRoutingID(), *settings));
+
+ bool print_friendly = false;
+ if (!settings->GetBoolean(printing::kSettingPrintFriendlyEnabled,
+ &print_friendly)) {
+ NOTREACHED();
+ }
+
+ if (print_friendly) {
+ if (!hidden_print_preview_)
+ MaybeStartDistillation(initiator);
nyquist 2015/05/13 07:56:38 Could this be simplified by using the new DistillA
arjunpatel 2015/05/27 00:16:45 Yes, depending on whether or not we keep the synch
+
+ hidden_print_preview_.reset(
+ new HiddenPrintPreview(initiator, print_preview_ui()));
+ hidden_print_preview_->SetSettings(settings.Pass());
+ } else {
+ RenderViewHost* rvh = initiator->GetRenderViewHost();
+ rvh->Send(new PrintMsg_PrintPreview(rvh->GetRoutingID(), *settings));
+ }
}
void PrintPreviewHandler::HandlePrint(const base::ListValue* args) {
@@ -1237,6 +1257,15 @@ void PrintPreviewHandler::SendInitialSettings(
initial_settings.SetBoolean(kHidePrintWithSystemDialogLink, is_ash);
#endif
+ WebContents* initiator = GetInitiator();
+ bool can_simplify = false;
+ if (initiator) {
+ can_simplify = cmdline->HasSwitch(switches::kEnableDomDistiller) &&
nyquist 2015/05/13 07:56:38 Should this also check to see if we assume that th
arjunpatel 2015/05/27 17:10:11 The latest version of the CL does this, showing th
+ dom_distiller::url_utils::IsUrlDistillable(
+ initiator->GetLastCommittedURL());
+ }
+ initial_settings.SetBoolean(kPrintFriendlyEnabled, can_simplify);
+
if (print_preview_ui()->source_is_modifiable())
GetNumberFormatAndMeasurementSystem(&initial_settings);
web_ui()->CallJavascriptFunction("setInitialSettings", initial_settings);

Powered by Google App Engine
This is Rietveld 408576698