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