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

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 2833993004: Print Preview: Make generate draft mode work again. (Closed)
Patch Set: Check NativeLayerStub Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/ui/webui/print_preview/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 DCHECK(ok); 730 DCHECK(ok);
731 731
732 EnsureExtensionPrinterHandlerSet(); 732 EnsureExtensionPrinterHandlerSet();
733 extension_printer_handler_->StartGetCapability( 733 extension_printer_handler_->StartGetCapability(
734 printer_id, 734 printer_id,
735 base::Bind(&PrintPreviewHandler::OnGotExtensionPrinterCapabilities, 735 base::Bind(&PrintPreviewHandler::OnGotExtensionPrinterCapabilities,
736 weak_factory_.GetWeakPtr())); 736 weak_factory_.GetWeakPtr()));
737 } 737 }
738 738
739 void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) { 739 void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) {
740 DCHECK_EQ(3U, args->GetSize()); 740 DCHECK_EQ(2U, args->GetSize());
741 std::unique_ptr<base::DictionaryValue> settings = GetSettingsDictionary(args); 741 std::unique_ptr<base::DictionaryValue> settings = GetSettingsDictionary(args);
742 if (!settings) 742 if (!settings)
743 return; 743 return;
744 int request_id = -1; 744 int request_id = -1;
745 if (!settings->GetInteger(printing::kPreviewRequestID, &request_id)) 745 if (!settings->GetInteger(printing::kPreviewRequestID, &request_id))
746 return; 746 return;
747 747
748 print_preview_ui()->OnPrintPreviewRequest(request_id); 748 print_preview_ui()->OnPrintPreviewRequest(request_id);
749 // Add an additional key in order to identify |print_preview_ui| later on 749 // Add an additional key in order to identify |print_preview_ui| later on
750 // when calling PrintPreviewUI::GetCurrentPrintPreviewStatus() on the IO 750 // when calling PrintPreviewUI::GetCurrentPrintPreviewStatus() on the IO
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 } 787 }
788 settings->SetString(printing::kSettingHeaderFooterURL, url); 788 settings->SetString(printing::kSettingHeaderFooterURL, url);
789 } 789 }
790 790
791 bool generate_draft_data = false; 791 bool generate_draft_data = false;
792 success = settings->GetBoolean(printing::kSettingGenerateDraftData, 792 success = settings->GetBoolean(printing::kSettingGenerateDraftData,
793 &generate_draft_data); 793 &generate_draft_data);
794 DCHECK(success); 794 DCHECK(success);
795 795
796 if (!generate_draft_data) { 796 if (!generate_draft_data) {
797 double draft_page_count_double = -1; 797 int page_count = -1;
798 success = args->GetDouble(1, &draft_page_count_double); 798 success = args->GetInteger(1, &page_count);
799 DCHECK(success);
800 int draft_page_count = static_cast<int>(draft_page_count_double);
801
802 bool preview_modifiable = false;
803 success = args->GetBoolean(2, &preview_modifiable);
804 DCHECK(success); 799 DCHECK(success);
805 800
806 if (draft_page_count != -1 && preview_modifiable && 801 if (page_count != -1) {
807 print_preview_ui()->GetAvailableDraftPageCount() != draft_page_count) { 802 bool preview_modifiable = false;
808 settings->SetBoolean(printing::kSettingGenerateDraftData, true); 803 success = settings->GetBoolean(printing::kSettingPreviewModifiable,
804 &preview_modifiable);
805 DCHECK(success);
806
807 if (preview_modifiable &&
808 print_preview_ui()->GetAvailableDraftPageCount() != page_count) {
809 settings->SetBoolean(printing::kSettingGenerateDraftData, true);
810 }
809 } 811 }
810 } 812 }
811 813
812 VLOG(1) << "Print preview request start"; 814 VLOG(1) << "Print preview request start";
813 815
814 rfh->Send(new PrintMsg_PrintPreview(rfh->GetRoutingID(), *settings)); 816 rfh->Send(new PrintMsg_PrintPreview(rfh->GetRoutingID(), *settings));
815 } 817 }
816 818
817 void PrintPreviewHandler::HandlePrint(const base::ListValue* args) { 819 void PrintPreviewHandler::HandlePrint(const base::ListValue* args) {
818 ReportStats(); 820 ReportStats();
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 1778
1777 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { 1779 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() {
1778 if (gaia_cookie_manager_service_) 1780 if (gaia_cookie_manager_service_)
1779 gaia_cookie_manager_service_->RemoveObserver(this); 1781 gaia_cookie_manager_service_->RemoveObserver(this);
1780 } 1782 }
1781 1783
1782 void PrintPreviewHandler::SetPdfSavedClosureForTesting( 1784 void PrintPreviewHandler::SetPdfSavedClosureForTesting(
1783 const base::Closure& closure) { 1785 const base::Closure& closure) {
1784 pdf_file_saved_closure_ = closure; 1786 pdf_file_saved_closure_ = closure;
1785 } 1787 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698