diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-19 22:23:36 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-19 22:23:36 +0000 |
commit | 9a60ccb9a18e801252c78aee635bb169bfb699e0 (patch) | |
tree | 7f63a140a43c63bbebc358633c54508424461778 /webkit | |
parent | 4ca60e35a3fc80e885a7296aaf742343e5ca8f30 (diff) | |
download | chromium_src-9a60ccb9a18e801252c78aee635bb169bfb699e0.zip chromium_src-9a60ccb9a18e801252c78aee635bb169bfb699e0.tar.gz chromium_src-9a60ccb9a18e801252c78aee635bb169bfb699e0.tar.bz2 |
Remove webkit/plugins/npapi.
-NPAPIPluginsSupported moves to PluginService
-no need to call it in PluginList methods anymore since PluginService is now the only place that calls these methods, and it can check first
-no need for the renderer to call this first since now the browser won't enumerate NPAPI plugins if it's disabled
-CreateVersionFromString moves to WebPluginInfo. I couldn't find a better place to put it.
-move the constants back to plugin_constants_win.h
-move PLUGIN_QUIRK_DIE_AFTER_UNLOAD handling to WebPluginDelegateStub and PluginThread instead of being a global
-GetDefaultWindowParent moves to plugin_constants_win.h. I couldn't find a better place.
-IsPluginWindow moves to PluginService
-GetPluginNameFromWindow and GetPluginVersionFromWindow are both replaced by GetPluginInfoFromWindow which is on PluginService
-IsDummyActivationWindow was called by one place so I moved the code there
BUG=237249
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/19844003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212672 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/npapi/DEPS | 3 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_utils.cc | 135 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_utils.h | 58 | ||||
-rw-r--r-- | webkit/plugins/webkit_plugins.gyp | 2 | ||||
-rw-r--r-- | webkit/plugins/webplugininfo.cc | 37 | ||||
-rw-r--r-- | webkit/plugins/webplugininfo.h | 9 | ||||
-rw-r--r-- | webkit/plugins/webplugininfo_unittest.cc (renamed from webkit/plugins/npapi/plugin_utils_unittest.cc) | 7 |
7 files changed, 49 insertions, 202 deletions
diff --git a/webkit/plugins/npapi/DEPS b/webkit/plugins/npapi/DEPS deleted file mode 100644 index e7cf2c6f..0000000 --- a/webkit/plugins/npapi/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - "+ui/base", -] diff --git a/webkit/plugins/npapi/plugin_utils.cc b/webkit/plugins/npapi/plugin_utils.cc deleted file mode 100644 index c110a44..0000000 --- a/webkit/plugins/npapi/plugin_utils.cc +++ /dev/null @@ -1,135 +0,0 @@ -// 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/plugin_utils.h" - -#include <algorithm> - -#include "base/strings/string_split.h" -#include "base/strings/string_util.h" -#include "base/version.h" - -#if defined(OS_WIN) -#include "ui/base/win/hwnd_util.h" -#endif - -namespace webkit { -namespace npapi { - -// Global variable used by the plugin quirk "die after unload". -bool g_forcefully_terminate_plugin_process = false; - -void CreateVersionFromString(const base::string16& version_string, - Version* parsed_version) { - // Remove spaces and ')' from the version string, - // Replace any instances of 'r', ',' or '(' with a dot. - std::string version = UTF16ToASCII(version_string); - RemoveChars(version, ") ", &version); - std::replace(version.begin(), version.end(), 'd', '.'); - std::replace(version.begin(), version.end(), 'r', '.'); - std::replace(version.begin(), version.end(), ',', '.'); - std::replace(version.begin(), version.end(), '(', '.'); - std::replace(version.begin(), version.end(), '_', '.'); - - // Remove leading zeros from each of the version components. - std::string no_leading_zeros_version; - std::vector<std::string> numbers; - base::SplitString(version, '.', &numbers); - for (size_t i = 0; i < numbers.size(); ++i) { - size_t n = numbers[i].size(); - size_t j = 0; - while (j < n && numbers[i][j] == '0') { - ++j; - } - no_leading_zeros_version += (j < n) ? numbers[i].substr(j) : "0"; - if (i != numbers.size() - 1) { - no_leading_zeros_version += "."; - } - } - - *parsed_version = Version(no_leading_zeros_version); -} - -bool NPAPIPluginsSupported() { -#if defined(OS_WIN) || defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(USE_AURA)) - return true; -#else - return false; -#endif -} - -void SetForcefullyTerminatePluginProcess(bool value) { - g_forcefully_terminate_plugin_process = value; -} - -bool ShouldForcefullyTerminatePluginProcess() { - return g_forcefully_terminate_plugin_process; -} - -#if defined(OS_WIN) - -const char16 kNativeWindowClassName[] = L"NativeWindowClass"; -const char16 kPluginNameAtomProperty[] = L"PluginNameAtom"; -const char16 kPluginVersionAtomProperty[] = L"PluginVersionAtom"; -const char16 kDummyActivationWindowName[] = L"DummyWindowForActivation"; - -namespace { - -bool GetPluginPropertyFromWindow( - HWND window, const wchar_t* plugin_atom_property, - base::string16* plugin_property) { - ATOM plugin_atom = reinterpret_cast<ATOM>( - GetPropW(window, plugin_atom_property)); - if (plugin_atom != 0) { - WCHAR plugin_property_local[MAX_PATH] = {0}; - GlobalGetAtomNameW(plugin_atom, - plugin_property_local, - ARRAYSIZE(plugin_property_local)); - *plugin_property = plugin_property_local; - return true; - } - return false; -} - -} // namespace - -bool IsPluginDelegateWindow(HWND window) { - return ui::GetClassName(window) == base::string16(kNativeWindowClassName); -} - -// static -bool GetPluginNameFromWindow( - HWND window, base::string16* plugin_name) { - return IsPluginDelegateWindow(window) && - GetPluginPropertyFromWindow( - window, kPluginNameAtomProperty, plugin_name); -} - -// static -bool GetPluginVersionFromWindow( - HWND window, base::string16* plugin_version) { - return IsPluginDelegateWindow(window) && - GetPluginPropertyFromWindow( - window, kPluginVersionAtomProperty, plugin_version); -} - -bool IsDummyActivationWindow(HWND window) { - if (!IsWindow(window)) - return false; - - wchar_t window_title[MAX_PATH + 1] = {0}; - if (GetWindowText(window, window_title, arraysize(window_title))) { - return (0 == lstrcmpiW(window_title, kDummyActivationWindowName)); - } - return false; -} - -HWND GetDefaultWindowParent() { - return GetDesktopWindow(); -} - -#endif - -} // namespace npapi -} // namespace webkit diff --git a/webkit/plugins/npapi/plugin_utils.h b/webkit/plugins/npapi/plugin_utils.h deleted file mode 100644 index 3cce1c5..0000000 --- a/webkit/plugins/npapi/plugin_utils.h +++ /dev/null @@ -1,58 +0,0 @@ -// 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. - -#ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_UTILS_H_ -#define WEBKIT_PLUGINS_NPAPI_PLUGIN_UTILS_H_ - -#include "base/strings/string16.h" -#include "ui/gfx/native_widget_types.h" - -namespace base { -class Version; -} - -namespace webkit { -namespace npapi { - -// Parse a version string as used by a plug-in. This method is more lenient -// in accepting weird version strings than base::Version::GetFromString() -void CreateVersionFromString( - const base::string16& version_string, - base::Version* parsed_version); - -// Returns true iff NPAPI plugins are supported on the current platform. -bool NPAPIPluginsSupported(); - -// Tells the plugin thread to terminate the process forcefully instead of -// exiting cleanly. -void SetForcefullyTerminatePluginProcess(bool value); - -// Returns true if the plugin thread should terminate the process forcefully -// instead of exiting cleanly. -bool ShouldForcefullyTerminatePluginProcess(); - -#if defined(OS_WIN) -// The window class name for a plugin window. -extern const char16 kNativeWindowClassName[]; -extern const char16 kPluginNameAtomProperty[]; -extern const char16 kPluginVersionAtomProperty[]; -extern const char16 kDummyActivationWindowName[]; - -bool IsPluginDelegateWindow(HWND window); -bool GetPluginNameFromWindow(HWND window, base::string16* plugin_name); -bool GetPluginVersionFromWindow(HWND window, base::string16* plugin_version); - -// Returns true if the window handle passed in is that of the dummy -// activation window for windowless plugins. -bool IsDummyActivationWindow(HWND window); - -// Returns the default HWND to parent the windowed plugins and dummy windows -// for activation to when none isavailable. -HWND GetDefaultWindowParent(); -#endif - -} // namespace npapi -} // namespace webkit - -#endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_UTILS_H_ diff --git a/webkit/plugins/webkit_plugins.gyp b/webkit/plugins/webkit_plugins.gyp index 605f3df..c4077a1 100644 --- a/webkit/plugins/webkit_plugins.gyp +++ b/webkit/plugins/webkit_plugins.gyp @@ -30,8 +30,6 @@ '../plugins/plugin_constants.h', '../plugins/plugin_switches.cc', '../plugins/plugin_switches.h', - '../plugins/npapi/plugin_utils.cc', - '../plugins/npapi/plugin_utils.h', '../common/plugins/ppapi/ppapi_utils.cc', '../common/plugins/ppapi/ppapi_utils.h', ], diff --git a/webkit/plugins/webplugininfo.cc b/webkit/plugins/webplugininfo.cc index f2f567c..1488307 100644 --- a/webkit/plugins/webplugininfo.cc +++ b/webkit/plugins/webplugininfo.cc @@ -4,8 +4,13 @@ #include "webkit/plugins/webplugininfo.h" +#include <algorithm> + #include "base/logging.h" +#include "base/strings/string_split.h" +#include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "base/version.h" namespace webkit { @@ -63,4 +68,36 @@ WebPluginInfo::WebPluginInfo(const base::string16& fake_name, pepper_permissions(0) { } +void WebPluginInfo::CreateVersionFromString( + const base::string16& version_string, + base::Version* parsed_version) { + // Remove spaces and ')' from the version string, + // Replace any instances of 'r', ',' or '(' with a dot. + std::string version = UTF16ToASCII(version_string); + RemoveChars(version, ") ", &version); + std::replace(version.begin(), version.end(), 'd', '.'); + std::replace(version.begin(), version.end(), 'r', '.'); + std::replace(version.begin(), version.end(), ',', '.'); + std::replace(version.begin(), version.end(), '(', '.'); + std::replace(version.begin(), version.end(), '_', '.'); + + // Remove leading zeros from each of the version components. + std::string no_leading_zeros_version; + std::vector<std::string> numbers; + base::SplitString(version, '.', &numbers); + for (size_t i = 0; i < numbers.size(); ++i) { + size_t n = numbers[i].size(); + size_t j = 0; + while (j < n && numbers[i][j] == '0') { + ++j; + } + no_leading_zeros_version += (j < n) ? numbers[i].substr(j) : "0"; + if (i != numbers.size() - 1) { + no_leading_zeros_version += "."; + } + } + + *parsed_version = Version(no_leading_zeros_version); +} + } // namespace webkit diff --git a/webkit/plugins/webplugininfo.h b/webkit/plugins/webplugininfo.h index befb3c7..0307eba 100644 --- a/webkit/plugins/webplugininfo.h +++ b/webkit/plugins/webplugininfo.h @@ -11,6 +11,10 @@ #include "base/basictypes.h" #include "base/files/file_path.h" +namespace base { +class Version; +} + namespace webkit { struct WebPluginMimeType { @@ -62,6 +66,11 @@ struct WebPluginInfo { (type == PLUGIN_TYPE_PEPPER_UNSANDBOXED)); } + // Parse a version string as used by a plug-in. This method is more lenient + // in accepting weird version strings than base::Version::GetFromString() + static void CreateVersionFromString(const base::string16& version_string, + base::Version* parsed_version); + // The name of the plugin (i.e. Flash). base::string16 name; diff --git a/webkit/plugins/npapi/plugin_utils_unittest.cc b/webkit/plugins/webplugininfo_unittest.cc index 780c112..11da25a 100644 --- a/webkit/plugins/npapi/plugin_utils_unittest.cc +++ b/webkit/plugins/webplugininfo_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "webkit/plugins/npapi/plugin_utils.h" +#include "webkit/plugins/webplugininfo.h" #include <string> #include <vector> @@ -13,7 +13,6 @@ #include "testing/gtest/include/gtest/gtest.h" namespace webkit { -namespace npapi { TEST(PluginUtilsTest, VersionExtraction) { // Some real-world plugin versions (spaces, commata, parentheses, 'r', oh my) @@ -33,12 +32,12 @@ TEST(PluginUtilsTest, VersionExtraction) { for (size_t i = 0; i < arraysize(versions); i++) { Version version; - CreateVersionFromString(ASCIIToUTF16(versions[i][0]), &version); + WebPluginInfo::CreateVersionFromString( + ASCIIToUTF16(versions[i][0]), &version); ASSERT_TRUE(version.IsValid()); EXPECT_EQ(versions[i][1], version.GetString()); } } -} // namespace npapi } // namespace webkit |