Chromium Code Reviews| 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 d9c40280300d4b92ec9d6a684095c25b5f160db2..cfce61e261277ef4965b49ad94693ab7af30a75d 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,8 @@ |
| #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/content/distillable_page_utils.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" |
| @@ -839,8 +842,20 @@ 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) { |
| + hidden_print_preview_.reset( |
| + new HiddenPrintPreview(initiator, print_preview_ui(), settings.Pass())); |
| + } else { |
| + RenderViewHost* rvh = initiator->GetRenderViewHost(); |
| + rvh->Send(new PrintMsg_PrintPreview(rvh->GetRoutingID(), *settings)); |
| + } |
| } |
| void PrintPreviewHandler::HandlePrint(const base::ListValue* args) { |
| @@ -1256,6 +1271,21 @@ void PrintPreviewHandler::SendInitialSettings( |
| if (print_preview_ui()->source_is_modifiable()) |
| GetNumberFormatAndMeasurementSystem(&initial_settings); |
| web_ui()->CallJavascriptFunction("setInitialSettings", initial_settings); |
| + |
| + WebContents* initiator = GetInitiator(); |
| + if (initiator && cmdline->HasSwitch(switches::kEnableDomDistiller) && |
| + dom_distiller::url_utils::IsUrlDistillable( |
| + initiator->GetLastCommittedURL())) { |
| + dom_distiller::IsDistillablePage(initiator, false, |
|
Vitaly Buka (NO REVIEWS)
2015/07/13 07:00:31
I don't see guaranty that HandleIsPageDistillableR
|
| + base::Bind(&PrintPreviewHandler::HandleIsPageDistillableResult, |
| + base::Unretained(this))); |
| + } |
| +} |
| + |
| +void PrintPreviewHandler::HandleIsPageDistillableResult(bool distillable) { |
| + VLOG(1) << "Distillable page detection finished"; |
| + if (distillable) |
| + web_ui()->CallJavascriptFunction("onDetectedSimplifiablePage"); |
| } |
| void PrintPreviewHandler::ClosePreviewDialog() { |