diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-29 08:21:28 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-29 08:21:28 +0000 |
commit | 685980787980c7be0dd1f8b83900718c8e2634f2 (patch) | |
tree | 8d5e3d52426658543f7ac025f9cb44afd0b9c531 /chrome | |
parent | 02601778c9535f4b23c084794204d6ee2bd0fa86 (diff) | |
download | chromium_src-685980787980c7be0dd1f8b83900718c8e2634f2.zip chromium_src-685980787980c7be0dd1f8b83900718c8e2634f2.tar.gz chromium_src-685980787980c7be0dd1f8b83900718c8e2634f2.tar.bz2 |
PluginList cleanup to fix a race condition and decrease the API surface for future refactorings:
* Remove "webkit/glue/plugins/plugin_list.h" includes in favor of "webkit/npapi/plugins/plugin_list.h"
* Remove |refresh| parameter from |GetPlugins| in favor of calling |RefreshPlugins| beforehand.
* Remove |GetPluginInfo| in favor of calling |GetPluginInfoArray| and looking for the first enabled plug-in.
* Remove |GetEnabledPlugins| in favor of calling |GetPlugins| and filtering out disabled plugins.
* Remove |stale| in favor of an outparameter to |GetPluginInfoArray|, to remove the race condition.
BUG=69516,80794
TEST=none
Review URL: http://codereview.chromium.org/7497030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94641 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 2 | ||||
-rw-r--r-- | chrome/browser/browser_about_handler.cc | 4 | ||||
-rw-r--r-- | chrome/browser/chromeos/gview_request_interceptor.cc | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/gview_request_interceptor_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.cc | 2 | ||||
-rw-r--r-- | chrome/browser/plugin_data_remover.cc | 14 | ||||
-rw-r--r-- | chrome/browser/plugin_data_remover_helper.h | 2 | ||||
-rw-r--r-- | chrome/browser/plugin_updater.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm | 5 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/drag_util.mm | 14 | ||||
-rw-r--r-- | chrome/browser/ui/views/content_setting_bubble_contents.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/webui/flash_ui.cc | 4 |
12 files changed, 31 insertions, 27 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index bc65b84..d892388 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -3389,7 +3389,7 @@ void TestingAutomationProvider::GetPluginsInfo( return; } std::vector<webkit::npapi::WebPluginInfo> plugins; - webkit::npapi::PluginList::Singleton()->GetPlugins(false, &plugins); + webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); ListValue* items = new ListValue; for (std::vector<webkit::npapi::WebPluginInfo>::const_iterator it = plugins.begin(); diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index c8a266e..7515700 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -59,7 +59,7 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "webkit/glue/webkit_glue.h" -#include "webkit/glue/plugins/plugin_list.h" +#include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/npapi/webplugininfo.h" #ifdef CHROME_V8 @@ -1108,7 +1108,7 @@ std::string AboutVersionStrings(DictionaryValue* localized_strings, // Obtain the version of the first enabled Flash plugin. std::vector<webkit::npapi::WebPluginInfo> info_array; webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( - GURL(), "application/x-shockwave-flash", false, &info_array, NULL); + GURL(), "application/x-shockwave-flash", false, NULL, &info_array, NULL); string16 flash_version = l10n_util::GetStringUTF16(IDS_PLUGINS_DISABLED_PLUGIN); for (size_t i = 0; i < info_array.size(); ++i) { diff --git a/chrome/browser/chromeos/gview_request_interceptor.cc b/chrome/browser/chromeos/gview_request_interceptor.cc index fe98c15..6d176ec 100644 --- a/chrome/browser/chromeos/gview_request_interceptor.cc +++ b/chrome/browser/chromeos/gview_request_interceptor.cc @@ -6,6 +6,8 @@ #include "base/file_path.h" #include "base/path_service.h" +#include "chrome/browser/profiles/profile_io_data.h" +#include "chrome/browser/plugin_prefs.h" #include "chrome/common/chrome_paths.h" #include "googleurl/src/gurl.h" #include "net/base/escape.h" diff --git a/chrome/browser/chromeos/gview_request_interceptor_unittest.cc b/chrome/browser/chromeos/gview_request_interceptor_unittest.cc index f841bf5..5e573fe 100644 --- a/chrome/browser/chromeos/gview_request_interceptor_unittest.cc +++ b/chrome/browser/chromeos/gview_request_interceptor_unittest.cc @@ -15,7 +15,7 @@ #include "net/url_request/url_request_test_job.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webkit/glue/plugins/plugin_list.h" +#include "webkit/plugins/npapi/plugin_list.h" namespace chromeos { diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index b3039d7..a1f4c1a 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -341,7 +341,7 @@ class MetricsService::InitTask : public Task { virtual void Run() { std::vector<webkit::npapi::WebPluginInfo> plugins; - webkit::npapi::PluginList::Singleton()->GetPlugins(false, &plugins); + webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); std::string hardware_class; // Empty string by default. #if defined(OS_CHROMEOS) chromeos::system::StatisticsProvider::GetInstance()->GetMachineStatistic( diff --git a/chrome/browser/plugin_data_remover.cc b/chrome/browser/plugin_data_remover.cc index ac5a5cf..e17254e 100644 --- a/chrome/browser/plugin_data_remover.cc +++ b/chrome/browser/plugin_data_remover.cc @@ -168,20 +168,20 @@ void PluginDataRemover::SignalDone() { bool PluginDataRemover::IsSupported() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); bool allow_wildcard = false; - webkit::npapi::WebPluginInfo plugin; - std::string mime_type; - if (!webkit::npapi::PluginList::Singleton()->GetPluginInfo( - GURL(), kFlashMimeType, allow_wildcard, &plugin, &mime_type)) { + std::vector<webkit::npapi::WebPluginInfo> plugins; + webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( + GURL(), kFlashMimeType, allow_wildcard, NULL, &plugins, NULL); + std::vector<webkit::npapi::WebPluginInfo>::iterator plugin = plugins.begin(); + if (plugin == plugins.end()) return false; - } scoped_ptr<Version> version( - webkit::npapi::PluginGroup::CreateVersionFromString(plugin.version)); + webkit::npapi::PluginGroup::CreateVersionFromString(plugin->version)); scoped_ptr<Version> min_version(Version::GetVersionFromString( CommandLine::ForCurrentProcess()->GetSwitchValueASCII( switches::kMinClearSiteDataFlashVersion))); if (!min_version.get()) min_version.reset(Version::GetVersionFromString(kMinFlashVersion)); - return webkit::npapi::IsPluginEnabled(plugin) && + return webkit::npapi::IsPluginEnabled(*plugin) && version.get() && min_version->CompareTo(*version) == -1; } diff --git a/chrome/browser/plugin_data_remover_helper.h b/chrome/browser/plugin_data_remover_helper.h index dec4f41..7cd37af 100644 --- a/chrome/browser/plugin_data_remover_helper.h +++ b/chrome/browser/plugin_data_remover_helper.h @@ -25,7 +25,7 @@ class PluginDataRemoverHelper : public NotificationObserver { // Binds this object to the |pref_name| preference in |prefs|, notifying // |observer| if the value changes. - // This fires off a request to the NPAPI::PluginList (via PluginDataRemover) + // This fires off a request to the PluginList (via PluginDataRemover) // on the FILE thread to get the list of installed plug-ins. void Init(const char* pref_name, PrefService* prefs, diff --git a/chrome/browser/plugin_updater.cc b/chrome/browser/plugin_updater.cc index bd12749..887fba8 100644 --- a/chrome/browser/plugin_updater.cc +++ b/chrome/browser/plugin_updater.cc @@ -264,7 +264,7 @@ void PluginUpdater::UpdatePreferences(Profile* profile, int delay_ms) { void PluginUpdater::GetPreferencesDataOnFileThread(void* profile) { std::vector<webkit::npapi::WebPluginInfo> plugins; - webkit::npapi::PluginList::Singleton()->GetPlugins(false, &plugins); + webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); std::vector<webkit::npapi::PluginGroup> groups; webkit::npapi::PluginList::Singleton()->GetPluginGroups(false, &groups); diff --git a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm index b8975c5..32f2549 100644 --- a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm +++ b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm @@ -9,7 +9,6 @@ #include "base/sys_string_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/browser/plugin_updater.h" #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h" #import "chrome/browser/ui/cocoa/info_bubble_view.h" @@ -18,7 +17,7 @@ #include "skia/ext/skia_utils_mac.h" #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" #include "ui/base/l10n/l10n_util.h" -#include "webkit/glue/plugins/plugin_list.h" +#include "webkit/plugins/npapi/plugin_list.h" namespace { @@ -243,7 +242,7 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) { for (std::set<std::string>::iterator it = plugins.begin(); it != plugins.end(); ++it) { NSString* name = SysUTF16ToNSString( - NPAPI::PluginList::Singleton()->GetPluginGroupName(*it)); + webkit::npapi::PluginList::Singleton()->GetPluginGroupName(*it)); if ([name length] == 0) name = base::SysUTF8ToNSString(*it); [pluginArray addObject:name]; diff --git a/chrome/browser/ui/cocoa/drag_util.mm b/chrome/browser/ui/cocoa/drag_util.mm index 3a0d580..88c746b 100644 --- a/chrome/browser/ui/cocoa/drag_util.mm +++ b/chrome/browser/ui/cocoa/drag_util.mm @@ -79,11 +79,15 @@ static BOOL IsSupportedFileURL(const GURL& url) { return YES; // Check whether there is a plugin that supports the mime type. (e.g. PDF) - webkit::npapi::PluginList* list = webkit::npapi::PluginList::Singleton(); - webkit::npapi::WebPluginInfo info; - if (!list->stale() && - list->GetPluginInfo(GURL(), mime_type, false, &info, NULL)) { - return webkit::npapi::IsPluginEnabled(info); + // TODO(bauerb): This possibly uses stale information, but it's guaranteed not + // to do disk access. + bool stale = false; + std::vector<webkit::npapi::WebPluginInfo> info_array; + webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( + url, mime_type, false, &stale, &info_array, NULL); + for (size_t i = 0; i < info_array.size(); ++i) { + if (webkit::npapi::IsPluginEnabled(info_array[i])) + return true; } return NO; diff --git a/chrome/browser/ui/views/content_setting_bubble_contents.cc b/chrome/browser/ui/views/content_setting_bubble_contents.cc index b3c28ac..e0b505a 100644 --- a/chrome/browser/ui/views/content_setting_bubble_contents.cc +++ b/chrome/browser/ui/views/content_setting_bubble_contents.cc @@ -10,7 +10,6 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/browser/plugin_updater.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" #include "chrome/browser/ui/views/browser_dialogs.h" @@ -28,7 +27,7 @@ #include "views/controls/separator.h" #include "views/layout/grid_layout.h" #include "views/layout/layout_constants.h" -#include "webkit/glue/plugins/plugin_list.h" +#include "webkit/plugins/npapi/plugin_list.h" #if defined(TOOLKIT_USES_GTK) #include "ui/gfx/gtk_util.h" @@ -206,7 +205,7 @@ void ContentSettingBubbleContents::InitControlLayout() { for (std::set<std::string>::const_iterator it = plugins.begin(); it != plugins.end(); ++it) { std::wstring name = UTF16ToWide( - NPAPI::PluginList::Singleton()->GetPluginGroupName(*it)); + webkit::npapi::PluginList::Singleton()->GetPluginGroupName(*it)); if (name.empty()) name = UTF8ToWide(*it); layout->StartRow(0, single_column_set_id); diff --git a/chrome/browser/ui/webui/flash_ui.cc b/chrome/browser/ui/webui/flash_ui.cc index a456eaf..bcf7cff 100644 --- a/chrome/browser/ui/webui/flash_ui.cc +++ b/chrome/browser/ui/webui/flash_ui.cc @@ -26,7 +26,7 @@ #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" -#include "webkit/glue/plugins/plugin_list.h" +#include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/npapi/webplugininfo.h" #if defined(OS_WIN) @@ -223,7 +223,7 @@ void FlashDOMHandler::MaybeRespondToPage() { // Obtain the version of the Flash plugins. std::vector<webkit::npapi::WebPluginInfo> info_array; webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( - GURL(), "application/x-shockwave-flash", false, &info_array, NULL); + GURL(), "application/x-shockwave-flash", false, NULL, &info_array, NULL); string16 flash_version; if (info_array.empty()) { AddPair(list, ASCIIToUTF16("Flash plugin"), "Disabled"); |