| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/print_web_view_helper.h" | 5 #include "chrome/renderer/print_web_view_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 if (old_print_pages_params_.get() && | 375 if (old_print_pages_params_.get() && |
| 376 PrintMsg_Print_Params_IsEqual(*old_print_pages_params_, | 376 PrintMsg_Print_Params_IsEqual(*old_print_pages_params_, |
| 377 *print_pages_params_)) { | 377 *print_pages_params_)) { |
| 378 PrintHostMsg_DidPreviewDocument_Params preview_params; | 378 PrintHostMsg_DidPreviewDocument_Params preview_params; |
| 379 preview_params.reuse_existing_data = true; | 379 preview_params.reuse_existing_data = true; |
| 380 preview_params.data_size = 0; | 380 preview_params.data_size = 0; |
| 381 preview_params.document_cookie = | 381 preview_params.document_cookie = |
| 382 print_pages_params_->params.document_cookie; | 382 print_pages_params_->params.document_cookie; |
| 383 preview_params.expected_pages_count = preview_page_count_; | 383 preview_params.expected_pages_count = preview_page_count_; |
| 384 preview_params.modifiable = IsModifiable(frame, node); | 384 preview_params.modifiable = IsModifiable(frame, node); |
| 385 preview_params.preview_request_id = |
| 386 print_pages_params_->params.preview_request_id; |
| 385 | 387 |
| 386 Send(new PrintHostMsg_PagesReadyForPreview(routing_id(), preview_params)); | 388 Send(new PrintHostMsg_PagesReadyForPreview(routing_id(), preview_params)); |
| 387 return; | 389 return; |
| 388 } | 390 } |
| 389 | 391 |
| 390 // Render Pages for preview. | 392 // Render Pages for preview. |
| 391 if (!RenderPagesForPreview(frame, node)) | 393 if (!RenderPagesForPreview(frame, node)) |
| 392 DidFinishPrinting(FAIL_PREVIEW); | 394 DidFinishPrinting(FAIL_PREVIEW); |
| 393 } | 395 } |
| 394 | 396 |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 bool PrintWebViewHelper::UpdatePrintSettingsLocal( | 681 bool PrintWebViewHelper::UpdatePrintSettingsLocal( |
| 680 const DictionaryValue& job_settings) { | 682 const DictionaryValue& job_settings) { |
| 681 PrintMsg_PrintPages_Params settings; | 683 PrintMsg_PrintPages_Params settings; |
| 682 | 684 |
| 683 Send(new PrintHostMsg_UpdatePrintSettings(routing_id(), | 685 Send(new PrintHostMsg_UpdatePrintSettings(routing_id(), |
| 684 print_pages_params_->params.document_cookie, job_settings, &settings)); | 686 print_pages_params_->params.document_cookie, job_settings, &settings)); |
| 685 | 687 |
| 686 if (settings.params.dpi < kMinDpi || !settings.params.document_cookie) | 688 if (settings.params.dpi < kMinDpi || !settings.params.document_cookie) |
| 687 return false; | 689 return false; |
| 688 | 690 |
| 691 if (!job_settings.GetInteger(printing::kPreviewRequestID, |
| 692 &settings.params.preview_request_id)) { |
| 693 NOTREACHED(); |
| 694 return false; |
| 695 } |
| 696 |
| 689 print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); | 697 print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); |
| 690 Send(new PrintHostMsg_DidGetDocumentCookie(routing_id(), | 698 Send(new PrintHostMsg_DidGetDocumentCookie(routing_id(), |
| 691 settings.params.document_cookie)); | 699 settings.params.document_cookie)); |
| 692 return true; | 700 return true; |
| 693 } | 701 } |
| 694 | 702 |
| 695 bool PrintWebViewHelper::UpdatePrintSettings( | 703 bool PrintWebViewHelper::UpdatePrintSettings( |
| 696 const DictionaryValue& job_settings) { | 704 const DictionaryValue& job_settings) { |
| 697 if (job_settings.HasKey(printing::kSettingCloudPrintId)) { | 705 if (job_settings.HasKey(printing::kSettingCloudPrintId)) { |
| 698 return UpdatePrintSettingsCloud(job_settings); | 706 return UpdatePrintSettingsCloud(job_settings); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 Send(new PrintHostMsg_RequestPrintPreview(routing_id())); | 864 Send(new PrintHostMsg_RequestPrintPreview(routing_id())); |
| 857 } | 865 } |
| 858 | 866 |
| 859 bool PrintWebViewHelper::PreviewPageRendered(int page_number) { | 867 bool PrintWebViewHelper::PreviewPageRendered(int page_number) { |
| 860 bool cancel = false; | 868 bool cancel = false; |
| 861 Send(new PrintHostMsg_DidPreviewPage(routing_id(), page_number, &cancel)); | 869 Send(new PrintHostMsg_DidPreviewPage(routing_id(), page_number, &cancel)); |
| 862 if (cancel) | 870 if (cancel) |
| 863 notify_browser_of_print_failure_ = false; | 871 notify_browser_of_print_failure_ = false; |
| 864 return !cancel; | 872 return !cancel; |
| 865 } | 873 } |
| OLD | NEW |