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