Commit 21620c21 authored by yzshen@chromium.org's avatar yzshen@chromium.org

Fix the issue that Pepper Flash cannot load on Linux.

BUG=125480
TEST=None


Review URL: http://codereview.chromium.org/10281007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134856 0039d316-1c4b-4281-b951-d872f2087c98
parent 319f8fda
......@@ -769,7 +769,8 @@ void BrowserProcessImpl::PreMainMessageLoopRun() {
bool add_at_beginning = false;
chrome::ChromeContentClient* content_client =
static_cast<chrome::ChromeContentClient*>(content::GetContentClient());
if (content_client->GetBundledPepperFlash(&plugin, &add_at_beginning)) {
if (content_client->GetBundledFieldTrialPepperFlash(&plugin,
&add_at_beginning)) {
plugin_service->RegisterInternalPlugin(plugin.ToWebPluginInfo(),
add_at_beginning);
}
......
......@@ -252,6 +252,38 @@ void AddPepperFlashFromCommandLine(
CreatePepperFlashInfo(FilePath(flash_path), flash_version));
}
bool GetBundledPepperFlash(content::PepperPluginInfo* plugin,
bool* override_npapi_flash) {
#if defined(FLAPPER_AVAILABLE)
// Ignore bundled Pepper Flash if there is Pepper Flash specified from the
// command-line.
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kPpapiFlashPath))
return false;
bool force_disable = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableBundledPpapiFlash);
if (force_disable)
return false;
FilePath flash_path;
if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path))
return false;
// It is an error to have FLAPPER_AVAILABLE defined but then not having the
// plugin file in place, but this happens in Chrome OS builds.
// Use --disable-bundled-ppapi-flash to skip this.
DCHECK(file_util::PathExists(flash_path));
bool force_enable = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBundledPpapiFlash);
*plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING);
*override_npapi_flash = force_enable || IsPepperFlashEnabledByDefault();
return true;
#else
return false;
#endif // FLAPPER_AVAILABLE
}
#if defined(OS_WIN)
// Launches the privileged flash broker, used when flash is sandboxed.
// The broker is the same flash dll, except that it uses a different
......@@ -327,6 +359,15 @@ void ChromeContentClient::AddPepperPlugins(
std::vector<content::PepperPluginInfo>* plugins) {
ComputeBuiltInPlugins(plugins);
AddPepperFlashFromCommandLine(plugins);
// Don't try to register Pepper Flash if there exists a Pepper Flash field
// trial. It will be registered separately.
if (!ConductingPepperFlashFieldTrial() && IsPepperFlashEnabledByDefault()) {
content::PepperPluginInfo plugin;
bool add_at_beginning = false;
if (GetBundledPepperFlash(&plugin, &add_at_beginning))
plugins->push_back(plugin);
}
}
void ChromeContentClient::AddNPAPIPlugins(
......@@ -456,37 +497,12 @@ bool ChromeContentClient::GetSandboxProfileForSandboxType(
}
#endif
bool ChromeContentClient::GetBundledPepperFlash(
bool ChromeContentClient::GetBundledFieldTrialPepperFlash(
content::PepperPluginInfo* plugin,
bool* override_npapi_flash) {
#if defined(FLAPPER_AVAILABLE)
// Ignore bundled Pepper Flash if there is Pepper Flash specified from the
// command-line.
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kPpapiFlashPath))
return false;
bool force_disable = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableBundledPpapiFlash);
if (force_disable)
return false;
FilePath flash_path;
if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path))
if (!ConductingPepperFlashFieldTrial())
return false;
// It is an error to have FLAPPER_AVAILABLE defined but then not having the
// plugin file in place, but this happens in Chrome OS builds.
// Use --disable-bundled-ppapi-flash to skip this.
DCHECK(file_util::PathExists(flash_path));
bool force_enable = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBundledPpapiFlash);
*plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING);
*override_npapi_flash = force_enable || IsPepperFlashEnabledByDefault();
return true;
#else
return false;
#endif // FLAPPER_AVAILABLE
return GetBundledPepperFlash(plugin, override_npapi_flash);
}
} // namespace chrome
......@@ -46,8 +46,9 @@ class ChromeContentClient : public content::ContentClient {
int* sandbox_profile_resource_id) const OVERRIDE;
#endif
// Gets information about the bundled Pepper Flash. |override_npapi_flash|
// indicates whether it should take precedence over the internal NPAPI Flash.
// Gets information about the bundled Pepper Flash for field trial.
// |override_npapi_flash| indicates whether it should take precedence over
// the internal NPAPI Flash.
// Returns false if bundled Pepper Flash is not available. In that case,
// |plugin| and |override_npapi_flash| are not touched.
//
......@@ -55,8 +56,8 @@ class ChromeContentClient : public content::ContentClient {
// trial with bundled Pepper Flash, and need extra information about how to
// order bundled Pepper Flash and internal NPAPI Flash. Once the field trial
// is over, we should merge this into AddPepperPlugins().
bool GetBundledPepperFlash(content::PepperPluginInfo* plugin,
bool* override_npapi_flash);
bool GetBundledFieldTrialPepperFlash(content::PepperPluginInfo* plugin,
bool* override_npapi_flash);
};
} // namespace chrome
......
......@@ -65,6 +65,14 @@ bool IsInFieldTrialGroup() {
} // namespace
bool ConductingPepperFlashFieldTrial() {
#if defined(OS_WIN)
return true;
#else
return false;
#endif
}
bool IsPepperFlashEnabledByDefault() {
#if defined(USE_AURA)
// Pepper Flash is required for Aura (on any OS).
......
......@@ -5,6 +5,9 @@
#ifndef CHROME_COMMON_PEPPER_FLASH_H_
#define CHROME_COMMON_PEPPER_FLASH_H_
// Whether a field trial for Pepper Flash is going on.
bool ConductingPepperFlashFieldTrial();
// True if Pepper Flash should be enabled by default.
bool IsPepperFlashEnabledByDefault();
......
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