зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1192695 - Use pref instead of pre-defined C string as origin of bluetooth app. r=btian
This commit is contained in:
Родитель
ecd31351f8
Коммит
8ce6e533bb
|
@ -1168,6 +1168,10 @@ pref("dom.vr.cardboard.enabled", true);
|
|||
// In B2G by deafult any AudioChannelAgent is muted when created.
|
||||
pref("dom.audiochannel.mutedByDefault", true);
|
||||
|
||||
// The app origin of bluetooth app, which is responsible for listening pairing
|
||||
// requests.
|
||||
pref("dom.bluetooth.app-origin", "app://bluetooth.gaiamobile.org");
|
||||
|
||||
// Default device name for Presentation API
|
||||
pref("dom.presentation.device.name", "Firefox OS");
|
||||
|
||||
|
|
|
@ -211,10 +211,10 @@ extern bool gBluetoothDebugFlag;
|
|||
#define SYS_MSG_BT_PAIRING_REQ "bluetooth-pairing-request"
|
||||
|
||||
/**
|
||||
* The app origin of bluetooth app, which is responsible for listening pairing
|
||||
* requests.
|
||||
* The preference name of bluetooth app origin of bluetooth app. The default
|
||||
* value is defined in b2g/app/b2g.js.
|
||||
*/
|
||||
#define BLUETOOTH_APP_ORIGIN "app://bluetooth.gaiamobile.org"
|
||||
#define PREF_BLUETOOTH_APP_ORIGIN "dom.bluetooth.app-origin"
|
||||
|
||||
/**
|
||||
* When a remote device gets paired / unpaired with local bluetooth adapter or
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "BluetoothUtils.h"
|
||||
#include "DOMRequest.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsTArrayHelpers.h"
|
||||
|
||||
|
@ -983,13 +985,30 @@ BluetoothAdapter::IsBluetoothCertifiedApp()
|
|||
NS_ENSURE_TRUE(doc, false);
|
||||
|
||||
uint16_t appStatus = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
|
||||
nsAutoCString appOrigin;
|
||||
|
||||
doc->NodePrincipal()->GetAppStatus(&appStatus);
|
||||
if (appStatus != nsIPrincipal::APP_STATUS_CERTIFIED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the app origin of Bluetooth app from PrefService.
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (!prefs) {
|
||||
BT_WARNING("Failed to get preference service");
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoCString prefOrigin;
|
||||
nsresult rv = prefs->GetCharPref(PREF_BLUETOOTH_APP_ORIGIN,
|
||||
getter_Copies(prefOrigin));
|
||||
if (NS_FAILED(rv)) {
|
||||
BT_WARNING("Failed to get the pref value '" PREF_BLUETOOTH_APP_ORIGIN "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoCString appOrigin;
|
||||
doc->NodePrincipal()->GetOriginNoSuffix(appOrigin);
|
||||
|
||||
return appStatus == nsIPrincipal::APP_STATUS_CERTIFIED &&
|
||||
appOrigin.EqualsLiteral(BLUETOOTH_APP_ORIGIN);
|
||||
return appOrigin.Equals(prefOrigin);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче