Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6713)

Unified Diff: chrome/browser/pdf_unsupported_feature.cc

Issue 7980011: Convert the PluginService interface to be an async wrapper around PluginList. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert to PS3 and rebase Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/pdf_unsupported_feature.cc
diff --git a/chrome/browser/pdf_unsupported_feature.cc b/chrome/browser/pdf_unsupported_feature.cc
index d69d8a0dfa1d4de1aa3ed30c19482e1307c75841..7f5e43a8b0e43fc41cd97af171a0c91c2914790f 100644
--- a/chrome/browser/pdf_unsupported_feature.cc
+++ b/chrome/browser/pdf_unsupported_feature.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/pdf_unsupported_feature.h"
+#include "base/bind.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "base/version.h"
@@ -30,11 +31,8 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
#include "webkit/plugins/npapi/plugin_group.h"
-#include "webkit/plugins/npapi/plugin_list.h"
-#include "webkit/plugins/webplugininfo.h"
using webkit::npapi::PluginGroup;
-using webkit::npapi::PluginList;
using webkit::WebPluginInfo;
namespace {
@@ -236,7 +234,7 @@ class PDFUnsupportedFeatureInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
// |reader_group| is NULL if Adobe Reader isn't installed.
PDFUnsupportedFeatureInfoBarDelegate(TabContentsWrapper* tab_contents,
- PluginGroup* reader_group);
+ const PluginGroup* reader_group);
virtual ~PDFUnsupportedFeatureInfoBarDelegate();
// ConfirmInfoBarDelegate
@@ -262,7 +260,7 @@ class PDFUnsupportedFeatureInfoBarDelegate : public ConfirmInfoBarDelegate {
PDFUnsupportedFeatureInfoBarDelegate::PDFUnsupportedFeatureInfoBarDelegate(
TabContentsWrapper* tab_contents,
- PluginGroup* reader_group)
+ const PluginGroup* reader_group)
: ConfirmInfoBarDelegate(tab_contents->tab_contents()),
tab_contents_(tab_contents),
reader_installed_(!!reader_group),
@@ -362,14 +360,8 @@ void PDFUnsupportedFeatureInfoBarDelegate::OnNo() {
UserMetricsAction("PDF_InstallReaderInfoBarCancel"));
}
-} // namespace
-
-void PDFHasUnsupportedFeature(TabContentsWrapper* tab) {
-#if !defined(OS_WIN)
- // Only works for Windows for now. For Mac, we'll have to launch the file
- // externally since Adobe Reader doesn't work inside Chrome.
- return;
-#endif
+void GotPluginGroupsCallback(TabContentsWrapper* tab,
+ const std::vector<PluginGroup>& groups) {
string16 reader_group_name(ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName));
// If the Reader plugin is disabled by policy, don't prompt them.
@@ -379,12 +371,10 @@ void PDFHasUnsupportedFeature(TabContentsWrapper* tab) {
return;
}
- PluginGroup* reader_group = NULL;
- std::vector<PluginGroup> plugin_groups;
- PluginList::Singleton()->GetPluginGroups(false, &plugin_groups);
- for (size_t i = 0; i < plugin_groups.size(); ++i) {
- if (plugin_groups[i].GetGroupName() == reader_group_name) {
- reader_group = &plugin_groups[i];
+ const PluginGroup* reader_group = NULL;
+ for (size_t i = 0; i < groups.size(); ++i) {
+ if (groups[i].GetGroupName() == reader_group_name) {
+ reader_group = &groups[i];
break;
}
}
@@ -392,3 +382,16 @@ void PDFHasUnsupportedFeature(TabContentsWrapper* tab) {
tab->infobar_tab_helper()->AddInfoBar(
new PDFUnsupportedFeatureInfoBarDelegate(tab, reader_group));
}
+
+} // namespace
+
+void PDFHasUnsupportedFeature(TabContentsWrapper* tab) {
+#if !defined(OS_WIN)
+ // Only works for Windows for now. For Mac, we'll have to launch the file
+ // externally since Adobe Reader doesn't work inside Chrome.
+ return;
+#endif
+
+ PluginService::GetInstance()->GetPluginGroups(
+ base::Bind(&GotPluginGroupsCallback, tab));
jam 2011/09/22 21:10:59 the TabContentsWrapper might not be around when th
Robert Sesek 2011/09/22 23:26:51 Done. Thanks for the detailed how-to :-).
+}

Powered by Google App Engine
This is Rietveld 408576698