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 28 matching lines...) Expand all Loading... |
39 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 39 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
40 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" | 40 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" |
41 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h" | 41 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h" |
42 #include "chrome/common/chrome_paths.h" | 42 #include "chrome/common/chrome_paths.h" |
43 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
44 #include "chrome/common/print_messages.h" | 44 #include "chrome/common/print_messages.h" |
45 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
46 #include "content/public/browser/navigation_controller.h" | 46 #include "content/public/browser/navigation_controller.h" |
47 #include "content/public/browser/navigation_entry.h" | 47 #include "content/public/browser/navigation_entry.h" |
48 #include "content/public/browser/render_view_host.h" | 48 #include "content/public/browser/render_view_host.h" |
49 #include "content/public/browser/render_view_host_delegate.h" | |
50 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
| 50 #include "content/public/browser/web_contents_delegate.h" |
51 #include "content/public/browser/web_ui.h" | 51 #include "content/public/browser/web_ui.h" |
52 #include "printing/backend/print_backend.h" | 52 #include "printing/backend/print_backend.h" |
53 #include "printing/metafile.h" | 53 #include "printing/metafile.h" |
54 #include "printing/metafile_impl.h" | 54 #include "printing/metafile_impl.h" |
55 #include "printing/page_range.h" | 55 #include "printing/page_range.h" |
56 #include "printing/page_size_margins.h" | 56 #include "printing/page_size_margins.h" |
57 #include "printing/print_settings.h" | 57 #include "printing/print_settings.h" |
58 #include "unicode/ulocdata.h" | 58 #include "unicode/ulocdata.h" |
59 | 59 |
60 #if !defined(OS_MACOSX) | 60 #if !defined(OS_MACOSX) |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 | 700 |
701 if (print_preview_ui->source_is_modifiable()) { | 701 if (print_preview_ui->source_is_modifiable()) { |
702 GetStickySettings()->GetLastUsedMarginSettings(&initial_settings); | 702 GetStickySettings()->GetLastUsedMarginSettings(&initial_settings); |
703 GetNumberFormatAndMeasurementSystem(&initial_settings); | 703 GetNumberFormatAndMeasurementSystem(&initial_settings); |
704 } | 704 } |
705 web_ui()->CallJavascriptFunction("setInitialSettings", initial_settings); | 705 web_ui()->CallJavascriptFunction("setInitialSettings", initial_settings); |
706 } | 706 } |
707 | 707 |
708 void PrintPreviewHandler::ActivateInitiatorTabAndClosePreviewTab() { | 708 void PrintPreviewHandler::ActivateInitiatorTabAndClosePreviewTab() { |
709 TabContentsWrapper* initiator_tab = GetInitiatorTab(); | 709 TabContentsWrapper* initiator_tab = GetInitiatorTab(); |
710 if (initiator_tab) | 710 if (initiator_tab) { |
711 initiator_tab->web_contents()->GetRenderViewHost()-> | 711 WebContents* web_contents = initiator_tab->web_contents(); |
712 GetDelegate()->Activate(); | 712 web_contents->GetDelegate()->ActivateContents(web_contents); |
| 713 } |
713 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( | 714 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( |
714 web_ui()->GetController()); | 715 web_ui()->GetController()); |
715 print_preview_ui->OnClosePrintPreviewTab(); | 716 print_preview_ui->OnClosePrintPreviewTab(); |
716 } | 717 } |
717 | 718 |
718 void PrintPreviewHandler::SendPrinterCapabilities( | 719 void PrintPreviewHandler::SendPrinterCapabilities( |
719 const DictionaryValue& settings_info) { | 720 const DictionaryValue& settings_info) { |
720 VLOG(1) << "Get printer capabilities finished"; | 721 VLOG(1) << "Get printer capabilities finished"; |
721 web_ui()->CallJavascriptFunction("updateWithPrinterCapabilities", | 722 web_ui()->CallJavascriptFunction("updateWithPrinterCapabilities", |
722 settings_info); | 723 settings_info); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 return; | 905 return; |
905 | 906 |
906 // We no longer require the initiator tab details. Remove those details | 907 // We no longer require the initiator tab details. Remove those details |
907 // associated with the preview tab to allow the initiator tab to create | 908 // associated with the preview tab to allow the initiator tab to create |
908 // another preview tab. | 909 // another preview tab. |
909 printing::PrintPreviewTabController* tab_controller = | 910 printing::PrintPreviewTabController* tab_controller = |
910 printing::PrintPreviewTabController::GetInstance(); | 911 printing::PrintPreviewTabController::GetInstance(); |
911 if (tab_controller) | 912 if (tab_controller) |
912 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); | 913 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); |
913 } | 914 } |
OLD | NEW |