Chromium Code Reviews| 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 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_plugin_path); | |
|
Lei Zhang
2012/11/12 21:27:52
We should probably return if this fails. Not sure
Bernhard Bauer
2012/11/13 18:06:38
Done.
| |
| 59 webkit::WebPluginInfo pdf_plugin; | 62 webkit::WebPluginInfo pdf_plugin; |
| 60 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_plugin.path); | 63 if (!content::PluginService::GetInstance()->GetPluginInfoByPath( |
| 64 pdf_plugin_path, &pdf_plugin)) { | |
| 65 return; | |
| 66 } | |
| 61 | 67 |
| 62 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( | 68 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( |
| 63 preview_tab->web_contents()->GetRenderProcessHost()->GetID(), | 69 preview_tab->web_contents()->GetRenderProcessHost()->GetID(), |
| 64 preview_tab->web_contents()->GetRenderViewHost()->GetRoutingID(), | 70 preview_tab->web_contents()->GetRenderViewHost()->GetRoutingID(), |
| 65 GURL(), pdf_plugin); | 71 GURL(), pdf_plugin); |
| 66 } | 72 } |
| 67 | 73 |
| 68 // WebDialogDelegate that specifies what the print preview dialog | 74 // WebDialogDelegate that specifies what the print preview dialog |
| 69 // will look like. | 75 // will look like. |
| 70 class PrintPreviewTabDelegate : public WebDialogDelegate { | 76 class PrintPreviewTabDelegate : public WebDialogDelegate { |
| 71 public: | 77 public: |
| 72 explicit PrintPreviewTabDelegate(TabContents* initiator_tab); | 78 explicit PrintPreviewTabDelegate(TabContents* initiator_tab); |
| 73 virtual ~PrintPreviewTabDelegate(); | 79 virtual ~PrintPreviewTabDelegate(); |
| 74 | 80 |
| 75 virtual ui::ModalType GetDialogModalType() const OVERRIDE; | 81 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*>( | 542 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( |
| 537 preview_tab->web_contents()->GetWebUI()->GetController()); | 543 preview_tab->web_contents()->GetWebUI()->GetController()); |
| 538 if (print_preview_ui) | 544 if (print_preview_ui) |
| 539 print_preview_ui->OnTabDestroyed(); | 545 print_preview_ui->OnTabDestroyed(); |
| 540 | 546 |
| 541 preview_tab_map_.erase(preview_tab); | 547 preview_tab_map_.erase(preview_tab); |
| 542 RemoveObservers(preview_tab); | 548 RemoveObservers(preview_tab); |
| 543 } | 549 } |
| 544 | 550 |
| 545 } // namespace printing | 551 } // namespace printing |
| OLD | NEW |