diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 18:41:56 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 18:41:56 +0000 |
commit | 49ba482a3a248c7cd4556b49ed601cda1e82aa9f (patch) | |
tree | af248f0ea23b1fe262e59daf734bdfe7bb75523a | |
parent | 34af8e7bd57b09064a5ffab971f74ec741afdba0 (diff) | |
download | chromium_src-49ba482a3a248c7cd4556b49ed601cda1e82aa9f.zip chromium_src-49ba482a3a248c7cd4556b49ed601cda1e82aa9f.tar.gz chromium_src-49ba482a3a248c7cd4556b49ed601cda1e82aa9f.tar.bz2 |
Content settings extension API: Implement ContentSetting.getResourceIdentifiers.
BUG=71067
Review URL: http://codereview.chromium.org/7041005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89226 0039d316-1c4b-4281-b951-d872f2087c98
16 files changed, 501 insertions, 44 deletions
diff --git a/chrome/browser/extensions/extension_content_settings_api.cc b/chrome/browser/extensions/extension_content_settings_api.cc index 0013b20..c17ac6c 100644 --- a/chrome/browser/extensions/extension_content_settings_api.cc +++ b/chrome/browser/extensions/extension_content_settings_api.cc @@ -4,6 +4,10 @@ #include "chrome/browser/extensions/extension_content_settings_api.h" +#include <vector> + +#include "base/bind.h" +#include "base/command_line.h" #include "base/values.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/extensions/extension_content_settings_api_constants.h" @@ -13,13 +17,22 @@ #include "chrome/browser/extensions/extension_preference_helpers.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension_error_utils.h" +#include "webkit/plugins/npapi/plugin_group.h" +#include "webkit/plugins/npapi/plugin_list.h" namespace helpers = extension_content_settings_helpers; namespace keys = extension_content_settings_api_constants; namespace pref_helpers = extension_preference_helpers; namespace pref_keys = extension_preference_api_constants; +namespace { + +webkit::npapi::PluginList* g_plugin_list = NULL; + +} // namespace + bool ClearContentSettingsFunction::RunImpl() { std::string content_type_str; EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &content_type_str)); @@ -241,3 +254,54 @@ bool SetContentSettingFunction::RunImpl() { resource_identifier, setting, scope); return true; } + +bool GetResourceIdentifiersFunction::RunImpl() { + std::string content_type_str; + EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &content_type_str)); + ContentSettingsType content_type = + helpers::StringToContentSettingsType(content_type_str); + EXTENSION_FUNCTION_VALIDATE(content_type != CONTENT_SETTINGS_TYPE_DEFAULT); + + if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS && + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableResourceContentSettings)) { + BrowserThread::PostTask( + BrowserThread::FILE, FROM_HERE, + base::Bind(&GetResourceIdentifiersFunction::GetPluginsOnFileThread, + this)); + } else { + SendResponse(true); + } + + return true; +} + +void GetResourceIdentifiersFunction::GetPluginsOnFileThread() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); + webkit::npapi::PluginList* plugin_list = g_plugin_list; + if (!plugin_list) { + plugin_list = webkit::npapi::PluginList::Singleton(); + } + + std::vector<webkit::npapi::PluginGroup> groups; + plugin_list->GetPluginGroups(true, &groups); + + ListValue* list = new ListValue(); + for (std::vector<webkit::npapi::PluginGroup>::iterator it = groups.begin(); + it != groups.end(); ++it) { + DictionaryValue* dict = new DictionaryValue(); + dict->SetString(keys::kIdKey, it->identifier()); + dict->SetString(keys::kDescriptionKey, it->GetGroupName()); + list->Append(dict); + } + result_.reset(list); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, base::Bind( + &GetResourceIdentifiersFunction::SendResponse, this, true)); +} + +// static +void GetResourceIdentifiersFunction::SetPluginListForTesting( + webkit::npapi::PluginList* plugin_list) { + g_plugin_list = plugin_list; +} diff --git a/chrome/browser/extensions/extension_content_settings_api.h b/chrome/browser/extensions/extension_content_settings_api.h index 470825e..25aca13 100644 --- a/chrome/browser/extensions/extension_content_settings_api.h +++ b/chrome/browser/extensions/extension_content_settings_api.h @@ -8,6 +8,14 @@ #include "chrome/browser/extensions/extension_function.h" +namespace webkit { +namespace npapi { + +class PluginList; + +} +} + class ClearContentSettingsFunction : public SyncExtensionFunction { public: virtual bool RunImpl(); @@ -29,4 +37,20 @@ class SetContentSettingFunction : public SyncExtensionFunction { "experimental.contentSettings.set") }; +class GetResourceIdentifiersFunction : public AsyncExtensionFunction { + public: + virtual bool RunImpl(); + DECLARE_EXTENSION_FUNCTION_NAME( + "experimental.contentSettings.getResourceIdentifiers") + + private: + FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, + ContentSettingsGetResourceIdentifiers); + + void GetPluginsOnFileThread(); + + // Used to override the global plugin list in tests. + static void SetPluginListForTesting(webkit::npapi::PluginList* plugin_list); +}; + #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_API_H__ diff --git a/chrome/browser/extensions/extension_content_settings_apitest.cc b/chrome/browser/extensions/extension_content_settings_apitest.cc index 0d8a704..078c009 100644 --- a/chrome/browser/extensions/extension_content_settings_apitest.cc +++ b/chrome/browser/extensions/extension_content_settings_apitest.cc @@ -2,13 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/utf_string_conversions.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/extensions/extension_apitest.h" +#include "chrome/browser/extensions/extension_content_settings_api.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "webkit/plugins/npapi/mock_plugin_list.h" IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) { CommandLine::ForCurrentProcess()->AppendSwitch( @@ -169,3 +172,39 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettingsOnChange) { EXPECT_TRUE(RunExtensionTestIncognito("content_settings/onchange")) << message_; } + +IN_PROC_BROWSER_TEST_F(ExtensionApiTest, + ContentSettingsGetResourceIdentifiers) { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableExperimentalExtensionApis); + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableResourceContentSettings); + + FilePath::CharType kFooPath[] = FILE_PATH_LITERAL("/plugins/foo.plugin"); + FilePath::CharType kBarPath[] = FILE_PATH_LITERAL("/plugins/bar.plugin"); + const char* kFooName = "Foo Plugin"; + const char* kBarName = "Bar Plugin"; + const webkit::npapi::PluginGroupDefinition kPluginDefinitions[] = { + { "foo", "Foo", kFooName, NULL, 0, + "http://example.com/foo" }, + }; + + webkit::npapi::MockPluginList plugin_list(kPluginDefinitions, + arraysize(kPluginDefinitions)); + plugin_list.AddPluginToLoad( + webkit::npapi::WebPluginInfo(ASCIIToUTF16(kFooName), + FilePath(kFooPath), + ASCIIToUTF16("1.2.3"), + ASCIIToUTF16("foo"))); + plugin_list.AddPluginToLoad( + webkit::npapi::WebPluginInfo(ASCIIToUTF16(kBarName), + FilePath(kBarPath), + ASCIIToUTF16("2.3.4"), + ASCIIToUTF16("bar"))); + GetResourceIdentifiersFunction::SetPluginListForTesting(&plugin_list); + + EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers")) + << message_; + + GetResourceIdentifiersFunction::SetPluginListForTesting(NULL); +} diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index bdd9798..36adcaa 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -364,6 +364,7 @@ void FactoryRegistry::ResetFunctions() { RegisterFunction<SendRequestDebuggerFunction>(); // Content settings. + RegisterFunction<GetResourceIdentifiersFunction>(); RegisterFunction<ClearContentSettingsFunction>(); RegisterFunction<GetContentSettingFunction>(); RegisterFunction<SetContentSettingFunction>(); diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 344ee7f..f280ae6 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -771,7 +771,7 @@ 'browser/content_settings/content_settings_notification_provider.cc', 'browser/content_settings/content_settings_notification_provider.h', 'browser/content_settings/content_settings_origin_identifier_value_map.cc', - 'browser/content_settings/content_settings_origin_identifier_value.h', + 'browser/content_settings/content_settings_origin_identifier_value_map.h', 'browser/content_settings/content_settings_pattern.cc', 'browser/content_settings/content_settings_pattern.h', 'browser/content_settings/content_settings_pattern_parser.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 96d2466..fc08286 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2287,6 +2287,7 @@ '../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icuuc', '../v8/tools/gyp/v8.gyp:v8', + '../webkit/webkit.gyp:test_shell_test_support', # Runtime dependencies '../third_party/mesa/mesa.gyp:osmesa', '../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:copy_TestNetscapePlugIn', diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index bcea876..5272b2a 100644 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -5702,6 +5702,7 @@ }, "description": { "type": "string", + "optional": true, "description": "A human readable description of the resource." } }, @@ -5857,6 +5858,27 @@ "parameters": [] } ] + }, + { + "name": "getResourceIdentifiers", + "type": "function", + "description": "", + "parameters": [ + { + "name": "callback", + "type": "function", + "parameters": [ + { + "type": "array", + "description": "A list of resource identifiers for this content type, or <var>undefined</var> if this content type does not use resource identifiers.", + "optional": true, + "items": { + "$ref": "ResourceIdentifier" + } + } + ] + } + ] } ] } diff --git a/chrome/common/extensions/docs/experimental.contentSettings.html b/chrome/common/extensions/docs/experimental.contentSettings.html index 913abda..b9c1138 100644 --- a/chrome/common/extensions/docs/experimental.contentSettings.html +++ b/chrome/common/extensions/docs/experimental.contentSettings.html @@ -1330,7 +1330,7 @@ <!-- TYPE --> <div style="display:inline"> ( - <span class="optional" style="display: none; ">optional</span> + <span class="optional">optional</span> <span class="enum" style="display: none; ">enumerated</span> <span id="typeTemplate"> <span style="display: none; "> @@ -2827,6 +2827,215 @@ </div> <!-- /description --> </div><div class="apiItem"> + <a name="method-ContentSetting-getResourceIdentifiers"></a> <!-- method-anchor --> + <h4>getResourceIdentifiers</h4> + + <div class="summary"><span style="display: none; ">void</span> + <!-- Note: intentionally longer 80 columns --> + <span>contentSetting.getResourceIdentifiers</span>(<span class="null"><span style="display: none; ">, </span><span>function</span> + <var><span>callback</span></var></span>)</div> + + <div class="description"> + <p class="todo">Undocumented.</p> + <p style="display: none; "> + A description from the json schema def of the function goes here. + </p> + + <!-- PARAMETERS --> + <h4>Parameters</h4> + <dl> + <div> + <div> + <dt> + <var>callback</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional" style="display: none; ">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>function</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo"> + Undocumented. + </dd> + <dd style="display: none; "> + Description of this parameter from the json schema. + </dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + </div> + </dl> + + <!-- RETURNS --> + <h4 style="display: none; ">Returns</h4> + <dl> + <div style="display: none; "> + <div> + </div> + </div> + </dl> + + <!-- CALLBACK --> + <div> + <div> + <h4>Callback function</h4> + <p> + The callback <em>parameter</em> should specify a function + that looks like this: + </p> + <p style="display: none; "> + If you specify the <em>callback</em> parameter, it should + specify a function that looks like this: + </p> + + <!-- Note: intentionally longer 80 columns --> + <pre>function(<span>array of ResourceIdentifier undefined</span>) <span class="subdued">{...}</span>;</pre> + <dl> + <div> + <div> + <dt> + <var style="display: none; ">paramName</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span> + array of <span><span> + <span> + <a href="experimental.contentSettings.html#type-ResourceIdentifier">ResourceIdentifier</a> + </span> + <span style="display: none; "> + <span> + array of <span><span></span></span> + </span> + <span>paramType</span> + <span></span> + </span> + </span></span> + </span> + <span style="display: none; ">paramType</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>A list of resource identifiers for this content type, or <var>undefined</var> if this content type does not use resource identifiers</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + </div> + </dl> + </div> + </div> + + <!-- MIN_VERSION --> + <p style="display: none; "> + This function was added in version <b><span></span></b>. + If you require this function, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </p> + </div> <!-- /description --> + + </div><div class="apiItem"> <a name="method-ContentSetting-set"></a> <!-- method-anchor --> <h4>set</h4> diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js index 1c6f5d5..cce5d38 100644 --- a/chrome/renderer/resources/extension_process_bindings.js +++ b/chrome/renderer/resources/extension_process_bindings.js @@ -405,6 +405,14 @@ var chrome = chrome || {}; [contentType, details, callback], extendSchema(clearSchema)); }; + this.getResourceIdentifiers = function(callback) { + var schema = this.parameters.getResourceIdentifiers; + chromeHidden.validate([callback], schema); + return sendRequest( + 'experimental.contentSettings.getResourceIdentifiers', + [contentType, callback], + extendSchema(schema)); + }; } ContentSetting.prototype = new CustomBindingsObject(); customBindings['ContentSetting'] = ContentSetting; diff --git a/chrome/test/data/extensions/api_test/content_settings/getresourceidentifiers/manifest.json b/chrome/test/data/extensions/api_test/content_settings/getresourceidentifiers/manifest.json new file mode 100644 index 0000000..ab04c76 --- /dev/null +++ b/chrome/test/data/extensions/api_test/content_settings/getresourceidentifiers/manifest.json @@ -0,0 +1,7 @@ +{ + "name" : "Content Settings API Test Extension", + "version" : "0.1", + "description" : "Content Settings API Test Extension", + "permissions": [ "experimental", "contentSettings" ], + "background_page": "test.html" +} diff --git a/chrome/test/data/extensions/api_test/content_settings/getresourceidentifiers/test.html b/chrome/test/data/extensions/api_test/content_settings/getresourceidentifiers/test.html new file mode 100644 index 0000000..210b84b --- /dev/null +++ b/chrome/test/data/extensions/api_test/content_settings/getresourceidentifiers/test.html @@ -0,0 +1,40 @@ +<script> +// Content settings API test +// Run with browser_tests +// --gtest_filter=ExtensionApiTest.ContentSettingsGetResourceIdentifiers + +Object.prototype.forEach = function(f) { + for (key in this) { + if (this.hasOwnProperty(key)) + f(key, this[key]); + } +} + +var cs = chrome.experimental.contentSettings; +chrome.test.runTests([ + function getResourceIdentifiers() { + var contentTypes = { + "cookies": undefined, + "images": undefined, + "javascript": undefined, + "plugins": [ + { + "description": "Foo", + "id": "foo", + }, + { + "description": "Bar Plugin", + "id": "bar.plugin", + }, + ], + "popups": undefined, + "notifications": undefined + }; + contentTypes.forEach(function(type, identifiers) { + cs[type].getResourceIdentifiers(chrome.test.callbackPass(function(value) { + chrome.test.assertEq(identifiers, value); + })); + }); + }, +]); +</script> diff --git a/webkit/plugins/npapi/mock_plugin_list.cc b/webkit/plugins/npapi/mock_plugin_list.cc new file mode 100644 index 0000000..5280052 --- /dev/null +++ b/webkit/plugins/npapi/mock_plugin_list.cc @@ -0,0 +1,33 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/plugins/npapi/mock_plugin_list.h" + +namespace webkit { +namespace npapi { + +MockPluginList::MockPluginList(const PluginGroupDefinition* group_definitions, + size_t num_group_definitions) : + PluginList(group_definitions, num_group_definitions) { +} + +MockPluginList::~MockPluginList() { +} + +void MockPluginList::AddPluginToLoad(const WebPluginInfo& plugin) { + plugins_to_load_.push_back(plugin); +} + +void MockPluginList::ClearPluginsToLoad() { + plugins_to_load_.clear(); +} + +void MockPluginList::LoadPluginsInternal( + ScopedVector<PluginGroup>* plugin_groups) { + for (size_t i = 0; i < plugins_to_load_.size(); ++i) + AddToPluginGroups(plugins_to_load_[i], plugin_groups); +} + +} // npapi +} // webkit diff --git a/webkit/plugins/npapi/mock_plugin_list.h b/webkit/plugins/npapi/mock_plugin_list.h new file mode 100644 index 0000000..15c11c9 --- /dev/null +++ b/webkit/plugins/npapi/mock_plugin_list.h @@ -0,0 +1,35 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_PLUGINS_NPAPI_MOCK_PLUGIN_LIST_H_ +#define WEBKIT_PLUGINS_NPAPI_MOCK_PLUGIN_LIST_H_ + +#include "webkit/plugins/npapi/plugin_list.h" + +namespace webkit { +namespace npapi { + +// A PluginList for tests that avoids file system IO. There is also no reason +// to use |lock_| (but it doesn't hurt either). +class MockPluginList : public PluginList { + public: + MockPluginList(const PluginGroupDefinition* group_definitions, + size_t num_group_definitions); + virtual ~MockPluginList(); + + void AddPluginToLoad(const WebPluginInfo& plugin); + void ClearPluginsToLoad(); + + private: + std::vector<WebPluginInfo> plugins_to_load_; + + // PluginList methods: + virtual void LoadPluginsInternal( + ScopedVector<PluginGroup>* plugin_groups) OVERRIDE; +}; + +} // npapi +} // webkit + +#endif // WEBKIT_PLUGINS_NPAPI_MOCK_PLUGIN_LIST_H_ diff --git a/webkit/plugins/npapi/plugin_group.h b/webkit/plugins/npapi/plugin_group.h index deb8461..fd0f8e3 100644 --- a/webkit/plugins/npapi/plugin_group.h +++ b/webkit/plugins/npapi/plugin_group.h @@ -26,9 +26,7 @@ namespace webkit { namespace npapi { class PluginList; -namespace plugin_test_internal { -class PluginListWithoutFileIO; -} +class MockPluginList; // Hard-coded version ranges for plugin groups. struct VersionRangeDefinition { @@ -202,7 +200,7 @@ class PluginGroup { private: friend class PluginList; - friend class plugin_test_internal::PluginListWithoutFileIO; + friend class MockPluginList; friend class PluginGroupTest; friend class ::TableModelArrayControllerTest; friend class ::PluginExceptionsTableModelTest; diff --git a/webkit/plugins/npapi/plugin_list_unittest.cc b/webkit/plugins/npapi/plugin_list_unittest.cc index d037e38..785fc3c 100644 --- a/webkit/plugins/npapi/plugin_list_unittest.cc +++ b/webkit/plugins/npapi/plugin_list_unittest.cc @@ -6,47 +6,11 @@ #include "base/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" +#include "webkit/plugins/npapi/mock_plugin_list.h" namespace webkit { namespace npapi { -namespace plugin_test_internal { - -// A PluginList for tests that avoids file system IO. There is also no reason -// to use |lock_| (but it doesn't hurt either). -class PluginListWithoutFileIO : public PluginList { - public: - PluginListWithoutFileIO(const PluginGroupDefinition* group_definitions, - size_t num_group_definitions) : - PluginList(group_definitions, num_group_definitions) {} - virtual ~PluginListWithoutFileIO() {} - - void AddPluginToLoad(const WebPluginInfo& plugin) { - plugins_to_load_.push_back(plugin); - } - - void ClearPluginsToLoad() { - plugins_to_load_.clear(); - } - - void AddPluginGroupDefinition(const PluginGroupDefinition& definition) { - hardcoded_definitions_.push_back(definition); - } - - private: - std::vector<WebPluginInfo> plugins_to_load_; - std::vector<PluginGroupDefinition> hardcoded_definitions_; - - // PluginList methods: - virtual void LoadPluginsInternal( - ScopedVector<PluginGroup>* plugin_groups) OVERRIDE { - for (size_t i = 0; i < plugins_to_load_.size(); ++i) - AddToPluginGroups(plugins_to_load_[i], plugin_groups); - } -}; - -} // namespace plugin_test_internal - namespace { bool Equals(const WebPluginInfo& a, const WebPluginInfo& b, @@ -103,7 +67,7 @@ class PluginListTest : public testing::Test { } protected: - plugin_test_internal::PluginListWithoutFileIO plugin_list_; + MockPluginList plugin_list_; WebPluginInfo foo_plugin_; WebPluginInfo bar_plugin_; }; diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi index 3cf6adc..37abb01 100644 --- a/webkit/tools/test_shell/test_shell.gypi +++ b/webkit/tools/test_shell/test_shell.gypi @@ -331,6 +331,17 @@ ], }, { + 'target_name': 'test_shell_test_support', + 'type': 'static_library', + 'dependencies': [ + '<(DEPTH)/webkit/support/webkit_support.gyp:glue' + ], + 'sources': [ + '../../plugins/npapi/mock_plugin_list.cc', + '../../plugins/npapi/mock_plugin_list.h', + ] + }, + { 'target_name': 'test_shell_tests', 'type': 'executable', 'variables': { @@ -343,6 +354,7 @@ ], 'dependencies': [ 'test_shell_common', + 'test_shell_test_support', '<(DEPTH)/base/base.gyp:test_support_base', '<(DEPTH)/media/media.gyp:media_test_support', '<(DEPTH)/net/net.gyp:net', |