| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/ui/webui/print_preview_ui.h" | 21 #include "chrome/browser/ui/webui/print_preview_ui.h" |
| 22 #include "chrome/common/chrome_content_client.h" | 22 #include "chrome/common/chrome_content_client.h" |
| 23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 25 #include "content/browser/renderer_host/render_view_host.h" | 25 #include "content/browser/renderer_host/render_view_host.h" |
| 26 #include "content/browser/tab_contents/navigation_details.h" | 26 #include "content/browser/tab_contents/navigation_details.h" |
| 27 #include "content/browser/tab_contents/tab_contents.h" | 27 #include "content/browser/tab_contents/tab_contents.h" |
| 28 #include "content/common/content_notification_types.h" | 28 #include "content/common/content_notification_types.h" |
| 29 #include "content/common/notification_details.h" | 29 #include "content/common/notification_details.h" |
| 30 #include "content/common/notification_source.h" | 30 #include "content/common/notification_source.h" |
| 31 #include "webkit/plugins/npapi/plugin_group.h" | |
| 32 #include "webkit/plugins/npapi/plugin_list.h" | |
| 33 #include "webkit/plugins/webplugininfo.h" | 31 #include "webkit/plugins/webplugininfo.h" |
| 34 | 32 |
| 35 using webkit::npapi::PluginGroup; | |
| 36 using webkit::npapi::PluginList; | |
| 37 using webkit::WebPluginInfo; | |
| 38 | |
| 39 namespace { | 33 namespace { |
| 40 | 34 |
| 41 void EnableInternalPDFPluginForTab(TabContentsWrapper* preview_tab) { | 35 void EnableInternalPDFPluginForTab(TabContentsWrapper* preview_tab) { |
| 42 // Always enable the internal PDF plugin for the print preview page. | 36 // Always enable the internal PDF plugin for the print preview page. |
| 43 string16 internal_pdf_group_name( | 37 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( |
| 44 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); | |
| 45 PluginGroup* internal_pdf_group = NULL; | |
| 46 std::vector<PluginGroup> plugin_groups; | |
| 47 PluginList::Singleton()->GetPluginGroups(false, &plugin_groups); | |
| 48 for (size_t i = 0; i < plugin_groups.size(); ++i) { | |
| 49 if (plugin_groups[i].GetGroupName() == internal_pdf_group_name) { | |
| 50 internal_pdf_group = &plugin_groups[i]; | |
| 51 break; | |
| 52 } | |
| 53 } | |
| 54 if (internal_pdf_group) { | |
| 55 const std::vector<WebPluginInfo>& plugins = | |
| 56 internal_pdf_group->web_plugin_infos(); | |
| 57 DCHECK_EQ(plugins.size(), 1U); | |
| 58 | |
| 59 webkit::WebPluginInfo plugin = plugins[0]; | |
| 60 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( | |
| 61 preview_tab->render_view_host()->process()->id(), | 38 preview_tab->render_view_host()->process()->id(), |
| 62 preview_tab->render_view_host()->routing_id(), | 39 preview_tab->render_view_host()->routing_id(), |
| 63 GURL(), | 40 GURL(), |
| 64 plugin); | 41 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); |
| 65 } | |
| 66 } | 42 } |
| 67 | 43 |
| 68 void ResetPreviewTabOverrideTitle(TabContentsWrapper* preview_tab) { | 44 void ResetPreviewTabOverrideTitle(TabContentsWrapper* preview_tab) { |
| 69 preview_tab->print_view_manager()->ResetTitleOverride(); | 45 preview_tab->print_view_manager()->ResetTitleOverride(); |
| 70 } | 46 } |
| 71 | 47 |
| 72 } // namespace | 48 } // namespace |
| 73 | 49 |
| 74 namespace printing { | 50 namespace printing { |
| 75 | 51 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 RenderProcessHost* rph = tab->render_view_host()->process(); | 365 RenderProcessHost* rph = tab->render_view_host()->process(); |
| 390 if (registrar_.IsRegistered(this, | 366 if (registrar_.IsRegistered(this, |
| 391 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 367 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 392 Source<RenderProcessHost>(rph))) { | 368 Source<RenderProcessHost>(rph))) { |
| 393 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 369 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 394 Source<RenderProcessHost>(rph)); | 370 Source<RenderProcessHost>(rph)); |
| 395 } | 371 } |
| 396 } | 372 } |
| 397 | 373 |
| 398 } // namespace printing | 374 } // namespace printing |
| OLD | NEW |