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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 IDS_PRINT_PREVIEW_PAGE_RANGE_INSTRUCTION); | 244 IDS_PRINT_PREVIEW_PAGE_RANGE_INSTRUCTION); |
245 source->AddLocalizedString("copiesInstruction", | 245 source->AddLocalizedString("copiesInstruction", |
246 IDS_PRINT_PREVIEW_COPIES_INSTRUCTION); | 246 IDS_PRINT_PREVIEW_COPIES_INSTRUCTION); |
247 source->AddLocalizedString("incrementTitle", | 247 source->AddLocalizedString("incrementTitle", |
248 IDS_PRINT_PREVIEW_INCREMENT_TITLE); | 248 IDS_PRINT_PREVIEW_INCREMENT_TITLE); |
249 source->AddLocalizedString("decrementTitle", | 249 source->AddLocalizedString("decrementTitle", |
250 IDS_PRINT_PREVIEW_DECREMENT_TITLE); | 250 IDS_PRINT_PREVIEW_DECREMENT_TITLE); |
251 source->AddLocalizedString("printPagesLabel", | 251 source->AddLocalizedString("printPagesLabel", |
252 IDS_PRINT_PREVIEW_PRINT_PAGES_LABEL); | 252 IDS_PRINT_PREVIEW_PRINT_PAGES_LABEL); |
253 source->AddLocalizedString("optionsLabel", IDS_PRINT_PREVIEW_OPTIONS_LABEL); | 253 source->AddLocalizedString("optionsLabel", IDS_PRINT_PREVIEW_OPTIONS_LABEL); |
| 254 source->AddLocalizedString("optionDistillPage", |
| 255 IDS_PRINT_PREVIEW_OPTION_DISTILL_PAGE); |
254 source->AddLocalizedString("optionHeaderFooter", | 256 source->AddLocalizedString("optionHeaderFooter", |
255 IDS_PRINT_PREVIEW_OPTION_HEADER_FOOTER); | 257 IDS_PRINT_PREVIEW_OPTION_HEADER_FOOTER); |
256 source->AddLocalizedString("optionFitToPage", | 258 source->AddLocalizedString("optionFitToPage", |
257 IDS_PRINT_PREVIEW_OPTION_FIT_TO_PAGE); | 259 IDS_PRINT_PREVIEW_OPTION_FIT_TO_PAGE); |
258 source->AddLocalizedString( | 260 source->AddLocalizedString( |
259 "optionBackgroundColorsAndImages", | 261 "optionBackgroundColorsAndImages", |
260 IDS_PRINT_PREVIEW_OPTION_BACKGROUND_COLORS_AND_IMAGES); | 262 IDS_PRINT_PREVIEW_OPTION_BACKGROUND_COLORS_AND_IMAGES); |
261 source->AddLocalizedString("optionSelectionOnly", | 263 source->AddLocalizedString("optionSelectionOnly", |
262 IDS_PRINT_PREVIEW_OPTION_SELECTION_ONLY); | 264 IDS_PRINT_PREVIEW_OPTION_SELECTION_ONLY); |
263 source->AddLocalizedString("marginsLabel", IDS_PRINT_PREVIEW_MARGINS_LABEL); | 265 source->AddLocalizedString("marginsLabel", IDS_PRINT_PREVIEW_MARGINS_LABEL); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 391 |
390 } // namespace | 392 } // namespace |
391 | 393 |
392 PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) | 394 PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) |
393 : ConstrainedWebDialogUI(web_ui), | 395 : ConstrainedWebDialogUI(web_ui), |
394 initial_preview_start_time_(base::TimeTicks::Now()), | 396 initial_preview_start_time_(base::TimeTicks::Now()), |
395 id_(g_print_preview_ui_id_map.Get().Add(this)), | 397 id_(g_print_preview_ui_id_map.Get().Add(this)), |
396 handler_(NULL), | 398 handler_(NULL), |
397 source_is_modifiable_(true), | 399 source_is_modifiable_(true), |
398 source_has_selection_(false), | 400 source_has_selection_(false), |
399 dialog_closed_(false) { | 401 dialog_closed_(false), |
| 402 weak_ptr_factory_(this) { |
400 // Set up the chrome://print/ data source. | 403 // Set up the chrome://print/ data source. |
401 Profile* profile = Profile::FromWebUI(web_ui); | 404 Profile* profile = Profile::FromWebUI(web_ui); |
402 content::WebUIDataSource::Add(profile, CreatePrintPreviewUISource()); | 405 content::WebUIDataSource::Add(profile, CreatePrintPreviewUISource()); |
403 | 406 |
404 // Set up the chrome://theme/ source. | 407 // Set up the chrome://theme/ source. |
405 content::URLDataSource::Add(profile, new ThemeSource(profile)); | 408 content::URLDataSource::Add(profile, new ThemeSource(profile)); |
406 | 409 |
407 // WebUI owns |handler_|. | 410 // WebUI owns |handler_|. |
408 handler_ = new PrintPreviewHandler(); | 411 handler_ = new PrintPreviewHandler(); |
409 web_ui->AddMessageHandler(handler_); | 412 web_ui->AddMessageHandler(handler_); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 } | 657 } |
655 | 658 |
656 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { | 659 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { |
657 handler_->FileSelected(path, 0, NULL); | 660 handler_->FileSelected(path, 0, NULL); |
658 } | 661 } |
659 | 662 |
660 void PrintPreviewUI::SetPdfSavedClosureForTesting( | 663 void PrintPreviewUI::SetPdfSavedClosureForTesting( |
661 const base::Closure& closure) { | 664 const base::Closure& closure) { |
662 handler_->SetPdfSavedClosureForTesting(closure); | 665 handler_->SetPdfSavedClosureForTesting(closure); |
663 } | 666 } |
| 667 |
| 668 base::WeakPtr<PrintPreviewUI> PrintPreviewUI::GetWeakPtr() { |
| 669 return weak_ptr_factory_.GetWeakPtr(); |
| 670 } |
OLD | NEW |