chromium: Allow env vars for passing plugin paths.

Introduces environment variables to set plugin base paths. The schema
for these is like NIX_CHROMIUM_PLUGIN_PATH_<N>. Where <N> is the path
type we want to change, the supported (full) variable names are:

 * NIX_CHROMIUM_PLUGIN_PATH_ALL
 * NIX_CHROMIUM_PLUGIN_PATH_PEPPERFLASH
 * NIX_CHROMIUM_PLUGIN_PATH_FILEFLASH
 * NIX_CHROMIUM_PLUGIN_PATH_PDF
 * NIX_CHROMIUM_PLUGIN_PATH_FILE_EFFECTS
 * NIX_CHROMIUM_PLUGIN_PATH_NACL
 * NIX_CHROMIUM_PLUGIN_PATH_PNACL
 * NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE

Whereas NIX_CHROMIUM_PLUGIN_PATH_ALL is the plugin base path for every
path which is not set explicitly, so by setting ..._ALL and not setting
..._WIDEVINE, the widevine plugin will be searched in the directory
specified using ..._ALL.

Right now, the only plugin where this is used is widevine, and it still
doesn't properly work yet.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2014-11-20 16:46:09 +01:00
parent 2495e819aa
commit 1b84fbf0ca
No known key found for this signature in database
GPG Key ID: D0EBD0EC8C2DC961
4 changed files with 109 additions and 3 deletions

View File

@ -74,6 +74,7 @@ in stdenv.mkDerivation {
ln -s "${chromium.browser}/share" "$out/share"
makeWrapper "${browserBinary}" "$out/bin/chromium" \
--set CHROMIUM_SANDBOX_BINARY_PATH "${sandboxBinary}" \
--run "export ${chromium.plugins.envVarsEnabled}" \
--add-flags "${chromium.plugins.flagsEnabled}"
ln -s "$out/bin/chromium" "$out/bin/chromium-browser"

View File

@ -88,13 +88,19 @@ let
mkdir -p "$widevine/nix-support"
echo "--register-pepper-plugins='${wvModule}${wvInfo}'" \
> "$widevine/nix-support/chromium-flags"
echo "NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE=$widevine/lib" \
> "$widevine/nix-support/chromium-env-vars"
'';
passthru.flagsEnabled = let
passthru = let
enabledPlugins = optional enablePepperFlash plugins.flash
++ optional enablePepperPDF plugins.pdf
++ optional enableWideVine plugins.widevine;
getFlags = plugin: "$(< ${plugin}/nix-support/chromium-flags)";
in concatStringsSep " " (map getFlags enabledPlugins);
getEnvVars = plugin: "$(< ${plugin}/nix-support/chromium-env-vars)";
in {
flagsEnabled = concatStringsSep " " (map getFlags enabledPlugins);
envVarsEnabled = concatStringsSep " " (map getEnvVars enabledPlugins);
};
};
in plugins

View File

@ -22,7 +22,7 @@ stdenv.mkDerivation {
prePatch = "patchShebangs .";
patches = [ ./sandbox_userns_36.patch ];
patches = [ ./sandbox_userns_36.patch ./nix_plugin_paths.patch ];
postPatch = ''
sed -i -r \

View File

@ -0,0 +1,99 @@
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index 8a205a6..d5c24e1 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -97,21 +97,14 @@ static base::LazyInstance<base::FilePath>
g_invalid_specified_user_data_dir = LAZY_INSTANCE_INITIALIZER;
// Gets the path for internal plugins.
-bool GetInternalPluginsDirectory(base::FilePath* result) {
-#if defined(OS_MACOSX) && !defined(OS_IOS)
- // If called from Chrome, get internal plugins from a subdirectory of the
- // framework.
- if (base::mac::AmIBundled()) {
- *result = chrome::GetFrameworkBundlePath();
- DCHECK(!result->empty());
- *result = result->Append("Internet Plug-Ins");
- return true;
- }
- // In tests, just look in the module directory (below).
-#endif
-
- // The rest of the world expects plugins in the module directory.
- return PathService::Get(base::DIR_MODULE, result);
+bool GetInternalPluginsDirectory(base::FilePath* result,
+ const std::string& ident) {
+ std::string full_env = std::string("NIX_CHROMIUM_PLUGIN_PATH_") + ident;
+ const char* value = getenv(full_env.c_str());
+ if (value == NULL)
+ return PathService::Get(base::DIR_MODULE, result);
+ else
+ *result = base::FilePath(value);
}
} // namespace
@@ -248,11 +241,11 @@ bool PathProvider(int key, base::FilePath* result) {
create_dir = true;
break;
case chrome::DIR_INTERNAL_PLUGINS:
- if (!GetInternalPluginsDirectory(&cur))
+ if (!GetInternalPluginsDirectory(&cur, "ALL"))
return false;
break;
case chrome::DIR_PEPPER_FLASH_PLUGIN:
- if (!GetInternalPluginsDirectory(&cur))
+ if (!GetInternalPluginsDirectory(&cur, "PEPPERFLASH"))
return false;
cur = cur.Append(kPepperFlashBaseDirectory);
break;
@@ -285,7 +278,7 @@ bool PathProvider(int key, base::FilePath* result) {
cur = cur.Append(FILE_PATH_LITERAL("script.log"));
break;
case chrome::FILE_FLASH_PLUGIN:
- if (!GetInternalPluginsDirectory(&cur))
+ if (!GetInternalPluginsDirectory(&cur, "FILEFLASH"))
return false;
cur = cur.Append(kInternalFlashPluginFileName);
break;
@@ -295,12 +288,12 @@ bool PathProvider(int key, base::FilePath* result) {
cur = cur.Append(chrome::kPepperFlashPluginFilename);
break;
case chrome::FILE_PDF_PLUGIN:
- if (!GetInternalPluginsDirectory(&cur))
+ if (!GetInternalPluginsDirectory(&cur, "PDF"))
return false;
cur = cur.Append(kInternalPDFPluginFileName);
break;
case chrome::FILE_EFFECTS_PLUGIN:
- if (!GetInternalPluginsDirectory(&cur))
+ if (!GetInternalPluginsDirectory(&cur, "FILE_EFFECTS"))
return false;
cur = cur.Append(kEffectsPluginFileName);
break;
@@ -308,7 +301,7 @@ bool PathProvider(int key, base::FilePath* result) {
// We currently need a path here to look up whether the plugin is disabled
// and what its permissions are.
case chrome::FILE_NACL_PLUGIN:
- if (!GetInternalPluginsDirectory(&cur))
+ if (!GetInternalPluginsDirectory(&cur, "NACL"))
return false;
cur = cur.Append(kInternalNaClPluginFileName);
break;
@@ -343,7 +336,7 @@ bool PathProvider(int key, base::FilePath* result) {
cur = cur.DirName();
}
#else
- if (!GetInternalPluginsDirectory(&cur))
+ if (!GetInternalPluginsDirectory(&cur, "PNACL"))
return false;
#endif
cur = cur.Append(FILE_PATH_LITERAL("pnacl"));
@@ -372,7 +365,7 @@ bool PathProvider(int key, base::FilePath* result) {
// In the component case, this is the source adapter. Otherwise, it is the
// actual Pepper module that gets loaded.
case chrome::FILE_WIDEVINE_CDM_ADAPTER:
- if (!GetInternalPluginsDirectory(&cur))
+ if (!GetInternalPluginsDirectory(&cur, "WIDEVINE"))
return false;
cur = cur.AppendASCII(kWidevineCdmAdapterFileName);
break;