| 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> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "chrome/browser/prefs/pref_service.h" | 28 #include "chrome/browser/prefs/pref_service.h" |
| 29 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 29 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| 30 #include "chrome/browser/printing/print_dialog_cloud.h" | 30 #include "chrome/browser/printing/print_dialog_cloud.h" |
| 31 #include "chrome/browser/printing/print_error_dialog.h" | 31 #include "chrome/browser/printing/print_error_dialog.h" |
| 32 #include "chrome/browser/printing/print_job_manager.h" | 32 #include "chrome/browser/printing/print_job_manager.h" |
| 33 #include "chrome/browser/printing/print_preview_tab_controller.h" | 33 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 34 #include "chrome/browser/printing/print_system_task_proxy.h" | 34 #include "chrome/browser/printing/print_system_task_proxy.h" |
| 35 #include "chrome/browser/printing/print_view_manager.h" | 35 #include "chrome/browser/printing/print_view_manager.h" |
| 36 #include "chrome/browser/printing/printer_manager_dialog.h" | 36 #include "chrome/browser/printing/printer_manager_dialog.h" |
| 37 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
| 38 #include "chrome/browser/ui/chrome_select_file_policy.h" | |
| 39 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 38 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 40 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" | 39 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" |
| 41 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h" | 40 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h" |
| 42 #include "chrome/common/chrome_paths.h" | 41 #include "chrome/common/chrome_paths.h" |
| 43 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
| 44 #include "chrome/common/print_messages.h" | 43 #include "chrome/common/print_messages.h" |
| 45 #include "content/public/browser/browser_thread.h" | 44 #include "content/public/browser/browser_thread.h" |
| 46 #include "content/public/browser/navigation_controller.h" | 45 #include "content/public/browser/navigation_controller.h" |
| 47 #include "content/public/browser/navigation_entry.h" | 46 #include "content/public/browser/navigation_entry.h" |
| 48 #include "content/public/browser/render_view_host.h" | 47 #include "content/public/browser/render_view_host.h" |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 if (!GetStickySettings()->save_path()) { | 828 if (!GetStickySettings()->save_path()) { |
| 830 // Allowing IO operation temporarily. It is ok to do so here because | 829 // Allowing IO operation temporarily. It is ok to do so here because |
| 831 // the select file dialog performs IO anyway in order to display the | 830 // the select file dialog performs IO anyway in order to display the |
| 832 // folders and also it is modal. | 831 // folders and also it is modal. |
| 833 base::ThreadRestrictions::ScopedAllowIO allow_io; | 832 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 834 FilePath file_path; | 833 FilePath file_path; |
| 835 PathService::Get(chrome::DIR_USER_DOCUMENTS, &file_path); | 834 PathService::Get(chrome::DIR_USER_DOCUMENTS, &file_path); |
| 836 GetStickySettings()->StoreSavePath(file_path); | 835 GetStickySettings()->StoreSavePath(file_path); |
| 837 } | 836 } |
| 838 | 837 |
| 839 select_file_dialog_ = SelectFileDialog::Create( | 838 if (!select_file_dialog_.get()) |
| 840 this, new ChromeSelectFilePolicy(preview_web_contents())), | 839 select_file_dialog_ = SelectFileDialog::Create(this); |
| 840 |
| 841 select_file_dialog_->SelectFile( | 841 select_file_dialog_->SelectFile( |
| 842 SelectFileDialog::SELECT_SAVEAS_FILE, | 842 SelectFileDialog::SELECT_SAVEAS_FILE, |
| 843 string16(), | 843 string16(), |
| 844 GetStickySettings()->save_path()->Append(default_filename), | 844 GetStickySettings()->save_path()->Append(default_filename), |
| 845 &file_type_info, | 845 &file_type_info, |
| 846 0, | 846 0, |
| 847 FILE_PATH_LITERAL(""), | 847 FILE_PATH_LITERAL(""), |
| 848 preview_web_contents(), |
| 848 platform_util::GetTopLevel(preview_web_contents()->GetNativeView()), | 849 platform_util::GetTopLevel(preview_web_contents()->GetNativeView()), |
| 849 NULL); | 850 NULL); |
| 850 } | 851 } |
| 851 | 852 |
| 852 void PrintPreviewHandler::OnTabDestroyed() { | 853 void PrintPreviewHandler::OnTabDestroyed() { |
| 853 TabContents* initiator_tab = GetInitiatorTab(); | 854 TabContents* initiator_tab = GetInitiatorTab(); |
| 854 if (!initiator_tab) | 855 if (!initiator_tab) |
| 855 return; | 856 return; |
| 856 | 857 |
| 857 initiator_tab->print_view_manager()->set_observer(NULL); | 858 initiator_tab->print_view_manager()->set_observer(NULL); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 return; | 911 return; |
| 911 | 912 |
| 912 // We no longer require the initiator tab details. Remove those details | 913 // We no longer require the initiator tab details. Remove those details |
| 913 // associated with the preview tab to allow the initiator tab to create | 914 // associated with the preview tab to allow the initiator tab to create |
| 914 // another preview tab. | 915 // another preview tab. |
| 915 printing::PrintPreviewTabController* tab_controller = | 916 printing::PrintPreviewTabController* tab_controller = |
| 916 printing::PrintPreviewTabController::GetInstance(); | 917 printing::PrintPreviewTabController::GetInstance(); |
| 917 if (tab_controller) | 918 if (tab_controller) |
| 918 tab_controller->EraseInitiatorTabInfo(preview_tab_contents()); | 919 tab_controller->EraseInitiatorTabInfo(preview_tab_contents()); |
| 919 } | 920 } |
| OLD | NEW |