| 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/pdf_unsupported_feature.h" | 5 #include "chrome/browser/pdf_unsupported_feature.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "base/version.h" | 9 #include "base/version.h" |
| 10 #include "chrome/browser/infobars/infobar_tab_helper.h" | 10 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 11 #include "chrome/browser/plugin_prefs.h" | 11 #include "chrome/browser/plugin_prefs.h" |
| 12 #include "chrome/browser/chrome_plugin_service_filter.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/tab_contents/chrome_interstitial_page.h" | 15 #include "chrome/browser/tab_contents/chrome_interstitial_page.h" |
| 15 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 16 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 17 #include "chrome/common/chrome_content_client.h" | 18 #include "chrome/common/chrome_content_client.h" |
| 18 #include "chrome/common/jstemplate_builder.h" | 19 #include "chrome/common/jstemplate_builder.h" |
| 19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 20 #include "content/browser/plugin_service.h" | 21 #include "content/browser/plugin_service.h" |
| 21 #include "content/browser/renderer_host/render_process_host.h" | 22 #include "content/browser/renderer_host/render_process_host.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 void OpenReaderUpdateURL(TabContents* tab) { | 132 void OpenReaderUpdateURL(TabContents* tab) { |
| 132 tab->OpenURL(GURL(kReaderUpdateUrl), GURL(), CURRENT_TAB, | 133 tab->OpenURL(GURL(kReaderUpdateUrl), GURL(), CURRENT_TAB, |
| 133 PageTransition::LINK); | 134 PageTransition::LINK); |
| 134 } | 135 } |
| 135 | 136 |
| 136 // Opens the PDF using Adobe Reader. | 137 // Opens the PDF using Adobe Reader. |
| 137 void OpenUsingReader(TabContentsWrapper* tab, | 138 void OpenUsingReader(TabContentsWrapper* tab, |
| 138 const WebPluginInfo& reader_plugin, | 139 const WebPluginInfo& reader_plugin, |
| 139 InfoBarDelegate* old_delegate, | 140 InfoBarDelegate* old_delegate, |
| 140 InfoBarDelegate* new_delegate) { | 141 InfoBarDelegate* new_delegate) { |
| 141 PluginService::OverriddenPlugin plugin; | 142 WebPluginInfo plugin = reader_plugin; |
| 142 plugin.render_process_id = tab->render_view_host()->process()->id(); | |
| 143 plugin.render_view_id = tab->render_view_host()->routing_id(); | |
| 144 plugin.url = tab->tab_contents()->GetURL(); | |
| 145 plugin.plugin = reader_plugin; | |
| 146 // The plugin is disabled, so enable it to get around the renderer check. | 143 // The plugin is disabled, so enable it to get around the renderer check. |
| 147 // Also give it a new version so that the renderer doesn't show the blocked | 144 // Also give it a new version so that the renderer doesn't show the blocked |
| 148 // plugin UI if it's vulnerable, since we already went through the | 145 // plugin UI if it's vulnerable, since we already went through the |
| 149 // interstitial. | 146 // interstitial. |
| 150 plugin.plugin.enabled = WebPluginInfo::USER_ENABLED; | 147 plugin.enabled = WebPluginInfo::USER_ENABLED; |
| 151 plugin.plugin.version = ASCIIToUTF16("11.0.0.0"); | 148 plugin.version = ASCIIToUTF16("11.0.0.0"); |
| 152 | 149 |
| 153 PluginService::GetInstance()->OverridePluginForTab(plugin); | 150 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( |
| 151 tab->render_view_host()->process()->id(), |
| 152 tab->render_view_host()->routing_id(), |
| 153 tab->tab_contents()->GetURL(), |
| 154 plugin); |
| 154 tab->render_view_host()->Send(new ViewMsg_ReloadFrame( | 155 tab->render_view_host()->Send(new ViewMsg_ReloadFrame( |
| 155 tab->render_view_host()->routing_id())); | 156 tab->render_view_host()->routing_id())); |
| 156 | 157 |
| 157 if (new_delegate) { | 158 if (new_delegate) { |
| 158 if (old_delegate) { | 159 if (old_delegate) { |
| 159 tab->infobar_tab_helper()->ReplaceInfoBar(old_delegate, new_delegate); | 160 tab->infobar_tab_helper()->ReplaceInfoBar(old_delegate, new_delegate); |
| 160 } else { | 161 } else { |
| 161 tab->infobar_tab_helper()->AddInfoBar(new_delegate); | 162 tab->infobar_tab_helper()->AddInfoBar(new_delegate); |
| 162 } | 163 } |
| 163 } | 164 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 return; | 372 return; |
| 372 #endif | 373 #endif |
| 373 string16 reader_group_name(ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName)); | 374 string16 reader_group_name(ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName)); |
| 374 | 375 |
| 375 // If the Reader plugin is disabled by policy, don't prompt them. | 376 // If the Reader plugin is disabled by policy, don't prompt them. |
| 376 if (PluginGroup::IsPluginNameDisabledByPolicy(reader_group_name)) | 377 if (PluginGroup::IsPluginNameDisabledByPolicy(reader_group_name)) |
| 377 return; | 378 return; |
| 378 | 379 |
| 379 PluginGroup* reader_group = NULL; | 380 PluginGroup* reader_group = NULL; |
| 380 std::vector<PluginGroup> plugin_groups; | 381 std::vector<PluginGroup> plugin_groups; |
| 381 PluginList::Singleton()->GetPluginGroups( | 382 PluginList::Singleton()->GetPluginGroups(false, &plugin_groups); |
| 382 false, &plugin_groups); | |
| 383 for (size_t i = 0; i < plugin_groups.size(); ++i) { | 383 for (size_t i = 0; i < plugin_groups.size(); ++i) { |
| 384 if (plugin_groups[i].GetGroupName() == reader_group_name) { | 384 if (plugin_groups[i].GetGroupName() == reader_group_name) { |
| 385 reader_group = &plugin_groups[i]; | 385 reader_group = &plugin_groups[i]; |
| 386 break; | 386 break; |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 tab->infobar_tab_helper()->AddInfoBar( | 390 tab->infobar_tab_helper()->AddInfoBar( |
| 391 new PDFUnsupportedFeatureInfoBarDelegate(tab, reader_group)); | 391 new PDFUnsupportedFeatureInfoBarDelegate(tab, reader_group)); |
| 392 } | 392 } |
| OLD | NEW |