Chromium Code Reviews| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #if !defined(OS_CHROMEOS) | 10 #if !defined(OS_CHROMEOS) |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 | 476 |
| 477 TabContents* initiator_tab = GetInitiatorTab(); | 477 TabContents* initiator_tab = GetInitiatorTab(); |
| 478 if (!initiator_tab) { | 478 if (!initiator_tab) { |
| 479 if (!reported_failed_preview_) { | 479 if (!reported_failed_preview_) { |
| 480 ReportUserActionHistogram(PREVIEW_FAILED); | 480 ReportUserActionHistogram(PREVIEW_FAILED); |
| 481 reported_failed_preview_ = true; | 481 reported_failed_preview_ = true; |
| 482 } | 482 } |
| 483 print_preview_ui->OnPrintPreviewFailed(); | 483 print_preview_ui->OnPrintPreviewFailed(); |
| 484 return; | 484 return; |
| 485 } | 485 } |
| 486 | |
| 487 bool isHeaderFooter; | |
| 488 if (!settings->GetBoolean(printing::kSettingHeaderFooter, &isHeaderFooter)) { | |
|
kmadhusu
2011/07/14 01:50:15
nit: Remove {}
http://google-styleguide.googlecode
Aayush Kumar
2011/07/19 01:20:30
It's now a multi-line if condition so braces have
| |
| 489 NOTREACHED(); | |
| 490 } | |
| 491 | |
| 492 // If the user has checked the Headers and footers option then we go ahead | |
| 493 // and retrieve the page URL and title since we're already in the browser | |
| 494 // process and send it along to the renderer along with other print settings. | |
| 495 // No point going back to the renderer and then making an explicit call to | |
|
kmadhusu
2011/07/14 01:50:15
Provide a simple comment. No need to specify any d
Aayush Kumar
2011/07/19 01:20:30
Done.
| |
| 496 // the browser process again to retrieve this information. | |
| 497 DictionaryValue header_footer_info; | |
| 498 if (isHeaderFooter) { | |
| 499 header_footer_info.SetString(printing::kSettingHeaderFooterTitle, | |
| 500 initiator_tab->GetTitle()); | |
| 501 | |
| 502 NavigationEntry* entry = initiator_tab->controller().GetActiveEntry(); | |
| 503 if (entry) { | |
| 504 header_footer_info.SetString(printing::kSettingHeaderFooterURL, | |
| 505 entry->virtual_url().spec()); | |
| 506 } else { | |
| 507 header_footer_info.SetString(printing::kSettingHeaderFooterURL, ""); | |
|
kmadhusu
2011/07/14 01:50:15
How about:
std::string footer_url;
NavigationEnt
Aayush Kumar
2011/07/19 01:20:30
Done.
| |
| 508 } | |
| 509 } | |
| 510 | |
| 486 VLOG(1) << "Print preview request start"; | 511 VLOG(1) << "Print preview request start"; |
| 487 RenderViewHost* rvh = initiator_tab->render_view_host(); | 512 RenderViewHost* rvh = initiator_tab->render_view_host(); |
| 488 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings)); | 513 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings, |
| 514 header_footer_info)); | |
|
kmadhusu
2011/07/14 01:50:15
As thestig suggested, header_footer_info can be a
Aayush Kumar
2011/07/19 01:20:30
I discussed it with him and in person and put a sm
| |
| 489 } | 515 } |
| 490 | 516 |
| 491 void PrintPreviewHandler::HandlePrint(const ListValue* args) { | 517 void PrintPreviewHandler::HandlePrint(const ListValue* args) { |
| 492 ReportStats(); | 518 ReportStats(); |
| 493 | 519 |
| 494 // Record the number of times the user requests to regenerate preview data | 520 // Record the number of times the user requests to regenerate preview data |
| 495 // before printing. | 521 // before printing. |
| 496 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", | 522 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", |
| 497 regenerate_preview_request_count_); | 523 regenerate_preview_request_count_); |
| 498 | 524 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 870 return; | 896 return; |
| 871 | 897 |
| 872 // We no longer require the initiator tab details. Remove those details | 898 // We no longer require the initiator tab details. Remove those details |
| 873 // associated with the preview tab to allow the initiator tab to create | 899 // associated with the preview tab to allow the initiator tab to create |
| 874 // another preview tab. | 900 // another preview tab. |
| 875 printing::PrintPreviewTabController* tab_controller = | 901 printing::PrintPreviewTabController* tab_controller = |
| 876 printing::PrintPreviewTabController::GetInstance(); | 902 printing::PrintPreviewTabController::GetInstance(); |
| 877 if (tab_controller) | 903 if (tab_controller) |
| 878 tab_controller->EraseInitiatorTabInfo(preview_tab()); | 904 tab_controller->EraseInitiatorTabInfo(preview_tab()); |
| 879 } | 905 } |
| OLD | NEW |