|
|
|
|
| 61 |
#include "nsMimeTypes.h" |
61 |
#include "nsMimeTypes.h" |
| 62 |
#include "nsNetUtil.h" |
62 |
#include "nsNetUtil.h" |
| 63 |
#include "nsStringStream.h" |
63 |
#include "nsStringStream.h" |
| 64 |
#include "nsComponentManagerUtils.h" |
64 |
#include "nsComponentManagerUtils.h" |
| 65 |
#include "nsIStringStream.h" |
65 |
#include "nsIStringStream.h" |
| 66 |
#include "nsIHttpChannel.h" |
66 |
#include "nsIHttpChannel.h" |
| 67 |
#include "nsIHttpChannelInternal.h" |
67 |
#include "nsIHttpChannelInternal.h" |
| 68 |
#include "TimeManager.h" |
68 |
#include "TimeManager.h" |
| 69 |
#include "DeviceStorage.h" |
|
|
| 70 |
#include "nsStreamUtils.h" |
69 |
#include "nsStreamUtils.h" |
| 71 |
#include "WidgetUtils.h" |
70 |
#include "WidgetUtils.h" |
| 72 |
#include "nsIPresentationService.h" |
71 |
#include "nsIPresentationService.h" |
| 73 |
|
72 |
|
| 74 |
#include "mozilla/dom/MediaDevices.h" |
73 |
#include "mozilla/dom/MediaDevices.h" |
| 75 |
#include "MediaManager.h" |
74 |
#include "MediaManager.h" |
| 76 |
|
75 |
|
| 77 |
#ifdef MOZ_AUDIO_CHANNEL_MANAGER |
76 |
#ifdef MOZ_AUDIO_CHANNEL_MANAGER |
|
Lines 272-296
Navigator::Invalidate()
|
Link Here
|
|---|
|
| 272 |
mMediaDevices = nullptr; |
271 |
mMediaDevices = nullptr; |
| 273 |
|
272 |
|
| 274 |
#ifdef MOZ_AUDIO_CHANNEL_MANAGER |
273 |
#ifdef MOZ_AUDIO_CHANNEL_MANAGER |
| 275 |
if (mAudioChannelManager) { |
274 |
if (mAudioChannelManager) { |
| 276 |
mAudioChannelManager = nullptr; |
275 |
mAudioChannelManager = nullptr; |
| 277 |
} |
276 |
} |
| 278 |
#endif |
277 |
#endif |
| 279 |
|
278 |
|
| 280 |
uint32_t len = mDeviceStorageStores.Length(); |
|
|
| 281 |
for (uint32_t i = 0; i < len; ++i) { |
| 282 |
RefPtr<nsDOMDeviceStorage> ds = do_QueryReferent(mDeviceStorageStores[i]); |
| 283 |
if (ds) { |
| 284 |
ds->Shutdown(); |
| 285 |
} |
| 286 |
} |
| 287 |
mDeviceStorageStores.Clear(); |
| 288 |
|
| 289 |
if (mTimeManager) { |
279 |
if (mTimeManager) { |
| 290 |
mTimeManager = nullptr; |
280 |
mTimeManager = nullptr; |
| 291 |
} |
281 |
} |
| 292 |
|
282 |
|
| 293 |
if (mPresentation) { |
283 |
if (mPresentation) { |
| 294 |
mPresentation = nullptr; |
284 |
mPresentation = nullptr; |
| 295 |
} |
285 |
} |
| 296 |
|
286 |
|
|
Lines 1020-1141
Navigator::RegisterProtocolHandler(const
|
Link Here
|
|---|
|
| 1020 |
if (!registrar) { |
1010 |
if (!registrar) { |
| 1021 |
return; |
1011 |
return; |
| 1022 |
} |
1012 |
} |
| 1023 |
|
1013 |
|
| 1024 |
aRv = registrar->RegisterProtocolHandler(aProtocol, aURI, aTitle, |
1014 |
aRv = registrar->RegisterProtocolHandler(aProtocol, aURI, aTitle, |
| 1025 |
mWindow->GetOuterWindow()); |
1015 |
mWindow->GetOuterWindow()); |
| 1026 |
} |
1016 |
} |
| 1027 |
|
1017 |
|
| 1028 |
already_AddRefed<nsDOMDeviceStorage> |
|
|
| 1029 |
Navigator::FindDeviceStorage(const nsAString& aName, const nsAString& aType) |
| 1030 |
{ |
| 1031 |
auto i = mDeviceStorageStores.Length(); |
| 1032 |
while (i > 0) { |
| 1033 |
--i; |
| 1034 |
RefPtr<nsDOMDeviceStorage> storage = |
| 1035 |
do_QueryReferent(mDeviceStorageStores[i]); |
| 1036 |
if (storage) { |
| 1037 |
if (storage->Equals(mWindow, aName, aType)) { |
| 1038 |
return storage.forget(); |
| 1039 |
} |
| 1040 |
} else { |
| 1041 |
mDeviceStorageStores.RemoveElementAt(i); |
| 1042 |
} |
| 1043 |
} |
| 1044 |
return nullptr; |
| 1045 |
} |
| 1046 |
|
| 1047 |
already_AddRefed<nsDOMDeviceStorage> |
| 1048 |
Navigator::GetDeviceStorage(const nsAString& aType, ErrorResult& aRv) |
| 1049 |
{ |
| 1050 |
if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { |
| 1051 |
aRv.Throw(NS_ERROR_FAILURE); |
| 1052 |
return nullptr; |
| 1053 |
} |
| 1054 |
|
| 1055 |
nsString name; |
| 1056 |
nsDOMDeviceStorage::GetDefaultStorageName(aType, name); |
| 1057 |
RefPtr<nsDOMDeviceStorage> storage = FindDeviceStorage(name, aType); |
| 1058 |
if (storage) { |
| 1059 |
return storage.forget(); |
| 1060 |
} |
| 1061 |
|
| 1062 |
nsDOMDeviceStorage::CreateDeviceStorageFor(mWindow, aType, |
| 1063 |
getter_AddRefs(storage)); |
| 1064 |
|
| 1065 |
if (!storage) { |
| 1066 |
return nullptr; |
| 1067 |
} |
| 1068 |
|
| 1069 |
mDeviceStorageStores.AppendElement( |
| 1070 |
do_GetWeakReference(static_cast<DOMEventTargetHelper*>(storage))); |
| 1071 |
return storage.forget(); |
| 1072 |
} |
| 1073 |
|
| 1074 |
void |
| 1075 |
Navigator::GetDeviceStorages(const nsAString& aType, |
| 1076 |
nsTArray<RefPtr<nsDOMDeviceStorage> >& aStores, |
| 1077 |
ErrorResult& aRv) |
| 1078 |
{ |
| 1079 |
if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { |
| 1080 |
aRv.Throw(NS_ERROR_FAILURE); |
| 1081 |
return; |
| 1082 |
} |
| 1083 |
|
| 1084 |
nsDOMDeviceStorage::VolumeNameArray volumes; |
| 1085 |
nsDOMDeviceStorage::GetOrderedVolumeNames(aType, volumes); |
| 1086 |
if (volumes.IsEmpty()) { |
| 1087 |
RefPtr<nsDOMDeviceStorage> storage = GetDeviceStorage(aType, aRv); |
| 1088 |
if (storage) { |
| 1089 |
aStores.AppendElement(storage.forget()); |
| 1090 |
} |
| 1091 |
} else { |
| 1092 |
uint32_t len = volumes.Length(); |
| 1093 |
aStores.SetCapacity(len); |
| 1094 |
for (uint32_t i = 0; i < len; ++i) { |
| 1095 |
RefPtr<nsDOMDeviceStorage> storage = |
| 1096 |
GetDeviceStorageByNameAndType(volumes[i], aType, aRv); |
| 1097 |
if (aRv.Failed()) { |
| 1098 |
break; |
| 1099 |
} |
| 1100 |
|
| 1101 |
if (storage) { |
| 1102 |
aStores.AppendElement(storage.forget()); |
| 1103 |
} |
| 1104 |
} |
| 1105 |
} |
| 1106 |
} |
| 1107 |
|
| 1108 |
already_AddRefed<nsDOMDeviceStorage> |
| 1109 |
Navigator::GetDeviceStorageByNameAndType(const nsAString& aName, |
| 1110 |
const nsAString& aType, |
| 1111 |
ErrorResult& aRv) |
| 1112 |
{ |
| 1113 |
if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { |
| 1114 |
aRv.Throw(NS_ERROR_FAILURE); |
| 1115 |
return nullptr; |
| 1116 |
} |
| 1117 |
|
| 1118 |
RefPtr<nsDOMDeviceStorage> storage = FindDeviceStorage(aName, aType); |
| 1119 |
if (storage) { |
| 1120 |
return storage.forget(); |
| 1121 |
} |
| 1122 |
nsDOMDeviceStorage::CreateDeviceStorageByNameAndType(mWindow, aName, aType, |
| 1123 |
getter_AddRefs(storage)); |
| 1124 |
|
| 1125 |
if (!storage) { |
| 1126 |
return nullptr; |
| 1127 |
} |
| 1128 |
|
| 1129 |
mDeviceStorageStores.AppendElement( |
| 1130 |
do_GetWeakReference(static_cast<DOMEventTargetHelper*>(storage))); |
| 1131 |
return storage.forget(); |
| 1132 |
} |
| 1133 |
|
| 1134 |
Geolocation* |
1018 |
Geolocation* |
| 1135 |
Navigator::GetGeolocation(ErrorResult& aRv) |
1019 |
Navigator::GetGeolocation(ErrorResult& aRv) |
| 1136 |
{ |
1020 |
{ |
| 1137 |
if (mGeolocation) { |
1021 |
if (mGeolocation) { |
| 1138 |
return mGeolocation; |
1022 |
return mGeolocation; |
| 1139 |
} |
1023 |
} |
| 1140 |
|
1024 |
|
| 1141 |
if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { |
1025 |
if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { |