diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-21 20:48:14 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-21 20:48:14 +0000 |
commit | cef7892773c40bbaf6da79cc9751c411a77c4da9 (patch) | |
tree | f39a6ec11ef0e9a957372cb814e6023656b98ec1 | |
parent | 74ed407aed52811af2f26230672602015c8c7100 (diff) | |
download | chromium_src-cef7892773c40bbaf6da79cc9751c411a77c4da9.zip chromium_src-cef7892773c40bbaf6da79cc9751c411a77c4da9.tar.gz chromium_src-cef7892773c40bbaf6da79cc9751c411a77c4da9.tar.bz2 |
Update the format of the Pepper Flash manifest.
Allow multiple "or" possibilities for interfaces. E.g., a string of the form
"Foo|Bar|Baz" indicates that (at least) one of the interfaces "Foo", "Bar",
"Baz" must be supported (for the plugin to be compatible).
This is needed so that we can remove support for old interfaces.
Review URL: http://codereview.chromium.org/9424018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122869 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 36 insertions, 26 deletions
diff --git a/chrome/browser/component_updater/component_installers_unittest.cc b/chrome/browser/component_updater/component_installers_unittest.cc index 4ebd973..14f8807 100644 --- a/chrome/browser/component_updater/component_installers_unittest.cc +++ b/chrome/browser/component_updater/component_installers_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -59,10 +59,6 @@ TEST(ComponentInstallerTest, PepperFlashCheck) { ASSERT_TRUE(root.get() != NULL); ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); - // This just tests the API (i.e., Pepper interfaces). - EXPECT_TRUE(VetoPepperFlashIntefaces( - static_cast<base::DictionaryValue*>(root.get()))); - // This checks that the whole manifest is compatible. Version version; EXPECT_TRUE(CheckPepperFlashManifest( diff --git a/chrome/browser/component_updater/flash_component_installer.h b/chrome/browser/component_updater/flash_component_installer.h index 95c3764..03a1d72 100644 --- a/chrome/browser/component_updater/flash_component_installer.h +++ b/chrome/browser/component_updater/flash_component_installer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -21,10 +21,6 @@ void RegisterNPAPIFlashComponent(ComponentUpdateService* cus); // The first part is IO intensive so we do it asynchronously in the file thread. void RegisterPepperFlashComponent(ComponentUpdateService* cus); -// Returns true if this browser implements all the interfaces that Flash -// specifies in its component installer manifest. -bool VetoPepperFlashIntefaces(base::DictionaryValue* manifest); - // Returns true if this browser is compatible with the given Pepper Flash // manifest, with the version specified in the manifest in |version_out|. bool CheckPepperFlashManifest(base::DictionaryValue* manifest, diff --git a/chrome/browser/component_updater/pepper_flash_component_installer.cc b/chrome/browser/component_updater/pepper_flash_component_installer.cc index 56f7c6c..9cde269 100644 --- a/chrome/browser/component_updater/pepper_flash_component_installer.cc +++ b/chrome/browser/component_updater/pepper_flash_component_installer.cc @@ -13,6 +13,7 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" +#include "base/string_split.h" #include "base/string_util.h" #include "base/stringprintf.h" #include "base/values.h" @@ -172,6 +173,38 @@ void RegisterPepperFlashWithChrome(const FilePath& path, PluginService::GetInstance()->RefreshPlugins(); } +// Returns true if this browser implements one of the interfaces given in +// |interface_string|, which is a '|'-separated string of interface names. +bool CheckPepperFlashInterfaceString(const std::string& interface_string) { + std::vector<std::string> interface_names; + base::SplitString(interface_string, '|', &interface_names); + for (size_t i = 0; i < interface_names.size(); i++) { + if (SupportsPepperInterface(interface_names[i].c_str())) + return true; + } + return false; +} + +// Returns true if this browser implements all the interfaces that Flash +// specifies in its component installer manifest. +bool CheckPepperFlashInterfaces(base::DictionaryValue* manifest) { + base::ListValue* interface_list = NULL; + + // We don't *require* an interface list, apparently. + if (!manifest->GetList("x-ppapi-required-interfaces", &interface_list)) + return true; + + for (size_t i = 0; i < interface_list->GetSize(); i++) { + std::string interface_string; + if (!interface_list->GetString(i, &interface_string)) + return false; + if (!CheckPepperFlashInterfaceString(interface_string)) + return false; + } + + return true; +} + } // namespace class PepperFlashComponentInstaller : public ComponentInstaller { @@ -226,21 +259,6 @@ bool PepperFlashComponentInstaller::Install(base::DictionaryValue* manifest, return true; } -bool VetoPepperFlashIntefaces(base::DictionaryValue* manifest) { - // Check that we implement the required interfaces. - base::ListValue* interfaces = NULL; - if (manifest->GetList("x-ppapi-required-interfaces", &interfaces)) { - for (size_t ix = 0; ix != interfaces->GetSize(); ++ix) { - std::string interface_name; - if (!interfaces->GetString(ix, &interface_name)) - return false; - if (!SupportsPepperInterface(interface_name.c_str())) - return false; - } - } - return true; -} - bool CheckPepperFlashManifest(base::DictionaryValue* manifest, Version* version_out) { std::string name; @@ -257,7 +275,7 @@ bool CheckPepperFlashManifest(base::DictionaryValue* manifest, if (!version.IsValid()) return false; - if (!VetoPepperFlashIntefaces(manifest)) + if (!CheckPepperFlashInterfaces(manifest)) return false; // TODO(viettrungluu): See above TODO. |