Chromium Code Reviews| Index: chrome/browser/component_updater/pepper_flash_component_installer.cc |
| diff --git a/chrome/browser/component_updater/pepper_flash_component_installer.cc b/chrome/browser/component_updater/pepper_flash_component_installer.cc |
| index e442d5da7170d8aa57b80c3eb18de158a3b036d6..b2296953ed54680cdafb9a4ac9b6435c09b2bcd6 100644 |
| --- a/chrome/browser/component_updater/pepper_flash_component_installer.cc |
| +++ b/chrome/browser/component_updater/pepper_flash_component_installer.cc |
| @@ -9,6 +9,7 @@ |
| #include <vector> |
| #include "base/base_paths.h" |
| +#include "base/base_paths_win.h" |
| #include "base/bind.h" |
| #include "base/command_line.h" |
| #include "base/compiler_specific.h" |
| @@ -90,6 +91,17 @@ base::FilePath GetPepperFlashBaseDirectory() { |
| return result; |
| } |
| +// Install directory for pepper flash debugger dlls will be like |
| +// c:\windows\system32\macromed\flash\, or basically the Macromed\Flash |
| +// subdirectory of the Windows system directory. |
| +base::FilePath GetPepperFlashDebuggerDirectory() { |
| + base::FilePath result; |
| + PathService::Get(base::DIR_SYSTEM, &result); |
| + base::FilePath subdir; |
| + PathService::Get(chrome::DIR_PEPPER_FLASH_DEBUGGER_PLUGIN, &subdir); |
|
cpu_(ooo_6.6-7.5)
2014/04/24 20:42:04
any reason not to return the full path when chrome
luken
2014/04/24 22:04:15
Done.
|
| + return result.Append(subdir); |
| +} |
| + |
| #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) |
| // Pepper Flash plugins have the version encoded in the path itself |
| // so we need to enumerate the directories to find the full path. |
| @@ -127,6 +139,65 @@ bool GetPepperFlashDirectory(base::FilePath* latest_dir, |
| } |
| #endif |
| +const wchar_t kPepperFlashDebuggerDLLSearchString[] = |
| +#if defined(ARCH_CPU_X86) |
| + L"pepflashplayer32*.dll"; |
| +#elif defined(ARCH_CPU_X86_64) |
| + L"pepflashplayer64*.dll"; |
| +#else // TODO(luken): ARM flash debugger? |
| + L"???"; |
|
cpu_(ooo_6.6-7.5)
2014/04/24 20:42:04
elif defined(ARCH_CPU_ARM_FAMILY) ?
luken
2014/04/24 22:04:15
Done.
|
| +#endif |
| + |
| +bool GetPepperFlashDebuggerPath(base::FilePath* dll_path, |
| + Version* dll_version) { |
|
cpu_(ooo_6.6-7.5)
2014/04/24 20:42:04
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::F
luken
2014/04/24 22:04:15
We are on the file IO thread, and the other functi
|
| + base::FilePath debugger_dir = GetPepperFlashDebuggerDirectory(); |
| + // If path doesn't exist they simply don't have the flash debugger installed. |
| + if (!base::PathExists(debugger_dir)) { |
|
cpu_(ooo_6.6-7.5)
2014/04/24 20:42:04
if the style of this file has single statement ifs
luken
2014/04/24 22:04:15
Done.
|
| + return false; |
| + } |
| + bool found = false; |
| + // Enumerate any DLLs that match the appropriate pattern for this DLL, and |
| + // pick the highest version number we find. |
| + base::FileEnumerator file_enumerator(debugger_dir, |
| + false, |
| + base::FileEnumerator::FILES, |
| + kPepperFlashDebuggerDLLSearchString); |
| + for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); |
| + path = file_enumerator.Next()) { |
| + // Version number is embedded in file name like basename_x_y_z.dll. Extract. |
| + std::string file_name(path.BaseName().MaybeAsASCII()); |
|
cpu_(ooo_6.6-7.5)
2014/04/24 20:42:04
I have the feeling that using base/strings/string_
luken
2014/04/24 22:04:15
I didn't know about this, yes!
|
| + std::size_t ver_start = file_name.find_first_of("_"); |
| + if (ver_start == std::string::npos) |
| + continue; |
| + // Add one to the ver_start to skip over the starting underscore. |
| + ++ver_start; |
| + std::size_t ver_end = file_name.find_first_of(".", ver_start); |
| + if (ver_end == std::string::npos) |
| + continue; |
| + std::string version_string = |
| + file_name.substr(ver_start, ver_end - ver_start); |
| + // Now swap all the underscores for dots, so our version object can parse. |
| + for (std::size_t i = 0; i < version_string.length(); ++i) { |
| + if (version_string[i] == '_') |
| + version_string[i] = '.'; |
| + } |
| + Version version(version_string); |
| + if (!version.IsValid()) |
| + continue; |
| + if (found) { |
| + if (version.CompareTo(*dll_version) > 0) { |
| + *dll_path = path; |
| + *dll_version = version; |
| + } |
| + } else { |
| + *dll_path = path; |
| + *dll_version = version; |
| + found = true; |
| + } |
| + } |
| + return found; |
| +} |
| + |
| // Returns true if the Pepper |interface_name| is implemented by this browser. |
| // It does not check if the interface is proxied. |
| bool SupportsPepperInterface(const char* interface_name) { |
| @@ -142,6 +213,7 @@ bool SupportsPepperInterface(const char* interface_name) { |
| bool MakePepperFlashPluginInfo(const base::FilePath& flash_path, |
| const Version& flash_version, |
| bool out_of_process, |
| + bool is_debugger, |
| content::PepperPluginInfo* plugin_info) { |
| if (!flash_version.IsValid()) |
| return false; |
| @@ -158,6 +230,9 @@ bool MakePepperFlashPluginInfo(const base::FilePath& flash_path, |
| // The description is like "Shockwave Flash 10.2 r154". |
| plugin_info->description = base::StringPrintf("%s %d.%d r%d", |
| content::kFlashPluginName, ver_nums[0], ver_nums[1], ver_nums[2]); |
| + if (is_debugger) { |
| + plugin_info->description += " Debug"; |
| + } |
| plugin_info->version = flash_version.GetString(); |
| @@ -181,33 +256,45 @@ bool IsPepperFlash(const content::WebPluginInfo& plugin) { |
| } |
| void RegisterPepperFlashWithChrome(const base::FilePath& path, |
| - const Version& version) { |
| + const Version& version, |
| + bool is_debugger) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| content::PepperPluginInfo plugin_info; |
| - if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) |
| + if (!MakePepperFlashPluginInfo( |
| + path, version, true, is_debugger, &plugin_info)) |
| return; |
| - std::vector<content::WebPluginInfo> plugins; |
| - PluginService::GetInstance()->GetInternalPlugins(&plugins); |
| - for (std::vector<content::WebPluginInfo>::const_iterator it = plugins.begin(); |
| - it != plugins.end(); ++it) { |
| - if (!IsPepperFlash(*it)) |
| - continue; |
| + // If this is the non-debugger version, we enumerate any installed versions of |
| + // pepper flash to make sure we only replace the installed version with a |
| + // newer version. |
| + if (!is_debugger) { |
| + std::vector<content::WebPluginInfo> plugins; |
| + PluginService::GetInstance()->GetInternalPlugins(&plugins); |
| + for (std::vector<content::WebPluginInfo>::const_iterator it = |
| + plugins.begin(); |
| + it != plugins.end(); |
| + ++it) { |
| + if (!IsPepperFlash(*it)) |
| + continue; |
| + |
| + // Do it only if the version we're trying to register is newer. |
| + Version registered_version(base::UTF16ToUTF8(it->version)); |
| + if (registered_version.IsValid() && |
| + version.CompareTo(registered_version) <= 0) { |
| + return; |
| + } |
| - // Do it only if the version we're trying to register is newer. |
| - Version registered_version(base::UTF16ToUTF8(it->version)); |
| - if (registered_version.IsValid() && |
| - version.CompareTo(registered_version) <= 0) { |
| - return; |
| + // If the version is newer, remove the old one first. |
| + PluginService::GetInstance()->UnregisterInternalPlugin(it->path); |
| + break; |
| } |
| - |
| - // If the version is newer, remove the old one first. |
| - PluginService::GetInstance()->UnregisterInternalPlugin(it->path); |
| - break; |
| } |
| + // We only ask for registration at the beginning for the non-debugger plugin, |
| + // that way the debugger plugin doesn't automatically clobber the built-in or |
| + // updated non-debugger version. |
| PluginService::GetInstance()->RegisterInternalPlugin( |
| - plugin_info.ToWebPluginInfo(), true); |
| + plugin_info.ToWebPluginInfo(), !is_debugger); |
| PluginService::GetInstance()->RefreshPlugins(); |
| } |
| @@ -296,8 +383,9 @@ bool PepperFlashComponentInstaller::Install( |
| PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path); |
| path = path.Append(chrome::kPepperFlashPluginFilename); |
| BrowserThread::PostTask( |
| - BrowserThread::UI, FROM_HERE, |
| - base::Bind(&RegisterPepperFlashWithChrome, path, version)); |
| + BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind(&RegisterPepperFlashWithChrome, path, version, false)); |
| return true; |
| } |
| @@ -377,8 +465,9 @@ void StartPepperFlashUpdateRegistration(ComponentUpdateService* cus) { |
| path = path.Append(chrome::kPepperFlashPluginFilename); |
| if (base::PathExists(path)) { |
| BrowserThread::PostTask( |
| - BrowserThread::UI, FROM_HERE, |
| - base::Bind(&RegisterPepperFlashWithChrome, path, version)); |
| + BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind(&RegisterPepperFlashWithChrome, path, version, false)); |
| } else { |
| version = Version(kNullVersion); |
| } |
| @@ -393,6 +482,18 @@ void StartPepperFlashUpdateRegistration(ComponentUpdateService* cus) { |
| iter != older_dirs.end(); ++iter) { |
| base::DeleteFile(*iter, true); |
| } |
| + |
| + // Check for Debugging version of Flash and register if present. |
| + base::FilePath debugger_path; |
| + Version debugger_version(kNullVersion); |
| + if (GetPepperFlashDebuggerPath(&debugger_path, &debugger_version)) { |
| + BrowserThread::PostTask(BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind(&RegisterPepperFlashWithChrome, |
| + debugger_path, |
| + debugger_version, |
| + true)); |
| + } |
| } |
| #endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) |