| 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/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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 342 |
| 343 void PrintPreviewHandler::HandlePrint(const ListValue* args) { | 343 void PrintPreviewHandler::HandlePrint(const ListValue* args) { |
| 344 ReportStats(); | 344 ReportStats(); |
| 345 | 345 |
| 346 // Record the number of times the user requests to regenerate preview data | 346 // Record the number of times the user requests to regenerate preview data |
| 347 // before printing. | 347 // before printing. |
| 348 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", | 348 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", |
| 349 regenerate_preview_request_count_); | 349 regenerate_preview_request_count_); |
| 350 | 350 |
| 351 TabContentsWrapper* initiator_tab = GetInitiatorTab(); | 351 TabContentsWrapper* initiator_tab = GetInitiatorTab(); |
| 352 CHECK(initiator_tab); | 352 if (initiator_tab) { |
| 353 | 353 RenderViewHost* rvh = initiator_tab->render_view_host(); |
| 354 RenderViewHost* init_rvh = initiator_tab->render_view_host(); | 354 rvh->Send(new PrintMsg_ResetScriptedPrintCount(rvh->routing_id())); |
| 355 init_rvh->Send(new PrintMsg_ResetScriptedPrintCount(init_rvh->routing_id())); | 355 } |
| 356 | 356 |
| 357 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); | 357 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); |
| 358 if (!settings.get()) | 358 if (!settings.get()) |
| 359 return; | 359 return; |
| 360 | 360 |
| 361 // Storing last used color model. | 361 // Storing last used color model. |
| 362 int color_model; | 362 int color_model; |
| 363 if (!settings->GetInteger(printing::kSettingColor, &color_model)) | 363 if (!settings->GetInteger(printing::kSettingColor, &color_model)) |
| 364 color_model = printing::GRAY; | 364 color_model = printing::GRAY; |
| 365 last_used_color_model_ = static_cast<printing::ColorModels>(color_model); | 365 last_used_color_model_ = static_cast<printing::ColorModels>(color_model); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 413 |
| 414 // Do this so the initiator tab can open a new print preview tab. | 414 // Do this so the initiator tab can open a new print preview tab. |
| 415 ClearInitiatorTabDetails(); | 415 ClearInitiatorTabDetails(); |
| 416 | 416 |
| 417 // The PDF being printed contains only the pages that the user selected, | 417 // The PDF being printed contains only the pages that the user selected, |
| 418 // so ignore the page range and print all pages. | 418 // so ignore the page range and print all pages. |
| 419 settings->Remove(printing::kSettingPageRange, NULL); | 419 settings->Remove(printing::kSettingPageRange, NULL); |
| 420 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); | 420 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); |
| 421 rvh->Send(new PrintMsg_PrintForPrintPreview(rvh->routing_id(), *settings)); | 421 rvh->Send(new PrintMsg_PrintForPrintPreview(rvh->routing_id(), *settings)); |
| 422 } | 422 } |
| 423 initiator_tab->print_view_manager()->PrintPreviewDone(); | 423 if (initiator_tab) |
| 424 initiator_tab->print_view_manager()->PrintPreviewDone(); |
| 424 } | 425 } |
| 425 | 426 |
| 426 void PrintPreviewHandler::HandlePrintToPdf( | 427 void PrintPreviewHandler::HandlePrintToPdf( |
| 427 const base::DictionaryValue& settings) { | 428 const base::DictionaryValue& settings) { |
| 428 if (print_to_pdf_path_.get()) { | 429 if (print_to_pdf_path_.get()) { |
| 429 // User has already selected a path, no need to show the dialog again. | 430 // User has already selected a path, no need to show the dialog again. |
| 430 PostPrintToPdfTask(); | 431 PostPrintToPdfTask(); |
| 431 } else if (!select_file_dialog_.get() || !select_file_dialog_->IsRunning( | 432 } else if (!select_file_dialog_.get() || !select_file_dialog_->IsRunning( |
| 432 platform_util::GetTopLevel(preview_tab()->GetNativeView()))) { | 433 platform_util::GetTopLevel(preview_tab()->GetNativeView()))) { |
| 433 ReportUserActionHistogram(PRINT_TO_PDF); | 434 ReportUserActionHistogram(PRINT_TO_PDF); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 return; | 838 return; |
| 838 | 839 |
| 839 // We no longer require the initiator tab details. Remove those details | 840 // We no longer require the initiator tab details. Remove those details |
| 840 // associated with the preview tab to allow the initiator tab to create | 841 // associated with the preview tab to allow the initiator tab to create |
| 841 // another preview tab. | 842 // another preview tab. |
| 842 printing::PrintPreviewTabController* tab_controller = | 843 printing::PrintPreviewTabController* tab_controller = |
| 843 printing::PrintPreviewTabController::GetInstance(); | 844 printing::PrintPreviewTabController::GetInstance(); |
| 844 if (tab_controller) | 845 if (tab_controller) |
| 845 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); | 846 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); |
| 846 } | 847 } |
| OLD | NEW |