Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | |
michael@0 | 5 | $Env:VIRTUAL_ENV = (gl); |
michael@0 | 6 | $Env:CUDDLEFISH_ROOT = $Env:VIRTUAL_ENV; |
michael@0 | 7 | |
michael@0 | 8 | # http://stackoverflow.com/questions/5648931/powershell-test-if-registry-value-exists/5652674#5652674 |
michael@0 | 9 | Function Test-RegistryValue { |
michael@0 | 10 | param( |
michael@0 | 11 | [Alias("PSPath")] |
michael@0 | 12 | [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] |
michael@0 | 13 | [String]$Path |
michael@0 | 14 | , |
michael@0 | 15 | [Parameter(Position = 1, Mandatory = $true)] |
michael@0 | 16 | [String]$Name |
michael@0 | 17 | , |
michael@0 | 18 | [Switch]$PassThru |
michael@0 | 19 | ) |
michael@0 | 20 | |
michael@0 | 21 | process { |
michael@0 | 22 | if (Test-Path $Path) { |
michael@0 | 23 | $Key = Get-Item -LiteralPath $Path |
michael@0 | 24 | if ($Key.GetValue($Name, $null) -ne $null) { |
michael@0 | 25 | if ($PassThru) { |
michael@0 | 26 | Get-ItemProperty $Path $Name |
michael@0 | 27 | } else { |
michael@0 | 28 | $true |
michael@0 | 29 | } |
michael@0 | 30 | } else { |
michael@0 | 31 | $false |
michael@0 | 32 | } |
michael@0 | 33 | } else { |
michael@0 | 34 | $false |
michael@0 | 35 | } |
michael@0 | 36 | } |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | $WINCURVERKEY = 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion'; |
michael@0 | 40 | $WIN64 = (Test-RegistryValue $WINCURVERKEY 'ProgramFilesDir (x86)'); |
michael@0 | 41 | |
michael@0 | 42 | if($WIN64) { |
michael@0 | 43 | $PYTHONKEY='HKLM:SOFTWARE\Wow6432Node\Python\PythonCore'; |
michael@0 | 44 | } |
michael@0 | 45 | else { |
michael@0 | 46 | $PYTHONKEY='HKLM:SOFTWARE\Python\PythonCore'; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | $Env:PYTHONVERSION = ''; |
michael@0 | 50 | $Env:PYTHONINSTALL = ''; |
michael@0 | 51 | |
michael@0 | 52 | foreach ($version in @('2.6', '2.5', '2.4')) { |
michael@0 | 53 | if (Test-RegistryValue "$PYTHONKEY\$version\InstallPath" '(default)') { |
michael@0 | 54 | $Env:PYTHONVERSION = $version; |
michael@0 | 55 | } |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | if ($Env:PYTHONVERSION) { |
michael@0 | 59 | $Env:PYTHONINSTALL = (Get-Item "$PYTHONKEY\$version\InstallPath)").'(default)'; |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | if ($Env:PYTHONINSTALL) { |
michael@0 | 63 | $Env:Path += ";$Env:PYTHONINSTALL"; |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | if (Test-Path Env:_OLD_PYTHONPATH) { |
michael@0 | 67 | $Env:PYTHONPATH = $Env:_OLD_PYTHONPATH; |
michael@0 | 68 | } |
michael@0 | 69 | else { |
michael@0 | 70 | $Env:PYTHONPATH = ''; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | $Env:_OLD_PYTHONPATH=$Env:PYTHONPATH; |
michael@0 | 74 | $Env:PYTHONPATH= "$Env:VIRTUAL_ENV\python-lib;$Env:PYTHONPATH"; |
michael@0 | 75 | |
michael@0 | 76 | if (Test-Path Function:_OLD_VIRTUAL_PROMPT) { |
michael@0 | 77 | Set-Content Function:Prompt (Get-Content Function:_OLD_VIRTUAL_PROMPT); |
michael@0 | 78 | } |
michael@0 | 79 | else { |
michael@0 | 80 | function global:_OLD_VIRTUAL_PROMPT {} |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | Set-Content Function:_OLD_VIRTUAL_PROMPT (Get-Content Function:Prompt); |
michael@0 | 84 | |
michael@0 | 85 | function global:prompt { "($Env:VIRTUAL_ENV) $(_OLD_VIRTUAL_PROMPT)"; }; |
michael@0 | 86 | |
michael@0 | 87 | if (Test-Path Env:_OLD_VIRTUAL_PATH) { |
michael@0 | 88 | $Env:PATH = $Env:_OLD_VIRTUAL_PATH; |
michael@0 | 89 | } |
michael@0 | 90 | else { |
michael@0 | 91 | $Env:_OLD_VIRTUAL_PATH = $Env:PATH; |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | $Env:Path="$Env:VIRTUAL_ENV\bin;$Env:Path" |
michael@0 | 95 | |
michael@0 | 96 | [System.Console]::WriteLine("Note: this PowerShell SDK activation script is experimental.") |
michael@0 | 97 | |
michael@0 | 98 | python -c "from jetpack_sdk_env import welcome; welcome()" |
michael@0 | 99 |