diff options
author | avi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-06 16:48:45 +0000 |
---|---|---|
committer | avi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-06 16:48:45 +0000 |
commit | 690a99c80e4fe4e6eda9010b88e4438f57912336 (patch) | |
tree | 423390d4af89abd910ffd69f5e446720b1aa5b1f /webkit/glue | |
parent | 8c643f00166c14b146f8e5e0d2beedddacb58aab (diff) | |
download | chromium_src-690a99c80e4fe4e6eda9010b88e4438f57912336.zip chromium_src-690a99c80e4fe4e6eda9010b88e4438f57912336.tar.gz chromium_src-690a99c80e4fe4e6eda9010b88e4438f57912336.tar.bz2 |
Move plugins to FilePaths, some cleanup
Review URL: http://codereview.chromium.org/16456
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/chromium_bridge_impl.cc | 8 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_host.cc | 3 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_lib.cc | 44 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_lib.h | 11 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_list.cc | 114 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_list.h | 19 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.cc | 6 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 7 | ||||
-rw-r--r-- | webkit/glue/webplugin.h | 7 | ||||
-rw-r--r-- | webkit/glue/webplugin_delegate.h | 3 |
10 files changed, 125 insertions, 97 deletions
diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc index c75ab15..4e29dfc 100644 --- a/webkit/glue/chromium_bridge_impl.cc +++ b/webkit/glue/chromium_bridge_impl.cc @@ -323,8 +323,12 @@ bool ChromiumBridge::plugins(bool refresh, Vector<PluginInfo*>* results) { const WebPluginInfo& plugin = glue_plugins[i]; rv->name = webkit_glue::StdWStringToString(plugin.name); rv->desc = webkit_glue::StdWStringToString(plugin.desc); - rv->file = webkit_glue::StdWStringToString( - file_util::GetFilenameFromPath(plugin.file)); + rv->file = +#if defined(OS_WIN) + webkit_glue::StdWStringToString(plugin.file.BaseName().value()); +#elif defined(OS_POSIX) + webkit_glue::StdStringToString(plugin.file.BaseName().value()); +#endif for (size_t j = 0; j < plugin.mime_types.size(); ++ j) { MimeClassInfo* new_mime = new MimeClassInfo(); const WebPluginMimeType& mime_type = plugin.mime_types[j]; diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc index 12e6330..3be9304 100644 --- a/webkit/glue/plugins/plugin_host.cc +++ b/webkit/glue/plugins/plugin_host.cc @@ -759,7 +759,8 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) { // to worry about future standard change that may conflict with the // variable definition. scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin->plugin_lib()->plugin_info().file == kDefaultPluginDllName) + if (plugin->plugin_lib()->plugin_info().file.value() == + kDefaultPluginDllName) plugin->webplugin()->OnMissingPluginStatus( variable - default_plugin::kMissingPluginStatusStart); break; diff --git a/webkit/glue/plugins/plugin_lib.cc b/webkit/glue/plugins/plugin_lib.cc index 96296dc..5936747 100644 --- a/webkit/glue/plugins/plugin_lib.cc +++ b/webkit/glue/plugins/plugin_lib.cc @@ -15,6 +15,7 @@ #include "base/string_util.h" #include "base/sys_string_conversions.h" #include "base/task.h" +#include "net/base/mime_util.h" #include "webkit/activex_shim/npp_impl.h" #include "webkit/default_plugin/plugin_main.h" #include "webkit/glue/glue_util.h" @@ -23,7 +24,6 @@ #include "webkit/glue/plugins/plugin_instance.h" #include "webkit/glue/plugins/plugin_host.h" #include "webkit/glue/plugins/plugin_list.h" -#include "net/base/mime_util.h" namespace NPAPI @@ -34,14 +34,22 @@ const char kPluginInstancesActiveCounter[] = "PluginInstancesActive"; PluginLib::PluginMap* PluginLib::loaded_libs_; -PluginLib* PluginLib::CreatePluginLib(const std::wstring& filename) { +PluginLib* PluginLib::CreatePluginLib(const FilePath& filename) { + // For Windows we have a bit of a problem in that we might have the same path + // cased differently for two different plugin load paths. Therefore we do a + // quick lowercase for canonicalization's sake. WARNING: If you clone this + // file for other platforms, remove this lowercasing. This is *wrong* for + // other platforms (and arguably the wrong way to do it for Windows too, but + // let's not get into that here). + FilePath filename_lc(StringToLowerASCII(filename.value())); + // We can only have one PluginLib object per plugin as it controls the per // instance function calls (i.e. NP_Initialize and NP_Shutdown). So we keep // a (non-ref counted) map of PluginLib objects. if (!loaded_libs_) loaded_libs_ = new PluginMap(); - PluginMap::const_iterator iter = loaded_libs_->find(filename); + PluginMap::const_iterator iter = loaded_libs_->find(filename_lc); if (iter != loaded_libs_->end()) return iter->second; @@ -91,23 +99,24 @@ PluginLib* PluginLib::CreatePluginLib(const std::wstring& filename) { WebPluginInfo* info = NULL; const InternalPluginInfo* internal_plugin_info = NULL; - if (!_wcsicmp(filename.c_str(), + if (!_wcsicmp(filename.value().c_str(), activex_shim_info_generic.version_info.file_name.c_str())) { info = CreateWebPluginInfo(activex_shim_info_generic.version_info); internal_plugin_info = &activex_shim_info_generic; - } else if (!_wcsicmp(filename.c_str(), + } else if (!_wcsicmp(filename.value().c_str(), activex_shim_wmplayer.version_info.file_name.c_str())) { info = CreateWebPluginInfo(activex_shim_wmplayer.version_info); internal_plugin_info = &activex_shim_wmplayer; } else if (!_wcsicmp( - filename.c_str(), + filename.value().c_str(), default_plugin_info.version_info.file_name.c_str())) { info = CreateWebPluginInfo(default_plugin_info.version_info); internal_plugin_info = &default_plugin_info; } else { - info = ReadWebPluginInfo(filename); + info = ReadWebPluginInfo(filename_lc); if (!info) { - DLOG(INFO) << "This file isn't a valid NPAPI plugin: " << filename; + DLOG(INFO) << "This file isn't a valid NPAPI plugin: " + << filename.value(); return NULL; } } @@ -281,21 +290,20 @@ bool PluginLib::Load() { return rv; } -HMODULE PluginLib::LoadPluginHelper(const std::wstring plugin_file) { +HMODULE PluginLib::LoadPluginHelper(const FilePath plugin_file) { // Switch the current directory to the plugin directory as the plugin // may have dependencies on dlls in this directory. bool restore_directory = false; std::wstring current_directory; if (PathService::Get(base::DIR_CURRENT, ¤t_directory)) { - std::wstring plugin_path = file_util::GetDirectoryFromPath( - plugin_file); - if (!plugin_path.empty()) { - PathService::SetCurrentDirectory(plugin_path); + FilePath plugin_path = plugin_file.DirName(); + if (!plugin_path.value().empty()) { + PathService::SetCurrentDirectory(plugin_path.value()); restore_directory = true; } } - HMODULE module = LoadLibrary(plugin_file.c_str()); + HMODULE module = LoadLibrary(plugin_file.value().c_str()); if (restore_directory) PathService::SetCurrentDirectory(current_directory); @@ -376,7 +384,7 @@ WebPluginInfo* PluginLib::CreateWebPluginInfo(const PluginVersionInfo& pvi) { info->name = pvi.product_name; info->desc = pvi.file_description; info->version = pvi.file_version; - info->file = StringToLowerASCII(pvi.file_name); + info->file = FilePath(pvi.file_name); for (size_t i = 0; i < mime_types.size(); ++i) { WebPluginMimeType mime_type; @@ -403,14 +411,14 @@ WebPluginInfo* PluginLib::CreateWebPluginInfo(const PluginVersionInfo& pvi) { return info; } -WebPluginInfo* PluginLib::ReadWebPluginInfo(const std::wstring &filename) { +WebPluginInfo* PluginLib::ReadWebPluginInfo(const FilePath &filename) { // On windows, the way we get the mime types for the library is // to check the version information in the DLL itself. This // will be a string of the format: <type1>|<type2>|<type3>|... // For example: // video/quicktime|audio/aiff|image/jpeg scoped_ptr<FileVersionInfo> version_info( - FileVersionInfo::CreateFileVersionInfo(filename)); + FileVersionInfo::CreateFileVersionInfo(filename.value())); if (!version_info.get()) return NULL; @@ -421,7 +429,7 @@ WebPluginInfo* PluginLib::ReadWebPluginInfo(const std::wstring &filename) { pvi.product_name = version_info->product_name(); pvi.file_description = version_info->file_description(); pvi.file_version = version_info->file_version(); - pvi.file_name = filename; + pvi.file_name = filename.value(); return CreateWebPluginInfo(pvi); } diff --git a/webkit/glue/plugins/plugin_lib.h b/webkit/glue/plugins/plugin_lib.h index 06b7ef9..11b3498 100644 --- a/webkit/glue/plugins/plugin_lib.h +++ b/webkit/glue/plugins/plugin_lib.h @@ -10,6 +10,7 @@ #include <string> #include "base/basictypes.h" +#include "base/file_path.h" #include "base/hash_tables.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" @@ -49,7 +50,7 @@ struct InternalPluginInfo { class PluginLib : public base::RefCounted<PluginLib> { public: virtual ~PluginLib(); - static PluginLib* CreatePluginLib(const std::wstring& filename); + static PluginLib* CreatePluginLib(const FilePath& filename); // Unloads all the loaded plugin dlls and cleans up the plugin map. static void UnloadAllPlugins(); @@ -88,7 +89,7 @@ class PluginLib : public base::RefCounted<PluginLib> { #if defined(OS_WIN) // Helper function to load a plugin. // Returns the module handle on success. - static HMODULE LoadPluginHelper(const std::wstring plugin_file); + static HMODULE LoadPluginHelper(const FilePath plugin_file); #endif int instance_count() const { return instance_count_; } @@ -112,7 +113,7 @@ class PluginLib : public base::RefCounted<PluginLib> { // Returns a WebPluginInfo structure given a plugin's path. Returns NULL if // the dll couldn't be found, or if it's not a plugin. - static WebPluginInfo* ReadWebPluginInfo(const std::wstring &filename); + static WebPluginInfo* ReadWebPluginInfo(const FilePath &filename); // Creates WebPluginInfo structure based on read in or built in // PluginVersionInfo. static WebPluginInfo* CreateWebPluginInfo(const PluginVersionInfo& info); @@ -127,8 +128,8 @@ class PluginLib : public base::RefCounted<PluginLib> { NPSavedData *saved_data_; // persisted plugin info for NPAPI int instance_count_; // count of plugins in use - // A map of all the insantiated plugins. - typedef base::hash_map<std::wstring, scoped_refptr<PluginLib> > PluginMap; + // A map of all the instantiated plugins. + typedef base::hash_map<FilePath, scoped_refptr<PluginLib> > PluginMap; static PluginMap* loaded_libs_; // C-style function pointers diff --git a/webkit/glue/plugins/plugin_list.cc b/webkit/glue/plugins/plugin_list.cc index 7ef4b92..a41f800 100644 --- a/webkit/glue/plugins/plugin_list.cc +++ b/webkit/glue/plugins/plugin_list.cc @@ -52,8 +52,8 @@ static const TCHAR kRegistryBrowserJavaVersion[] = _T("BrowserJavaVersion"); static const TCHAR kRegistryCurrentJavaVersion[] = _T("CurrentVersion"); static const TCHAR kRegistryJavaHome[] = _T("JavaHome"); -// Extra registry paths to search. -static std::vector<std::wstring>* extra_plugin_paths_ = NULL; +// Extra paths to search. +static std::vector<FilePath>* extra_plugin_paths_ = NULL; PluginList* PluginList::Singleton() { if (singleton_.get() == NULL) { @@ -64,11 +64,11 @@ PluginList* PluginList::Singleton() { return singleton_; } -void PluginList::AddExtraPluginPath(const std::wstring& plugin_path) { +void PluginList::AddExtraPluginPath(const FilePath& plugin_path) { DCHECK(!singleton_.get() || !singleton_->plugins_loaded_); if (!extra_plugin_paths_) - extra_plugin_paths_ = new std::vector<std::wstring>; + extra_plugin_paths_ = new std::vector<FilePath>; extra_plugin_paths_->push_back(plugin_path); } @@ -123,7 +123,7 @@ void PluginList::LoadPlugins(bool refresh) { if (webkit_glue::IsDefaultPluginEnabled()) { scoped_refptr<PluginLib> default_plugin = PluginLib::CreatePluginLib( - kDefaultPluginDllName); + FilePath(kDefaultPluginDllName)); plugins_.push_back(default_plugin); } @@ -132,11 +132,11 @@ void PluginList::LoadPlugins(bool refresh) { DLOG(INFO) << "Loaded plugin list in " << elapsed.InMilliseconds() << " ms."; } -void PluginList::LoadPlugins(const std::wstring &path) { +void PluginList::LoadPlugins(const FilePath &path) { WIN32_FIND_DATA find_file_data; HANDLE find_handle; - std::wstring dir = path; + std::wstring dir = path.value(); // FindFirstFile requires that you specify a wildcard for directories. dir.append(L"\\NP*.DLL"); @@ -146,10 +146,7 @@ void PluginList::LoadPlugins(const std::wstring &path) { do { if (!(find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - std::wstring filename = path; - filename.append(L"\\"); - filename.append(find_file_data.cFileName); - + FilePath filename = path.Append(find_file_data.cFileName); LoadPlugin(filename); } } while (FindNextFile(find_handle, &find_file_data) != 0); @@ -158,12 +155,11 @@ void PluginList::LoadPlugins(const std::wstring &path) { FindClose(find_handle); } -void PluginList::LoadPlugin(const std::wstring &path) { - std::wstring path_lc = StringToLowerASCII(path); - if (!ShouldLoadPlugin(file_util::GetFilenameFromPath(path_lc))) +void PluginList::LoadPlugin(const FilePath &path) { + if (!ShouldLoadPlugin(path.BaseName())) return; - scoped_refptr<PluginLib> new_plugin = PluginLib::CreatePluginLib(path_lc); + scoped_refptr<PluginLib> new_plugin = PluginLib::CreatePluginLib(path); if (!new_plugin.get()) return; @@ -176,7 +172,7 @@ void PluginList::LoadPlugin(const std::wstring &path) { if (mime_type == "*" ) { #ifndef NDEBUG // Make an exception for NPSPY. - if (plugin_info.file.find(L"npspy.dll") != std::wstring::npos) { + if (plugin_info.file.value().find(L"npspy.dll") != std::wstring::npos) { // Put it at the beginning so it's used before the real plugin. plugins_.insert(plugins_.begin(), new_plugin.get()); } @@ -184,36 +180,41 @@ void PluginList::LoadPlugin(const std::wstring &path) { continue; } - if (!SupportsType(mime_type)) + if (!SupportsType(mime_type)) { plugins_.push_back(new_plugin); + return; + } } } -bool PluginList::ShouldLoadPlugin(const std::wstring& filename) { +bool PluginList::ShouldLoadPlugin(const FilePath& filename) { + // Canonicalize names. + std::wstring filename_lc = StringToLowerASCII(filename.value()); + // Depends on XPCOM. - if (filename == kMozillaActiveXPlugin) + if (filename_lc == kMozillaActiveXPlugin) return false; // Disable the yahoo application state plugin as it crashes the plugin // process on return from NPObjectStub::OnInvoke. Please refer to // http://b/issue?id=1372124 for more information. - if (filename == kYahooApplicationStatePlugin) + if (filename_lc == kYahooApplicationStatePlugin) return false; // We will use activex shim to handle embeded wmp media. if (use_internal_activex_shim_) { - if (filename == kNewWMPPlugin || filename == kOldWMPPlugin) + if (filename_lc == kNewWMPPlugin || filename_lc == kOldWMPPlugin) return false; } else { // If both the new and old WMP plugins exist, only load the new one. - if (filename == kNewWMPPlugin) { + if (filename_lc == kNewWMPPlugin) { if (dont_load_new_wmp_) return false; int old_plugin = FindPluginFile(kOldWMPPlugin); if (old_plugin != -1) plugins_.erase(plugins_.begin() + old_plugin); - } else if (filename == kOldWMPPlugin) { + } else if (filename_lc == kOldWMPPlugin) { if (FindPluginFile(kNewWMPPlugin) != -1) return false; } @@ -225,19 +226,21 @@ bool PluginList::ShouldLoadPlugin(const std::wstring& filename) { void PluginList::LoadInternalPlugins() { if (use_internal_activex_shim_) { scoped_refptr<PluginLib> new_plugin = PluginLib::CreatePluginLib( - kActiveXShimFileName); + FilePath(kActiveXShimFileName)); plugins_.push_back(new_plugin); new_plugin = PluginLib::CreatePluginLib( - kActivexShimFileNameForMediaPlayer); + FilePath(kActivexShimFileNameForMediaPlayer)); plugins_.push_back(new_plugin); } } int PluginList::FindPluginFile(const std::wstring& filename) { + std::string filename_narrow = WideToASCII(filename); for (size_t i = 0; i < plugins_.size(); ++i) { - if (file_util::GetFilenameFromPath(plugins_[i]->plugin_info().file) == - filename) { + if (LowerCaseEqualsASCII( + plugins_[i]->plugin_info().file.BaseName().value(), + filename_narrow.c_str())) { return static_cast<int>(i); } } @@ -253,7 +256,7 @@ PluginLib* PluginList::FindPlugin(const std::string& mime_type, for (size_t idx = 0; idx < plugins_.size(); ++idx) { if (plugins_[idx]->SupportsType(mime_type, allow_wildcard)) { if (!clsid.empty() && - plugins_[idx]->plugin_info().file == kActiveXShimFileName) { + plugins_[idx]->plugin_info().file.value() == kActiveXShimFileName) { // Special handling for ActiveX shim. If ActiveX is not installed, we // should use the default plugin to show the installation UI. if (!activex_shim::IsActiveXInstalled(clsid)) @@ -270,7 +273,7 @@ PluginLib* PluginList::FindPlugin(const GURL &url, std::string* actual_mime_type std::wstring path = base::SysNativeMBToWide(url.path()); std::wstring extension_wide = file_util::GetFileExtensionFromPath(path); if (extension_wide.empty()) - return NULL;; + return NULL; std::string extension = StringToLowerASCII(base::SysWideToNativeMB(extension_wide)); @@ -329,7 +332,8 @@ bool PluginList::GetPluginInfo(const GURL& url, allow_wildcard); if (plugin.get() == NULL || - (plugin->plugin_info().file == kDefaultPluginDllName && clsid.empty())) { + (plugin->plugin_info().file.value() == kDefaultPluginDllName + && clsid.empty())) { scoped_refptr<PluginLib> default_plugin = plugin; plugin = FindPlugin(url, actual_mime_type); // url matches may not return the default plugin if no match is found. @@ -344,11 +348,11 @@ bool PluginList::GetPluginInfo(const GURL& url, return true; } -bool PluginList::GetPluginInfoByDllPath(const std::wstring& dll_path, +bool PluginList::GetPluginInfoByDllPath(const FilePath& dll_path, WebPluginInfo* info) { for (size_t i = 0; i < plugins_.size(); ++i) { - if (wcsicmp(plugins_[i]->plugin_info().file.c_str(), - dll_path.c_str()) == 0) { + if (wcsicmp(plugins_[i]->plugin_info().file.value().c_str(), + dll_path.value().c_str()) == 0) { *info = plugins_[i]->plugin_info(); return true; } @@ -361,35 +365,43 @@ void PluginList::Shutdown() { // TODO } -std::wstring PluginList::GetPluginAppDirectory() { +FilePath PluginList::GetPluginAppDirectory() { std::wstring app_path; + // TODO(avi): use PathService directly if (webkit_glue::GetApplicationDirectory(&app_path)) app_path.append(L"\\plugins"); - return app_path; + return FilePath(app_path); } -std::wstring PluginList::GetPluginExeDirectory() { +FilePath PluginList::GetPluginExeDirectory() { std::wstring exe_path; + // TODO(avi): use PathService directly if (webkit_glue::GetExeDirectory(&exe_path)) exe_path.append(L"\\plugins"); - return exe_path; + return FilePath(exe_path); } // Gets the installed path for a registered app. -static bool GetInstalledPath(const TCHAR* app, std::wstring* out) { +static bool GetInstalledPath(const TCHAR* app, FilePath* out) { std::wstring reg_path(kRegistryApps); reg_path.append(L"\\"); reg_path.append(app); RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str()); - return key.ReadValue(kRegistryPath, out); + std::wstring path; + if (key.ReadValue(kRegistryPath, &path)) { + *out = FilePath(path); + return true; + } + + return false; } // Enumerate through the registry key to find all installed FireFox paths. // FireFox 3 beta and version 2 can coexist. See bug: 1025003 -static void GetFirefoxInstalledPaths(std::vector<std::wstring>* out) { +static void GetFirefoxInstalledPaths(std::vector<FilePath>* out) { RegistryKeyIterator it(HKEY_LOCAL_MACHINE, kRegistryFirefoxInstalled); for (; it.Valid(); ++it) { std::wstring full_path = std::wstring(kRegistryFirefoxInstalled) + L"\\" + @@ -398,15 +410,15 @@ static void GetFirefoxInstalledPaths(std::vector<std::wstring>* out) { std::wstring install_dir; if (!key.ReadValue(L"Install Directory", &install_dir)) continue; - out->push_back(install_dir); + out->push_back(FilePath(install_dir)); } } void PluginList::LoadFirefoxPlugins() { - std::vector<std::wstring> paths; + std::vector<FilePath> paths; GetFirefoxInstalledPaths(&paths); for (unsigned int i = 0; i < paths.size(); ++i) { - std::wstring path = paths[i] + L"\\plugins"; + FilePath path = paths[i].Append(L"plugins"); LoadPlugins(path); } @@ -416,31 +428,31 @@ void PluginList::LoadFirefoxPlugins() { std::wstring firefox_app_data_plugin_path; if (PathService::Get(base::DIR_APP_DATA, &firefox_app_data_plugin_path)) { firefox_app_data_plugin_path += L"\\Mozilla\\plugins"; - LoadPlugins(firefox_app_data_plugin_path); + LoadPlugins(FilePath(firefox_app_data_plugin_path)); } } void PluginList::LoadAcrobatPlugins() { - std::wstring path; + FilePath path; if (!GetInstalledPath(kRegistryAcrobatReader, &path) && !GetInstalledPath(kRegistryAcrobat, &path)) { return; } - path.append(L"\\Browser"); + path = path.Append(L"Browser"); LoadPlugins(path); } void PluginList::LoadQuicktimePlugins() { - std::wstring path; + FilePath path; if (GetInstalledPath(kRegistryQuickTime, &path)) { - path.append(L"\\plugins"); + path = path.Append(L"plugins"); LoadPlugins(path); } } void PluginList::LoadWindowsMediaPlugins() { - std::wstring path; + FilePath path; if (GetInstalledPath(kRegistryWindowsMedia, &path)) { LoadPlugins(path); } @@ -471,7 +483,7 @@ void PluginList::LoadJavaPlugin() { // 5. We don't know the exact name of the DLL but it's in the form // NP*.dll so just invoke LoadPlugins on this path. - LoadPlugins(java_plugin_directory); + LoadPlugins(FilePath(java_plugin_directory)); } } } @@ -489,7 +501,7 @@ void PluginList::LoadPluginsInRegistryFolder( std::wstring path; if (key.ReadValue(kRegistryPath, &path)) - LoadPlugin(path); + LoadPlugin(FilePath(path)); } } diff --git a/webkit/glue/plugins/plugin_list.h b/webkit/glue/plugins/plugin_list.h index 43cc46d..d2cab7d 100644 --- a/webkit/glue/plugins/plugin_list.h +++ b/webkit/glue/plugins/plugin_list.h @@ -53,7 +53,7 @@ class PluginList : public base::RefCounted<PluginList> { // Add an extra plugin to load when we actually do the loading. This is // static because we want to be able to add to it without searching the disk // for plugins. Must be called before the plugins have been loaded. - static void AddExtraPluginPath(const std::wstring& plugin_path); + static void AddExtraPluginPath(const FilePath& plugin_path); virtual ~PluginList(); @@ -104,7 +104,7 @@ class PluginList : public base::RefCounted<PluginList> { // Get plugin info by plugin dll path. Returns true if the plugin is found and // WebPluginInfo has been filled in |info| - bool GetPluginInfoByDllPath(const std::wstring& dll_path, + bool GetPluginInfoByDllPath(const FilePath& dll_path, WebPluginInfo* info); private: // Constructors are private for singletons @@ -114,27 +114,26 @@ class PluginList : public base::RefCounted<PluginList> { void LoadPlugins(bool refresh); // Load all plugins from a specific directory - void LoadPlugins(const std::wstring &path); + void LoadPlugins(const FilePath& path); - // Load a specific plugin with full path. filename can be mixed case. - void LoadPlugin(const std::wstring &filename); + // Load a specific plugin with full path. + void LoadPlugin(const FilePath& filename); // Returns true if we should load the given plugin, or false otherwise. - // filename must be lower case. - bool ShouldLoadPlugin(const std::wstring& filename); + bool ShouldLoadPlugin(const FilePath& filename); // Load internal plugins. Right now there is only one: activex_shim. void LoadInternalPlugins(); // Find a plugin by filename. Returns -1 if it's not found, otherwise its - // index in plugins_. filename needs to be lower case. + // index in plugins_. int FindPluginFile(const std::wstring& filename); // The application path where we expect to find plugins. - static std::wstring GetPluginAppDirectory(); + static FilePath GetPluginAppDirectory(); // The executable path where we expect to find plugins. - static std::wstring GetPluginExeDirectory(); + static FilePath GetPluginExeDirectory(); // Load plugins from the Firefox install path. This is kind of // a kludge, but it helps us locate the flash player for users that diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc index a48d7ed..655a37a 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl.cc @@ -51,7 +51,7 @@ bool WebPluginDelegateImpl::track_popup_menu_patched_ = false; iat_patch::IATPatchFunction WebPluginDelegateImpl::iat_patch_helper_; WebPluginDelegateImpl* WebPluginDelegateImpl::Create( - const std::wstring& filename, + const FilePath& filename, const std::string& mime_type, gfx::NativeView containing_view) { scoped_refptr<NPAPI::PluginLib> plugin = @@ -145,7 +145,7 @@ WebPluginDelegateImpl::WebPluginDelegateImpl( memset(&window_, 0, sizeof(window_)); const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info(); - std::wstring filename = file_util::GetFilenameFromPath(plugin_info.file); + std::wstring filename = plugin_info.file.BaseName().value(); if (instance_->mime_type() == "application/x-shockwave-flash" || filename == L"npswf32.dll") { @@ -365,7 +365,7 @@ void WebPluginDelegateImpl::DidManualLoadFail() { instance()->DidManualLoadFail(); } -std::wstring WebPluginDelegateImpl::GetPluginPath() { +FilePath WebPluginDelegateImpl::GetPluginPath() { return instance()->plugin_lib()->plugin_info().file; } diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index db3d8f3..a89189c 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -8,12 +8,13 @@ #include <string> #include <list> +#include "base/file_path.h" #include "base/gfx/native_widget_types.h" #include "base/iat_patch.h" #include "base/ref_counted.h" #include "base/task.h" -#include "webkit/glue/webplugin_delegate.h" #include "third_party/npapi/bindings/npapi.h" +#include "webkit/glue/webplugin_delegate.h" #include "webkit/glue/webcursor.h" namespace NPAPI { @@ -24,7 +25,7 @@ namespace NPAPI { // the plugin process. class WebPluginDelegateImpl : public WebPluginDelegate { public: - static WebPluginDelegateImpl* Create(const std::wstring& filename, + static WebPluginDelegateImpl* Create(const FilePath& filename, const std::string& mime_type, gfx::NativeView containing_view); static bool IsPluginDelegateWindow(HWND window); @@ -70,7 +71,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { virtual void DidReceiveManualData(const char* buffer, int length); virtual void DidFinishManualLoading(); virtual void DidManualLoadFail(); - virtual std::wstring GetPluginPath(); + virtual FilePath GetPluginPath(); virtual void InstallMissingPlugin(); virtual WebPluginResourceClient* CreateResourceClient(int resource_id, const std::string &url, diff --git a/webkit/glue/webplugin.h b/webkit/glue/webplugin.h index 8124857..96807fb 100644 --- a/webkit/glue/webplugin.h +++ b/webkit/glue/webplugin.h @@ -9,6 +9,7 @@ #include <vector> #include "base/basictypes.h" +#include "base/file_path.h" #include "base/gfx/rect.h" typedef struct HWND__* HWND; @@ -38,13 +39,13 @@ struct WebPluginInfo { // The name of the plugin (i.e. Flash). std::wstring name; - // The path to the dll. - std::wstring file; + // The path to the plugin file (DLL/bundle/library). + FilePath file; // The version number of the plugin file (may be OS-specific) std::wstring version; - // A description of the plugin that we get from it's version info. + // A description of the plugin that we get from its version info. std::wstring desc; // A list of all the mime types that this plugin supports. diff --git a/webkit/glue/webplugin_delegate.h b/webkit/glue/webplugin_delegate.h index df5716a..bfa462a 100644 --- a/webkit/glue/webplugin_delegate.h +++ b/webkit/glue/webplugin_delegate.h @@ -9,6 +9,7 @@ #include <vector> #include "base/basictypes.h" +#include "base/file_path.h" #include "base/gfx/native_widget_types.h" #include "base/gfx/rect.h" #include "third_party/npapi/bindings/npapi.h" @@ -104,7 +105,7 @@ class WebPluginDelegate { virtual void DidManualLoadFail() = 0; // Only Available after Initialize is called. - virtual std::wstring GetPluginPath() = 0; + virtual FilePath GetPluginPath() = 0; // Only Supported when the plugin is the default plugin. virtual void InstallMissingPlugin() = 0; |