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/printing/print_preview_tab_controller.h" | 5 #include "chrome/browser/printing/print_preview_tab_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "chrome/common/chrome_content_client.h" | 30 #include "chrome/common/chrome_content_client.h" |
31 #include "chrome/common/chrome_notification_types.h" | 31 #include "chrome/common/chrome_notification_types.h" |
32 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
33 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
34 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
35 #include "content/public/browser/navigation_controller.h" | 35 #include "content/public/browser/navigation_controller.h" |
36 #include "content/public/browser/navigation_details.h" | 36 #include "content/public/browser/navigation_details.h" |
37 #include "content/public/browser/navigation_entry.h" | 37 #include "content/public/browser/navigation_entry.h" |
38 #include "content/public/browser/notification_details.h" | 38 #include "content/public/browser/notification_details.h" |
39 #include "content/public/browser/notification_source.h" | 39 #include "content/public/browser/notification_source.h" |
40 #include "content/public/browser/plugin_service.h" | |
41 #include "content/public/browser/render_process_host.h" | 40 #include "content/public/browser/render_process_host.h" |
42 #include "content/public/browser/render_view_host.h" | 41 #include "content/public/browser/render_view_host.h" |
43 #include "content/public/browser/web_contents.h" | 42 #include "content/public/browser/web_contents.h" |
44 #include "content/public/browser/web_contents_delegate.h" | 43 #include "content/public/browser/web_contents_delegate.h" |
45 #include "ui/web_dialogs/web_dialog_delegate.h" | 44 #include "ui/web_dialogs/web_dialog_delegate.h" |
46 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" | 45 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" |
47 #include "webkit/plugins/webplugininfo.h" | 46 #include "webkit/plugins/webplugininfo.h" |
48 | 47 |
49 using content::NativeWebKeyboardEvent; | 48 using content::NativeWebKeyboardEvent; |
50 using content::NavigationController; | 49 using content::NavigationController; |
51 using content::WebContents; | 50 using content::WebContents; |
52 using content::WebUIMessageHandler; | 51 using content::WebUIMessageHandler; |
53 using ui::WebDialogDelegate; | 52 using ui::WebDialogDelegate; |
54 using ui::WebDialogWebContentsDelegate; | 53 using ui::WebDialogWebContentsDelegate; |
55 | 54 |
56 namespace { | 55 namespace { |
57 | 56 |
58 void EnableInternalPDFPluginForTab(TabContents* preview_tab) { | 57 void EnableInternalPDFPluginForTab(TabContents* preview_tab) { |
59 // Always enable the internal PDF plugin for the print preview page. | 58 // Always enable the internal PDF plugin for the print preview page. |
60 FilePath pdf_plugin_path; | |
61 if (!PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_plugin_path)) | |
62 return; | |
63 | |
64 webkit::WebPluginInfo pdf_plugin; | 59 webkit::WebPluginInfo pdf_plugin; |
65 if (!content::PluginService::GetInstance()->GetPluginInfoByPath( | 60 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_plugin.path); |
66 pdf_plugin_path, &pdf_plugin)) { | |
67 return; | |
68 } | |
69 | 61 |
70 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( | 62 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( |
71 preview_tab->web_contents()->GetRenderProcessHost()->GetID(), | 63 preview_tab->web_contents()->GetRenderProcessHost()->GetID(), |
72 preview_tab->web_contents()->GetRenderViewHost()->GetRoutingID(), | 64 preview_tab->web_contents()->GetRenderViewHost()->GetRoutingID(), |
73 GURL(), pdf_plugin); | 65 GURL(), pdf_plugin); |
74 } | 66 } |
75 | 67 |
76 // WebDialogDelegate that specifies what the print preview dialog | 68 // WebDialogDelegate that specifies what the print preview dialog |
77 // will look like. | 69 // will look like. |
78 class PrintPreviewTabDelegate : public WebDialogDelegate { | 70 class PrintPreviewTabDelegate : public WebDialogDelegate { |
79 public: | 71 public: |
80 explicit PrintPreviewTabDelegate(TabContents* initiator_tab); | 72 explicit PrintPreviewTabDelegate(TabContents* initiator_tab); |
81 virtual ~PrintPreviewTabDelegate(); | 73 virtual ~PrintPreviewTabDelegate(); |
82 | 74 |
83 virtual ui::ModalType GetDialogModalType() const OVERRIDE; | 75 virtual ui::ModalType GetDialogModalType() const OVERRIDE; |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( | 536 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( |
545 preview_tab->web_contents()->GetWebUI()->GetController()); | 537 preview_tab->web_contents()->GetWebUI()->GetController()); |
546 if (print_preview_ui) | 538 if (print_preview_ui) |
547 print_preview_ui->OnTabDestroyed(); | 539 print_preview_ui->OnTabDestroyed(); |
548 | 540 |
549 preview_tab_map_.erase(preview_tab); | 541 preview_tab_map_.erase(preview_tab); |
550 RemoveObservers(preview_tab); | 542 RemoveObservers(preview_tab); |
551 } | 543 } |
552 | 544 |
553 } // namespace printing | 545 } // namespace printing |
OLD | NEW |