Commit 49799b6d authored by luken@chromium.org's avatar luken@chromium.org

Modifies the pepper flash component installer to also look in a path under the...

Modifies the pepper flash component installer to also look in a path under the Windows system directory for a debugger version of the flash DLL. This DLL is not registered as a chrome component. It is configured to load after the non-debugger flash DLL.

BUG=345886

Review URL: https://codereview.chromium.org/203993004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266761 0039d316-1c4b-4281-b951-d872f2087c98
parent 6725ec53
...@@ -91,6 +91,15 @@ base::FilePath GetPepperFlashBaseDirectory() { ...@@ -91,6 +91,15 @@ base::FilePath GetPepperFlashBaseDirectory() {
} }
#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
// 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(chrome::DIR_PEPPER_FLASH_DEBUGGER_PLUGIN, &result);
return result;
}
// Pepper Flash plugins have the version encoded in the path itself // Pepper Flash plugins have the version encoded in the path itself
// so we need to enumerate the directories to find the full path. // so we need to enumerate the directories to find the full path.
// On success, |latest_dir| returns something like: // On success, |latest_dir| returns something like:
...@@ -100,6 +109,7 @@ base::FilePath GetPepperFlashBaseDirectory() { ...@@ -100,6 +109,7 @@ base::FilePath GetPepperFlashBaseDirectory() {
bool GetPepperFlashDirectory(base::FilePath* latest_dir, bool GetPepperFlashDirectory(base::FilePath* latest_dir,
Version* latest_version, Version* latest_version,
std::vector<base::FilePath>* older_dirs) { std::vector<base::FilePath>* older_dirs) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
base::FilePath base_dir = GetPepperFlashBaseDirectory(); base::FilePath base_dir = GetPepperFlashBaseDirectory();
bool found = false; bool found = false;
base::FileEnumerator base::FileEnumerator
...@@ -125,7 +135,68 @@ bool GetPepperFlashDirectory(base::FilePath* latest_dir, ...@@ -125,7 +135,68 @@ bool GetPepperFlashDirectory(base::FilePath* latest_dir,
} }
return found; return found;
} }
#if defined(OS_WIN)
const wchar_t kPepperFlashDebuggerDLLSearchString[] =
#if defined(ARCH_CPU_X86)
L"pepflashplayer32*.dll";
#elif defined(ARCH_CPU_X86_64)
L"pepflashplayer64*.dll";
#else
#error Unsupported Windows CPU architecture.
#endif // defined(ARCH_CPU_X86)
#endif // defined(OS_WIN)
bool GetPepperFlashDebuggerPath(base::FilePath* dll_path,
Version* dll_version) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
base::FilePath debugger_dir = GetPepperFlashDebuggerDirectory();
// If path doesn't exist they simply don't have the flash debugger installed.
if (!base::PathExists(debugger_dir))
return false;
bool found = false;
#if defined(OS_WIN)
// 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().RemoveExtension().MaybeAsASCII());
// file_name should now be basename_x_y_z. Split along '_' for version.
std::vector<std::string> components;
base::SplitString(file_name, '_', &components);
// Should have at least one version number.
if (components.size() <= 1)
continue;
// Meld version components back into a string, now separated by periods, so
// Version can parse it.
std::string version_string(components[1]);
for (size_t i = 2; i < components.size(); ++i) {
version_string += "." + components[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;
}
}
#endif #endif
return found;
}
#endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
// Returns true if the Pepper |interface_name| is implemented by this browser. // Returns true if the Pepper |interface_name| is implemented by this browser.
// It does not check if the interface is proxied. // It does not check if the interface is proxied.
...@@ -142,6 +213,7 @@ bool SupportsPepperInterface(const char* interface_name) { ...@@ -142,6 +213,7 @@ bool SupportsPepperInterface(const char* interface_name) {
bool MakePepperFlashPluginInfo(const base::FilePath& flash_path, bool MakePepperFlashPluginInfo(const base::FilePath& flash_path,
const Version& flash_version, const Version& flash_version,
bool out_of_process, bool out_of_process,
bool is_debugger,
content::PepperPluginInfo* plugin_info) { content::PepperPluginInfo* plugin_info) {
if (!flash_version.IsValid()) if (!flash_version.IsValid())
return false; return false;
...@@ -158,6 +230,9 @@ bool MakePepperFlashPluginInfo(const base::FilePath& flash_path, ...@@ -158,6 +230,9 @@ bool MakePepperFlashPluginInfo(const base::FilePath& flash_path,
// The description is like "Shockwave Flash 10.2 r154". // The description is like "Shockwave Flash 10.2 r154".
plugin_info->description = base::StringPrintf("%s %d.%d r%d", plugin_info->description = base::StringPrintf("%s %d.%d r%d",
content::kFlashPluginName, ver_nums[0], ver_nums[1], ver_nums[2]); content::kFlashPluginName, ver_nums[0], ver_nums[1], ver_nums[2]);
if (is_debugger) {
plugin_info->description += " Debug";
}
plugin_info->version = flash_version.GetString(); plugin_info->version = flash_version.GetString();
...@@ -181,33 +256,45 @@ bool IsPepperFlash(const content::WebPluginInfo& plugin) { ...@@ -181,33 +256,45 @@ bool IsPepperFlash(const content::WebPluginInfo& plugin) {
} }
void RegisterPepperFlashWithChrome(const base::FilePath& path, void RegisterPepperFlashWithChrome(const base::FilePath& path,
const Version& version) { const Version& version,
bool is_debugger) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
content::PepperPluginInfo plugin_info; content::PepperPluginInfo plugin_info;
if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) if (!MakePepperFlashPluginInfo(
path, version, true, is_debugger, &plugin_info))
return; return;
std::vector<content::WebPluginInfo> plugins; // If this is the non-debugger version, we enumerate any installed versions of
PluginService::GetInstance()->GetInternalPlugins(&plugins); // pepper flash to make sure we only replace the installed version with a
for (std::vector<content::WebPluginInfo>::const_iterator it = plugins.begin(); // newer version.
it != plugins.end(); ++it) { if (!is_debugger) {
if (!IsPepperFlash(*it)) std::vector<content::WebPluginInfo> plugins;
continue; 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. // If the version is newer, remove the old one first.
Version registered_version(base::UTF16ToUTF8(it->version)); PluginService::GetInstance()->UnregisterInternalPlugin(it->path);
if (registered_version.IsValid() && break;
version.CompareTo(registered_version) <= 0) {
return;
} }
// 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( PluginService::GetInstance()->RegisterInternalPlugin(
plugin_info.ToWebPluginInfo(), true); plugin_info.ToWebPluginInfo(), !is_debugger);
PluginService::GetInstance()->RefreshPlugins(); PluginService::GetInstance()->RefreshPlugins();
} }
...@@ -296,8 +383,9 @@ bool PepperFlashComponentInstaller::Install( ...@@ -296,8 +383,9 @@ bool PepperFlashComponentInstaller::Install(
PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path); PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path);
path = path.Append(chrome::kPepperFlashPluginFilename); path = path.Append(chrome::kPepperFlashPluginFilename);
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI,
base::Bind(&RegisterPepperFlashWithChrome, path, version)); FROM_HERE,
base::Bind(&RegisterPepperFlashWithChrome, path, version, false));
return true; return true;
} }
...@@ -377,8 +465,9 @@ void StartPepperFlashUpdateRegistration(ComponentUpdateService* cus) { ...@@ -377,8 +465,9 @@ void StartPepperFlashUpdateRegistration(ComponentUpdateService* cus) {
path = path.Append(chrome::kPepperFlashPluginFilename); path = path.Append(chrome::kPepperFlashPluginFilename);
if (base::PathExists(path)) { if (base::PathExists(path)) {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI,
base::Bind(&RegisterPepperFlashWithChrome, path, version)); FROM_HERE,
base::Bind(&RegisterPepperFlashWithChrome, path, version, false));
} else { } else {
version = Version(kNullVersion); version = Version(kNullVersion);
} }
...@@ -393,13 +482,25 @@ void StartPepperFlashUpdateRegistration(ComponentUpdateService* cus) { ...@@ -393,13 +482,25 @@ void StartPepperFlashUpdateRegistration(ComponentUpdateService* cus) {
iter != older_dirs.end(); ++iter) { iter != older_dirs.end(); ++iter) {
base::DeleteFile(*iter, true); 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) #endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
} // namespace } // namespace
void RegisterPepperFlashComponent(ComponentUpdateService* cus) { void RegisterPepperFlashComponent(ComponentUpdateService* cus) {
#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
// Component updated flash supersedes bundled flash therefore if that one // Component updated flash supersedes bundled flash therefore if that one
// is disabled then this one should never install. // is disabled then this one should never install.
CommandLine* cmd_line = CommandLine::ForCurrentProcess(); CommandLine* cmd_line = CommandLine::ForCurrentProcess();
...@@ -407,7 +508,7 @@ void RegisterPepperFlashComponent(ComponentUpdateService* cus) { ...@@ -407,7 +508,7 @@ void RegisterPepperFlashComponent(ComponentUpdateService* cus) {
return; return;
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
base::Bind(&StartPepperFlashUpdateRegistration, cus)); base::Bind(&StartPepperFlashUpdateRegistration, cus));
#endif #endif
} }
} // namespace component_updater } // namespace component_updater
......
...@@ -44,6 +44,11 @@ const base::FilePath::CharType kInternalFlashPluginFileName[] = ...@@ -44,6 +44,11 @@ const base::FilePath::CharType kInternalFlashPluginFileName[] =
const base::FilePath::CharType kPepperFlashBaseDirectory[] = const base::FilePath::CharType kPepperFlashBaseDirectory[] =
FILE_PATH_LITERAL("PepperFlash"); FILE_PATH_LITERAL("PepperFlash");
#if defined(OS_WIN)
const base::FilePath::CharType kPepperFlashDebuggerBaseDirectory[] =
FILE_PATH_LITERAL("Macromed\\Flash");
#endif
// File name of the internal PDF plugin on different platforms. // File name of the internal PDF plugin on different platforms.
const base::FilePath::CharType kInternalPDFPluginFileName[] = const base::FilePath::CharType kInternalPDFPluginFileName[] =
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -263,6 +268,19 @@ bool PathProvider(int key, base::FilePath* result) { ...@@ -263,6 +268,19 @@ bool PathProvider(int key, base::FilePath* result) {
return false; return false;
cur = cur.Append(kPepperFlashBaseDirectory); cur = cur.Append(kPepperFlashBaseDirectory);
break; break;
case chrome::DIR_PEPPER_FLASH_DEBUGGER_PLUGIN:
#if defined(OS_WIN)
if (!PathService::Get(base::DIR_SYSTEM, &cur))
return false;
cur = cur.Append(kPepperFlashDebuggerBaseDirectory);
#elif defined(OS_MACOSX)
// TODO(luken): finalize Mac OS directory paths, current consensus is
// around /Library/Internet Plug-Ins/PepperFlashPlayer/
return false;
#else
return false;
#endif
break;
case chrome::FILE_LOCAL_STATE: case chrome::FILE_LOCAL_STATE:
if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
return false; return false;
......
...@@ -70,6 +70,8 @@ enum { ...@@ -70,6 +70,8 @@ enum {
DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, // Base directory of the Pepper DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, // Base directory of the Pepper
// Flash plugins downloaded by the // Flash plugins downloaded by the
// component updater. // component updater.
DIR_PEPPER_FLASH_DEBUGGER_PLUGIN, // Base directory of the debugging version
// of the Pepper Flash plugin.
FILE_RESOURCE_MODULE, // Full path and filename of the module that FILE_RESOURCE_MODULE, // Full path and filename of the module that
// contains embedded resources (version, // contains embedded resources (version,
// strings, images, etc.). // strings, images, etc.).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment