summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-26 20:40:14 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-26 20:40:14 +0000
commitb7715f1e5ceeb9734da977732b4dd5fe2b7bd1c9 (patch)
tree8fa6f62dbbe9226e195b2af16a43011ad9fd149a
parentc94a6109bd2db552573ccbac287b6999c1e998c3 (diff)
downloadchromium_src-b7715f1e5ceeb9734da977732b4dd5fe2b7bd1c9.zip
chromium_src-b7715f1e5ceeb9734da977732b4dd5fe2b7bd1c9.tar.gz
chromium_src-b7715f1e5ceeb9734da977732b4dd5fe2b7bd1c9.tar.bz2
Also use plugin group identifiers in PluginExceptionsTableModel.
BUG=39252 TEST=TableModelArrayControllerTest.*:PluginExceptionsTableModelTest.* Review URL: http://codereview.chromium.org/3474010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60615 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/table_model_array_controller_unittest.mm26
-rw-r--r--chrome/browser/mock_plugin_exceptions_table_model.cc6
-rw-r--r--chrome/browser/mock_plugin_exceptions_table_model.h6
-rw-r--r--chrome/browser/plugin_exceptions_table_model.cc19
-rw-r--r--chrome/browser/plugin_exceptions_table_model.h5
-rw-r--r--chrome/browser/plugin_exceptions_table_model_unittest.cc22
6 files changed, 44 insertions, 40 deletions
diff --git a/chrome/browser/cocoa/table_model_array_controller_unittest.mm b/chrome/browser/cocoa/table_model_array_controller_unittest.mm
index 4f32358..527d3db 100644
--- a/chrome/browser/cocoa/table_model_array_controller_unittest.mm
+++ b/chrome/browser/cocoa/table_model_array_controller_unittest.mm
@@ -11,6 +11,7 @@
#import "chrome/browser/cocoa/cocoa_test_helper.h"
#include "chrome/browser/mock_plugin_exceptions_table_model.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/plugin_group.h"
#include "chrome/test/testing_profile.h"
#include "grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -38,35 +39,38 @@ class TableModelArrayControllerTest : public CocoaTest {
HostContentSettingsMap::Pattern moose_org("[*.]moose.org");
map->SetContentSetting(example_com,
CONTENT_SETTINGS_TYPE_PLUGINS,
- "foo",
+ "a-foo",
CONTENT_SETTING_ALLOW);
map->SetContentSetting(moose_org,
CONTENT_SETTINGS_TYPE_PLUGINS,
- "bar",
+ "b-bar",
CONTENT_SETTING_BLOCK);
map->SetContentSetting(example_com,
CONTENT_SETTINGS_TYPE_PLUGINS,
- "bar",
+ "b-bar",
CONTENT_SETTING_ALLOW);
model_.reset(new MockPluginExceptionsTableModel(map, NULL));
- std::vector<WebPluginInfo> plugins;
+ PluginUpdater::PluginMap plugins;
WebPluginInfo foo_plugin;
- foo_plugin.path = FilePath(FILE_PATH_LITERAL("foo"));
+ foo_plugin.path = FilePath(FILE_PATH_LITERAL("a-foo"));
foo_plugin.name = ASCIIToUTF16("FooPlugin");
foo_plugin.enabled = true;
- plugins.push_back(foo_plugin);
+ PluginGroup* foo_group = PluginGroup::FromWebPluginInfo(foo_plugin);
+ plugins[foo_group->identifier()] = linked_ptr<PluginGroup>(foo_group);
WebPluginInfo bar_plugin;
- bar_plugin.path = FilePath(FILE_PATH_LITERAL("bar"));
+ bar_plugin.path = FilePath(FILE_PATH_LITERAL("b-bar"));
bar_plugin.name = ASCIIToUTF16("BarPlugin");
bar_plugin.enabled = true;
- plugins.push_back(bar_plugin);
+ PluginGroup* bar_group = PluginGroup::FromWebPluginInfo(bar_plugin);
+ plugins[bar_group->identifier()] = linked_ptr<PluginGroup>(bar_group);
WebPluginInfo blurp_plugin;
- blurp_plugin.path = FilePath(FILE_PATH_LITERAL("blurp"));
+ blurp_plugin.path = FilePath(FILE_PATH_LITERAL("c-blurp"));
blurp_plugin.name = ASCIIToUTF16("BlurpPlugin");
blurp_plugin.enabled = true;
- plugins.push_back(blurp_plugin);
+ PluginGroup* blurp_group = PluginGroup::FromWebPluginInfo(blurp_plugin);
+ plugins[blurp_group->identifier()] = linked_ptr<PluginGroup>(blurp_group);
model_->set_plugins(plugins);
model_->LoadSettings();
@@ -137,7 +141,7 @@ TEST_F(TableModelArrayControllerTest, AddException) {
HostContentSettingsMap::Pattern example_com("[*.]example.com");
map->SetContentSetting(example_com,
CONTENT_SETTINGS_TYPE_PLUGINS,
- "blurp",
+ "c-blurp",
CONTENT_SETTING_BLOCK);
NSArrayController* controller = controller_.get();
diff --git a/chrome/browser/mock_plugin_exceptions_table_model.cc b/chrome/browser/mock_plugin_exceptions_table_model.cc
index d74dfa0..fe5c904 100644
--- a/chrome/browser/mock_plugin_exceptions_table_model.cc
+++ b/chrome/browser/mock_plugin_exceptions_table_model.cc
@@ -4,14 +4,14 @@
#include "chrome/browser/mock_plugin_exceptions_table_model.h"
-#include "webkit/glue/plugins/webplugininfo.h"
+#include "chrome/common/plugin_group.h"
void MockPluginExceptionsTableModel::set_plugins(
- const std::vector<WebPluginInfo>& plugins) {
+ const PluginUpdater::PluginMap& plugins) {
plugins_ = plugins;
}
void MockPluginExceptionsTableModel::GetPlugins(
- std::vector<WebPluginInfo>* plugins) {
+ PluginUpdater::PluginMap* plugins) {
*plugins = plugins_;
}
diff --git a/chrome/browser/mock_plugin_exceptions_table_model.h b/chrome/browser/mock_plugin_exceptions_table_model.h
index 4cedcd3..eea5a4d 100644
--- a/chrome/browser/mock_plugin_exceptions_table_model.h
+++ b/chrome/browser/mock_plugin_exceptions_table_model.h
@@ -17,13 +17,13 @@ class MockPluginExceptionsTableModel : public PluginExceptionsTableModel {
: PluginExceptionsTableModel(map, otr_map) {}
virtual ~MockPluginExceptionsTableModel() {}
- void set_plugins(const std::vector<WebPluginInfo>& plugins);
+ void set_plugins(const PluginUpdater::PluginMap& plugins);
protected:
- virtual void GetPlugins(std::vector<WebPluginInfo>* plugins);
+ virtual void GetPlugins(PluginUpdater::PluginMap* plugins);
private:
- std::vector<WebPluginInfo> plugins_;
+ PluginUpdater::PluginMap plugins_;
};
#endif // CHROME_BROWSER_MOCK_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_
diff --git a/chrome/browser/plugin_exceptions_table_model.cc b/chrome/browser/plugin_exceptions_table_model.cc
index 5b01df5..e9abc35 100644
--- a/chrome/browser/plugin_exceptions_table_model.cc
+++ b/chrome/browser/plugin_exceptions_table_model.cc
@@ -10,8 +10,8 @@
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/common/notification_service.h"
+#include "chrome/common/plugin_group.h"
#include "grit/generated_resources.h"
-#include "webkit/glue/plugins/plugin_list.h"
PluginExceptionsTableModel::PluginExceptionsTableModel(
HostContentSettingsMap* content_settings_map,
@@ -128,22 +128,17 @@ void PluginExceptionsTableModel::ClearSettings() {
resources_.clear();
}
-void PluginExceptionsTableModel::GetPlugins(
- std::vector<WebPluginInfo>* plugins) {
- NPAPI::PluginList::Singleton()->GetPlugins(false, plugins);
+void PluginExceptionsTableModel::GetPlugins(PluginUpdater::PluginMap* plugins) {
+ PluginUpdater::GetPluginUpdater()->GetPluginGroups(plugins);
}
void PluginExceptionsTableModel::LoadSettings() {
int group_id = 0;
- std::vector<WebPluginInfo> plugins;
+ PluginUpdater::PluginMap plugins;
GetPlugins(&plugins);
- for (std::vector<WebPluginInfo>::iterator it = plugins.begin();
+ for (PluginUpdater::PluginMap::iterator it = plugins.begin();
it != plugins.end(); ++it) {
-#if defined OS_POSIX
- std::string plugin = it->path.value();
-#elif defined OS_WIN
- std::string plugin = base::SysWideToUTF8(it->path.value());
-#endif
+ std::string plugin = it->first;
HostContentSettingsMap::SettingsForOneType settings;
map_->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_PLUGINS,
plugin,
@@ -154,7 +149,7 @@ void PluginExceptionsTableModel::LoadSettings() {
plugin,
&otr_settings);
}
- std::wstring title = UTF16ToWide(it->name);
+ std::wstring title = UTF16ToWide(it->second->GetGroupName());
for (HostContentSettingsMap::SettingsForOneType::iterator setting_it =
settings.begin(); setting_it != settings.end(); ++setting_it) {
SettingsEntry entry = {
diff --git a/chrome/browser/plugin_exceptions_table_model.h b/chrome/browser/plugin_exceptions_table_model.h
index c7b9583..491aab1 100644
--- a/chrome/browser/plugin_exceptions_table_model.h
+++ b/chrome/browser/plugin_exceptions_table_model.h
@@ -8,8 +8,9 @@
#include <deque>
-#include "chrome/browser/remove_rows_table_model.h"
#include "chrome/browser/host_content_settings_map.h"
+#include "chrome/browser/plugin_updater.h"
+#include "chrome/browser/remove_rows_table_model.h"
#include "chrome/common/notification_observer.h"
namespace plugin_test_internal {
@@ -48,7 +49,7 @@ class PluginExceptionsTableModel : public RemoveRowsTableModel,
protected:
// Subclasses can override this method for testing.
- virtual void GetPlugins(std::vector<WebPluginInfo>* plugins);
+ virtual void GetPlugins(PluginUpdater::PluginMap* plugins);
private:
friend class plugin_test_internal::PluginExceptionsTableModelTest;
diff --git a/chrome/browser/plugin_exceptions_table_model_unittest.cc b/chrome/browser/plugin_exceptions_table_model_unittest.cc
index 2e7528f..6b508c6 100644
--- a/chrome/browser/plugin_exceptions_table_model_unittest.cc
+++ b/chrome/browser/plugin_exceptions_table_model_unittest.cc
@@ -8,6 +8,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/mock_plugin_exceptions_table_model.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/plugin_group.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/testing_pref_service.h"
#include "chrome/test/testing_profile.h"
@@ -68,30 +69,33 @@ class PluginExceptionsTableModelTest : public testing::Test {
HostContentSettingsMap::Pattern moose_org("[*.]moose.org");
map->SetContentSetting(example_com,
CONTENT_SETTINGS_TYPE_PLUGINS,
- "foo",
+ "a-foo",
CONTENT_SETTING_ALLOW);
map->SetContentSetting(moose_org,
CONTENT_SETTINGS_TYPE_PLUGINS,
- "bar",
+ "b-bar",
CONTENT_SETTING_BLOCK);
map->SetContentSetting(example_com,
CONTENT_SETTINGS_TYPE_PLUGINS,
- "bar",
+ "b-bar",
CONTENT_SETTING_ALLOW);
table_model_.reset(new MockPluginExceptionsTableModel(map, NULL));
- std::vector<WebPluginInfo> plugins;
+ PluginUpdater::PluginMap plugins;
WebPluginInfo foo_plugin;
- foo_plugin.path = FilePath(FILE_PATH_LITERAL("foo"));
+ foo_plugin.path = FilePath(FILE_PATH_LITERAL("a-foo"));
foo_plugin.name = ASCIIToUTF16("FooPlugin");
foo_plugin.enabled = true;
- plugins.push_back(foo_plugin);
+ PluginGroup* foo_group = PluginGroup::FromWebPluginInfo(foo_plugin);
+ plugins[foo_group->identifier()] = linked_ptr<PluginGroup>(foo_group);
+
WebPluginInfo bar_plugin;
- bar_plugin.path = FilePath(FILE_PATH_LITERAL("bar"));
+ bar_plugin.path = FilePath(FILE_PATH_LITERAL("b-bar"));
bar_plugin.name = ASCIIToUTF16("BarPlugin");
bar_plugin.enabled = true;
- plugins.push_back(bar_plugin);
+ PluginGroup* bar_group = PluginGroup::FromWebPluginInfo(bar_plugin);
+ plugins[bar_group->identifier()] = linked_ptr<PluginGroup>(bar_group);
table_model_->set_plugins(plugins);
table_model_->ReloadSettings();
@@ -177,7 +181,7 @@ TEST_F(PluginExceptionsTableModelTest, RemoveLastRowInGroup) {
EXPECT_CALL(observer, OnModelChanged());
map->SetContentSetting(HostContentSettingsMap::Pattern("[*.]blurp.net"),
CONTENT_SETTINGS_TYPE_PLUGINS,
- "bar",
+ "b-bar",
CONTENT_SETTING_BLOCK);
EXPECT_EQ(3, table_model_->RowCount());