Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsOSHelperAppService.h" |
michael@0 | 7 | #include "nsMIMEInfoAndroid.h" |
michael@0 | 8 | #include "AndroidBridge.h" |
michael@0 | 9 | |
michael@0 | 10 | nsOSHelperAppService::nsOSHelperAppService() : nsExternalHelperAppService() |
michael@0 | 11 | { |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | nsOSHelperAppService::~nsOSHelperAppService() |
michael@0 | 15 | { |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | already_AddRefed<nsIMIMEInfo> |
michael@0 | 19 | nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType, |
michael@0 | 20 | const nsACString& aFileExt, |
michael@0 | 21 | bool* aFound) |
michael@0 | 22 | { |
michael@0 | 23 | nsRefPtr<nsMIMEInfoAndroid> mimeInfo; |
michael@0 | 24 | *aFound = false; |
michael@0 | 25 | if (!aMIMEType.IsEmpty()) |
michael@0 | 26 | *aFound = |
michael@0 | 27 | nsMIMEInfoAndroid::GetMimeInfoForMimeType(aMIMEType, |
michael@0 | 28 | getter_AddRefs(mimeInfo)); |
michael@0 | 29 | if (!*aFound) |
michael@0 | 30 | *aFound = |
michael@0 | 31 | nsMIMEInfoAndroid::GetMimeInfoForFileExt(aFileExt, |
michael@0 | 32 | getter_AddRefs(mimeInfo)); |
michael@0 | 33 | |
michael@0 | 34 | // Code that calls this requires an object regardless if the OS has |
michael@0 | 35 | // something for us, so we return the empty object. |
michael@0 | 36 | if (!*aFound) |
michael@0 | 37 | mimeInfo = new nsMIMEInfoAndroid(aMIMEType); |
michael@0 | 38 | |
michael@0 | 39 | return mimeInfo.forget(); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | nsresult |
michael@0 | 43 | nsOSHelperAppService::OSProtocolHandlerExists(const char* aScheme, |
michael@0 | 44 | bool* aExists) |
michael@0 | 45 | { |
michael@0 | 46 | *aExists = mozilla::AndroidBridge::Bridge()->GetHandlersForURL(NS_ConvertUTF8toUTF16(aScheme)); |
michael@0 | 47 | return NS_OK; |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | nsresult nsOSHelperAppService::GetProtocolHandlerInfoFromOS(const nsACString &aScheme, |
michael@0 | 51 | bool *found, |
michael@0 | 52 | nsIHandlerInfo **info) |
michael@0 | 53 | { |
michael@0 | 54 | return nsMIMEInfoAndroid::GetMimeInfoForURL(aScheme, found, info); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | nsIHandlerApp* |
michael@0 | 58 | nsOSHelperAppService::CreateAndroidHandlerApp(const nsAString& aName, |
michael@0 | 59 | const nsAString& aDescription, |
michael@0 | 60 | const nsAString& aPackageName, |
michael@0 | 61 | const nsAString& aClassName, |
michael@0 | 62 | const nsACString& aMimeType, |
michael@0 | 63 | const nsAString& aAction) |
michael@0 | 64 | { |
michael@0 | 65 | return new nsAndroidHandlerApp(aName, aDescription, aPackageName, |
michael@0 | 66 | aClassName, aMimeType, aAction); |
michael@0 | 67 | } |