| 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/ui/pdf/pdf_unsupported_feature.h" | 5 #include "chrome/browser/ui/pdf/pdf_unsupported_feature.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "base/version.h" | 10 #include "base/version.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 OpenUsingReader(tab_contents_, reader_webplugininfo_, NULL, NULL); | 378 OpenUsingReader(tab_contents_, reader_webplugininfo_, NULL, NULL); |
| 379 return true; | 379 return true; |
| 380 } | 380 } |
| 381 | 381 |
| 382 void PDFUnsupportedFeatureInfoBarDelegate::OnNo() { | 382 void PDFUnsupportedFeatureInfoBarDelegate::OnNo() { |
| 383 content::RecordAction(reader_installed_ ? | 383 content::RecordAction(reader_installed_ ? |
| 384 UserMetricsAction("PDF_UseReaderInfoBarCancel") : | 384 UserMetricsAction("PDF_UseReaderInfoBarCancel") : |
| 385 UserMetricsAction("PDF_InstallReaderInfoBarCancel")); | 385 UserMetricsAction("PDF_InstallReaderInfoBarCancel")); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void GotPluginGroupsCallback(int process_id, | 388 void GotPluginsCallback(int process_id, |
| 389 int routing_id, | 389 int routing_id, |
| 390 PluginFinder* plugin_finder, | 390 PluginFinder* plugin_finder, |
| 391 const std::vector<PluginGroup>& groups) { | 391 const std::vector<webkit::WebPluginInfo>& plugins) { |
| 392 WebContents* web_contents = | 392 WebContents* web_contents = |
| 393 tab_util::GetWebContentsByID(process_id, routing_id); | 393 tab_util::GetWebContentsByID(process_id, routing_id); |
| 394 if (!web_contents) | 394 if (!web_contents) |
| 395 return; | 395 return; |
| 396 | 396 |
| 397 TabContents* tab = TabContents::FromWebContents(web_contents); | 397 TabContents* tab = TabContents::FromWebContents(web_contents); |
| 398 if (!tab) | 398 if (!tab) |
| 399 return; | 399 return; |
| 400 | 400 |
| 401 string16 reader_group_name(ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName)); | 401 string16 reader_group_name(ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName)); |
| 402 // If the Reader plugin is disabled by policy, don't prompt them. | 402 // If the Reader plugin is disabled by policy, don't prompt them. |
| 403 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(tab->profile()); | 403 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(tab->profile()); |
| 404 if (plugin_prefs->PolicyStatusForPlugin(reader_group_name) == | 404 if (plugin_prefs->PolicyStatusForPlugin(reader_group_name) == |
| 405 PluginPrefs::POLICY_DISABLED) { | 405 PluginPrefs::POLICY_DISABLED) { |
| 406 return; | 406 return; |
| 407 } | 407 } |
| 408 | 408 |
| 409 const webkit::WebPluginInfo* reader = NULL; | 409 const webkit::WebPluginInfo* reader = NULL; |
| 410 for (size_t i = 0; i < groups.size(); ++i) { | 410 for (size_t i = 0; i < plugins.size(); ++i) { |
| 411 if (groups[i].GetGroupName() == reader_group_name) { | 411 PluginInstaller* installer = plugin_finder->GetPluginInstaller(plugins[i]); |
| 412 const std::vector<WebPluginInfo>& plugins = | 412 if (reader_group_name == installer->name()) { |
| 413 groups[i].web_plugin_infos(); | 413 DCHECK(!reader); |
| 414 DCHECK_EQ(plugins.size(), 1u); | 414 reader = &plugins[i]; |
| 415 reader = &plugins[0]; | |
| 416 break; | |
| 417 } | 415 } |
| 418 } | 416 } |
| 419 | 417 |
| 420 tab->infobar_tab_helper()->AddInfoBar( | 418 tab->infobar_tab_helper()->AddInfoBar( |
| 421 new PDFUnsupportedFeatureInfoBarDelegate(tab, reader, plugin_finder)); | 419 new PDFUnsupportedFeatureInfoBarDelegate(tab, reader, plugin_finder)); |
| 422 } | 420 } |
| 423 | 421 |
| 424 void GotPluginFinderCallback(int process_id, | 422 void GotPluginFinderCallback(int process_id, |
| 425 int routing_id, | 423 int routing_id, |
| 426 PluginFinder* plugin_finder) { | 424 PluginFinder* plugin_finder) { |
| 427 PluginService::GetInstance()->GetPluginGroups( | 425 PluginService::GetInstance()->GetPlugins( |
| 428 base::Bind(&GotPluginGroupsCallback, process_id, routing_id, | 426 base::Bind(&GotPluginsCallback, process_id, routing_id, |
| 429 base::Unretained(plugin_finder))); | 427 base::Unretained(plugin_finder))); |
| 430 } | 428 } |
| 431 | 429 |
| 432 } // namespace | 430 } // namespace |
| 433 | 431 |
| 434 void PDFHasUnsupportedFeature(TabContents* tab) { | 432 void PDFHasUnsupportedFeature(TabContents* tab) { |
| 435 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) | 433 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) |
| 436 // Only works for Windows for now. For Mac, we'll have to launch the file | 434 // Only works for Windows for now. For Mac, we'll have to launch the file |
| 437 // externally since Adobe Reader doesn't work inside Chrome. | 435 // externally since Adobe Reader doesn't work inside Chrome. |
| 438 PluginFinder::Get(base::Bind(&GotPluginFinderCallback, | 436 PluginFinder::Get(base::Bind(&GotPluginFinderCallback, |
| 439 tab->web_contents()->GetRenderProcessHost()->GetID(), | 437 tab->web_contents()->GetRenderProcessHost()->GetID(), |
| 440 tab->web_contents()->GetRenderViewHost()->GetRoutingID())); | 438 tab->web_contents()->GetRenderViewHost()->GetRoutingID())); |
| 441 #endif | 439 #endif |
| 442 } | 440 } |
| OLD | NEW |