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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 364 |
365 void PrintPreviewHandler::HandlePrint(const ListValue* args) { | 365 void PrintPreviewHandler::HandlePrint(const ListValue* args) { |
366 ReportStats(); | 366 ReportStats(); |
367 | 367 |
368 // Record the number of times the user requests to regenerate preview data | 368 // Record the number of times the user requests to regenerate preview data |
369 // before printing. | 369 // before printing. |
370 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", | 370 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", |
371 regenerate_preview_request_count_); | 371 regenerate_preview_request_count_); |
372 | 372 |
373 TabContentsWrapper* initiator_tab = GetInitiatorTab(); | 373 TabContentsWrapper* initiator_tab = GetInitiatorTab(); |
374 if (initiator_tab) { | 374 CHECK(initiator_tab); |
375 RenderViewHost* rvh = initiator_tab->render_view_host(); | 375 |
376 rvh->Send(new PrintMsg_ResetScriptedPrintCount(rvh->routing_id())); | 376 RenderViewHost* init_rvh = initiator_tab->render_view_host(); |
377 } | 377 init_rvh->Send(new PrintMsg_ResetScriptedPrintCount(init_rvh->routing_id())); |
378 | 378 |
379 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); | 379 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); |
380 if (!settings.get()) | 380 if (!settings.get()) |
381 return; | 381 return; |
382 | 382 |
383 // Storing last used color model. | 383 // Storing last used color model. |
384 int color_model; | 384 int color_model; |
385 if (!settings->GetInteger(printing::kSettingColor, &color_model)) | 385 if (!settings->GetInteger(printing::kSettingColor, &color_model)) |
386 color_model = printing::GRAY; | 386 color_model = printing::GRAY; |
387 last_used_color_model_ = static_cast<printing::ColorModels>(color_model); | 387 last_used_color_model_ = static_cast<printing::ColorModels>(color_model); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 | 421 |
422 // Do this so the initiator tab can open a new print preview tab. | 422 // Do this so the initiator tab can open a new print preview tab. |
423 ClearInitiatorTabDetails(); | 423 ClearInitiatorTabDetails(); |
424 | 424 |
425 // The PDF being printed contains only the pages that the user selected, | 425 // The PDF being printed contains only the pages that the user selected, |
426 // so ignore the page range and print all pages. | 426 // so ignore the page range and print all pages. |
427 settings->Remove(printing::kSettingPageRange, NULL); | 427 settings->Remove(printing::kSettingPageRange, NULL); |
428 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); | 428 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); |
429 rvh->Send(new PrintMsg_PrintForPrintPreview(rvh->routing_id(), *settings)); | 429 rvh->Send(new PrintMsg_PrintForPrintPreview(rvh->routing_id(), *settings)); |
430 } | 430 } |
| 431 initiator_tab->print_view_manager()->PrintPreviewDone(); |
431 } | 432 } |
432 | 433 |
433 void PrintPreviewHandler::HandlePrintToPdf( | 434 void PrintPreviewHandler::HandlePrintToPdf( |
434 const base::DictionaryValue& settings) { | 435 const base::DictionaryValue& settings) { |
435 if (print_to_pdf_path_.get()) { | 436 if (print_to_pdf_path_.get()) { |
436 // User has already selected a path, no need to show the dialog again. | 437 // User has already selected a path, no need to show the dialog again. |
437 PostPrintToPdfTask(); | 438 PostPrintToPdfTask(); |
438 } else if (!select_file_dialog_.get() || !select_file_dialog_->IsRunning( | 439 } else if (!select_file_dialog_.get() || !select_file_dialog_->IsRunning( |
439 platform_util::GetTopLevel(preview_tab()->GetNativeView()))) { | 440 platform_util::GetTopLevel(preview_tab()->GetNativeView()))) { |
440 ReportUserActionHistogram(PRINT_TO_PDF); | 441 ReportUserActionHistogram(PRINT_TO_PDF); |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 return; | 820 return; |
820 | 821 |
821 // We no longer require the initiator tab details. Remove those details | 822 // We no longer require the initiator tab details. Remove those details |
822 // associated with the preview tab to allow the initiator tab to create | 823 // associated with the preview tab to allow the initiator tab to create |
823 // another preview tab. | 824 // another preview tab. |
824 printing::PrintPreviewTabController* tab_controller = | 825 printing::PrintPreviewTabController* tab_controller = |
825 printing::PrintPreviewTabController::GetInstance(); | 826 printing::PrintPreviewTabController::GetInstance(); |
826 if (tab_controller) | 827 if (tab_controller) |
827 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); | 828 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); |
828 } | 829 } |
OLD | NEW |