| OLD | NEW |
| 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_ui.h" | 5 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 int PrintPreviewUI::GetAvailableDraftPageCount() { | 387 int PrintPreviewUI::GetAvailableDraftPageCount() { |
| 388 return print_preview_data_service()->GetAvailableDraftPageCount(id_); | 388 return print_preview_data_service()->GetAvailableDraftPageCount(id_); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void PrintPreviewUI::SetInitiatorTabTitle( | 391 void PrintPreviewUI::SetInitiatorTabTitle( |
| 392 const string16& job_title) { | 392 const string16& job_title) { |
| 393 initiator_tab_title_ = job_title; | 393 initiator_tab_title_ = job_title; |
| 394 } | 394 } |
| 395 | 395 |
| 396 // static | 396 // static |
| 397 void PrintPreviewUI::SetSourceIsModifiable(WebContents* print_preview_dialog, | 397 void PrintPreviewUI::SetInitialParams( |
| 398 bool source_is_modifiable) { | 398 content::WebContents* print_preview_dialog, |
| 399 const PrintHostMsg_RequestPrintPreview_Params& params) { |
| 399 if (!print_preview_dialog || !print_preview_dialog->GetWebUI()) | 400 if (!print_preview_dialog || !print_preview_dialog->GetWebUI()) |
| 400 return; | 401 return; |
| 401 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( | 402 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( |
| 402 print_preview_dialog->GetWebUI()->GetController()); | 403 print_preview_dialog->GetWebUI()->GetController()); |
| 403 print_preview_ui->source_is_modifiable_ = source_is_modifiable; | 404 print_preview_ui->source_is_modifiable_ = params.is_modifiable; |
| 405 print_preview_ui->source_has_selection_ = params.has_selection; |
| 406 print_preview_ui->print_selection_only_ = params.selection_only; |
| 404 } | 407 } |
| 405 | 408 |
| 406 // static | 409 // static |
| 407 void PrintPreviewUI::SetSourceHasSelection(WebContents* print_preview_dialog, | |
| 408 bool source_has_selection) { | |
| 409 if (!print_preview_dialog || !print_preview_dialog->GetWebUI()) | |
| 410 return; | |
| 411 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( | |
| 412 print_preview_dialog->GetWebUI()->GetController()); | |
| 413 print_preview_ui->source_has_selection_ = source_has_selection; | |
| 414 } | |
| 415 | |
| 416 // static | |
| 417 void PrintPreviewUI::GetCurrentPrintPreviewStatus(int32 preview_ui_id, | 410 void PrintPreviewUI::GetCurrentPrintPreviewStatus(int32 preview_ui_id, |
| 418 int request_id, | 411 int request_id, |
| 419 bool* cancel) { | 412 bool* cancel) { |
| 420 int current_id = -1; | 413 int current_id = -1; |
| 421 if (!g_print_preview_request_id_map.Get().Get(preview_ui_id, ¤t_id)) { | 414 if (!g_print_preview_request_id_map.Get().Get(preview_ui_id, ¤t_id)) { |
| 422 *cancel = true; | 415 *cancel = true; |
| 423 return; | 416 return; |
| 424 } | 417 } |
| 425 *cancel = (request_id != current_id); | 418 *cancel = (request_id != current_id); |
| 426 } | 419 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 delegate->OnDialogCloseFromWebUI(); | 575 delegate->OnDialogCloseFromWebUI(); |
| 583 } | 576 } |
| 584 | 577 |
| 585 void PrintPreviewUI::OnReloadPrintersList() { | 578 void PrintPreviewUI::OnReloadPrintersList() { |
| 586 web_ui()->CallJavascriptFunction("reloadPrintersList"); | 579 web_ui()->CallJavascriptFunction("reloadPrintersList"); |
| 587 } | 580 } |
| 588 | 581 |
| 589 void PrintPreviewUI::OnPrintPreviewScalingDisabled() { | 582 void PrintPreviewUI::OnPrintPreviewScalingDisabled() { |
| 590 web_ui()->CallJavascriptFunction("printScalingDisabledForSourcePDF"); | 583 web_ui()->CallJavascriptFunction("printScalingDisabledForSourcePDF"); |
| 591 } | 584 } |
| OLD | NEW |