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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 391 |
392 } // namespace | 392 } // namespace |
393 | 393 |
394 PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) | 394 PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) |
395 : ConstrainedWebDialogUI(web_ui), | 395 : ConstrainedWebDialogUI(web_ui), |
396 initial_preview_start_time_(base::TimeTicks::Now()), | 396 initial_preview_start_time_(base::TimeTicks::Now()), |
397 id_(g_print_preview_ui_id_map.Get().Add(this)), | 397 id_(g_print_preview_ui_id_map.Get().Add(this)), |
398 handler_(NULL), | 398 handler_(NULL), |
399 source_is_modifiable_(true), | 399 source_is_modifiable_(true), |
400 source_has_selection_(false), | 400 source_has_selection_(false), |
401 dialog_closed_(false), | 401 dialog_closed_(false) { |
402 weak_ptr_factory_(this) { | |
403 // Set up the chrome://print/ data source. | 402 // Set up the chrome://print/ data source. |
404 Profile* profile = Profile::FromWebUI(web_ui); | 403 Profile* profile = Profile::FromWebUI(web_ui); |
405 content::WebUIDataSource::Add(profile, CreatePrintPreviewUISource()); | 404 content::WebUIDataSource::Add(profile, CreatePrintPreviewUISource()); |
406 | 405 |
407 // Set up the chrome://theme/ source. | 406 // Set up the chrome://theme/ source. |
408 content::URLDataSource::Add(profile, new ThemeSource(profile)); | 407 content::URLDataSource::Add(profile, new ThemeSource(profile)); |
409 | 408 |
410 // WebUI owns |handler_|. | 409 // WebUI owns |handler_|. |
411 handler_ = new PrintPreviewHandler(); | 410 handler_ = new PrintPreviewHandler(); |
412 web_ui->AddMessageHandler(handler_); | 411 web_ui->AddMessageHandler(handler_); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 } | 656 } |
658 | 657 |
659 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { | 658 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { |
660 handler_->FileSelected(path, 0, NULL); | 659 handler_->FileSelected(path, 0, NULL); |
661 } | 660 } |
662 | 661 |
663 void PrintPreviewUI::SetPdfSavedClosureForTesting( | 662 void PrintPreviewUI::SetPdfSavedClosureForTesting( |
664 const base::Closure& closure) { | 663 const base::Closure& closure) { |
665 handler_->SetPdfSavedClosureForTesting(closure); | 664 handler_->SetPdfSavedClosureForTesting(closure); |
666 } | 665 } |
667 | |
668 base::WeakPtr<PrintPreviewUI> PrintPreviewUI::GetWeakPtr() { | |
669 return weak_ptr_factory_.GetWeakPtr(); | |
670 } | |
OLD | NEW |