diff options
author | pastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-24 17:37:12 +0000 |
---|---|---|
committer | pastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-24 17:37:12 +0000 |
commit | b83ff229cfe2c15a6dab2278acf7d328645470a5 (patch) | |
tree | a1b9183bbb3c9aaa91364b5e15c22115336b9786 /chrome/browser | |
parent | 77d13338e12da7ac2c177f4da53b9293850ff357 (diff) | |
download | chromium_src-b83ff229cfe2c15a6dab2278acf7d328645470a5.zip chromium_src-b83ff229cfe2c15a6dab2278acf7d328645470a5.tar.gz chromium_src-b83ff229cfe2c15a6dab2278acf7d328645470a5.tar.bz2 |
Refactor the plugin lists handling code.
Effects of this refactor:
1. The WebPluginInfo now keep information not only if a plugin is disabled but also the reason for that. It can either be user, policy or both. That way we can restore the right value after policies stop to control the feature.
2. Plugins can be correctly enabled and disabled either as a group or separately.
3. The code is cleaner and PluginGroup is not duplicating information from PluginList but stores all needed information and provides it through cleaner interface.
BUG=54681,66505,69374,69148
TEST=Manual for the policy. DefaultPluginUITest.DefaultPluginLoadTest from ui_tests and Plugin* from test_shell_tests.
Review URL: http://codereview.chromium.org/5699005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72341 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 10 | ||||
-rw-r--r-- | chrome/browser/chromeos/gview_request_interceptor.cc | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/gview_request_interceptor_unittest.cc | 5 | ||||
-rw-r--r-- | chrome/browser/dom_ui/plugins_ui.cc | 4 | ||||
-rw-r--r-- | chrome/browser/plugin_data_remover.cc | 2 | ||||
-rw-r--r-- | chrome/browser/plugin_exceptions_table_model_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/plugin_service.cc | 5 | ||||
-rw-r--r-- | chrome/browser/plugin_updater.cc | 42 | ||||
-rw-r--r-- | chrome/browser/plugin_updater.h | 2 | ||||
-rw-r--r-- | chrome/browser/renderer_host/buffered_resource_handler.cc | 3 | ||||
-rw-r--r-- | chrome/browser/resources/plugins.html | 5 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/table_model_array_controller_unittest.mm | 9 |
12 files changed, 55 insertions, 40 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index eab458f..2a32d3b 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -4,6 +4,10 @@ #include "chrome/browser/automation/testing_automation_provider.h" +#include <map> +#include <string> +#include <vector> + #include "base/command_line.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" @@ -2590,7 +2594,7 @@ DownloadItem* GetDownloadItemFromId(int id, DownloadManager* download_manager) { return selected_item; } -} // namespace +} // namespace // See PerformActionOnDownload() in chrome/test/pyautolib/pyauto.py for sample // json input and output. @@ -2979,7 +2983,7 @@ void TestingAutomationProvider::GetPluginsInfo( item->SetString("path", it->path.value()); item->SetString("version", it->version); item->SetString("desc", it->desc); - item->SetBoolean("enabled", it->enabled); + item->SetBoolean("enabled", webkit::npapi::IsPluginEnabled(*it)); // Add info about mime types. ListValue* mime_types = new ListValue(); for (std::vector<webkit::npapi::WebPluginMimeType>::const_iterator type_it = @@ -3197,7 +3201,7 @@ webkit_glue::PasswordForm GetPasswordFormFromDict( return password_form; } -} // namespace +} // namespace // See AddSavedPassword() in chrome/test/functional/pyauto.py for sample json // input. diff --git a/chrome/browser/chromeos/gview_request_interceptor.cc b/chrome/browser/chromeos/gview_request_interceptor.cc index 5e5c521..c6b1f9c 100644 --- a/chrome/browser/chromeos/gview_request_interceptor.cc +++ b/chrome/browser/chromeos/gview_request_interceptor.cc @@ -67,7 +67,7 @@ net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptResponse( PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( pdf_path, &info) && - info.enabled) + webkit::npapi::IsPluginEnabled(info)) return NULL; } // If supported, build the URL to the Google Document Viewer diff --git a/chrome/browser/chromeos/gview_request_interceptor_unittest.cc b/chrome/browser/chromeos/gview_request_interceptor_unittest.cc index 556a9f7..ee72c26 100644 --- a/chrome/browser/chromeos/gview_request_interceptor_unittest.cc +++ b/chrome/browser/chromeos/gview_request_interceptor_unittest.cc @@ -68,7 +68,8 @@ class GViewRequestInterceptorTest : public testing::Test { void RegisterPDFPlugin() { webkit::npapi::WebPluginInfo info; info.path = pdf_path_; - info.enabled = true; + info.name = ASCIIToUTF16("Internal PDF Plugin"); + info.enabled = webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info); webkit::npapi::PluginList::Singleton()->RefreshPlugins(); } @@ -96,7 +97,7 @@ class GViewRequestInterceptorTest : public testing::Test { pdf_path_, &info); } EXPECT_EQ(want_loaded, is_loaded); - *out_is_enabled = info.enabled; + *out_is_enabled = webkit::npapi::IsPluginEnabled(info); } protected: diff --git a/chrome/browser/dom_ui/plugins_ui.cc b/chrome/browser/dom_ui/plugins_ui.cc index 6cb237e..d5e9879 100644 --- a/chrome/browser/dom_ui/plugins_ui.cc +++ b/chrome/browser/dom_ui/plugins_ui.cc @@ -83,8 +83,6 @@ void PluginsUIHTMLSource::StartDataRequest(const std::string& path, l10n_util::GetStringUTF16(IDS_PLUGINS_DOWNLOAD)); localized_strings.SetString("pluginName", l10n_util::GetStringUTF16(IDS_PLUGINS_NAME)); - localized_strings.SetString("pluginPriority", - l10n_util::GetStringUTF16(IDS_PLUGINS_PRIORITY)); localized_strings.SetString("pluginVersion", l10n_util::GetStringUTF16(IDS_PLUGINS_VERSION)); localized_strings.SetString("pluginDescription", @@ -237,7 +235,7 @@ void PluginsDOMHandler::HandleEnablePluginMessage(const ListValue* args) { if (!args->GetString(0, &file_path)) return; - plugin_updater->EnablePluginFile(enable, file_path); + plugin_updater->EnablePlugin(enable, file_path); } // TODO(viettrungluu): We might also want to ensure that the plugins diff --git a/chrome/browser/plugin_data_remover.cc b/chrome/browser/plugin_data_remover.cc index bfc9811..188140a 100644 --- a/chrome/browser/plugin_data_remover.cc +++ b/chrome/browser/plugin_data_remover.cc @@ -176,7 +176,7 @@ bool PluginDataRemover::IsSupported() { switches::kMinClearSiteDataFlashVersion))); if (!min_version.get()) min_version.reset(Version::GetVersionFromString(kMinFlashVersion)); - return plugin.enabled && + return webkit::npapi::IsPluginEnabled(plugin) && version.get() && min_version->CompareTo(*version) == -1; } diff --git a/chrome/browser/plugin_exceptions_table_model_unittest.cc b/chrome/browser/plugin_exceptions_table_model_unittest.cc index 18bd3bc..cdfd537 100644 --- a/chrome/browser/plugin_exceptions_table_model_unittest.cc +++ b/chrome/browser/plugin_exceptions_table_model_unittest.cc @@ -88,7 +88,8 @@ class PluginExceptionsTableModelTest : public testing::Test { webkit::npapi::WebPluginInfo foo_plugin; foo_plugin.path = FilePath(FILE_PATH_LITERAL("a-foo")); foo_plugin.name = ASCIIToUTF16("FooPlugin"); - foo_plugin.enabled = true; + foo_plugin.enabled = + webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; scoped_ptr<webkit::npapi::PluginGroup> foo_group( webkit::npapi::PluginGroup::FromWebPluginInfo(foo_plugin)); plugins.push_back(*foo_group); @@ -96,7 +97,8 @@ class PluginExceptionsTableModelTest : public testing::Test { webkit::npapi::WebPluginInfo bar_plugin; bar_plugin.path = FilePath(FILE_PATH_LITERAL("b-bar")); bar_plugin.name = ASCIIToUTF16("BarPlugin"); - bar_plugin.enabled = true; + bar_plugin.enabled = + webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; scoped_ptr<webkit::npapi::PluginGroup> bar_group( webkit::npapi::PluginGroup::FromWebPluginInfo(bar_plugin)); plugins.push_back(*bar_group); diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc index 82fa237..534773a 100644 --- a/chrome/browser/plugin_service.cc +++ b/chrome/browser/plugin_service.cc @@ -314,7 +314,7 @@ void PluginService::GetAllowedPluginForOpenChannelToPlugin( bool found = GetFirstAllowedPluginInfo( render_process_id, render_view_id, url, mime_type, &info, NULL); FilePath plugin_path; - if (found && info.enabled) + if (found && webkit::npapi::IsPluginEnabled(info)) plugin_path = FilePath(info.path); // Now we jump back to the IO thread to finish opening the channel. @@ -456,6 +456,7 @@ void PluginService::Observe(NotificationType type, #endif case NotificationType::PLUGIN_ENABLE_STATUS_CHANGED: { + webkit::npapi::PluginList::Singleton()->RefreshPlugins(); PurgePluginListCache(false); break; } @@ -507,7 +508,7 @@ void PluginService::RegisterPepperPlugins() { WideToUTF16(plugins[i].path.BaseName().ToWStringHack()) : ASCIIToUTF16(plugins[i].name); info.desc = ASCIIToUTF16(plugins[i].description); - info.enabled = true; + info.enabled = webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; // TODO(evan): Pepper shouldn't require us to parse strings to get // the list of mime types out. diff --git a/chrome/browser/plugin_updater.cc b/chrome/browser/plugin_updater.cc index d994efd..375bf0a 100644 --- a/chrome/browser/plugin_updater.cc +++ b/chrome/browser/plugin_updater.cc @@ -40,7 +40,7 @@ DictionaryValue* PluginUpdater::CreatePluginFileSummary( data->SetString("path", plugin.path.value()); data->SetString("name", plugin.name); data->SetString("version", plugin.version); - data->SetBoolean("enabled", plugin.enabled); + data->SetBoolean("enabled", webkit::npapi::IsPluginEnabled(plugin)); return data; } @@ -58,17 +58,14 @@ ListValue* PluginUpdater::GetPluginGroupsData() { } void PluginUpdater::EnablePluginGroup(bool enable, const string16& group_name) { - if (webkit::npapi::PluginGroup::IsPluginNameDisabledByPolicy(group_name)) - enable = false; webkit::npapi::PluginList::Singleton()->EnableGroup(enable, group_name); NotifyPluginStatusChanged(); } -void PluginUpdater::EnablePluginFile(bool enable, - const FilePath::StringType& path) { +void PluginUpdater::EnablePlugin(bool enable, + const FilePath::StringType& path) { FilePath file_path(path); - if (enable && - !webkit::npapi::PluginGroup::IsPluginPathDisabledByPolicy(file_path)) + if (enable) webkit::npapi::PluginList::Singleton()->EnablePlugin(file_path); else webkit::npapi::PluginList::Singleton()->DisablePlugin(file_path); @@ -250,9 +247,9 @@ void PluginUpdater::GetPreferencesDataOnFileThread(void* profile) { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - NewRunnableFunction( - &PluginUpdater::OnUpdatePreferences, - static_cast<Profile*>(profile), plugins, groups)); + NewRunnableFunction(&PluginUpdater::OnUpdatePreferences, + static_cast<Profile*>(profile), + plugins, groups)); } void PluginUpdater::OnUpdatePreferences( @@ -269,16 +266,29 @@ void PluginUpdater::OnUpdatePreferences( internal_dir); // Add the plugin files. - for (std::vector<webkit::npapi::WebPluginInfo>::const_iterator it = - plugins.begin(); - it != plugins.end(); - ++it) { - plugins_list->Append(CreatePluginFileSummary(*it)); + for (size_t i = 0; i < plugins.size(); ++i) { + DictionaryValue* summary = CreatePluginFileSummary(plugins[i]); + // If the plugin is disabled only by policy don't store this state in the + // user pref store. + if (plugins[i].enabled == + webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_DISABLED) { + summary->SetBoolean("enabled", true); + } + bool enabled_val; + summary->GetBoolean("enabled", &enabled_val); + plugins_list->Append(summary); } // Add the groups as well. for (size_t i = 0; i < groups.size(); ++i) { - plugins_list->Append(groups[i].GetSummary()); + DictionaryValue* summary = groups[i].GetSummary(); + // If the plugin is disabled only by policy don't store this state in the + // user pref store. + if (!groups[i].Enabled() && + webkit::npapi::PluginGroup::IsPluginNameDisabledByPolicy( + groups[i].GetGroupName())) + summary->SetBoolean("enabled", true); + plugins_list->Append(summary); } } diff --git a/chrome/browser/plugin_updater.h b/chrome/browser/plugin_updater.h index dc18595..2c4fed7 100644 --- a/chrome/browser/plugin_updater.h +++ b/chrome/browser/plugin_updater.h @@ -36,7 +36,7 @@ class PluginUpdater : public NotificationObserver { void EnablePluginGroup(bool enable, const string16& group_name); // Enable or disable a specific plugin file. - void EnablePluginFile(bool enable, const FilePath::StringType& file_path); + void EnablePlugin(bool enable, const FilePath::StringType& file_path); // Disable all plugin groups as defined by the user's preference file. void DisablePluginGroupsFromPrefs(Profile* profile); diff --git a/chrome/browser/renderer_host/buffered_resource_handler.cc b/chrome/browser/renderer_host/buffered_resource_handler.cc index 2cccbc2..05aa75f 100644 --- a/chrome/browser/renderer_host/buffered_resource_handler.cc +++ b/chrome/browser/renderer_host/buffered_resource_handler.cc @@ -434,7 +434,8 @@ bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) { webkit::npapi::WebPluginInfo info; bool allow_wildcard = false; return !webkit::npapi::PluginList::Singleton()->GetPluginInfo( - GURL(), type, allow_wildcard, &info, NULL) || !info.enabled; + GURL(), type, allow_wildcard, &info, NULL) || + !webkit::npapi::IsPluginEnabled(info); } void BufferedResourceHandler::UseAlternateResourceHandler( diff --git a/chrome/browser/resources/plugins.html b/chrome/browser/resources/plugins.html index cb0a164..350d73f 100644 --- a/chrome/browser/resources/plugins.html +++ b/chrome/browser/resources/plugins.html @@ -528,11 +528,6 @@ document.addEventListener('DOMContentLoaded', requestPluginsData); </tr></table></div> <div><table><tr> <td class="plugin-details-label" - i18n-content="pluginPriority">PRIORITY:</td> - <td><span dir="ltr" jscontent="priority">x</span></td> - </tr></table></div> - <div><table><tr> - <td class="plugin-details-label" i18n-content="pluginPath">PATH:</td> <td><span dir="ltr" jscontent="path"></span></td> </tr></table></div> diff --git a/chrome/browser/ui/cocoa/table_model_array_controller_unittest.mm b/chrome/browser/ui/cocoa/table_model_array_controller_unittest.mm index 8b217fb..65a14910 100644 --- a/chrome/browser/ui/cocoa/table_model_array_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/table_model_array_controller_unittest.mm @@ -54,21 +54,24 @@ class TableModelArrayControllerTest : public CocoaTest { webkit::npapi::WebPluginInfo foo_plugin; foo_plugin.path = FilePath(FILE_PATH_LITERAL("a-foo")); foo_plugin.name = ASCIIToUTF16("FooPlugin"); - foo_plugin.enabled = true; + foo_plugin.enabled = + webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; scoped_ptr<webkit::npapi::PluginGroup> foo_group( webkit::npapi::PluginGroup::FromWebPluginInfo(foo_plugin)); plugins.push_back(*foo_group); webkit::npapi::WebPluginInfo bar_plugin; bar_plugin.path = FilePath(FILE_PATH_LITERAL("b-bar")); bar_plugin.name = ASCIIToUTF16("BarPlugin"); - bar_plugin.enabled = true; + bar_plugin.enabled = + webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; scoped_ptr<webkit::npapi::PluginGroup> bar_group( webkit::npapi::PluginGroup::FromWebPluginInfo(bar_plugin)); plugins.push_back(*bar_group); webkit::npapi::WebPluginInfo blurp_plugin; blurp_plugin.path = FilePath(FILE_PATH_LITERAL("c-blurp")); blurp_plugin.name = ASCIIToUTF16("BlurpPlugin"); - blurp_plugin.enabled = true; + blurp_plugin.enabled = + webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; scoped_ptr<webkit::npapi::PluginGroup> blurp_group( webkit::npapi::PluginGroup::FromWebPluginInfo(blurp_plugin)); plugins.push_back(*blurp_group); |