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

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

Issue 8428005: Print Preview: Making margin selection sticky (part 1/2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | printing/print_job_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/browser/ui/webui/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // The absolute path where the file will be saved. 192 // The absolute path where the file will be saved.
193 FilePath path_; 193 FilePath path_;
194 }; 194 };
195 195
196 // static 196 // static
197 FilePath* PrintPreviewHandler::last_saved_path_ = NULL; 197 FilePath* PrintPreviewHandler::last_saved_path_ = NULL;
198 std::string* PrintPreviewHandler::last_used_printer_cloud_print_data_ = NULL; 198 std::string* PrintPreviewHandler::last_used_printer_cloud_print_data_ = NULL;
199 std::string* PrintPreviewHandler::last_used_printer_name_ = NULL; 199 std::string* PrintPreviewHandler::last_used_printer_name_ = NULL;
200 printing::ColorModels PrintPreviewHandler::last_used_color_model_ = 200 printing::ColorModels PrintPreviewHandler::last_used_color_model_ =
201 printing::UNKNOWN_COLOR_MODEL; 201 printing::UNKNOWN_COLOR_MODEL;
202 printing::MarginType PrintPreviewHandler::last_used_margins_type_ =
203 printing::DEFAULT_MARGINS;
202 204
203 PrintPreviewHandler::PrintPreviewHandler() 205 PrintPreviewHandler::PrintPreviewHandler()
204 : print_backend_(printing::PrintBackend::CreateInstance(NULL)), 206 : print_backend_(printing::PrintBackend::CreateInstance(NULL)),
205 regenerate_preview_request_count_(0), 207 regenerate_preview_request_count_(0),
206 manage_printers_dialog_request_count_(0), 208 manage_printers_dialog_request_count_(0),
207 reported_failed_preview_(false), 209 reported_failed_preview_(false),
208 has_logged_printers_count_(false) { 210 has_logged_printers_count_(false) {
209 ReportUserActionHistogram(PREVIEW_STARTED); 211 ReportUserActionHistogram(PREVIEW_STARTED);
210 } 212 }
211 213
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); 384 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args));
383 if (!settings.get()) 385 if (!settings.get())
384 return; 386 return;
385 387
386 // Storing last used color model. 388 // Storing last used color model.
387 int color_model; 389 int color_model;
388 if (!settings->GetInteger(printing::kSettingColor, &color_model)) 390 if (!settings->GetInteger(printing::kSettingColor, &color_model))
389 color_model = printing::GRAY; 391 color_model = printing::GRAY;
390 last_used_color_model_ = static_cast<printing::ColorModels>(color_model); 392 last_used_color_model_ = static_cast<printing::ColorModels>(color_model);
391 393
394 // Storing last used margin settings.
395 int margin_type;
396 if (!settings->GetInteger(printing::kSettingMarginsType, &margin_type))
397 margin_type = printing::DEFAULT_MARGINS;
398 last_used_margins_type_ = static_cast<printing::MarginType>(margin_type);
399
392 bool print_to_pdf = false; 400 bool print_to_pdf = false;
393 settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf); 401 settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf);
394 402
395 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); 403 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false);
396 404
397 bool is_cloud_printer = settings->HasKey(printing::kSettingCloudPrintId); 405 bool is_cloud_printer = settings->HasKey(printing::kSettingCloudPrintId);
398 bool is_cloud_dialog = false; 406 bool is_cloud_dialog = false;
399 settings->GetBoolean(printing::kSettingCloudPrintDialog, &is_cloud_dialog); 407 settings->GetBoolean(printing::kSettingCloudPrintDialog, &is_cloud_dialog);
400 if (is_cloud_printer) { 408 if (is_cloud_printer) {
401 std::string print_ticket; 409 std::string print_ticket;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 void PrintPreviewHandler::SendPrinterCapabilities( 648 void PrintPreviewHandler::SendPrinterCapabilities(
641 const DictionaryValue& settings_info) { 649 const DictionaryValue& settings_info) {
642 VLOG(1) << "Get printer capabilities finished"; 650 VLOG(1) << "Get printer capabilities finished";
643 web_ui_->CallJavascriptFunction("updateWithPrinterCapabilities", 651 web_ui_->CallJavascriptFunction("updateWithPrinterCapabilities",
644 settings_info); 652 settings_info);
645 } 653 }
646 654
647 void PrintPreviewHandler::SendDefaultPrinter( 655 void PrintPreviewHandler::SendDefaultPrinter(
648 const StringValue& default_printer, 656 const StringValue& default_printer,
649 const StringValue& cloud_print_data) { 657 const StringValue& cloud_print_data) {
658 base::FundamentalValue margins_type(
659 PrintPreviewHandler::last_used_margins_type_);
650 web_ui_->CallJavascriptFunction("setDefaultPrinter", 660 web_ui_->CallJavascriptFunction("setDefaultPrinter",
651 default_printer, 661 default_printer,
652 cloud_print_data); 662 cloud_print_data,
663 margins_type);
653 } 664 }
654 665
655 void PrintPreviewHandler::SetupPrinterList(const ListValue& printers) { 666 void PrintPreviewHandler::SetupPrinterList(const ListValue& printers) {
656 SendCloudPrintEnabled(); 667 SendCloudPrintEnabled();
657 web_ui_->CallJavascriptFunction("setPrinters", printers); 668 web_ui_->CallJavascriptFunction("setPrinters", printers);
658 } 669 }
659 670
660 void PrintPreviewHandler::SendCloudPrintEnabled() { 671 void PrintPreviewHandler::SendCloudPrintEnabled() {
661 GURL gcp_url(CloudPrintURL(BrowserList::GetLastActive()->profile()). 672 GURL gcp_url(CloudPrintURL(BrowserList::GetLastActive()->profile()).
662 GetCloudPrintServiceURL()); 673 GetCloudPrintServiceURL());
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 return; 860 return;
850 861
851 // We no longer require the initiator tab details. Remove those details 862 // We no longer require the initiator tab details. Remove those details
852 // associated with the preview tab to allow the initiator tab to create 863 // associated with the preview tab to allow the initiator tab to create
853 // another preview tab. 864 // another preview tab.
854 printing::PrintPreviewTabController* tab_controller = 865 printing::PrintPreviewTabController* tab_controller =
855 printing::PrintPreviewTabController::GetInstance(); 866 printing::PrintPreviewTabController::GetInstance();
856 if (tab_controller) 867 if (tab_controller)
857 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); 868 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper());
858 } 869 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | printing/print_job_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698