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_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/base64.h" | 12 #include "base/base64.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/i18n/file_util_icu.h" | 15 #include "base/i18n/file_util_icu.h" |
16 #include "base/i18n/number_formatting.h" | 16 #include "base/i18n/number_formatting.h" |
17 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
18 #include "base/lazy_instance.h" | 18 #include "base/lazy_instance.h" |
19 #include "base/memory/ref_counted_memory.h" | 19 #include "base/memory/ref_counted_memory.h" |
20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
22 #include "base/threading/thread.h" | 22 #include "base/threading/thread.h" |
23 #include "base/threading/thread_restrictions.h" | 23 #include "base/threading/thread_restrictions.h" |
24 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
25 #include "base/values.h" | 25 #include "base/values.h" |
26 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
| 27 #include "chrome/browser/chrome_select_file_policy.h" |
27 #include "chrome/browser/platform_util.h" | 28 #include "chrome/browser/platform_util.h" |
28 #include "chrome/browser/prefs/pref_service.h" | 29 #include "chrome/browser/prefs/pref_service.h" |
29 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 30 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
30 #include "chrome/browser/printing/print_dialog_cloud.h" | 31 #include "chrome/browser/printing/print_dialog_cloud.h" |
31 #include "chrome/browser/printing/print_error_dialog.h" | 32 #include "chrome/browser/printing/print_error_dialog.h" |
32 #include "chrome/browser/printing/print_job_manager.h" | 33 #include "chrome/browser/printing/print_job_manager.h" |
33 #include "chrome/browser/printing/print_preview_tab_controller.h" | 34 #include "chrome/browser/printing/print_preview_tab_controller.h" |
34 #include "chrome/browser/printing/print_system_task_proxy.h" | 35 #include "chrome/browser/printing/print_system_task_proxy.h" |
35 #include "chrome/browser/printing/print_view_manager.h" | 36 #include "chrome/browser/printing/print_view_manager.h" |
36 #include "chrome/browser/printing/printer_manager_dialog.h" | 37 #include "chrome/browser/printing/printer_manager_dialog.h" |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 if (!select_file_dialog_.get()) | 839 if (!select_file_dialog_.get()) |
839 select_file_dialog_ = SelectFileDialog::Create(this); | 840 select_file_dialog_ = SelectFileDialog::Create(this); |
840 | 841 |
841 select_file_dialog_->SelectFile( | 842 select_file_dialog_->SelectFile( |
842 SelectFileDialog::SELECT_SAVEAS_FILE, | 843 SelectFileDialog::SELECT_SAVEAS_FILE, |
843 string16(), | 844 string16(), |
844 GetStickySettings()->save_path()->Append(default_filename), | 845 GetStickySettings()->save_path()->Append(default_filename), |
845 &file_type_info, | 846 &file_type_info, |
846 0, | 847 0, |
847 FILE_PATH_LITERAL(""), | 848 FILE_PATH_LITERAL(""), |
848 preview_web_contents(), | 849 ChromeSelectFilePolicy::DisplayInfobarCallback(preview_web_contents()), |
849 platform_util::GetTopLevel(preview_web_contents()->GetNativeView()), | 850 platform_util::GetTopLevel(preview_web_contents()->GetNativeView()), |
850 NULL); | 851 NULL); |
851 } | 852 } |
852 | 853 |
853 void PrintPreviewHandler::OnTabDestroyed() { | 854 void PrintPreviewHandler::OnTabDestroyed() { |
854 TabContents* initiator_tab = GetInitiatorTab(); | 855 TabContents* initiator_tab = GetInitiatorTab(); |
855 if (!initiator_tab) | 856 if (!initiator_tab) |
856 return; | 857 return; |
857 | 858 |
858 initiator_tab->print_view_manager()->set_observer(NULL); | 859 initiator_tab->print_view_manager()->set_observer(NULL); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 return; | 912 return; |
912 | 913 |
913 // We no longer require the initiator tab details. Remove those details | 914 // We no longer require the initiator tab details. Remove those details |
914 // associated with the preview tab to allow the initiator tab to create | 915 // associated with the preview tab to allow the initiator tab to create |
915 // another preview tab. | 916 // another preview tab. |
916 printing::PrintPreviewTabController* tab_controller = | 917 printing::PrintPreviewTabController* tab_controller = |
917 printing::PrintPreviewTabController::GetInstance(); | 918 printing::PrintPreviewTabController::GetInstance(); |
918 if (tab_controller) | 919 if (tab_controller) |
919 tab_controller->EraseInitiatorTabInfo(preview_tab_contents()); | 920 tab_controller->EraseInitiatorTabInfo(preview_tab_contents()); |
920 } | 921 } |
OLD | NEW |