| 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 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 IDS_PRINT_PREVIEW_PAGE_RANGE_SYNTAX_INSTRUCTION); | 252 IDS_PRINT_PREVIEW_PAGE_RANGE_SYNTAX_INSTRUCTION); |
| 253 source->AddLocalizedString("copiesInstruction", | 253 source->AddLocalizedString("copiesInstruction", |
| 254 IDS_PRINT_PREVIEW_COPIES_INSTRUCTION); | 254 IDS_PRINT_PREVIEW_COPIES_INSTRUCTION); |
| 255 source->AddLocalizedString("incrementTitle", | 255 source->AddLocalizedString("incrementTitle", |
| 256 IDS_PRINT_PREVIEW_INCREMENT_TITLE); | 256 IDS_PRINT_PREVIEW_INCREMENT_TITLE); |
| 257 source->AddLocalizedString("decrementTitle", | 257 source->AddLocalizedString("decrementTitle", |
| 258 IDS_PRINT_PREVIEW_DECREMENT_TITLE); | 258 IDS_PRINT_PREVIEW_DECREMENT_TITLE); |
| 259 source->AddLocalizedString("printPagesLabel", | 259 source->AddLocalizedString("printPagesLabel", |
| 260 IDS_PRINT_PREVIEW_PRINT_PAGES_LABEL); | 260 IDS_PRINT_PREVIEW_PRINT_PAGES_LABEL); |
| 261 source->AddLocalizedString("optionsLabel", IDS_PRINT_PREVIEW_OPTIONS_LABEL); | 261 source->AddLocalizedString("optionsLabel", IDS_PRINT_PREVIEW_OPTIONS_LABEL); |
| 262 source->AddLocalizedString("optionDistillPage", | |
| 263 IDS_PRINT_PREVIEW_OPTION_DISTILL_PAGE); | |
| 264 source->AddLocalizedString("optionHeaderFooter", | 262 source->AddLocalizedString("optionHeaderFooter", |
| 265 IDS_PRINT_PREVIEW_OPTION_HEADER_FOOTER); | 263 IDS_PRINT_PREVIEW_OPTION_HEADER_FOOTER); |
| 266 source->AddLocalizedString("optionFitToPage", | 264 source->AddLocalizedString("optionFitToPage", |
| 267 IDS_PRINT_PREVIEW_OPTION_FIT_TO_PAGE); | 265 IDS_PRINT_PREVIEW_OPTION_FIT_TO_PAGE); |
| 268 source->AddLocalizedString( | 266 source->AddLocalizedString( |
| 269 "optionBackgroundColorsAndImages", | 267 "optionBackgroundColorsAndImages", |
| 270 IDS_PRINT_PREVIEW_OPTION_BACKGROUND_COLORS_AND_IMAGES); | 268 IDS_PRINT_PREVIEW_OPTION_BACKGROUND_COLORS_AND_IMAGES); |
| 271 source->AddLocalizedString("optionSelectionOnly", | 269 source->AddLocalizedString("optionSelectionOnly", |
| 272 IDS_PRINT_PREVIEW_OPTION_SELECTION_ONLY); | 270 IDS_PRINT_PREVIEW_OPTION_SELECTION_ONLY); |
| 273 source->AddLocalizedString("marginsLabel", IDS_PRINT_PREVIEW_MARGINS_LABEL); | 271 source->AddLocalizedString("marginsLabel", IDS_PRINT_PREVIEW_MARGINS_LABEL); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 401 |
| 404 } // namespace | 402 } // namespace |
| 405 | 403 |
| 406 PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) | 404 PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) |
| 407 : ConstrainedWebDialogUI(web_ui), | 405 : ConstrainedWebDialogUI(web_ui), |
| 408 initial_preview_start_time_(base::TimeTicks::Now()), | 406 initial_preview_start_time_(base::TimeTicks::Now()), |
| 409 id_(g_print_preview_ui_id_map.Get().Add(this)), | 407 id_(g_print_preview_ui_id_map.Get().Add(this)), |
| 410 handler_(NULL), | 408 handler_(NULL), |
| 411 source_is_modifiable_(true), | 409 source_is_modifiable_(true), |
| 412 source_has_selection_(false), | 410 source_has_selection_(false), |
| 413 dialog_closed_(false), | 411 dialog_closed_(false) { |
| 414 weak_ptr_factory_(this) { | |
| 415 // Set up the chrome://print/ data source. | 412 // Set up the chrome://print/ data source. |
| 416 Profile* profile = Profile::FromWebUI(web_ui); | 413 Profile* profile = Profile::FromWebUI(web_ui); |
| 417 content::WebUIDataSource::Add(profile, CreatePrintPreviewUISource()); | 414 content::WebUIDataSource::Add(profile, CreatePrintPreviewUISource()); |
| 418 | 415 |
| 419 // Set up the chrome://theme/ source. | 416 // Set up the chrome://theme/ source. |
| 420 content::URLDataSource::Add(profile, new ThemeSource(profile)); | 417 content::URLDataSource::Add(profile, new ThemeSource(profile)); |
| 421 | 418 |
| 422 // WebUI owns |handler_|. | 419 // WebUI owns |handler_|. |
| 423 handler_ = new PrintPreviewHandler(); | 420 handler_ = new PrintPreviewHandler(); |
| 424 web_ui->AddMessageHandler(handler_); | 421 web_ui->AddMessageHandler(handler_); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 } | 662 } |
| 666 | 663 |
| 667 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { | 664 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { |
| 668 handler_->FileSelected(path, 0, NULL); | 665 handler_->FileSelected(path, 0, NULL); |
| 669 } | 666 } |
| 670 | 667 |
| 671 void PrintPreviewUI::SetPdfSavedClosureForTesting( | 668 void PrintPreviewUI::SetPdfSavedClosureForTesting( |
| 672 const base::Closure& closure) { | 669 const base::Closure& closure) { |
| 673 handler_->SetPdfSavedClosureForTesting(closure); | 670 handler_->SetPdfSavedClosureForTesting(closure); |
| 674 } | 671 } |
| 675 | |
| 676 base::WeakPtr<PrintPreviewUI> PrintPreviewUI::GetWeakPtr() { | |
| 677 return weak_ptr_factory_.GetWeakPtr(); | |
| 678 } | |
| OLD | NEW |