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 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 if (!tab_controller) | 834 if (!tab_controller) |
835 return NULL; | 835 return NULL; |
836 return tab_controller->GetInitiatorTab(preview_tab_contents()); | 836 return tab_controller->GetInitiatorTab(preview_tab_contents()); |
837 } | 837 } |
838 | 838 |
839 void PrintPreviewHandler::OnPrintDialogShown() { | 839 void PrintPreviewHandler::OnPrintDialogShown() { |
840 ActivateInitiatorTabAndClosePreviewTab(); | 840 ActivateInitiatorTabAndClosePreviewTab(); |
841 } | 841 } |
842 | 842 |
843 void PrintPreviewHandler::SelectFile(const FilePath& default_filename) { | 843 void PrintPreviewHandler::SelectFile(const FilePath& default_filename) { |
844 SelectFileDialog::FileTypeInfo file_type_info; | 844 ui::SelectFileDialog::FileTypeInfo file_type_info; |
845 file_type_info.extensions.resize(1); | 845 file_type_info.extensions.resize(1); |
846 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("pdf")); | 846 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("pdf")); |
847 | 847 |
848 // Initializing save_path_ if it is not already initialized. | 848 // Initializing save_path_ if it is not already initialized. |
849 if (!GetStickySettings()->save_path()) { | 849 if (!GetStickySettings()->save_path()) { |
850 // Allowing IO operation temporarily. It is ok to do so here because | 850 // Allowing IO operation temporarily. It is ok to do so here because |
851 // the select file dialog performs IO anyway in order to display the | 851 // the select file dialog performs IO anyway in order to display the |
852 // folders and also it is modal. | 852 // folders and also it is modal. |
853 base::ThreadRestrictions::ScopedAllowIO allow_io; | 853 base::ThreadRestrictions::ScopedAllowIO allow_io; |
854 FilePath file_path; | 854 FilePath file_path; |
855 PathService::Get(chrome::DIR_USER_DOCUMENTS, &file_path); | 855 PathService::Get(chrome::DIR_USER_DOCUMENTS, &file_path); |
856 GetStickySettings()->StoreSavePath(file_path); | 856 GetStickySettings()->StoreSavePath(file_path); |
857 } | 857 } |
858 | 858 |
859 select_file_dialog_ = SelectFileDialog::Create( | 859 select_file_dialog_ = ui::SelectFileDialog::Create( |
860 this, new ChromeSelectFilePolicy(preview_web_contents())), | 860 this, new ChromeSelectFilePolicy(preview_web_contents())), |
861 select_file_dialog_->SelectFile( | 861 select_file_dialog_->SelectFile( |
862 SelectFileDialog::SELECT_SAVEAS_FILE, | 862 ui::SelectFileDialog::SELECT_SAVEAS_FILE, |
863 string16(), | 863 string16(), |
864 GetStickySettings()->save_path()->Append(default_filename), | 864 GetStickySettings()->save_path()->Append(default_filename), |
865 &file_type_info, | 865 &file_type_info, |
866 0, | 866 0, |
867 FILE_PATH_LITERAL(""), | 867 FILE_PATH_LITERAL(""), |
868 platform_util::GetTopLevel(preview_web_contents()->GetNativeView()), | 868 platform_util::GetTopLevel(preview_web_contents()->GetNativeView()), |
869 NULL); | 869 NULL); |
870 } | 870 } |
871 | 871 |
872 void PrintPreviewHandler::OnTabDestroyed() { | 872 void PrintPreviewHandler::OnTabDestroyed() { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 return; | 930 return; |
931 | 931 |
932 // We no longer require the initiator tab details. Remove those details | 932 // We no longer require the initiator tab details. Remove those details |
933 // associated with the preview tab to allow the initiator tab to create | 933 // associated with the preview tab to allow the initiator tab to create |
934 // another preview tab. | 934 // another preview tab. |
935 printing::PrintPreviewTabController* tab_controller = | 935 printing::PrintPreviewTabController* tab_controller = |
936 printing::PrintPreviewTabController::GetInstance(); | 936 printing::PrintPreviewTabController::GetInstance(); |
937 if (tab_controller) | 937 if (tab_controller) |
938 tab_controller->EraseInitiatorTabInfo(preview_tab_contents()); | 938 tab_controller->EraseInitiatorTabInfo(preview_tab_contents()); |
939 } | 939 } |
OLD | NEW |