mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Merge mozilla-central to fx-team
This commit is contained in:
commit
4b912997a8
@ -970,51 +970,50 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
||||
}
|
||||
|
||||
if (!newAcc && isHTML) { // HTML accessibles
|
||||
if (roleMapEntry) {
|
||||
// Create pure ARIA grid/treegrid related accessibles if they weren't used
|
||||
// on accessible HTML table elements.
|
||||
if ((roleMapEntry->accTypes & eTableCell)) {
|
||||
if (aContext->IsTableRow() &&
|
||||
(frame->AccessibleType() != eHTMLTableCellType ||
|
||||
aContext->GetContent() != content->GetParent())) {
|
||||
newAcc = new ARIAGridCellAccessibleWrap(content, document);
|
||||
}
|
||||
bool isARIATableOrCell = roleMapEntry &&
|
||||
(roleMapEntry->accTypes & (eTableCell | eTable));
|
||||
|
||||
} else if ((roleMapEntry->IsOfType(eTable)) &&
|
||||
frame->AccessibleType() != eHTMLTableType) {
|
||||
if (!isARIATableOrCell ||
|
||||
frame->AccessibleType() == eHTMLTableCellType ||
|
||||
frame->AccessibleType() == eHTMLTableType) {
|
||||
// Prefer to use markup (mostly tag name, perhaps attributes) to decide if
|
||||
// and what kind of accessible to create,
|
||||
newAcc = CreateHTMLAccessibleByMarkup(frame, content, aContext);
|
||||
if (!newAcc) // try by frame accessible type.
|
||||
newAcc = CreateAccessibleByFrameType(frame, content, aContext);
|
||||
}
|
||||
|
||||
// In case of ARIA grids use grid-specific classes if it's not native table
|
||||
// based.
|
||||
if (isARIATableOrCell && (!newAcc || newAcc->IsGenericHyperText())) {
|
||||
if ((roleMapEntry->accTypes & eTableCell)) {
|
||||
if (aContext->IsTableRow())
|
||||
newAcc = new ARIAGridCellAccessibleWrap(content, document);
|
||||
|
||||
} else if (roleMapEntry->IsOfType(eTable)) {
|
||||
newAcc = new ARIAGridAccessibleWrap(content, document);
|
||||
}
|
||||
}
|
||||
|
||||
if (!newAcc) {
|
||||
// Prefer to use markup (mostly tag name, perhaps attributes) to decide if
|
||||
// and what kind of accessible to create.
|
||||
newAcc = CreateHTMLAccessibleByMarkup(frame, content, aContext);
|
||||
|
||||
// Try using frame to do it.
|
||||
if (!newAcc)
|
||||
newAcc = CreateAccessibleByFrameType(frame, content, aContext);
|
||||
|
||||
// If table has strong ARIA role then all table descendants shouldn't
|
||||
// expose their native roles.
|
||||
if (!roleMapEntry && newAcc && aContext->HasStrongARIARole()) {
|
||||
if (frame->AccessibleType() == eHTMLTableRowType) {
|
||||
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
|
||||
if (!contextRoleMap->IsOfType(eTable))
|
||||
roleMapEntry = &aria::gEmptyRoleMap;
|
||||
|
||||
} else if (frame->AccessibleType() == eHTMLTableCellType &&
|
||||
aContext->ARIARoleMap() == &aria::gEmptyRoleMap) {
|
||||
// If table has strong ARIA role then all table descendants shouldn't
|
||||
// expose their native roles.
|
||||
if (!roleMapEntry && newAcc && aContext->HasStrongARIARole()) {
|
||||
if (frame->AccessibleType() == eHTMLTableRowType) {
|
||||
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
|
||||
if (!contextRoleMap->IsOfType(eTable))
|
||||
roleMapEntry = &aria::gEmptyRoleMap;
|
||||
|
||||
} else if (content->Tag() == nsGkAtoms::dt ||
|
||||
content->Tag() == nsGkAtoms::li ||
|
||||
content->Tag() == nsGkAtoms::dd ||
|
||||
frame->AccessibleType() == eHTMLLiType) {
|
||||
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
|
||||
if (!contextRoleMap->IsOfType(eList))
|
||||
roleMapEntry = &aria::gEmptyRoleMap;
|
||||
}
|
||||
} else if (frame->AccessibleType() == eHTMLTableCellType &&
|
||||
aContext->ARIARoleMap() == &aria::gEmptyRoleMap) {
|
||||
roleMapEntry = &aria::gEmptyRoleMap;
|
||||
|
||||
} else if (content->Tag() == nsGkAtoms::dt ||
|
||||
content->Tag() == nsGkAtoms::li ||
|
||||
content->Tag() == nsGkAtoms::dd ||
|
||||
frame->AccessibleType() == eHTMLLiType) {
|
||||
nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
|
||||
if (!contextRoleMap->IsOfType(eList))
|
||||
roleMapEntry = &aria::gEmptyRoleMap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -604,5 +604,12 @@ ARIAGridCellAccessible::NativeAttributes()
|
||||
stringIdx.AppendInt(rowIdx * colCount + colIdx);
|
||||
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::tableCellIndex, stringIdx);
|
||||
|
||||
#ifdef DEBUG
|
||||
nsAutoString unused;
|
||||
attributes->SetStringProperty(NS_LITERAL_CSTRING("cppclass"),
|
||||
NS_LITERAL_STRING("ARIAGridCellAccessible"),
|
||||
unused);
|
||||
#endif
|
||||
|
||||
return attributes.forget();
|
||||
}
|
||||
|
@ -579,6 +579,7 @@ public:
|
||||
bool IsDoc() const { return HasGenericType(eDocument); }
|
||||
DocAccessible* AsDoc();
|
||||
|
||||
bool IsGenericHyperText() const { return mType == eHyperTextType; }
|
||||
bool IsHyperText() const { return HasGenericType(eHyperText); }
|
||||
HyperTextAccessible* AsHyperText();
|
||||
|
||||
|
@ -50,6 +50,7 @@ HyperTextAccessible::
|
||||
HyperTextAccessible(nsIContent* aNode, DocAccessible* aDoc) :
|
||||
AccessibleWrap(aNode, aDoc)
|
||||
{
|
||||
mType = eHyperTextType;
|
||||
mGenericTypes |= eHyperText;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@ HTMLTableCellAccessible::
|
||||
HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
||||
HyperTextAccessibleWrap(aContent, aDoc)
|
||||
{
|
||||
mType = eHTMLTableCellType;
|
||||
mGenericTypes |= eTableCell;
|
||||
}
|
||||
|
||||
@ -129,6 +130,13 @@ HTMLTableCellAccessible::NativeAttributes()
|
||||
if (!axisText.IsEmpty())
|
||||
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::axis, axisText);
|
||||
|
||||
#ifdef DEBUG
|
||||
nsAutoString unused;
|
||||
attributes->SetStringProperty(NS_LITERAL_CSTRING("cppclass"),
|
||||
NS_LITERAL_STRING("HTMLTableCellAccessible"),
|
||||
unused);
|
||||
#endif
|
||||
|
||||
return attributes.forget();
|
||||
}
|
||||
|
||||
|
@ -62,13 +62,13 @@
|
||||
|
||||
headerInfoMap = [
|
||||
{
|
||||
// not focusable cell (nsARIAGridCellAccessible is used)
|
||||
// not focusable cell (ARIAGridCellAccessible is used)
|
||||
cell: "table2_dc_1",
|
||||
rowHeaderCells: [],
|
||||
columnHeaderCells: [ "table2_ch_1" ]
|
||||
},
|
||||
{
|
||||
// focusable cell (nsARIAGridCellAccessible is used)
|
||||
// focusable cell (ARIAGridCellAccessible is used)
|
||||
cell: "table2_dc_2",
|
||||
rowHeaderCells: [],
|
||||
columnHeaderCells: [ "table2_ch_2" ]
|
||||
@ -77,6 +77,27 @@
|
||||
|
||||
testHeaderCells(headerInfoMap);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// column and row headers from markup for one more crazy grid.
|
||||
|
||||
headerInfoMap = [
|
||||
{
|
||||
// ARIAGridCellAccessible is used
|
||||
cell: "t3_dc_1",
|
||||
rowHeaderCells: [ "t3_rh_1" ],
|
||||
columnHeaderCells: [ ]
|
||||
},
|
||||
{
|
||||
// ARIAGridCellAccessible is used (inside rowgroup)
|
||||
cell: "t3_dc_2",
|
||||
rowHeaderCells: [ "t3_rh_2" ],
|
||||
columnHeaderCells: [ ]
|
||||
}
|
||||
];
|
||||
|
||||
testHeaderCells(headerInfoMap);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
@ -135,5 +156,30 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div role="grid">
|
||||
<table role="presentation">
|
||||
<tbody role="presentation">
|
||||
<tr role="row">
|
||||
<th id="t3_rh_1" role="rowheader">Row 1</th>
|
||||
<td id="t3_dc_1" role="gridcell" tabindex="-1">
|
||||
Apple Inc.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div role="rowgroup" tabindex="0">
|
||||
<table role="presentation">
|
||||
<tbody role="presentation">
|
||||
<tr role="row">
|
||||
<th id="t3_rh_2" role="rowheader">Row 2</th>
|
||||
<td id="t3_dc_2" role="gridcell" tabindex="-1">
|
||||
Apple-Shmapple Inc.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1114,8 +1114,10 @@ pref("dom.requestSync.enabled", true);
|
||||
pref("gfx.vsync.hw-vsync.enabled", true);
|
||||
pref("gfx.vsync.compositor", true);
|
||||
pref("gfx.touch.resample", true);
|
||||
pref("gfx.vsync.refreshdriver", true);
|
||||
#else
|
||||
pref("gfx.vsync.hw-vsync.enabled", false);
|
||||
pref("gfx.vsync.compositor", false);
|
||||
pref("gfx.touch.resample", false);
|
||||
pref("gfx.vsync.refreshdriver", false);
|
||||
#endif
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="cdaa0a4ac28c781709df8c318ed079e9e475503a">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f0b93e0668ef9565bd6f050b15b4f794d59feb65"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ae02fbdeae77b2002cebe33c61aedeee4b9439fd"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2262d4a77d4f46ab230fd747bb91e9b77bad36cb"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f0b93e0668ef9565bd6f050b15b4f794d59feb65"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ae02fbdeae77b2002cebe33c61aedeee4b9439fd"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2262d4a77d4f46ab230fd747bb91e9b77bad36cb"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="eb1795a9002eb142ac58c8d68f8f4ba094af07ca"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f0b93e0668ef9565bd6f050b15b4f794d59feb65"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ae02fbdeae77b2002cebe33c61aedeee4b9439fd"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2262d4a77d4f46ab230fd747bb91e9b77bad36cb"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8d0d11d190ccc50d7d66009bcc896ad4b42d3f0d"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="cdaa0a4ac28c781709df8c318ed079e9e475503a">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f0b93e0668ef9565bd6f050b15b4f794d59feb65"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ae02fbdeae77b2002cebe33c61aedeee4b9439fd"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2262d4a77d4f46ab230fd747bb91e9b77bad36cb"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="f0b93e0668ef9565bd6f050b15b4f794d59feb65"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ae02fbdeae77b2002cebe33c61aedeee4b9439fd"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2262d4a77d4f46ab230fd747bb91e9b77bad36cb"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="eb1795a9002eb142ac58c8d68f8f4ba094af07ca"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="cdaa0a4ac28c781709df8c318ed079e9e475503a">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f0b93e0668ef9565bd6f050b15b4f794d59feb65"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ae02fbdeae77b2002cebe33c61aedeee4b9439fd"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2262d4a77d4f46ab230fd747bb91e9b77bad36cb"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f0b93e0668ef9565bd6f050b15b4f794d59feb65"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ae02fbdeae77b2002cebe33c61aedeee4b9439fd"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2262d4a77d4f46ab230fd747bb91e9b77bad36cb"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8d0d11d190ccc50d7d66009bcc896ad4b42d3f0d"/>
|
||||
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"git": {
|
||||
"git_revision": "f0b93e0668ef9565bd6f050b15b4f794d59feb65",
|
||||
"git_revision": "ae02fbdeae77b2002cebe33c61aedeee4b9439fd",
|
||||
"remote": "https://git.mozilla.org/releases/gaia.git",
|
||||
"branch": ""
|
||||
},
|
||||
"revision": "d170342f8e1837435749392fc2bded3b9fee01d4",
|
||||
"revision": "62d026a98ea42f2b93de000e8d0d4f1254f86730",
|
||||
"repo_path": "integration/gaia-central"
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f0b93e0668ef9565bd6f050b15b4f794d59feb65"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ae02fbdeae77b2002cebe33c61aedeee4b9439fd"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2262d4a77d4f46ab230fd747bb91e9b77bad36cb"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="8d0d11d190ccc50d7d66009bcc896ad4b42d3f0d"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="7f2ee9f4cb926684883fc2a2e407045fd9db2199">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="f0b93e0668ef9565bd6f050b15b4f794d59feb65"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ae02fbdeae77b2002cebe33c61aedeee4b9439fd"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="2262d4a77d4f46ab230fd747bb91e9b77bad36cb"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1423263875000">
|
||||
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1423697587000">
|
||||
<emItems>
|
||||
<emItem blockID="i58" id="webmaster@buzzzzvideos.info">
|
||||
<versionRange minVersion="0" maxVersion="*">
|
||||
@ -220,6 +220,26 @@
|
||||
</versionRange>
|
||||
<prefs>
|
||||
</prefs>
|
||||
</emItem>
|
||||
<emItem blockID="i858" id="fftoolbar2014@etech.com">
|
||||
<versionRange minVersion="0" maxVersion="*" severity="1">
|
||||
</versionRange>
|
||||
<prefs>
|
||||
<pref>browser.startup.homepage</pref>
|
||||
<pref>browser.search.defaultenginename</pref>
|
||||
</prefs>
|
||||
</emItem>
|
||||
<emItem blockID="i854" id="/^(7tG@zEb\.net|ru@gfK0J\.edu)$/">
|
||||
<versionRange minVersion="0" maxVersion="*" severity="3">
|
||||
</versionRange>
|
||||
<prefs>
|
||||
</prefs>
|
||||
</emItem>
|
||||
<emItem blockID="i850" id="P2@D.edu">
|
||||
<versionRange minVersion="0" maxVersion="*" severity="1">
|
||||
</versionRange>
|
||||
<prefs>
|
||||
</prefs>
|
||||
</emItem>
|
||||
<emItem blockID="i554" id="lightningnewtab@gmail.com">
|
||||
<versionRange minVersion="0" maxVersion="*" severity="1">
|
||||
@ -268,6 +288,12 @@
|
||||
</versionRange>
|
||||
<prefs>
|
||||
</prefs>
|
||||
</emItem>
|
||||
<emItem blockID="i856" id="/^({94d62e35-4b43-494c-bf52-ba5935df36ef}|firefox@advanceelite\.com|{bb7b7a60-f574-47c2-8a0b-4c56f2da9802})$/">
|
||||
<versionRange minVersion="0" maxVersion="*" severity="3">
|
||||
</versionRange>
|
||||
<prefs>
|
||||
</prefs>
|
||||
</emItem>
|
||||
<emItem blockID="i482" id="brasilescapeeight@facebook.com">
|
||||
<versionRange minVersion="0" maxVersion="*" severity="3">
|
||||
@ -452,6 +478,12 @@
|
||||
</versionRange>
|
||||
<prefs>
|
||||
</prefs>
|
||||
</emItem>
|
||||
<emItem blockID="i848" id="bcVX5@nQm9l.org">
|
||||
<versionRange minVersion="0" maxVersion="*" severity="1">
|
||||
</versionRange>
|
||||
<prefs>
|
||||
</prefs>
|
||||
</emItem>
|
||||
<emItem blockID="i431" id="chinaescapeone@facebook.com">
|
||||
<versionRange minVersion="0" maxVersion="*" severity="3">
|
||||
@ -1544,6 +1576,12 @@
|
||||
</versionRange>
|
||||
<prefs>
|
||||
</prefs>
|
||||
</emItem>
|
||||
<emItem blockID="i852" id="6lIy@T.edu">
|
||||
<versionRange minVersion="0" maxVersion="*" severity="1">
|
||||
</versionRange>
|
||||
<prefs>
|
||||
</prefs>
|
||||
</emItem>
|
||||
<emItem blockID="i505" id="extacylife@a.com">
|
||||
<versionRange minVersion="0" maxVersion="*" severity="3">
|
||||
|
@ -1,4 +1,3 @@
|
||||
browser.jar:
|
||||
|
||||
# The file that holds the default permissions (which is loaded by nsPermissionManager) for the browser.
|
||||
default_permissions (default_permissions)
|
||||
% resource app %
|
||||
defaults/permissions (permissions)
|
||||
|
@ -410,6 +410,9 @@ pref("browser.search.hiddenOneOffs", "");
|
||||
|
||||
pref("browser.sessionhistory.max_entries", 50);
|
||||
|
||||
// Built-in default permissions.
|
||||
pref("permissions.manager.defaultsUrl", "resource://app/defaults/permissions");
|
||||
|
||||
// handle links targeting new windows
|
||||
// 1=current window/tab, 2=new window, 3=new tab in most recent window
|
||||
pref("browser.link.open_newwindow", 3);
|
||||
|
@ -13,9 +13,12 @@
|
||||
* from the source profile.
|
||||
*/
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource:///modules/MigrationUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource:///modules/MigrationUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesBackups",
|
||||
"resource://gre/modules/PlacesBackups.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SessionMigration",
|
||||
@ -34,6 +37,34 @@ function FirefoxProfileMigrator() {
|
||||
|
||||
FirefoxProfileMigrator.prototype = Object.create(MigratorPrototype);
|
||||
|
||||
FirefoxProfileMigrator.prototype._getAllProfiles = function () {
|
||||
let allProfiles = new Map();
|
||||
let profiles =
|
||||
Components.classes["@mozilla.org/toolkit/profile-service;1"]
|
||||
.getService(Components.interfaces.nsIToolkitProfileService)
|
||||
.profiles;
|
||||
while (profiles.hasMoreElements()) {
|
||||
let profile = profiles.getNext().QueryInterface(Ci.nsIToolkitProfile);
|
||||
let rootDir = profile.rootDir;
|
||||
|
||||
if (rootDir.exists() && rootDir.isReadable() &&
|
||||
!rootDir.equals(MigrationUtils.profileStartup.directory)) {
|
||||
allProfiles.set(profile.name, rootDir);
|
||||
}
|
||||
}
|
||||
return allProfiles;
|
||||
};
|
||||
|
||||
function sorter(a, b) {
|
||||
return a.id.toLocaleLowerCase().localeCompare(b.id.toLocaleLowerCase());
|
||||
}
|
||||
|
||||
Object.defineProperty(FirefoxProfileMigrator.prototype, "sourceProfiles", {
|
||||
get: function() {
|
||||
return [{id: x, name: x} for (x of this._getAllProfiles().keys())].sort(sorter);
|
||||
}
|
||||
});
|
||||
|
||||
FirefoxProfileMigrator.prototype._getFileObject = function(dir, fileName) {
|
||||
let file = dir.clone();
|
||||
file.append(fileName);
|
||||
@ -42,19 +73,13 @@ FirefoxProfileMigrator.prototype._getFileObject = function(dir, fileName) {
|
||||
// they are not expected to work alone. Return null to avoid trying to
|
||||
// copy non-existing files.
|
||||
return file.exists() ? file : null;
|
||||
}
|
||||
};
|
||||
|
||||
FirefoxProfileMigrator.prototype.getResources = function() {
|
||||
// Only allow migrating from the default (selected) profile since this will
|
||||
// be the only one returned by the toolkit profile service after bug 214675.
|
||||
let sourceProfile =
|
||||
FirefoxProfileMigrator.prototype.getResources = function(aProfile) {
|
||||
let sourceProfileDir = aProfile ? this._getAllProfiles().get(aProfile.id) :
|
||||
Components.classes["@mozilla.org/toolkit/profile-service;1"]
|
||||
.getService(Components.interfaces.nsIToolkitProfileService)
|
||||
.selectedProfile;
|
||||
if (!sourceProfile)
|
||||
return null;
|
||||
|
||||
let sourceProfileDir = sourceProfile.rootDir;
|
||||
.selectedProfile.rootDir;
|
||||
if (!sourceProfileDir || !sourceProfileDir.exists() ||
|
||||
!sourceProfileDir.isReadable())
|
||||
return null;
|
||||
@ -67,10 +92,10 @@ FirefoxProfileMigrator.prototype.getResources = function() {
|
||||
if (sourceProfileDir.equals(currentProfileDir))
|
||||
return null;
|
||||
|
||||
return this._getResourcesInternal(sourceProfileDir, currentProfileDir);
|
||||
}
|
||||
return this._getResourcesInternal(sourceProfileDir, currentProfileDir, aProfile);
|
||||
};
|
||||
|
||||
FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileDir, currentProfileDir) {
|
||||
FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileDir, currentProfileDir, aProfile) {
|
||||
let getFileResource = function(aMigrationType, aFileNames) {
|
||||
let files = [];
|
||||
for (let fileName of aFileNames) {
|
||||
@ -107,7 +132,7 @@ FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileD
|
||||
let sessionFile = this._getFileObject(sourceProfileDir, "sessionstore.js");
|
||||
let session;
|
||||
if (sessionFile) {
|
||||
session = {
|
||||
session = aProfile ? getFileResource(types.SESSION, ["sessionstore.js"]) : {
|
||||
type: types.SESSION,
|
||||
migrate: function(aCallback) {
|
||||
sessionCheckpoints.copyTo(currentProfileDir, "sessionCheckpoints.json");
|
||||
@ -217,7 +242,7 @@ FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileD
|
||||
return [r for each (r in [places, cookies, passwords, formData,
|
||||
dictionary, bookmarksBackups, session,
|
||||
times, healthReporter]) if (r)];
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(FirefoxProfileMigrator.prototype, "startupOnlyMigrator", {
|
||||
get: function() true
|
||||
|
@ -45,13 +45,10 @@ function getMigrationBundle() {
|
||||
* but it will soon be exposed properly.
|
||||
*/
|
||||
function getMigratorKeyForDefaultBrowser() {
|
||||
// Don't map Firefox to the Firefox migrator, because we don't
|
||||
// expect it to ever show up as an option in the wizard.
|
||||
// We may want to revise this if/when we use separate profiles
|
||||
// for each Firefox-update channel.
|
||||
const APP_DESC_TO_KEY = {
|
||||
"Internet Explorer": "ie",
|
||||
"Safari": "safari",
|
||||
"Firefox": "firefox",
|
||||
"Google Chrome": "chrome", // Windows, Linux
|
||||
"Chrome": "chrome", // OS X
|
||||
};
|
||||
@ -485,11 +482,11 @@ this.MigrationUtils = Object.freeze({
|
||||
get migrators() {
|
||||
let migratorKeysOrdered = [
|
||||
#ifdef XP_WIN
|
||||
"ie", "chrome", "safari"
|
||||
"firefox", "ie", "chrome", "safari"
|
||||
#elifdef XP_MACOSX
|
||||
"safari", "chrome"
|
||||
"firefox", "safari", "chrome"
|
||||
#elifdef XP_UNIX
|
||||
"chrome"
|
||||
"firefox", "chrome"
|
||||
#endif
|
||||
];
|
||||
|
||||
|
@ -125,7 +125,10 @@ var MigrationWizard = {
|
||||
|
||||
// check for more than one source profile
|
||||
var sourceProfiles = this._migrator.sourceProfiles;
|
||||
if (sourceProfiles && sourceProfiles.length > 1) {
|
||||
if (this._skipImportSourcePage) {
|
||||
this._wiz.currentPage.next = "homePageImport";
|
||||
}
|
||||
else if (sourceProfiles && sourceProfiles.length > 1) {
|
||||
this._wiz.currentPage.next = "selectProfile";
|
||||
}
|
||||
else {
|
||||
|
@ -32,6 +32,7 @@
|
||||
<description id="importBookmarks" control="importSourceGroup" hidden="true">&importFromBookmarks.label;</description>
|
||||
|
||||
<radiogroup id="importSourceGroup" align="start">
|
||||
<radio id="firefox" label="&importFromFirefox.label;" accesskey="&importFromFirefox.accesskey;"/>
|
||||
#ifdef XP_WIN
|
||||
<radio id="ie" label="&importFromIE.label;" accesskey="&importFromIE.accesskey;"/>
|
||||
<radio id="chrome" label="&importFromChrome.label;" accesskey="&importFromChrome.accesskey;"/>
|
||||
@ -42,7 +43,6 @@
|
||||
#elifdef XP_UNIX
|
||||
<radio id="chrome" label="&importFromChrome.label;" accesskey="&importFromChrome.accesskey;"/>
|
||||
#endif
|
||||
<radio id="firefox" label="&importFromFirefox.label;" accesskey="&importFromFirefox.accesskey;"/>
|
||||
<radio id="nothing" label="&importFromNothing.label;" accesskey="&importFromNothing.accesskey;" hidden="true"/>
|
||||
</radiogroup>
|
||||
<label id="noSources" hidden="true">&noMigrationSources.label;</label>
|
||||
|
19
configure.in
19
configure.in
@ -57,18 +57,21 @@ NSS_VERSION=3
|
||||
|
||||
dnl Set the minimum version of toolkit libs used by mozilla
|
||||
dnl ========================================================
|
||||
GLIB_VERSION=1.2.0
|
||||
GLIB_VERSION=2.22
|
||||
# 2_26 is the earliest version we can set GLIB_VERSION_MIN_REQUIRED.
|
||||
# The macro won't be used when compiling with earlier versions anyway.
|
||||
GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26
|
||||
GIO_VERSION=2.22
|
||||
PERL_VERSION=5.006
|
||||
CAIRO_VERSION=1.10
|
||||
PANGO_VERSION=1.22.0
|
||||
GTK2_VERSION=2.18.0
|
||||
GTK3_VERSION=3.0.0
|
||||
GTK3_VERSION=3.4.0
|
||||
WINDRES_VERSION=2.14.90
|
||||
W32API_VERSION=3.14
|
||||
GNOMEVFS_VERSION=2.0
|
||||
GNOMEUI_VERSION=2.2.0
|
||||
GCONF_VERSION=1.2.1
|
||||
GIO_VERSION=2.20
|
||||
STARTUP_NOTIFICATION_VERSION=0.8
|
||||
DBUS_VERSION=0.60
|
||||
SQLITE_VERSION=3.8.8.2
|
||||
@ -4407,13 +4410,19 @@ if test "$COMPILE_ENVIRONMENT"; then
|
||||
dnl of a make reference because of how TK_LIBS is mangled in toolkit/library/moz.build
|
||||
dnl for GTK+3 builds.
|
||||
TK_LIBS=$MOZ_GTK3_LIBS
|
||||
GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32
|
||||
fi
|
||||
if test "$MOZ_ENABLE_GTK2"; then
|
||||
GLIB_VERSION_MAX_ALLOWED=$GLIB_VERSION_MIN_REQUIRED
|
||||
fi
|
||||
if test "$MOZ_ENABLE_GTK"; then
|
||||
if test "$MOZ_X11"; then
|
||||
GDK_PACKAGES=gdk-x11-2.0
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED)
|
||||
AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED)
|
||||
|
||||
PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
|
||||
PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 >= $GLIB_VERSION gobject-2.0 $GDK_PACKAGES)
|
||||
MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS"
|
||||
fi
|
||||
|
||||
@ -5617,7 +5626,7 @@ MOZ_ARG_ENABLE_BOOL(alsa,
|
||||
if test -n "$MOZ_ALSA"; then
|
||||
PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
|
||||
[echo "$MOZ_ALSA_PKG_ERRORS"
|
||||
AC_MSG_ERROR([Need alsa for Ogg, Wave or WebM decoding on Linux. Disable with --disable-ogg --disable-wave --disable-webm. (On Ubuntu, you might try installing the package libasound2-dev.)])])
|
||||
AC_MSG_ERROR([Need alsa for audio output on Linux. (On Ubuntu, you might try installing the package libasound2-dev.)])])
|
||||
fi
|
||||
|
||||
AC_SUBST(MOZ_ALSA)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=4 sw=4 et tw=80:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@ -14,9 +14,9 @@ class nsString;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
class Link;
|
||||
}
|
||||
namespace dom {
|
||||
class Link;
|
||||
}
|
||||
|
||||
// 0057c9d3-b98e-4933-bdc5-0275d06705e1
|
||||
#define IHISTORY_IID \
|
||||
@ -25,121 +25,120 @@ namespace mozilla {
|
||||
class IHistory : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(IHISTORY_IID)
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(IHISTORY_IID)
|
||||
|
||||
/**
|
||||
* Registers the Link for notifications about the visited-ness of aURI.
|
||||
* Consumers should assume that the URI is unvisited after calling this, and
|
||||
* they will be notified if that state (unvisited) changes by having
|
||||
* SetLinkState called on themselves. This function is guaranteed to run to
|
||||
* completion before aLink is notified. After the node is notified, it will
|
||||
* be unregistered.
|
||||
*
|
||||
* @note SetLinkState must not call RegisterVisitedCallback or
|
||||
* UnregisterVisitedCallback.
|
||||
*
|
||||
* @pre aURI must not be null.
|
||||
* @pre aLink may be null only in the parent (chrome) process.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI to check.
|
||||
* @param aLink
|
||||
* The link to update whenever the history status changes. The
|
||||
* implementation will only hold onto a raw pointer, so if this
|
||||
* object should be destroyed, be sure to call
|
||||
* UnregisterVistedCallback first.
|
||||
*/
|
||||
NS_IMETHOD RegisterVisitedCallback(nsIURI* aURI, dom::Link* aLink) = 0;
|
||||
|
||||
/**
|
||||
* Unregisters a previously registered Link object. This must be called
|
||||
* before destroying the registered object.
|
||||
*
|
||||
* @pre aURI must not be null.
|
||||
* @pre aLink must not be null.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI that aLink was registered for.
|
||||
* @param aLink
|
||||
* The link object to unregister for aURI.
|
||||
*/
|
||||
NS_IMETHOD UnregisterVisitedCallback(nsIURI* aURI, dom::Link* aLink) = 0;
|
||||
|
||||
enum VisitFlags
|
||||
{
|
||||
/**
|
||||
* Registers the Link for notifications about the visited-ness of aURI.
|
||||
* Consumers should assume that the URI is unvisited after calling this, and
|
||||
* they will be notified if that state (unvisited) changes by having
|
||||
* SetLinkState called on themselves. This function is guaranteed to run to
|
||||
* completion before aLink is notified. After the node is notified, it will
|
||||
* be unregistered.
|
||||
*
|
||||
* @note SetLinkState must not call RegisterVisitedCallback or
|
||||
* UnregisterVisitedCallback.
|
||||
*
|
||||
* @pre aURI must not be null.
|
||||
* @pre aLink may be null only in the parent (chrome) process.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI to check.
|
||||
* @param aLink
|
||||
* The link to update whenever the history status changes. The
|
||||
* implementation will only hold onto a raw pointer, so if this
|
||||
* object should be destroyed, be sure to call
|
||||
* UnregisterVistedCallback first.
|
||||
* Indicates whether the URI was loaded in a top-level window.
|
||||
*/
|
||||
NS_IMETHOD RegisterVisitedCallback(nsIURI *aURI, dom::Link *aLink) = 0;
|
||||
|
||||
TOP_LEVEL = 1 << 0,
|
||||
/**
|
||||
* Unregisters a previously registered Link object. This must be called
|
||||
* before destroying the registered object.
|
||||
*
|
||||
* @pre aURI must not be null.
|
||||
* @pre aLink must not be null.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI that aLink was registered for.
|
||||
* @param aLink
|
||||
* The link object to unregister for aURI.
|
||||
* Indicates whether the URI was loaded as part of a permanent redirect.
|
||||
*/
|
||||
NS_IMETHOD UnregisterVisitedCallback(nsIURI *aURI, dom::Link *aLink) = 0;
|
||||
|
||||
enum VisitFlags {
|
||||
/**
|
||||
* Indicates whether the URI was loaded in a top-level window.
|
||||
*/
|
||||
TOP_LEVEL = 1 << 0,
|
||||
/**
|
||||
* Indicates whether the URI was loaded as part of a permanent redirect.
|
||||
*/
|
||||
REDIRECT_PERMANENT = 1 << 1,
|
||||
/**
|
||||
* Indicates whether the URI was loaded as part of a temporary redirect.
|
||||
*/
|
||||
REDIRECT_TEMPORARY = 1 << 2,
|
||||
/**
|
||||
* Indicates the URI is redirecting (Response code 3xx).
|
||||
*/
|
||||
REDIRECT_SOURCE = 1 << 3,
|
||||
/**
|
||||
* Indicates the URI caused an error that is unlikely fixable by a
|
||||
* retry, like a not found or unfetchable page.
|
||||
*/
|
||||
UNRECOVERABLE_ERROR = 1 << 4
|
||||
};
|
||||
|
||||
REDIRECT_PERMANENT = 1 << 1,
|
||||
/**
|
||||
* Adds a history visit for the URI.
|
||||
*
|
||||
* @pre aURI must not be null.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI of the page being visited.
|
||||
* @param aLastVisitedURI
|
||||
* The URI of the last visit in the chain.
|
||||
* @param aFlags
|
||||
* The VisitFlags describing this visit.
|
||||
* Indicates whether the URI was loaded as part of a temporary redirect.
|
||||
*/
|
||||
NS_IMETHOD VisitURI(
|
||||
nsIURI *aURI,
|
||||
nsIURI *aLastVisitedURI,
|
||||
uint32_t aFlags
|
||||
) = 0;
|
||||
|
||||
REDIRECT_TEMPORARY = 1 << 2,
|
||||
/**
|
||||
* Set the title of the URI.
|
||||
*
|
||||
* @pre aURI must not be null.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI to set the title for.
|
||||
* @param aTitle
|
||||
* The title string.
|
||||
* Indicates the URI is redirecting (Response code 3xx).
|
||||
*/
|
||||
NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) = 0;
|
||||
|
||||
REDIRECT_SOURCE = 1 << 3,
|
||||
/**
|
||||
* Notifies about the visited status of a given URI.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI to notify about.
|
||||
* Indicates the URI caused an error that is unlikely fixable by a
|
||||
* retry, like a not found or unfetchable page.
|
||||
*/
|
||||
NS_IMETHOD NotifyVisited(nsIURI* aURI) = 0;
|
||||
UNRECOVERABLE_ERROR = 1 << 4
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a history visit for the URI.
|
||||
*
|
||||
* @pre aURI must not be null.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI of the page being visited.
|
||||
* @param aLastVisitedURI
|
||||
* The URI of the last visit in the chain.
|
||||
* @param aFlags
|
||||
* The VisitFlags describing this visit.
|
||||
*/
|
||||
NS_IMETHOD VisitURI(nsIURI* aURI,
|
||||
nsIURI* aLastVisitedURI,
|
||||
uint32_t aFlags) = 0;
|
||||
|
||||
/**
|
||||
* Set the title of the URI.
|
||||
*
|
||||
* @pre aURI must not be null.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI to set the title for.
|
||||
* @param aTitle
|
||||
* The title string.
|
||||
*/
|
||||
NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) = 0;
|
||||
|
||||
/**
|
||||
* Notifies about the visited status of a given URI.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI to notify about.
|
||||
*/
|
||||
NS_IMETHOD NotifyVisited(nsIURI* aURI) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(IHistory, IHISTORY_IID)
|
||||
|
||||
#define NS_DECL_IHISTORY \
|
||||
NS_IMETHOD RegisterVisitedCallback(nsIURI *aURI, \
|
||||
mozilla::dom::Link *aContent) MOZ_OVERRIDE; \
|
||||
NS_IMETHOD UnregisterVisitedCallback(nsIURI *aURI, \
|
||||
mozilla::dom::Link *aContent) MOZ_OVERRIDE; \
|
||||
NS_IMETHOD VisitURI(nsIURI *aURI, \
|
||||
nsIURI *aLastVisitedURI, \
|
||||
uint32_t aFlags) MOZ_OVERRIDE; \
|
||||
NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) MOZ_OVERRIDE; \
|
||||
NS_IMETHOD NotifyVisited(nsIURI* aURI) MOZ_OVERRIDE;
|
||||
NS_IMETHOD RegisterVisitedCallback(nsIURI* aURI, \
|
||||
mozilla::dom::Link* aContent) MOZ_OVERRIDE; \
|
||||
NS_IMETHOD UnregisterVisitedCallback(nsIURI* aURI, \
|
||||
mozilla::dom::Link* aContent) MOZ_OVERRIDE; \
|
||||
NS_IMETHOD VisitURI(nsIURI* aURI, \
|
||||
nsIURI* aLastVisitedURI, \
|
||||
uint32_t aFlags) MOZ_OVERRIDE; \
|
||||
NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) MOZ_OVERRIDE; \
|
||||
NS_IMETHOD NotifyVisited(nsIURI* aURI) MOZ_OVERRIDE;
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 ts=8 et tw=80 : */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -159,7 +159,7 @@ LoadContext::GetAppId(uint32_t* aAppId)
|
||||
// LoadContext::nsIInterfaceRequestor
|
||||
//-----------------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
LoadContext::GetInterface(const nsIID &aIID, void **aResult)
|
||||
LoadContext::GetInterface(const nsIID& aIID, void** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = nullptr;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 ts=8 et tw=80 : */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -31,8 +31,9 @@ namespace mozilla {
|
||||
* to separate the safebrowsing cookie.
|
||||
*/
|
||||
|
||||
class LoadContext MOZ_FINAL : public nsILoadContext,
|
||||
public nsIInterfaceRequestor
|
||||
class LoadContext MOZ_FINAL
|
||||
: public nsILoadContext
|
||||
, public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -112,15 +113,15 @@ public:
|
||||
private:
|
||||
~LoadContext() {}
|
||||
|
||||
nsWeakPtr mTopFrameElement;
|
||||
uint64_t mNestedFrameId;
|
||||
uint32_t mAppId;
|
||||
bool mIsContent;
|
||||
bool mUsePrivateBrowsing;
|
||||
bool mUseRemoteTabs;
|
||||
bool mIsInBrowserElement;
|
||||
nsWeakPtr mTopFrameElement;
|
||||
uint64_t mNestedFrameId;
|
||||
uint32_t mAppId;
|
||||
bool mIsContent;
|
||||
bool mUsePrivateBrowsing;
|
||||
bool mUseRemoteTabs;
|
||||
bool mIsInBrowserElement;
|
||||
#ifdef DEBUG
|
||||
bool mIsNotNull;
|
||||
bool mIsNotNull;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 ts=8 et tw=80 : */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -93,12 +93,12 @@ LoadInfo::TriggeringPrincipal()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetLoadingDocument(nsIDOMDocument** outLoadingDocument)
|
||||
LoadInfo::GetLoadingDocument(nsIDOMDocument** aResult)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext);
|
||||
if (node) {
|
||||
nsCOMPtr<nsIDOMDocument> context = do_QueryInterface(node->OwnerDoc());
|
||||
context.forget(outLoadingDocument);
|
||||
context.forget(aResult);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -111,16 +111,17 @@ LoadInfo::LoadingNode()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetSecurityFlags(nsSecurityFlags* outSecurityFlags)
|
||||
LoadInfo::GetSecurityFlags(nsSecurityFlags* aResult)
|
||||
{
|
||||
*outSecurityFlags = mSecurityFlags;
|
||||
*aResult = mSecurityFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetForceInheritPrincipal(bool* aInheritPrincipal)
|
||||
{
|
||||
*aInheritPrincipal = (mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
|
||||
*aInheritPrincipal =
|
||||
(mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -132,9 +133,9 @@ LoadInfo::GetLoadingSandboxed(bool* aLoadingSandboxed)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetContentPolicyType(nsContentPolicyType* outContentPolicyType)
|
||||
LoadInfo::GetContentPolicyType(nsContentPolicyType* aResult)
|
||||
{
|
||||
*outContentPolicyType = mContentPolicyType;
|
||||
*aResult = mContentPolicyType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -153,9 +154,9 @@ LoadInfo::BaseURI()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetInnerWindowID(uint32_t* outInnerWindowID)
|
||||
LoadInfo::GetInnerWindowID(uint32_t* aResult)
|
||||
{
|
||||
*outInnerWindowID = mInnerWindowID;
|
||||
*aResult = mInnerWindowID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 ts=8 et tw=80 : */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -56,11 +56,11 @@ private:
|
||||
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
|
||||
nsWeakPtr mLoadingContext;
|
||||
nsSecurityFlags mSecurityFlags;
|
||||
nsContentPolicyType mContentPolicyType;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
uint32_t mInnerWindowID;
|
||||
nsWeakPtr mLoadingContext;
|
||||
nsSecurityFlags mSecurityFlags;
|
||||
nsContentPolicyType mContentPolicyType;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
uint32_t mInnerWindowID;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 ts=8 et tw=80 : */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -34,7 +34,8 @@ SerializedLoadContext::SerializedLoadContext(nsIChannel* aChannel)
|
||||
bool isOverriden = false;
|
||||
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(aChannel);
|
||||
if (pbChannel &&
|
||||
NS_SUCCEEDED(pbChannel->IsPrivateModeOverriden(&isPrivate, &isOverriden)) &&
|
||||
NS_SUCCEEDED(pbChannel->IsPrivateModeOverriden(&isPrivate,
|
||||
&isOverriden)) &&
|
||||
isOverriden) {
|
||||
mUsePrivateBrowsing = isPrivate;
|
||||
mIsPrivateBitValid = true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 ts=8 et tw=80 : */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -37,26 +37,19 @@ public:
|
||||
|
||||
void Init(nsILoadContext* aLoadContext);
|
||||
|
||||
bool IsNotNull() const
|
||||
{
|
||||
return mIsNotNull;
|
||||
}
|
||||
|
||||
bool IsPrivateBitValid() const
|
||||
{
|
||||
return mIsPrivateBitValid;
|
||||
}
|
||||
bool IsNotNull() const { return mIsNotNull; }
|
||||
bool IsPrivateBitValid() const { return mIsPrivateBitValid; }
|
||||
|
||||
// used to indicate if child-side LoadContext * was null.
|
||||
bool mIsNotNull;
|
||||
bool mIsNotNull;
|
||||
// used to indicate if child-side mUsePrivateBrowsing flag is valid, even if
|
||||
// mIsNotNull is false, i.e., child LoadContext was null.
|
||||
bool mIsPrivateBitValid;
|
||||
bool mIsContent;
|
||||
bool mUsePrivateBrowsing;
|
||||
bool mUseRemoteTabs;
|
||||
bool mIsInBrowserElement;
|
||||
uint32_t mAppId;
|
||||
bool mIsPrivateBitValid;
|
||||
bool mIsContent;
|
||||
bool mUsePrivateBrowsing;
|
||||
bool mUseRemoteTabs;
|
||||
bool mIsInBrowserElement;
|
||||
uint32_t mAppId;
|
||||
};
|
||||
|
||||
// Function to serialize over IPDL
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: set ts=2 sw=2 tw=80 et:
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: set ts=2 sw=2 tw=80 et:
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@ -34,9 +33,9 @@ public:
|
||||
// Check whether two markers should be considered the same,
|
||||
// for the purpose of pairing start and end markers. Normally
|
||||
// this definition suffices.
|
||||
virtual bool Equals(const TimelineMarker* other)
|
||||
virtual bool Equals(const TimelineMarker* aOther)
|
||||
{
|
||||
return strcmp(mName, other->mName) == 0;
|
||||
return strcmp(mName, aOther->mName) == 0;
|
||||
}
|
||||
|
||||
// Add details specific to this marker type to aMarker. The
|
||||
@ -44,34 +43,18 @@ public:
|
||||
// called on both the starting and ending markers of a pair.
|
||||
// Ordinarily the ending marker doesn't need to do anything
|
||||
// here.
|
||||
virtual void AddDetails(mozilla::dom::ProfileTimelineMarker& aMarker)
|
||||
{
|
||||
}
|
||||
virtual void AddDetails(mozilla::dom::ProfileTimelineMarker& aMarker) {}
|
||||
|
||||
virtual void AddLayerRectangles(mozilla::dom::Sequence<mozilla::dom::ProfileTimelineLayerRect>&)
|
||||
virtual void AddLayerRectangles(
|
||||
mozilla::dom::Sequence<mozilla::dom::ProfileTimelineLayerRect>&)
|
||||
{
|
||||
MOZ_ASSERT_UNREACHABLE("can only be called on layer markers");
|
||||
}
|
||||
|
||||
const char* GetName() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
TracingMetadata GetMetaData() const
|
||||
{
|
||||
return mMetaData;
|
||||
}
|
||||
|
||||
DOMHighResTimeStamp GetTime() const
|
||||
{
|
||||
return mTime;
|
||||
}
|
||||
|
||||
const nsString& GetCause() const
|
||||
{
|
||||
return mCause;
|
||||
}
|
||||
const char* GetName() const { return mName; }
|
||||
TracingMetadata GetMetaData() const { return mMetaData; }
|
||||
DOMHighResTimeStamp GetTime() const { return mTime; }
|
||||
const nsString& GetCause() const { return mCause; }
|
||||
|
||||
JSObject* GetStack()
|
||||
{
|
||||
@ -82,7 +65,6 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void CaptureStack()
|
||||
{
|
||||
JSContext* ctx = nsContentUtils::GetCurrentJSContext();
|
||||
@ -97,7 +79,6 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const char* mName;
|
||||
TracingMetadata mMetaData;
|
||||
DOMHighResTimeStamp mTime;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:set ts=4 sw=4 sts=4 et cindent: */
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -12,10 +12,11 @@
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsAboutRedirector, nsIAboutModule)
|
||||
|
||||
struct RedirEntry {
|
||||
const char* id;
|
||||
const char* url;
|
||||
uint32_t flags;
|
||||
struct RedirEntry
|
||||
{
|
||||
const char* id;
|
||||
const char* url;
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -29,142 +30,166 @@ struct RedirEntry {
|
||||
URI. Perhaps we should separate the two concepts out...
|
||||
*/
|
||||
static RedirEntry kRedirMap[] = {
|
||||
{ "", "chrome://global/content/about.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
{ "about", "chrome://global/content/aboutAbout.xhtml", 0 },
|
||||
{ "credits", "http://www.mozilla.org/credits/",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
|
||||
{ "mozilla", "chrome://global/content/mozilla.xhtml",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
|
||||
{ "plugins", "chrome://global/content/plugins.html", 0 },
|
||||
{ "config", "chrome://global/content/config.xul", 0 },
|
||||
{
|
||||
"", "chrome://global/content/about.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT
|
||||
},
|
||||
{ "about", "chrome://global/content/aboutAbout.xhtml", 0 },
|
||||
{
|
||||
"credits", "http://www.mozilla.org/credits/",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
|
||||
},
|
||||
{
|
||||
"mozilla", "chrome://global/content/mozilla.xhtml",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
|
||||
},
|
||||
{ "plugins", "chrome://global/content/plugins.html", 0 },
|
||||
{ "config", "chrome://global/content/config.xul", 0 },
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
{ "crashes", "chrome://global/content/crashes.xhtml", 0 },
|
||||
{ "crashes", "chrome://global/content/crashes.xhtml", 0 },
|
||||
#endif
|
||||
{ "logo", "chrome://branding/content/about.png",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT},
|
||||
{ "buildconfig", "chrome://global/content/buildconfig.html",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
|
||||
{ "license", "chrome://global/content/license.html",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
|
||||
{ "neterror", "chrome://global/content/netError.xhtml",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
{
|
||||
"logo", "chrome://branding/content/about.png",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
|
||||
},
|
||||
{
|
||||
"buildconfig", "chrome://global/content/buildconfig.html",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
|
||||
},
|
||||
{
|
||||
"license", "chrome://global/content/license.html",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
|
||||
},
|
||||
{
|
||||
"neterror", "chrome://global/content/netError.xhtml",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
nsIAboutModule::URI_CAN_LOAD_IN_CHILD |
|
||||
nsIAboutModule::ALLOW_SCRIPT |
|
||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
|
||||
{ "memory", "chrome://global/content/aboutMemory.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
{ "compartments", "chrome://global/content/aboutCompartments.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
{ "addons", "chrome://mozapps/content/extensions/extensions.xul",
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
{ "newaddon", "chrome://mozapps/content/extensions/newaddon.xul",
|
||||
nsIAboutModule::ALLOW_SCRIPT |
|
||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
|
||||
{ "support", "chrome://global/content/aboutSupport.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
{ "telemetry", "chrome://global/content/aboutTelemetry.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
{ "networking", "chrome://global/content/aboutNetworking.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
{ "webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT },
|
||||
// about:srcdoc is unresolvable by specification. It is included here
|
||||
// because the security manager would disallow srcdoc iframes otherwise.
|
||||
{ "srcdoc", "about:blank",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT }
|
||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT
|
||||
},
|
||||
{
|
||||
"memory", "chrome://global/content/aboutMemory.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT
|
||||
},
|
||||
{
|
||||
"compartments", "chrome://global/content/aboutCompartments.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT
|
||||
},
|
||||
{
|
||||
"addons", "chrome://mozapps/content/extensions/extensions.xul",
|
||||
nsIAboutModule::ALLOW_SCRIPT
|
||||
},
|
||||
{
|
||||
"newaddon", "chrome://mozapps/content/extensions/newaddon.xul",
|
||||
nsIAboutModule::ALLOW_SCRIPT |
|
||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT
|
||||
},
|
||||
{
|
||||
"support", "chrome://global/content/aboutSupport.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT
|
||||
},
|
||||
{
|
||||
"telemetry", "chrome://global/content/aboutTelemetry.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT
|
||||
},
|
||||
{
|
||||
"networking", "chrome://global/content/aboutNetworking.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT
|
||||
},
|
||||
{
|
||||
"webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.xhtml",
|
||||
nsIAboutModule::ALLOW_SCRIPT
|
||||
},
|
||||
// about:srcdoc is unresolvable by specification. It is included here
|
||||
// because the security manager would disallow srcdoc iframes otherwise.
|
||||
{
|
||||
"srcdoc", "about:blank",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT
|
||||
}
|
||||
};
|
||||
static const int kRedirTotal = mozilla::ArrayLength(kRedirMap);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAboutRedirector::NewChannel(nsIURI* aURI,
|
||||
nsILoadInfo* aLoadInfo,
|
||||
nsIChannel** result)
|
||||
nsIChannel** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
NS_ASSERTION(result, "must not be null");
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
NS_ASSERTION(aResult, "must not be null");
|
||||
|
||||
nsAutoCString path;
|
||||
nsresult rv = NS_GetAboutModuleName(aURI, path);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAutoCString path;
|
||||
nsresult rv = NS_GetAboutModuleName(aURI, path);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (int i = 0; i < kRedirTotal; i++) {
|
||||
if (!strcmp(path.get(), kRedirMap[i].id)) {
|
||||
nsCOMPtr<nsIChannel> tempChannel;
|
||||
nsCOMPtr<nsIURI> tempURI;
|
||||
rv = NS_NewURI(getter_AddRefs(tempURI), kRedirMap[i].url);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// Bug 1087720 (and Bug 1099296):
|
||||
// Once all callsites have been updated to call NewChannel2()
|
||||
// instead of NewChannel() we should have a non-null loadInfo
|
||||
// consistently. Until then we have to branch on the loadInfo.
|
||||
if (aLoadInfo) {
|
||||
rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
|
||||
tempURI,
|
||||
aLoadInfo);
|
||||
} else {
|
||||
rv = ioService->NewChannelFromURI(tempURI, getter_AddRefs(tempChannel));
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
for (int i=0; i<kRedirTotal; i++)
|
||||
{
|
||||
if (!strcmp(path.get(), kRedirMap[i].id))
|
||||
{
|
||||
nsCOMPtr<nsIChannel> tempChannel;
|
||||
nsCOMPtr<nsIURI> tempURI;
|
||||
rv = NS_NewURI(getter_AddRefs(tempURI), kRedirMap[i].url);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// Bug 1087720 (and Bug 1099296):
|
||||
// Once all callsites have been updated to call NewChannel2()
|
||||
// instead of NewChannel() we should have a non-null loadInfo
|
||||
// consistently. Until then we have to branch on the loadInfo.
|
||||
if (aLoadInfo) {
|
||||
rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
|
||||
tempURI,
|
||||
aLoadInfo);
|
||||
}
|
||||
else {
|
||||
rv = ioService->NewChannelFromURI(tempURI,
|
||||
getter_AddRefs(tempChannel));
|
||||
}
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
tempChannel->SetOriginalURI(aURI);
|
||||
|
||||
tempChannel->SetOriginalURI(aURI);
|
||||
|
||||
NS_ADDREF(*result = tempChannel);
|
||||
return rv;
|
||||
}
|
||||
NS_ADDREF(*aResult = tempChannel);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ERROR("nsAboutRedirector called for unknown case");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
NS_ERROR("nsAboutRedirector called for unknown case");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result)
|
||||
nsAboutRedirector::GetURIFlags(nsIURI* aURI, uint32_t* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
|
||||
nsAutoCString name;
|
||||
nsresult rv = NS_GetAboutModuleName(aURI, name);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAutoCString name;
|
||||
nsresult rv = NS_GetAboutModuleName(aURI, name);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (int i=0; i < kRedirTotal; i++)
|
||||
{
|
||||
if (name.EqualsASCII(kRedirMap[i].id))
|
||||
{
|
||||
*result = kRedirMap[i].flags;
|
||||
return NS_OK;
|
||||
}
|
||||
for (int i = 0; i < kRedirTotal; i++) {
|
||||
if (name.EqualsASCII(kRedirMap[i].id)) {
|
||||
*aResult = kRedirMap[i].flags;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ERROR("nsAboutRedirector called for unknown case");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
NS_ERROR("nsAboutRedirector called for unknown case");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAboutRedirector::GetIndexedDBOriginPostfix(nsIURI *aURI, nsAString &result)
|
||||
nsAboutRedirector::GetIndexedDBOriginPostfix(nsIURI* aURI, nsAString& aResult)
|
||||
{
|
||||
SetDOMStringToNull(result);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
SetDOMStringToNull(aResult);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAboutRedirector::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
nsAboutRedirector::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
||||
{
|
||||
nsAboutRedirector* about = new nsAboutRedirector();
|
||||
if (about == nullptr)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(about);
|
||||
nsresult rv = about->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(about);
|
||||
return rv;
|
||||
nsAboutRedirector* about = new nsAboutRedirector();
|
||||
NS_ADDREF(about);
|
||||
nsresult rv = about->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(about);
|
||||
return rv;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -11,17 +12,16 @@
|
||||
class nsAboutRedirector : public nsIAboutModule
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIABOUTMODULE
|
||||
NS_DECL_NSIABOUTMODULE
|
||||
|
||||
nsAboutRedirector() {}
|
||||
nsAboutRedirector() {}
|
||||
|
||||
static nsresult
|
||||
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
|
||||
|
||||
protected:
|
||||
virtual ~nsAboutRedirector() {}
|
||||
virtual ~nsAboutRedirector() {}
|
||||
};
|
||||
|
||||
#define NS_ABOUT_REDIRECTOR_MODULE_CID \
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -29,9 +30,9 @@ using namespace mozilla;
|
||||
//*****************************************************************************
|
||||
|
||||
nsDSURIContentListener::nsDSURIContentListener(nsDocShell* aDocShell)
|
||||
: mDocShell(aDocShell)
|
||||
, mExistingJPEGRequest(nullptr)
|
||||
, mParentContentListener(nullptr)
|
||||
: mDocShell(aDocShell)
|
||||
, mExistingJPEGRequest(nullptr)
|
||||
, mParentContentListener(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@ -40,439 +41,437 @@ nsDSURIContentListener::~nsDSURIContentListener()
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDSURIContentListener::Init()
|
||||
nsDSURIContentListener::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
mNavInfo = do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to get webnav info");
|
||||
return rv;
|
||||
nsresult rv;
|
||||
mNavInfo = do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to get webnav info");
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// nsDSURIContentListener::nsISupports
|
||||
//*****************************************************************************
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ADDREF(nsDSURIContentListener)
|
||||
NS_IMPL_RELEASE(nsDSURIContentListener)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsDSURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//*****************************************************************************
|
||||
// nsDSURIContentListener::nsIURIContentListener
|
||||
//*****************************************************************************
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::OnStartURIOpen(nsIURI* aURI, bool* aAbortOpen)
|
||||
{
|
||||
// If mDocShell is null here, that means someone's starting a load
|
||||
// in our docshell after it's already been destroyed. Don't let
|
||||
// that happen.
|
||||
if (!mDocShell) {
|
||||
*aAbortOpen = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURIContentListener> parentListener;
|
||||
GetParentContentListener(getter_AddRefs(parentListener));
|
||||
if (parentListener)
|
||||
return parentListener->OnStartURIOpen(aURI, aAbortOpen);
|
||||
|
||||
// If mDocShell is null here, that means someone's starting a load
|
||||
// in our docshell after it's already been destroyed. Don't let
|
||||
// that happen.
|
||||
if (!mDocShell) {
|
||||
*aAbortOpen = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURIContentListener> parentListener;
|
||||
GetParentContentListener(getter_AddRefs(parentListener));
|
||||
if (parentListener) {
|
||||
return parentListener->OnStartURIOpen(aURI, aAbortOpen);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::DoContent(const char* aContentType,
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::DoContent(const char* aContentType,
|
||||
bool aIsContentPreferred,
|
||||
nsIRequest* request,
|
||||
nsIRequest* aRequest,
|
||||
nsIStreamListener** aContentHandler,
|
||||
bool* aAbortProcess)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_ARG_POINTER(aContentHandler);
|
||||
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
|
||||
|
||||
// Check whether X-Frame-Options permits us to load this content in an
|
||||
// iframe and abort the load (unless we've disabled x-frame-options
|
||||
// checking).
|
||||
if (!CheckFrameOptions(request)) {
|
||||
*aAbortProcess = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aAbortProcess = false;
|
||||
|
||||
// determine if the channel has just been retargeted to us...
|
||||
nsLoadFlags loadFlags = 0;
|
||||
nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(request);
|
||||
|
||||
if (aOpenedChannel)
|
||||
aOpenedChannel->GetLoadFlags(&loadFlags);
|
||||
|
||||
if(loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI)
|
||||
{
|
||||
// XXX: Why does this not stop the content too?
|
||||
mDocShell->Stop(nsIWebNavigation::STOP_NETWORK);
|
||||
|
||||
mDocShell->SetLoadType(aIsContentPreferred ? LOAD_LINK : LOAD_NORMAL);
|
||||
}
|
||||
|
||||
// In case of multipart jpeg request (mjpeg) we don't really want to
|
||||
// create new viewer since the one we already have is capable of
|
||||
// rendering multipart jpeg correctly (see bug 625012)
|
||||
nsCOMPtr<nsIChannel> baseChannel;
|
||||
if (nsCOMPtr<nsIMultiPartChannel> mpchan = do_QueryInterface(request)) {
|
||||
mpchan->GetBaseChannel(getter_AddRefs(baseChannel));
|
||||
}
|
||||
|
||||
bool reuseCV = baseChannel
|
||||
&& baseChannel == mExistingJPEGRequest
|
||||
&& nsDependentCString(aContentType).EqualsLiteral("image/jpeg");
|
||||
|
||||
if (mExistingJPEGStreamListener && reuseCV) {
|
||||
nsRefPtr<nsIStreamListener> copy(mExistingJPEGStreamListener);
|
||||
copy.forget(aContentHandler);
|
||||
rv = NS_OK;
|
||||
} else {
|
||||
rv = mDocShell->CreateContentViewer(aContentType, request, aContentHandler);
|
||||
if (NS_SUCCEEDED(rv) && reuseCV) {
|
||||
mExistingJPEGStreamListener = *aContentHandler;
|
||||
} else {
|
||||
mExistingJPEGStreamListener = nullptr;
|
||||
}
|
||||
mExistingJPEGRequest = baseChannel;
|
||||
}
|
||||
|
||||
|
||||
if (rv == NS_ERROR_REMOTE_XUL) {
|
||||
request->Cancel(rv);
|
||||
*aAbortProcess = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// we don't know how to handle the content
|
||||
*aContentHandler = nullptr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
|
||||
nsCOMPtr<nsIDOMWindow> domWindow = mDocShell ? mDocShell->GetWindow()
|
||||
: nullptr;
|
||||
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
|
||||
domWindow->Focus();
|
||||
}
|
||||
nsresult rv;
|
||||
NS_ENSURE_ARG_POINTER(aContentHandler);
|
||||
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
|
||||
|
||||
// Check whether X-Frame-Options permits us to load this content in an
|
||||
// iframe and abort the load (unless we've disabled x-frame-options
|
||||
// checking).
|
||||
if (!CheckFrameOptions(aRequest)) {
|
||||
*aAbortProcess = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aAbortProcess = false;
|
||||
|
||||
// determine if the channel has just been retargeted to us...
|
||||
nsLoadFlags loadFlags = 0;
|
||||
nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(aRequest);
|
||||
|
||||
if (aOpenedChannel) {
|
||||
aOpenedChannel->GetLoadFlags(&loadFlags);
|
||||
}
|
||||
|
||||
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
|
||||
// XXX: Why does this not stop the content too?
|
||||
mDocShell->Stop(nsIWebNavigation::STOP_NETWORK);
|
||||
|
||||
mDocShell->SetLoadType(aIsContentPreferred ? LOAD_LINK : LOAD_NORMAL);
|
||||
}
|
||||
|
||||
// In case of multipart jpeg request (mjpeg) we don't really want to
|
||||
// create new viewer since the one we already have is capable of
|
||||
// rendering multipart jpeg correctly (see bug 625012)
|
||||
nsCOMPtr<nsIChannel> baseChannel;
|
||||
if (nsCOMPtr<nsIMultiPartChannel> mpchan = do_QueryInterface(aRequest)) {
|
||||
mpchan->GetBaseChannel(getter_AddRefs(baseChannel));
|
||||
}
|
||||
|
||||
bool reuseCV = baseChannel && baseChannel == mExistingJPEGRequest &&
|
||||
nsDependentCString(aContentType).EqualsLiteral("image/jpeg");
|
||||
|
||||
if (mExistingJPEGStreamListener && reuseCV) {
|
||||
nsRefPtr<nsIStreamListener> copy(mExistingJPEGStreamListener);
|
||||
copy.forget(aContentHandler);
|
||||
rv = NS_OK;
|
||||
} else {
|
||||
rv = mDocShell->CreateContentViewer(aContentType, aRequest, aContentHandler);
|
||||
if (NS_SUCCEEDED(rv) && reuseCV) {
|
||||
mExistingJPEGStreamListener = *aContentHandler;
|
||||
} else {
|
||||
mExistingJPEGStreamListener = nullptr;
|
||||
}
|
||||
mExistingJPEGRequest = baseChannel;
|
||||
}
|
||||
|
||||
if (rv == NS_ERROR_REMOTE_XUL) {
|
||||
aRequest->Cancel(rv);
|
||||
*aAbortProcess = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// we don't know how to handle the content
|
||||
*aContentHandler = nullptr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
|
||||
nsCOMPtr<nsIDOMWindow> domWindow =
|
||||
mDocShell ? mDocShell->GetWindow() : nullptr;
|
||||
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
|
||||
domWindow->Focus();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::IsPreferred(const char* aContentType,
|
||||
char ** aDesiredContentType,
|
||||
char** aDesiredContentType,
|
||||
bool* aCanHandle)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCanHandle);
|
||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||
NS_ENSURE_ARG_POINTER(aCanHandle);
|
||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||
|
||||
// the docshell has no idea if it is the preferred content provider or not.
|
||||
// It needs to ask its parent if it is the preferred content handler or not...
|
||||
// the docshell has no idea if it is the preferred content provider or not.
|
||||
// It needs to ask its parent if it is the preferred content handler or not...
|
||||
|
||||
nsCOMPtr<nsIURIContentListener> parentListener;
|
||||
GetParentContentListener(getter_AddRefs(parentListener));
|
||||
if (parentListener) {
|
||||
return parentListener->IsPreferred(aContentType,
|
||||
aDesiredContentType,
|
||||
aCanHandle);
|
||||
}
|
||||
// we used to return false here if we didn't have a parent properly
|
||||
// registered at the top of the docshell hierarchy to dictate what
|
||||
// content types this docshell should be a preferred handler for. But
|
||||
// this really makes it hard for developers using iframe or browser tags
|
||||
// because then they need to make sure they implement
|
||||
// nsIURIContentListener otherwise all link clicks would get sent to
|
||||
// another window because we said we weren't the preferred handler type.
|
||||
// I'm going to change the default now...if we can handle the content,
|
||||
// and someone didn't EXPLICITLY set a nsIURIContentListener at the top
|
||||
// of our docshell chain, then we'll now always attempt to process the
|
||||
// content ourselves...
|
||||
return CanHandleContent(aContentType,
|
||||
true,
|
||||
aDesiredContentType,
|
||||
aCanHandle);
|
||||
nsCOMPtr<nsIURIContentListener> parentListener;
|
||||
GetParentContentListener(getter_AddRefs(parentListener));
|
||||
if (parentListener) {
|
||||
return parentListener->IsPreferred(aContentType,
|
||||
aDesiredContentType,
|
||||
aCanHandle);
|
||||
}
|
||||
// we used to return false here if we didn't have a parent properly
|
||||
// registered at the top of the docshell hierarchy to dictate what
|
||||
// content types this docshell should be a preferred handler for. But
|
||||
// this really makes it hard for developers using iframe or browser tags
|
||||
// because then they need to make sure they implement
|
||||
// nsIURIContentListener otherwise all link clicks would get sent to
|
||||
// another window because we said we weren't the preferred handler type.
|
||||
// I'm going to change the default now...if we can handle the content,
|
||||
// and someone didn't EXPLICITLY set a nsIURIContentListener at the top
|
||||
// of our docshell chain, then we'll now always attempt to process the
|
||||
// content ourselves...
|
||||
return CanHandleContent(aContentType, true, aDesiredContentType, aCanHandle);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::CanHandleContent(const char* aContentType,
|
||||
bool aIsContentPreferred,
|
||||
char ** aDesiredContentType,
|
||||
char** aDesiredContentType,
|
||||
bool* aCanHandleContent)
|
||||
{
|
||||
NS_PRECONDITION(aCanHandleContent, "Null out param?");
|
||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||
NS_PRECONDITION(aCanHandleContent, "Null out param?");
|
||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||
|
||||
*aCanHandleContent = false;
|
||||
*aDesiredContentType = nullptr;
|
||||
*aCanHandleContent = false;
|
||||
*aDesiredContentType = nullptr;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (aContentType) {
|
||||
uint32_t canHandle = nsIWebNavigationInfo::UNSUPPORTED;
|
||||
rv = mNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||
mDocShell,
|
||||
&canHandle);
|
||||
*aCanHandleContent = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||
}
|
||||
nsresult rv = NS_OK;
|
||||
if (aContentType) {
|
||||
uint32_t canHandle = nsIWebNavigationInfo::UNSUPPORTED;
|
||||
rv = mNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||
mDocShell,
|
||||
&canHandle);
|
||||
*aCanHandleContent = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||
}
|
||||
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::GetLoadCookie(nsISupports ** aLoadCookie)
|
||||
nsDSURIContentListener::GetLoadCookie(nsISupports** aLoadCookie)
|
||||
{
|
||||
NS_IF_ADDREF(*aLoadCookie = nsDocShell::GetAsSupports(mDocShell));
|
||||
return NS_OK;
|
||||
NS_IF_ADDREF(*aLoadCookie = nsDocShell::GetAsSupports(mDocShell));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::SetLoadCookie(nsISupports * aLoadCookie)
|
||||
nsDSURIContentListener::SetLoadCookie(nsISupports* aLoadCookie)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
nsRefPtr<nsDocLoader> cookieAsDocLoader =
|
||||
nsDocLoader::GetAsDocLoader(aLoadCookie);
|
||||
NS_ASSERTION(cookieAsDocLoader && cookieAsDocLoader == mDocShell,
|
||||
"Invalid load cookie being set!");
|
||||
nsRefPtr<nsDocLoader> cookieAsDocLoader =
|
||||
nsDocLoader::GetAsDocLoader(aLoadCookie);
|
||||
NS_ASSERTION(cookieAsDocLoader && cookieAsDocLoader == mDocShell,
|
||||
"Invalid load cookie being set!");
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::GetParentContentListener(nsIURIContentListener**
|
||||
aParentListener)
|
||||
{
|
||||
if (mWeakParentContentListener)
|
||||
{
|
||||
nsCOMPtr<nsIURIContentListener> tempListener =
|
||||
do_QueryReferent(mWeakParentContentListener);
|
||||
*aParentListener = tempListener;
|
||||
NS_IF_ADDREF(*aParentListener);
|
||||
}
|
||||
else {
|
||||
*aParentListener = mParentContentListener;
|
||||
NS_IF_ADDREF(*aParentListener);
|
||||
}
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::SetParentContentListener(nsIURIContentListener*
|
||||
aParentListener)
|
||||
nsDSURIContentListener::GetParentContentListener(
|
||||
nsIURIContentListener** aParentListener)
|
||||
{
|
||||
if (aParentListener)
|
||||
{
|
||||
// Store the parent listener as a weak ref. Parents not supporting
|
||||
// nsISupportsWeakReference assert but may still be used.
|
||||
mParentContentListener = nullptr;
|
||||
mWeakParentContentListener = do_GetWeakReference(aParentListener);
|
||||
if (!mWeakParentContentListener)
|
||||
{
|
||||
mParentContentListener = aParentListener;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mWeakParentContentListener = nullptr;
|
||||
mParentContentListener = nullptr;
|
||||
}
|
||||
return NS_OK;
|
||||
if (mWeakParentContentListener) {
|
||||
nsCOMPtr<nsIURIContentListener> tempListener =
|
||||
do_QueryReferent(mWeakParentContentListener);
|
||||
*aParentListener = tempListener;
|
||||
NS_IF_ADDREF(*aParentListener);
|
||||
} else {
|
||||
*aParentListener = mParentContentListener;
|
||||
NS_IF_ADDREF(*aParentListener);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChannel,
|
||||
const nsAString& policy) {
|
||||
static const char allowFrom[] = "allow-from";
|
||||
const uint32_t allowFromLen = ArrayLength(allowFrom) - 1;
|
||||
bool isAllowFrom =
|
||||
StringHead(policy, allowFromLen).LowerCaseEqualsLiteral(allowFrom);
|
||||
|
||||
// return early if header does not have one of the values with meaning
|
||||
if (!policy.LowerCaseEqualsLiteral("deny") &&
|
||||
!policy.LowerCaseEqualsLiteral("sameorigin") &&
|
||||
!isAllowFrom)
|
||||
return true;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
httpChannel->GetURI(getter_AddRefs(uri));
|
||||
|
||||
// XXXkhuey when does this happen? Is returning true safe here?
|
||||
if (!mDocShell) {
|
||||
return true;
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::SetParentContentListener(
|
||||
nsIURIContentListener* aParentListener)
|
||||
{
|
||||
if (aParentListener) {
|
||||
// Store the parent listener as a weak ref. Parents not supporting
|
||||
// nsISupportsWeakReference assert but may still be used.
|
||||
mParentContentListener = nullptr;
|
||||
mWeakParentContentListener = do_GetWeakReference(aParentListener);
|
||||
if (!mWeakParentContentListener) {
|
||||
mParentContentListener = aParentListener;
|
||||
}
|
||||
} else {
|
||||
mWeakParentContentListener = nullptr;
|
||||
mParentContentListener = nullptr;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// We need to check the location of this window and the location of the top
|
||||
// window, if we're not the top. X-F-O: SAMEORIGIN requires that the
|
||||
// document must be same-origin with top window. X-F-O: DENY requires that
|
||||
// the document must never be framed.
|
||||
nsCOMPtr<nsIDOMWindow> thisWindow = mDocShell->GetWindow();
|
||||
// If we don't have DOMWindow there is no risk of clickjacking
|
||||
if (!thisWindow)
|
||||
return true;
|
||||
|
||||
// GetScriptableTop, not GetTop, because we want this to respect
|
||||
// <iframe mozbrowser> boundaries.
|
||||
nsCOMPtr<nsIDOMWindow> topWindow;
|
||||
thisWindow->GetScriptableTop(getter_AddRefs(topWindow));
|
||||
|
||||
// if the document is in the top window, it's not in a frame.
|
||||
if (thisWindow == topWindow)
|
||||
return true;
|
||||
|
||||
// Find the top docshell in our parent chain that doesn't have the system
|
||||
// principal and use it for the principal comparison. Finding the top
|
||||
// content-type docshell doesn't work because some chrome documents are
|
||||
// loaded in content docshells (see bug 593387).
|
||||
nsCOMPtr<nsIDocShellTreeItem> thisDocShellItem(do_QueryInterface(
|
||||
static_cast<nsIDocShell*> (mDocShell)));
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem,
|
||||
curDocShellItem = thisDocShellItem;
|
||||
nsCOMPtr<nsIDocument> topDoc;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIScriptSecurityManager> ssm =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
if (!ssm) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
// Traverse up the parent chain and stop when we see a docshell whose
|
||||
// parent has a system principal, or a docshell corresponding to
|
||||
// <iframe mozbrowser>.
|
||||
while (NS_SUCCEEDED(curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem))) &&
|
||||
parentDocShellItem) {
|
||||
|
||||
nsCOMPtr<nsIDocShell> curDocShell = do_QueryInterface(curDocShellItem);
|
||||
if (curDocShell && curDocShell->GetIsBrowserOrApp()) {
|
||||
break;
|
||||
}
|
||||
|
||||
bool system = false;
|
||||
topDoc = parentDocShellItem->GetDocument();
|
||||
if (topDoc) {
|
||||
if (NS_SUCCEEDED(ssm->IsSystemPrincipal(topDoc->NodePrincipal(),
|
||||
&system)) && system) {
|
||||
// Found a system-principled doc: last docshell was top.
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
curDocShellItem = parentDocShellItem;
|
||||
}
|
||||
|
||||
// If this document has the top non-SystemPrincipal docshell it is not being
|
||||
// framed or it is being framed by a chrome document, which we allow.
|
||||
if (curDocShellItem == thisDocShellItem)
|
||||
return true;
|
||||
|
||||
// If the value of the header is DENY, and the previous condition is
|
||||
// not met (current docshell is not the top docshell), prohibit the
|
||||
// load.
|
||||
if (policy.LowerCaseEqualsLiteral("deny")) {
|
||||
ReportXFOViolation(curDocShellItem, uri, eDENY);
|
||||
return false;
|
||||
}
|
||||
|
||||
topDoc = curDocShellItem->GetDocument();
|
||||
nsCOMPtr<nsIURI> topUri;
|
||||
topDoc->NodePrincipal()->GetURI(getter_AddRefs(topUri));
|
||||
|
||||
// If the X-Frame-Options value is SAMEORIGIN, then the top frame in the
|
||||
// parent chain must be from the same origin as this document.
|
||||
if (policy.LowerCaseEqualsLiteral("sameorigin")) {
|
||||
rv = ssm->CheckSameOriginURI(uri, topUri, true);
|
||||
if (NS_FAILED(rv)) {
|
||||
ReportXFOViolation(curDocShellItem, uri, eSAMEORIGIN);
|
||||
return false; /* wasn't same-origin */
|
||||
}
|
||||
}
|
||||
|
||||
// If the X-Frame-Options value is "allow-from [uri]", then the top
|
||||
// frame in the parent chain must be from that origin
|
||||
if (isAllowFrom) {
|
||||
if (policy.Length() == allowFromLen ||
|
||||
(policy[allowFromLen] != ' ' &&
|
||||
policy[allowFromLen] != '\t')) {
|
||||
ReportXFOViolation(curDocShellItem, uri, eALLOWFROM);
|
||||
return false;
|
||||
}
|
||||
rv = NS_NewURI(getter_AddRefs(uri),
|
||||
Substring(policy, allowFromLen));
|
||||
if (NS_FAILED(rv))
|
||||
return false;
|
||||
|
||||
rv = ssm->CheckSameOriginURI(uri, topUri, true);
|
||||
if (NS_FAILED(rv)) {
|
||||
ReportXFOViolation(curDocShellItem, uri, eALLOWFROM);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool
|
||||
nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
|
||||
const nsAString& aPolicy)
|
||||
{
|
||||
static const char allowFrom[] = "allow-from";
|
||||
const uint32_t allowFromLen = ArrayLength(allowFrom) - 1;
|
||||
bool isAllowFrom =
|
||||
StringHead(aPolicy, allowFromLen).LowerCaseEqualsLiteral(allowFrom);
|
||||
|
||||
// return early if header does not have one of the values with meaning
|
||||
if (!aPolicy.LowerCaseEqualsLiteral("deny") &&
|
||||
!aPolicy.LowerCaseEqualsLiteral("sameorigin") &&
|
||||
!isAllowFrom) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
aHttpChannel->GetURI(getter_AddRefs(uri));
|
||||
|
||||
// XXXkhuey when does this happen? Is returning true safe here?
|
||||
if (!mDocShell) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We need to check the location of this window and the location of the top
|
||||
// window, if we're not the top. X-F-O: SAMEORIGIN requires that the
|
||||
// document must be same-origin with top window. X-F-O: DENY requires that
|
||||
// the document must never be framed.
|
||||
nsCOMPtr<nsIDOMWindow> thisWindow = mDocShell->GetWindow();
|
||||
// If we don't have DOMWindow there is no risk of clickjacking
|
||||
if (!thisWindow) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// GetScriptableTop, not GetTop, because we want this to respect
|
||||
// <iframe mozbrowser> boundaries.
|
||||
nsCOMPtr<nsIDOMWindow> topWindow;
|
||||
thisWindow->GetScriptableTop(getter_AddRefs(topWindow));
|
||||
|
||||
// if the document is in the top window, it's not in a frame.
|
||||
if (thisWindow == topWindow) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Find the top docshell in our parent chain that doesn't have the system
|
||||
// principal and use it for the principal comparison. Finding the top
|
||||
// content-type docshell doesn't work because some chrome documents are
|
||||
// loaded in content docshells (see bug 593387).
|
||||
nsCOMPtr<nsIDocShellTreeItem> thisDocShellItem(
|
||||
do_QueryInterface(static_cast<nsIDocShell*>(mDocShell)));
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
|
||||
nsCOMPtr<nsIDocShellTreeItem> curDocShellItem = thisDocShellItem;
|
||||
nsCOMPtr<nsIDocument> topDoc;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIScriptSecurityManager> ssm =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
if (!ssm) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
// Traverse up the parent chain and stop when we see a docshell whose
|
||||
// parent has a system principal, or a docshell corresponding to
|
||||
// <iframe mozbrowser>.
|
||||
while (NS_SUCCEEDED(
|
||||
curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem))) &&
|
||||
parentDocShellItem) {
|
||||
nsCOMPtr<nsIDocShell> curDocShell = do_QueryInterface(curDocShellItem);
|
||||
if (curDocShell && curDocShell->GetIsBrowserOrApp()) {
|
||||
break;
|
||||
}
|
||||
|
||||
bool system = false;
|
||||
topDoc = parentDocShellItem->GetDocument();
|
||||
if (topDoc) {
|
||||
if (NS_SUCCEEDED(
|
||||
ssm->IsSystemPrincipal(topDoc->NodePrincipal(), &system)) &&
|
||||
system) {
|
||||
// Found a system-principled doc: last docshell was top.
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
curDocShellItem = parentDocShellItem;
|
||||
}
|
||||
|
||||
// If this document has the top non-SystemPrincipal docshell it is not being
|
||||
// framed or it is being framed by a chrome document, which we allow.
|
||||
if (curDocShellItem == thisDocShellItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the value of the header is DENY, and the previous condition is
|
||||
// not met (current docshell is not the top docshell), prohibit the
|
||||
// load.
|
||||
if (aPolicy.LowerCaseEqualsLiteral("deny")) {
|
||||
ReportXFOViolation(curDocShellItem, uri, eDENY);
|
||||
return false;
|
||||
}
|
||||
|
||||
topDoc = curDocShellItem->GetDocument();
|
||||
nsCOMPtr<nsIURI> topUri;
|
||||
topDoc->NodePrincipal()->GetURI(getter_AddRefs(topUri));
|
||||
|
||||
// If the X-Frame-Options value is SAMEORIGIN, then the top frame in the
|
||||
// parent chain must be from the same origin as this document.
|
||||
if (aPolicy.LowerCaseEqualsLiteral("sameorigin")) {
|
||||
rv = ssm->CheckSameOriginURI(uri, topUri, true);
|
||||
if (NS_FAILED(rv)) {
|
||||
ReportXFOViolation(curDocShellItem, uri, eSAMEORIGIN);
|
||||
return false; /* wasn't same-origin */
|
||||
}
|
||||
}
|
||||
|
||||
// If the X-Frame-Options value is "allow-from [uri]", then the top
|
||||
// frame in the parent chain must be from that origin
|
||||
if (isAllowFrom) {
|
||||
if (aPolicy.Length() == allowFromLen ||
|
||||
(aPolicy[allowFromLen] != ' ' &&
|
||||
aPolicy[allowFromLen] != '\t')) {
|
||||
ReportXFOViolation(curDocShellItem, uri, eALLOWFROM);
|
||||
return false;
|
||||
}
|
||||
rv = NS_NewURI(getter_AddRefs(uri), Substring(aPolicy, allowFromLen));
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
rv = ssm->CheckSameOriginURI(uri, topUri, true);
|
||||
if (NS_FAILED(rv)) {
|
||||
ReportXFOViolation(curDocShellItem, uri, eALLOWFROM);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if X-Frame-Options permits this document to be loaded as a subdocument.
|
||||
// This will iterate through and check any number of X-Frame-Options policies
|
||||
// in the request (comma-separated in a header, multiple headers, etc).
|
||||
bool nsDSURIContentListener::CheckFrameOptions(nsIRequest *request)
|
||||
bool
|
||||
nsDSURIContentListener::CheckFrameOptions(nsIRequest* aRequest)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIChannel> chan = do_QueryInterface(request);
|
||||
if (!chan) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(chan);
|
||||
if (!httpChannel) {
|
||||
// check if it is hiding in a multipart channel
|
||||
rv = mDocShell->GetHttpChannel(chan, getter_AddRefs(httpChannel));
|
||||
if (NS_FAILED(rv))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!httpChannel) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsAutoCString xfoHeaderCValue;
|
||||
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("X-Frame-Options"),
|
||||
xfoHeaderCValue);
|
||||
NS_ConvertUTF8toUTF16 xfoHeaderValue(xfoHeaderCValue);
|
||||
|
||||
// if no header value, there's nothing to do.
|
||||
if (xfoHeaderValue.IsEmpty())
|
||||
return true;
|
||||
|
||||
// iterate through all the header values (usually there's only one, but can
|
||||
// be many. If any want to deny the load, deny the load.
|
||||
nsCharSeparatedTokenizer tokenizer(xfoHeaderValue, ',');
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
const nsSubstring& tok = tokenizer.nextToken();
|
||||
if (!CheckOneFrameOptionsPolicy(httpChannel, tok)) {
|
||||
// cancel the load and display about:blank
|
||||
httpChannel->Cancel(NS_BINDING_ABORTED);
|
||||
if (mDocShell) {
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryObject(mDocShell));
|
||||
if (webNav) {
|
||||
webNav->LoadURI(MOZ_UTF16("about:blank"),
|
||||
0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIChannel> chan = do_QueryInterface(aRequest);
|
||||
if (!chan) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(chan);
|
||||
if (!httpChannel) {
|
||||
// check if it is hiding in a multipart channel
|
||||
rv = mDocShell->GetHttpChannel(chan, getter_AddRefs(httpChannel));
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!httpChannel) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsAutoCString xfoHeaderCValue;
|
||||
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("X-Frame-Options"),
|
||||
xfoHeaderCValue);
|
||||
NS_ConvertUTF8toUTF16 xfoHeaderValue(xfoHeaderCValue);
|
||||
|
||||
// if no header value, there's nothing to do.
|
||||
if (xfoHeaderValue.IsEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// iterate through all the header values (usually there's only one, but can
|
||||
// be many. If any want to deny the load, deny the load.
|
||||
nsCharSeparatedTokenizer tokenizer(xfoHeaderValue, ',');
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
const nsSubstring& tok = tokenizer.nextToken();
|
||||
if (!CheckOneFrameOptionsPolicy(httpChannel, tok)) {
|
||||
// cancel the load and display about:blank
|
||||
httpChannel->Cancel(NS_BINDING_ABORTED);
|
||||
if (mDocShell) {
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryObject(mDocShell));
|
||||
if (webNav) {
|
||||
webNav->LoadURI(MOZ_UTF16("about:blank"),
|
||||
0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
@ -482,67 +481,75 @@ nsDSURIContentListener::ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem
|
||||
{
|
||||
MOZ_ASSERT(aTopDocShellItem, "Need a top docshell");
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> topOuterWindow = aTopDocShellItem->GetWindow();
|
||||
if (!topOuterWindow)
|
||||
return;
|
||||
nsCOMPtr<nsPIDOMWindow> topOuterWindow = aTopDocShellItem->GetWindow();
|
||||
if (!topOuterWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
NS_ASSERTION(topOuterWindow->IsOuterWindow(), "Huh?");
|
||||
nsPIDOMWindow* topInnerWindow = topOuterWindow->GetCurrentInnerWindow();
|
||||
if (!topInnerWindow)
|
||||
return;
|
||||
NS_ASSERTION(topOuterWindow->IsOuterWindow(), "Huh?");
|
||||
nsPIDOMWindow* topInnerWindow = topOuterWindow->GetCurrentInnerWindow();
|
||||
if (!topInnerWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> topURI;
|
||||
nsCOMPtr<nsIURI> topURI;
|
||||
|
||||
nsCOMPtr<nsIDocument> document = aTopDocShellItem->GetDocument();
|
||||
nsresult rv = document->NodePrincipal()->GetURI(getter_AddRefs(topURI));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
nsCOMPtr<nsIDocument> document = aTopDocShellItem->GetDocument();
|
||||
nsresult rv = document->NodePrincipal()->GetURI(getter_AddRefs(topURI));
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!topURI)
|
||||
return;
|
||||
if (!topURI) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCString topURIString;
|
||||
nsCString thisURIString;
|
||||
nsCString topURIString;
|
||||
nsCString thisURIString;
|
||||
|
||||
rv = topURI->GetSpec(topURIString);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
rv = topURI->GetSpec(topURIString);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
rv = aThisURI->GetSpec(thisURIString);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
rv = aThisURI->GetSpec(thisURIString);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIConsoleService> consoleService =
|
||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIScriptError> errorObject =
|
||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
|
||||
nsCOMPtr<nsIConsoleService> consoleService =
|
||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIScriptError> errorObject =
|
||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
|
||||
|
||||
if (!consoleService || !errorObject)
|
||||
return;
|
||||
if (!consoleService || !errorObject) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsString msg = NS_LITERAL_STRING("Load denied by X-Frame-Options: ");
|
||||
msg.Append(NS_ConvertUTF8toUTF16(thisURIString));
|
||||
nsString msg = NS_LITERAL_STRING("Load denied by X-Frame-Options: ");
|
||||
msg.Append(NS_ConvertUTF8toUTF16(thisURIString));
|
||||
|
||||
switch (aHeader) {
|
||||
case eDENY:
|
||||
msg.AppendLiteral(" does not permit framing.");
|
||||
break;
|
||||
case eSAMEORIGIN:
|
||||
msg.AppendLiteral(" does not permit cross-origin framing.");
|
||||
break;
|
||||
case eALLOWFROM:
|
||||
msg.AppendLiteral(" does not permit framing by ");
|
||||
msg.Append(NS_ConvertUTF8toUTF16(topURIString));
|
||||
msg.Append('.');
|
||||
break;
|
||||
}
|
||||
switch (aHeader) {
|
||||
case eDENY:
|
||||
msg.AppendLiteral(" does not permit framing.");
|
||||
break;
|
||||
case eSAMEORIGIN:
|
||||
msg.AppendLiteral(" does not permit cross-origin framing.");
|
||||
break;
|
||||
case eALLOWFROM:
|
||||
msg.AppendLiteral(" does not permit framing by ");
|
||||
msg.Append(NS_ConvertUTF8toUTF16(topURIString));
|
||||
msg.Append('.');
|
||||
break;
|
||||
}
|
||||
|
||||
rv = errorObject->InitWithWindowID(msg, EmptyString(), EmptyString(), 0, 0,
|
||||
nsIScriptError::errorFlag,
|
||||
"X-Frame-Options",
|
||||
topInnerWindow->WindowID());
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
rv = errorObject->InitWithWindowID(msg, EmptyString(), EmptyString(), 0, 0,
|
||||
nsIScriptError::errorFlag,
|
||||
"X-Frame-Options",
|
||||
topInnerWindow->WindowID());
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
consoleService->LogMessage(errorObject);
|
||||
consoleService->LogMessage(errorObject);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@ -16,56 +16,59 @@ class nsIWebNavigationInfo;
|
||||
class nsIHttpChannel;
|
||||
class nsAString;
|
||||
|
||||
class nsDSURIContentListener MOZ_FINAL :
|
||||
public nsIURIContentListener,
|
||||
public nsSupportsWeakReference
|
||||
|
||||
class nsDSURIContentListener MOZ_FINAL
|
||||
: public nsIURIContentListener
|
||||
, public nsSupportsWeakReference
|
||||
{
|
||||
friend class nsDocShell;
|
||||
friend class nsDocShell;
|
||||
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIURICONTENTLISTENER
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIURICONTENTLISTENER
|
||||
|
||||
nsresult Init();
|
||||
nsresult Init();
|
||||
|
||||
protected:
|
||||
explicit nsDSURIContentListener(nsDocShell* aDocShell);
|
||||
virtual ~nsDSURIContentListener();
|
||||
explicit nsDSURIContentListener(nsDocShell* aDocShell);
|
||||
virtual ~nsDSURIContentListener();
|
||||
|
||||
void DropDocShellreference() {
|
||||
mDocShell = nullptr;
|
||||
mExistingJPEGRequest = nullptr;
|
||||
mExistingJPEGStreamListener = nullptr;
|
||||
}
|
||||
void DropDocShellReference()
|
||||
{
|
||||
mDocShell = nullptr;
|
||||
mExistingJPEGRequest = nullptr;
|
||||
mExistingJPEGStreamListener = nullptr;
|
||||
}
|
||||
|
||||
// Determine if X-Frame-Options allows content to be framed
|
||||
// as a subdocument
|
||||
bool CheckFrameOptions(nsIRequest* request);
|
||||
bool CheckOneFrameOptionsPolicy(nsIHttpChannel* httpChannel,
|
||||
const nsAString& policy);
|
||||
// Determine if X-Frame-Options allows content to be framed
|
||||
// as a subdocument
|
||||
bool CheckFrameOptions(nsIRequest* aRequest);
|
||||
bool CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
|
||||
const nsAString& aPolicy);
|
||||
|
||||
enum XFOHeader {
|
||||
eDENY,
|
||||
eSAMEORIGIN,
|
||||
eALLOWFROM
|
||||
};
|
||||
enum XFOHeader
|
||||
{
|
||||
eDENY,
|
||||
eSAMEORIGIN,
|
||||
eALLOWFROM
|
||||
};
|
||||
|
||||
void ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem,
|
||||
nsIURI* aThisURI,
|
||||
XFOHeader aHeader);
|
||||
|
||||
void ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem,
|
||||
nsIURI* aThisURI,
|
||||
XFOHeader aHeader);
|
||||
protected:
|
||||
nsDocShell* mDocShell;
|
||||
// Hack to handle multipart images without creating a new viewer
|
||||
nsCOMPtr<nsIStreamListener> mExistingJPEGStreamListener;
|
||||
nsCOMPtr<nsIChannel> mExistingJPEGRequest;
|
||||
nsDocShell* mDocShell;
|
||||
// Hack to handle multipart images without creating a new viewer
|
||||
nsCOMPtr<nsIStreamListener> mExistingJPEGStreamListener;
|
||||
nsCOMPtr<nsIChannel> mExistingJPEGRequest;
|
||||
|
||||
// Store the parent listener in either of these depending on
|
||||
// if supports weak references or not. Proper weak refs are
|
||||
// preferred and encouraged!
|
||||
nsWeakPtr mWeakParentContentListener;
|
||||
nsIURIContentListener* mParentContentListener;
|
||||
// Store the parent listener in either of these depending on
|
||||
// if supports weak references or not. Proper weak refs are
|
||||
// preferred and encouraged!
|
||||
nsWeakPtr mWeakParentContentListener;
|
||||
nsIURIContentListener* mParentContentListener;
|
||||
|
||||
nsCOMPtr<nsIWebNavigationInfo> mNavInfo;
|
||||
nsCOMPtr<nsIWebNavigationInfo> mNavInfo;
|
||||
};
|
||||
|
||||
#endif /* nsDSURIContentListener_h__ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@ -15,56 +15,56 @@ class nsDefaultURIFixupInfo;
|
||||
class nsDefaultURIFixup : public nsIURIFixup
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIURIFIXUP
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIURIFIXUP
|
||||
|
||||
nsDefaultURIFixup();
|
||||
nsDefaultURIFixup();
|
||||
|
||||
protected:
|
||||
virtual ~nsDefaultURIFixup();
|
||||
virtual ~nsDefaultURIFixup();
|
||||
|
||||
private:
|
||||
/* additional members */
|
||||
nsresult FileURIFixup(const nsACString &aStringURI, nsIURI** aURI);
|
||||
nsresult ConvertFileToStringURI(const nsACString& aIn, nsCString& aOut);
|
||||
nsresult FixupURIProtocol(const nsACString& aIn,
|
||||
nsDefaultURIFixupInfo* aFixupInfo,
|
||||
nsIURI** aURI);
|
||||
nsresult KeywordURIFixup(const nsACString &aStringURI,
|
||||
nsDefaultURIFixupInfo* aFixupInfo,
|
||||
nsIInputStream** aPostData);
|
||||
nsresult TryKeywordFixupForURIInfo(const nsACString &aStringURI,
|
||||
nsDefaultURIFixupInfo* aFixupInfo,
|
||||
nsIInputStream** aPostData);
|
||||
bool PossiblyByteExpandedFileName(const nsAString& aIn);
|
||||
bool PossiblyHostPortUrl(const nsACString& aUrl);
|
||||
bool MakeAlternateURI(nsIURI *aURI);
|
||||
bool IsLikelyFTP(const nsCString& aHostSpec);
|
||||
bool IsDomainWhitelisted(const nsAutoCString aAsciiHost,
|
||||
const uint32_t aDotLoc);
|
||||
/* additional members */
|
||||
nsresult FileURIFixup(const nsACString& aStringURI, nsIURI** aURI);
|
||||
nsresult ConvertFileToStringURI(const nsACString& aIn, nsCString& aResult);
|
||||
nsresult FixupURIProtocol(const nsACString& aIn,
|
||||
nsDefaultURIFixupInfo* aFixupInfo,
|
||||
nsIURI** aURI);
|
||||
nsresult KeywordURIFixup(const nsACString& aStringURI,
|
||||
nsDefaultURIFixupInfo* aFixupInfo,
|
||||
nsIInputStream** aPostData);
|
||||
nsresult TryKeywordFixupForURIInfo(const nsACString& aStringURI,
|
||||
nsDefaultURIFixupInfo* aFixupInfo,
|
||||
nsIInputStream** aPostData);
|
||||
bool PossiblyByteExpandedFileName(const nsAString& aIn);
|
||||
bool PossiblyHostPortUrl(const nsACString& aUrl);
|
||||
bool MakeAlternateURI(nsIURI* aURI);
|
||||
bool IsLikelyFTP(const nsCString& aHostSpec);
|
||||
bool IsDomainWhitelisted(const nsAutoCString aAsciiHost,
|
||||
const uint32_t aDotLoc);
|
||||
};
|
||||
|
||||
class nsDefaultURIFixupInfo : public nsIURIFixupInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIURIFIXUPINFO
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIURIFIXUPINFO
|
||||
|
||||
explicit nsDefaultURIFixupInfo(const nsACString& aOriginalInput);
|
||||
explicit nsDefaultURIFixupInfo(const nsACString& aOriginalInput);
|
||||
|
||||
friend class nsDefaultURIFixup;
|
||||
friend class nsDefaultURIFixup;
|
||||
|
||||
protected:
|
||||
virtual ~nsDefaultURIFixupInfo();
|
||||
virtual ~nsDefaultURIFixupInfo();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISupports> mConsumer;
|
||||
nsCOMPtr<nsIURI> mPreferredURI;
|
||||
nsCOMPtr<nsIURI> mFixedURI;
|
||||
bool mFixupChangedProtocol;
|
||||
bool mFixupCreatedAlternateURI;
|
||||
nsString mKeywordProviderName;
|
||||
nsString mKeywordAsSent;
|
||||
nsAutoCString mOriginalInput;
|
||||
nsCOMPtr<nsISupports> mConsumer;
|
||||
nsCOMPtr<nsIURI> mPreferredURI;
|
||||
nsCOMPtr<nsIURI> mFixedURI;
|
||||
bool mFixupChangedProtocol;
|
||||
bool mFixupCreatedAlternateURI;
|
||||
nsString mKeywordProviderName;
|
||||
nsString mKeywordAsSent;
|
||||
nsAutoCString mOriginalInput;
|
||||
};
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,9 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#include "nsDocShellEditorData.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
@ -14,28 +13,16 @@
|
||||
#include "nsIEditingSession.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
nsDocShellEditorData
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
nsDocShellEditorData::nsDocShellEditorData(nsIDocShell* inOwningDocShell)
|
||||
: mDocShell(inOwningDocShell)
|
||||
, mMakeEditable(false)
|
||||
, mIsDetached(false)
|
||||
, mDetachedMakeEditable(false)
|
||||
, mDetachedEditingState(nsIHTMLDocument::eOff)
|
||||
nsDocShellEditorData::nsDocShellEditorData(nsIDocShell* aOwningDocShell)
|
||||
: mDocShell(aOwningDocShell)
|
||||
, mMakeEditable(false)
|
||||
, mIsDetached(false)
|
||||
, mDetachedMakeEditable(false)
|
||||
, mDetachedEditingState(nsIHTMLDocument::eOff)
|
||||
{
|
||||
NS_ASSERTION(mDocShell, "Where is my docShell?");
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
~nsDocShellEditorData
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
nsDocShellEditorData::~nsDocShellEditorData()
|
||||
{
|
||||
TearDownEditor();
|
||||
@ -52,143 +39,103 @@ nsDocShellEditorData::TearDownEditor()
|
||||
mIsDetached = false;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
MakeEditable
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
nsresult
|
||||
nsDocShellEditorData::MakeEditable(bool inWaitForUriLoad)
|
||||
nsDocShellEditorData::MakeEditable(bool aInWaitForUriLoad)
|
||||
{
|
||||
if (mMakeEditable)
|
||||
if (mMakeEditable) {
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
// if we are already editable, and are getting turned off,
|
||||
// nuke the editor.
|
||||
if (mEditor)
|
||||
{
|
||||
if (mEditor) {
|
||||
NS_WARNING("Destroying existing editor on frame");
|
||||
|
||||
|
||||
mEditor->PreDestroy(false);
|
||||
mEditor = nullptr;
|
||||
}
|
||||
|
||||
if (inWaitForUriLoad)
|
||||
|
||||
if (aInWaitForUriLoad) {
|
||||
mMakeEditable = true;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
GetEditable
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
bool
|
||||
nsDocShellEditorData::GetEditable()
|
||||
{
|
||||
return mMakeEditable || (mEditor != nullptr);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
CreateEditor
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
nsresult
|
||||
nsDocShellEditorData::CreateEditor()
|
||||
{
|
||||
nsCOMPtr<nsIEditingSession> editingSession;
|
||||
nsCOMPtr<nsIEditingSession> editingSession;
|
||||
nsresult rv = GetEditingSession(getter_AddRefs(editingSession));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow =
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow =
|
||||
mDocShell ? mDocShell->GetWindow() : nullptr;
|
||||
rv = editingSession->SetupEditorOnWindow(domWindow);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
GetEditingSession
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
nsresult
|
||||
nsDocShellEditorData::GetEditingSession(nsIEditingSession **outEditingSession)
|
||||
nsDocShellEditorData::GetEditingSession(nsIEditingSession** aResult)
|
||||
{
|
||||
nsresult rv = EnsureEditingSession();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ADDREF(*outEditingSession = mEditingSession);
|
||||
NS_ADDREF(*aResult = mEditingSession);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
GetEditor
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
nsresult
|
||||
nsDocShellEditorData::GetEditor(nsIEditor **outEditor)
|
||||
nsDocShellEditorData::GetEditor(nsIEditor** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(outEditor);
|
||||
NS_IF_ADDREF(*outEditor = mEditor);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_IF_ADDREF(*aResult = mEditor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
SetEditor
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
nsresult
|
||||
nsDocShellEditorData::SetEditor(nsIEditor *inEditor)
|
||||
nsDocShellEditorData::SetEditor(nsIEditor* aEditor)
|
||||
{
|
||||
// destroy any editor that we have. Checks for equality are
|
||||
// necessary to ensure that assigment into the nsCOMPtr does
|
||||
// not temporarily reduce the refCount of the editor to zero
|
||||
if (mEditor.get() != inEditor)
|
||||
{
|
||||
if (mEditor)
|
||||
{
|
||||
if (mEditor.get() != aEditor) {
|
||||
if (mEditor) {
|
||||
mEditor->PreDestroy(false);
|
||||
mEditor = nullptr;
|
||||
}
|
||||
|
||||
mEditor = inEditor; // owning addref
|
||||
if (!mEditor)
|
||||
|
||||
mEditor = aEditor; // owning addref
|
||||
if (!mEditor) {
|
||||
mMakeEditable = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
EnsureEditingSession
|
||||
|
||||
This creates the editing session on the content docShell that owns
|
||||
'this'.
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
// This creates the editing session on the content docShell that owns 'this'.
|
||||
nsresult
|
||||
nsDocShellEditorData::EnsureEditingSession()
|
||||
{
|
||||
NS_ASSERTION(mDocShell, "Should have docShell here");
|
||||
NS_ASSERTION(!mIsDetached, "This will stomp editing session!");
|
||||
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mEditingSession)
|
||||
{
|
||||
|
||||
if (!mEditingSession) {
|
||||
mEditingSession =
|
||||
do_CreateInstance("@mozilla.org/editor/editingsession;1", &rv);
|
||||
}
|
||||
@ -201,7 +148,7 @@ nsDocShellEditorData::DetachFromWindow()
|
||||
{
|
||||
NS_ASSERTION(mEditingSession,
|
||||
"Can't detach when we don't have a session to detach!");
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow =
|
||||
mDocShell ? mDocShell->GetWindow() : nullptr;
|
||||
nsresult rv = mEditingSession->DetachFromWindow(domWindow);
|
||||
@ -214,8 +161,9 @@ nsDocShellEditorData::DetachFromWindow()
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
domWindow->GetDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
|
||||
if (htmlDoc)
|
||||
if (htmlDoc) {
|
||||
mDetachedEditingState = htmlDoc->GetEditingState();
|
||||
}
|
||||
|
||||
mDocShell = nullptr;
|
||||
|
||||
@ -238,8 +186,9 @@ nsDocShellEditorData::ReattachToWindow(nsIDocShell* aDocShell)
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
domWindow->GetDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
|
||||
if (htmlDoc)
|
||||
if (htmlDoc) {
|
||||
htmlDoc->SetEditingState(mDetachedEditingState);
|
||||
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef nsDocShellEditorData_h__
|
||||
@ -19,26 +19,24 @@ class nsIEditor;
|
||||
class nsDocShellEditorData
|
||||
{
|
||||
public:
|
||||
|
||||
explicit nsDocShellEditorData(nsIDocShell* inOwningDocShell);
|
||||
explicit nsDocShellEditorData(nsIDocShell* aOwningDocShell);
|
||||
~nsDocShellEditorData();
|
||||
|
||||
nsresult MakeEditable(bool inWaitForUriLoad);
|
||||
nsresult MakeEditable(bool aWaitForUriLoad);
|
||||
bool GetEditable();
|
||||
nsresult CreateEditor();
|
||||
nsresult GetEditingSession(nsIEditingSession **outEditingSession);
|
||||
nsresult GetEditor(nsIEditor **outEditor);
|
||||
nsresult SetEditor(nsIEditor *inEditor);
|
||||
nsresult GetEditingSession(nsIEditingSession** aResult);
|
||||
nsresult GetEditor(nsIEditor** aResult);
|
||||
nsresult SetEditor(nsIEditor* aEditor);
|
||||
void TearDownEditor();
|
||||
nsresult DetachFromWindow();
|
||||
nsresult ReattachToWindow(nsIDocShell *aDocShell);
|
||||
nsresult ReattachToWindow(nsIDocShell* aDocShell);
|
||||
bool WaitingForLoad() const { return mMakeEditable; }
|
||||
|
||||
protected:
|
||||
|
||||
nsresult EnsureEditingSession();
|
||||
|
||||
// The doc shell that owns us. Weak ref, since it always outlives us.
|
||||
// The doc shell that owns us. Weak ref, since it always outlives us.
|
||||
nsIDocShell* mDocShell;
|
||||
|
||||
// Only present for the content root docShell. Session is owned here.
|
||||
@ -46,7 +44,7 @@ protected:
|
||||
|
||||
// Indicates whether to make an editor after a url load.
|
||||
bool mMakeEditable;
|
||||
|
||||
|
||||
// If this frame is editable, store editor here. Editor is owned here.
|
||||
nsCOMPtr<nsIEditor> mEditor;
|
||||
|
||||
@ -63,5 +61,4 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // nsDocShellEditorData_h__
|
||||
|
@ -1,20 +1,19 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#include "nsDocShellEnumerator.h"
|
||||
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
|
||||
nsDocShellEnumerator::nsDocShellEnumerator(int32_t inEnumerationDirection)
|
||||
: mRootItem(nullptr)
|
||||
, mCurIndex(0)
|
||||
, mDocShellType(nsIDocShellTreeItem::typeAll)
|
||||
, mArrayValid(false)
|
||||
, mEnumerationDirection(inEnumerationDirection)
|
||||
nsDocShellEnumerator::nsDocShellEnumerator(int32_t aEnumerationDirection)
|
||||
: mRootItem(nullptr)
|
||||
, mCurIndex(0)
|
||||
, mDocShellType(nsIDocShellTreeItem::typeAll)
|
||||
, mArrayValid(false)
|
||||
, mEnumerationDirection(aEnumerationDirection)
|
||||
{
|
||||
}
|
||||
|
||||
@ -24,40 +23,47 @@ nsDocShellEnumerator::~nsDocShellEnumerator()
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsDocShellEnumerator, nsISimpleEnumerator)
|
||||
|
||||
|
||||
/* nsISupports getNext (); */
|
||||
NS_IMETHODIMP nsDocShellEnumerator::GetNext(nsISupports **outCurItem)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellEnumerator::GetNext(nsISupports** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(outCurItem);
|
||||
*outCurItem = nullptr;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = nullptr;
|
||||
|
||||
nsresult rv = EnsureDocShellArray();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (mCurIndex >= mItemArray.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// post-increment is important here
|
||||
nsCOMPtr<nsISupports> item = do_QueryReferent(mItemArray[mCurIndex++], &rv);
|
||||
item.forget(outCurItem);
|
||||
item.forget(aResult);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* boolean hasMoreElements (); */
|
||||
NS_IMETHODIMP nsDocShellEnumerator::HasMoreElements(bool *outHasMore)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellEnumerator::HasMoreElements(bool* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(outHasMore);
|
||||
*outHasMore = false;
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = false;
|
||||
|
||||
nsresult rv = EnsureDocShellArray();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
*outHasMore = (mCurIndex < mItemArray.Length());
|
||||
*aResult = (mCurIndex < mItemArray.Length());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShellEnumerator::GetEnumerationRootItem(nsIDocShellTreeItem * *aEnumerationRootItem)
|
||||
nsresult
|
||||
nsDocShellEnumerator::GetEnumerationRootItem(
|
||||
nsIDocShellTreeItem** aEnumerationRootItem)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEnumerationRootItem);
|
||||
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
|
||||
@ -65,45 +71,51 @@ nsresult nsDocShellEnumerator::GetEnumerationRootItem(nsIDocShellTreeItem * *aEn
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShellEnumerator::SetEnumerationRootItem(nsIDocShellTreeItem * aEnumerationRootItem)
|
||||
nsresult
|
||||
nsDocShellEnumerator::SetEnumerationRootItem(
|
||||
nsIDocShellTreeItem* aEnumerationRootItem)
|
||||
{
|
||||
mRootItem = do_GetWeakReference(aEnumerationRootItem);
|
||||
ClearState();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShellEnumerator::GetEnumDocShellType(int32_t *aEnumerationItemType)
|
||||
nsresult
|
||||
nsDocShellEnumerator::GetEnumDocShellType(int32_t* aEnumerationItemType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEnumerationItemType);
|
||||
*aEnumerationItemType = mDocShellType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShellEnumerator::SetEnumDocShellType(int32_t aEnumerationItemType)
|
||||
nsresult
|
||||
nsDocShellEnumerator::SetEnumDocShellType(int32_t aEnumerationItemType)
|
||||
{
|
||||
mDocShellType = aEnumerationItemType;
|
||||
ClearState();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShellEnumerator::First()
|
||||
nsresult
|
||||
nsDocShellEnumerator::First()
|
||||
{
|
||||
mCurIndex = 0;
|
||||
return EnsureDocShellArray();
|
||||
}
|
||||
|
||||
nsresult nsDocShellEnumerator::EnsureDocShellArray()
|
||||
nsresult
|
||||
nsDocShellEnumerator::EnsureDocShellArray()
|
||||
{
|
||||
if (!mArrayValid)
|
||||
{
|
||||
if (!mArrayValid) {
|
||||
mArrayValid = true;
|
||||
return BuildDocShellArray(mItemArray);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShellEnumerator::ClearState()
|
||||
nsresult
|
||||
nsDocShellEnumerator::ClearState()
|
||||
{
|
||||
mItemArray.Clear();
|
||||
mArrayValid = false;
|
||||
@ -111,66 +123,84 @@ nsresult nsDocShellEnumerator::ClearState()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDocShellEnumerator::BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray)
|
||||
nsresult
|
||||
nsDocShellEnumerator::BuildDocShellArray(nsTArray<nsWeakPtr>& aItemArray)
|
||||
{
|
||||
NS_ENSURE_TRUE(mRootItem, NS_ERROR_NOT_INITIALIZED);
|
||||
inItemArray.Clear();
|
||||
aItemArray.Clear();
|
||||
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
|
||||
return BuildArrayRecursive(item, inItemArray);
|
||||
return BuildArrayRecursive(item, aItemArray);
|
||||
}
|
||||
|
||||
nsresult nsDocShellForwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray)
|
||||
nsresult
|
||||
nsDocShellForwardsEnumerator::BuildArrayRecursive(
|
||||
nsIDocShellTreeItem* aItem,
|
||||
nsTArray<nsWeakPtr>& aItemArray)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// add this item to the array
|
||||
if (mDocShellType == nsIDocShellTreeItem::typeAll ||
|
||||
inItem->ItemType() == mDocShellType) {
|
||||
if (!inItemArray.AppendElement(do_GetWeakReference(inItem)))
|
||||
aItem->ItemType() == mDocShellType) {
|
||||
if (!aItemArray.AppendElement(do_GetWeakReference(aItem))) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t numChildren;
|
||||
rv = inItem->GetChildCount(&numChildren);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
for (int32_t i = 0; i < numChildren; ++i)
|
||||
{
|
||||
int32_t numChildren;
|
||||
rv = aItem->GetChildCount(&numChildren);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < numChildren; ++i) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> curChild;
|
||||
rv = inItem->GetChildAt(i, getter_AddRefs(curChild));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = BuildArrayRecursive(curChild, inItemArray);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = aItem->GetChildAt(i, getter_AddRefs(curChild));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = BuildArrayRecursive(curChild, aItemArray);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsDocShellBackwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray)
|
||||
nsresult
|
||||
nsDocShellBackwardsEnumerator::BuildArrayRecursive(
|
||||
nsIDocShellTreeItem* aItem,
|
||||
nsTArray<nsWeakPtr>& aItemArray)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
int32_t numChildren;
|
||||
rv = inItem->GetChildCount(&numChildren);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
for (int32_t i = numChildren - 1; i >= 0; --i)
|
||||
{
|
||||
int32_t numChildren;
|
||||
rv = aItem->GetChildCount(&numChildren);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
for (int32_t i = numChildren - 1; i >= 0; --i) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> curChild;
|
||||
rv = inItem->GetChildAt(i, getter_AddRefs(curChild));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = BuildArrayRecursive(curChild, inItemArray);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = aItem->GetChildAt(i, getter_AddRefs(curChild));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = BuildArrayRecursive(curChild, aItemArray);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// add this item to the array
|
||||
if (mDocShellType == nsIDocShellTreeItem::typeAll ||
|
||||
inItem->ItemType() == mDocShellType) {
|
||||
if (!inItemArray.AppendElement(do_GetWeakReference(inItem)))
|
||||
aItem->ItemType() == mDocShellType) {
|
||||
if (!aItemArray.AppendElement(do_GetWeakReference(aItem))) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@ -32,82 +32,77 @@ class nsIDocShellTreeItem;
|
||||
class nsDocShellEnumerator : public nsISimpleEnumerator
|
||||
{
|
||||
protected:
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
enumerateForwards,
|
||||
enumerateBackwards
|
||||
};
|
||||
|
||||
virtual ~nsDocShellEnumerator();
|
||||
virtual ~nsDocShellEnumerator();
|
||||
|
||||
public:
|
||||
|
||||
explicit nsDocShellEnumerator(int32_t inEnumerationDirection);
|
||||
explicit nsDocShellEnumerator(int32_t aEnumerationDirection);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
// nsISimpleEnumerator
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
|
||||
public:
|
||||
nsresult GetEnumerationRootItem(nsIDocShellTreeItem** aEnumerationRootItem);
|
||||
nsresult SetEnumerationRootItem(nsIDocShellTreeItem* aEnumerationRootItem);
|
||||
|
||||
nsresult GetEnumerationRootItem(nsIDocShellTreeItem * *aEnumerationRootItem);
|
||||
nsresult SetEnumerationRootItem(nsIDocShellTreeItem * aEnumerationRootItem);
|
||||
|
||||
nsresult GetEnumDocShellType(int32_t *aEnumerationItemType);
|
||||
nsresult SetEnumDocShellType(int32_t aEnumerationItemType);
|
||||
|
||||
nsresult First();
|
||||
nsresult GetEnumDocShellType(int32_t* aEnumerationItemType);
|
||||
nsresult SetEnumDocShellType(int32_t aEnumerationItemType);
|
||||
|
||||
nsresult First();
|
||||
|
||||
protected:
|
||||
nsresult EnsureDocShellArray();
|
||||
nsresult ClearState();
|
||||
|
||||
nsresult BuildDocShellArray(nsTArray<nsWeakPtr>& aItemArray);
|
||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
|
||||
nsTArray<nsWeakPtr>& aItemArray) = 0;
|
||||
|
||||
nsresult EnsureDocShellArray();
|
||||
nsresult ClearState();
|
||||
|
||||
nsresult BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray);
|
||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray) = 0;
|
||||
|
||||
protected:
|
||||
nsWeakPtr mRootItem; // weak ref!
|
||||
|
||||
nsWeakPtr mRootItem; // weak ref!
|
||||
|
||||
nsTArray<nsWeakPtr> mItemArray; // flattened list of items with matching type
|
||||
uint32_t mCurIndex;
|
||||
|
||||
int32_t mDocShellType; // only want shells of this type
|
||||
bool mArrayValid; // is mItemArray up to date?
|
||||
nsTArray<nsWeakPtr> mItemArray; // flattened list of items with matching type
|
||||
uint32_t mCurIndex;
|
||||
|
||||
const int8_t mEnumerationDirection;
|
||||
int32_t mDocShellType; // only want shells of this type
|
||||
bool mArrayValid; // is mItemArray up to date?
|
||||
|
||||
const int8_t mEnumerationDirection;
|
||||
};
|
||||
|
||||
|
||||
class nsDocShellForwardsEnumerator : public nsDocShellEnumerator
|
||||
{
|
||||
public:
|
||||
|
||||
nsDocShellForwardsEnumerator()
|
||||
: nsDocShellEnumerator(enumerateForwards)
|
||||
{
|
||||
}
|
||||
nsDocShellForwardsEnumerator()
|
||||
: nsDocShellEnumerator(enumerateForwards)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray);
|
||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
|
||||
nsTArray<nsWeakPtr>& aItemArray);
|
||||
|
||||
};
|
||||
|
||||
class nsDocShellBackwardsEnumerator : public nsDocShellEnumerator
|
||||
{
|
||||
public:
|
||||
nsDocShellBackwardsEnumerator()
|
||||
: nsDocShellEnumerator(enumerateBackwards)
|
||||
{
|
||||
}
|
||||
|
||||
nsDocShellBackwardsEnumerator()
|
||||
: nsDocShellEnumerator(enumerateBackwards)
|
||||
{
|
||||
}
|
||||
protected:
|
||||
|
||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray);
|
||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
|
||||
nsTArray<nsWeakPtr>& aItemArray);
|
||||
};
|
||||
|
||||
#endif // nsDocShellEnumerator_h___
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@ -17,12 +17,12 @@
|
||||
//*****************************************************************************
|
||||
|
||||
nsDocShellLoadInfo::nsDocShellLoadInfo()
|
||||
: mInheritOwner(false),
|
||||
mOwnerIsExplicit(false),
|
||||
mSendReferrer(true),
|
||||
mReferrerPolicy(mozilla::net::RP_Default),
|
||||
mLoadType(nsIDocShellLoadInfo::loadNormal),
|
||||
mIsSrcdocLoad(false)
|
||||
: mInheritOwner(false)
|
||||
, mOwnerIsExplicit(false)
|
||||
, mSendReferrer(true)
|
||||
, mReferrerPolicy(mozilla::net::RP_Default)
|
||||
, mLoadType(nsIDocShellLoadInfo::loadNormal)
|
||||
, mIsSrcdocLoad(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -32,123 +32,136 @@ nsDocShellLoadInfo::~nsDocShellLoadInfo()
|
||||
|
||||
//*****************************************************************************
|
||||
// nsDocShellLoadInfo::nsISupports
|
||||
//*****************************************************************************
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ADDREF(nsDocShellLoadInfo)
|
||||
NS_IMPL_RELEASE(nsDocShellLoadInfo)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsDocShellLoadInfo)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellLoadInfo)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocShellLoadInfo)
|
||||
NS_INTERFACE_MAP_END
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellLoadInfo)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocShellLoadInfo)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//*****************************************************************************
|
||||
// nsDocShellLoadInfo::nsIDocShellLoadInfo
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReferrer);
|
||||
|
||||
*aReferrer = mReferrer;
|
||||
NS_IF_ADDREF(*aReferrer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetReferrer(nsIURI* aReferrer)
|
||||
{
|
||||
mReferrer = aReferrer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetOwner(nsISupports** aOwner)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOwner);
|
||||
|
||||
*aOwner = mOwner;
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetInheritOwner(bool* aInheritOwner)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInheritOwner);
|
||||
|
||||
*aInheritOwner = mInheritOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetInheritOwner(bool aInheritOwner)
|
||||
{
|
||||
mInheritOwner = aInheritOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetOwnerIsExplicit(bool* aOwnerIsExplicit)
|
||||
{
|
||||
*aOwnerIsExplicit = mOwnerIsExplicit;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetOwnerIsExplicit(bool aOwnerIsExplicit)
|
||||
{
|
||||
mOwnerIsExplicit = aOwnerIsExplicit;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType * aLoadType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLoadType);
|
||||
|
||||
*aLoadType = mLoadType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetLoadType(nsDocShellInfoLoadType aLoadType)
|
||||
{
|
||||
mLoadType = aLoadType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetSHEntry(nsISHEntry** aSHEntry)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSHEntry);
|
||||
|
||||
*aSHEntry = mSHEntry;
|
||||
NS_IF_ADDREF(*aSHEntry);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetSHEntry(nsISHEntry* aSHEntry)
|
||||
{
|
||||
mSHEntry = aSHEntry;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetTarget(char16_t** aTarget)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aTarget);
|
||||
|
||||
*aTarget = ToNewUnicode(mTarget);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetTarget(const char16_t* aTarget)
|
||||
{
|
||||
mTarget.Assign(aTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetPostDataStream(nsIInputStream **aResult)
|
||||
nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReferrer);
|
||||
|
||||
*aReferrer = mReferrer;
|
||||
NS_IF_ADDREF(*aReferrer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetReferrer(nsIURI* aReferrer)
|
||||
{
|
||||
mReferrer = aReferrer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetOwner(nsISupports** aOwner)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOwner);
|
||||
|
||||
*aOwner = mOwner;
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetInheritOwner(bool* aInheritOwner)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInheritOwner);
|
||||
|
||||
*aInheritOwner = mInheritOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetInheritOwner(bool aInheritOwner)
|
||||
{
|
||||
mInheritOwner = aInheritOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetOwnerIsExplicit(bool* aOwnerIsExplicit)
|
||||
{
|
||||
*aOwnerIsExplicit = mOwnerIsExplicit;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetOwnerIsExplicit(bool aOwnerIsExplicit)
|
||||
{
|
||||
mOwnerIsExplicit = aOwnerIsExplicit;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType* aLoadType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLoadType);
|
||||
|
||||
*aLoadType = mLoadType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetLoadType(nsDocShellInfoLoadType aLoadType)
|
||||
{
|
||||
mLoadType = aLoadType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetSHEntry(nsISHEntry** aSHEntry)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSHEntry);
|
||||
|
||||
*aSHEntry = mSHEntry;
|
||||
NS_IF_ADDREF(*aSHEntry);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetSHEntry(nsISHEntry* aSHEntry)
|
||||
{
|
||||
mSHEntry = aSHEntry;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetTarget(char16_t** aTarget)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aTarget);
|
||||
|
||||
*aTarget = ToNewUnicode(mTarget);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetTarget(const char16_t* aTarget)
|
||||
{
|
||||
mTarget.Assign(aTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetPostDataStream(nsIInputStream** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
@ -158,106 +171,112 @@ nsDocShellLoadInfo::GetPostDataStream(nsIInputStream **aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetPostDataStream(nsIInputStream *aStream)
|
||||
nsDocShellLoadInfo::SetPostDataStream(nsIInputStream* aStream)
|
||||
{
|
||||
mPostDataStream = aStream;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute nsIInputStream headersStream; */
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetHeadersStream(nsIInputStream * *aHeadersStream)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetHeadersStream(nsIInputStream** aHeadersStream)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aHeadersStream);
|
||||
*aHeadersStream = mHeadersStream;
|
||||
NS_IF_ADDREF(*aHeadersStream);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetHeadersStream(nsIInputStream * aHeadersStream)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetHeadersStream(nsIInputStream* aHeadersStream)
|
||||
{
|
||||
mHeadersStream = aHeadersStream;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetSendReferrer(bool* aSendReferrer)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetSendReferrer(bool* aSendReferrer)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSendReferrer);
|
||||
NS_ENSURE_ARG_POINTER(aSendReferrer);
|
||||
|
||||
*aSendReferrer = mSendReferrer;
|
||||
return NS_OK;
|
||||
*aSendReferrer = mSendReferrer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetSendReferrer(bool aSendReferrer)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetSendReferrer(bool aSendReferrer)
|
||||
{
|
||||
mSendReferrer = aSendReferrer;
|
||||
return NS_OK;
|
||||
mSendReferrer = aSendReferrer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetReferrerPolicy(nsDocShellInfoReferrerPolicy* aReferrerPolicy)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetReferrerPolicy(
|
||||
nsDocShellInfoReferrerPolicy* aReferrerPolicy)
|
||||
{
|
||||
*aReferrerPolicy = mReferrerPolicy;
|
||||
return NS_OK;
|
||||
*aReferrerPolicy = mReferrerPolicy;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetReferrerPolicy(nsDocShellInfoReferrerPolicy aReferrerPolicy)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetReferrerPolicy(
|
||||
nsDocShellInfoReferrerPolicy aReferrerPolicy)
|
||||
{
|
||||
mReferrerPolicy = aReferrerPolicy;
|
||||
return NS_OK;
|
||||
mReferrerPolicy = aReferrerPolicy;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetIsSrcdocLoad(bool* aIsSrcdocLoad)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetIsSrcdocLoad(bool* aIsSrcdocLoad)
|
||||
{
|
||||
*aIsSrcdocLoad = mIsSrcdocLoad;
|
||||
return NS_OK;
|
||||
*aIsSrcdocLoad = mIsSrcdocLoad;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetSrcdocData(nsAString &aSrcdocData)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetSrcdocData(nsAString& aSrcdocData)
|
||||
{
|
||||
aSrcdocData = mSrcdocData;
|
||||
return NS_OK;
|
||||
aSrcdocData = mSrcdocData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetSrcdocData(const nsAString &aSrcdocData)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetSrcdocData(const nsAString& aSrcdocData)
|
||||
{
|
||||
mSrcdocData = aSrcdocData;
|
||||
mIsSrcdocLoad = true;
|
||||
return NS_OK;
|
||||
mSrcdocData = aSrcdocData;
|
||||
mIsSrcdocLoad = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetSourceDocShell(nsIDocShell** aSourceDocShell)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetSourceDocShell(nsIDocShell** aSourceDocShell)
|
||||
{
|
||||
MOZ_ASSERT(aSourceDocShell);
|
||||
nsCOMPtr<nsIDocShell> result = mSourceDocShell;
|
||||
result.forget(aSourceDocShell);
|
||||
return NS_OK;
|
||||
MOZ_ASSERT(aSourceDocShell);
|
||||
nsCOMPtr<nsIDocShell> result = mSourceDocShell;
|
||||
result.forget(aSourceDocShell);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetSourceDocShell(nsIDocShell* aSourceDocShell)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetSourceDocShell(nsIDocShell* aSourceDocShell)
|
||||
{
|
||||
mSourceDocShell = aSourceDocShell;
|
||||
return NS_OK;
|
||||
mSourceDocShell = aSourceDocShell;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::GetBaseURI(nsIURI** aBaseURI)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetBaseURI(nsIURI** aBaseURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aBaseURI);
|
||||
NS_ENSURE_ARG_POINTER(aBaseURI);
|
||||
|
||||
*aBaseURI = mBaseURI;
|
||||
NS_IF_ADDREF(*aBaseURI);
|
||||
return NS_OK;
|
||||
*aBaseURI = mBaseURI;
|
||||
NS_IF_ADDREF(*aBaseURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI)
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI)
|
||||
{
|
||||
mBaseURI = aBaseURI;
|
||||
return NS_OK;
|
||||
mBaseURI = aBaseURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsDocShellLoadInfo: Helpers
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
// nsDocShellLoadInfo: Accessors
|
||||
//*****************************************************************************
|
||||
|
@ -1,13 +1,12 @@
|
||||
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef nsDocShellLoadInfo_h__
|
||||
#define nsDocShellLoadInfo_h__
|
||||
|
||||
|
||||
// Helper Classes
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
@ -32,21 +31,21 @@ protected:
|
||||
virtual ~nsDocShellLoadInfo();
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIURI> mReferrer;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
bool mInheritOwner;
|
||||
bool mOwnerIsExplicit;
|
||||
bool mSendReferrer;
|
||||
nsDocShellInfoReferrerPolicy mReferrerPolicy;
|
||||
nsDocShellInfoLoadType mLoadType;
|
||||
nsCOMPtr<nsISHEntry> mSHEntry;
|
||||
nsString mTarget;
|
||||
nsCOMPtr<nsIInputStream> mPostDataStream;
|
||||
nsCOMPtr<nsIInputStream> mHeadersStream;
|
||||
bool mIsSrcdocLoad;
|
||||
nsString mSrcdocData;
|
||||
nsCOMPtr<nsIDocShell> mSourceDocShell;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
nsCOMPtr<nsIURI> mReferrer;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
bool mInheritOwner;
|
||||
bool mOwnerIsExplicit;
|
||||
bool mSendReferrer;
|
||||
nsDocShellInfoReferrerPolicy mReferrerPolicy;
|
||||
nsDocShellInfoLoadType mLoadType;
|
||||
nsCOMPtr<nsISHEntry> mSHEntry;
|
||||
nsString mTarget;
|
||||
nsCOMPtr<nsIInputStream> mPostDataStream;
|
||||
nsCOMPtr<nsIInputStream> mHeadersStream;
|
||||
bool mIsSrcdocLoad;
|
||||
nsString mSrcdocData;
|
||||
nsCOMPtr<nsIDocShell> mSourceDocShell;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
};
|
||||
|
||||
#endif /* nsDocShellLoadInfo_h__ */
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=4 sw=4 et tw=80:
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@ -32,49 +31,48 @@
|
||||
LOAD_FLAGS_ALLOW_POPUPS | \
|
||||
0xffff0000)
|
||||
|
||||
|
||||
|
||||
/* load types are legal combinations of load commands and flags
|
||||
*
|
||||
/* load types are legal combinations of load commands and flags
|
||||
*
|
||||
* NOTE:
|
||||
* Remember to update the IsValidLoadType function below if you change this
|
||||
* enum to ensure bad flag combinations will be rejected.
|
||||
*/
|
||||
enum LoadType {
|
||||
LOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||
LOAD_NORMAL_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
|
||||
LOAD_NORMAL_EXTERNAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL),
|
||||
LOAD_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_HISTORY, nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||
LOAD_NORMAL_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||
LOAD_NORMAL_BYPASS_PROXY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
||||
LOAD_NORMAL_BYPASS_PROXY_AND_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
||||
LOAD_NORMAL_ALLOW_MIXED_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||
LOAD_RELOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||
LOAD_RELOAD_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||
LOAD_RELOAD_BYPASS_PROXY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
||||
LOAD_RELOAD_ALLOW_MIXED_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||
LOAD_RELOAD_BYPASS_PROXY_AND_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
||||
LOAD_LINK = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_IS_LINK),
|
||||
LOAD_REFRESH = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_IS_REFRESH),
|
||||
LOAD_RELOAD_CHARSET_CHANGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE),
|
||||
LOAD_BYPASS_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY),
|
||||
LOAD_STOP_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT),
|
||||
LOAD_STOP_CONTENT_AND_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT | nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
|
||||
LOAD_PUSHSTATE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_PUSHSTATE, nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||
LOAD_REPLACE_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||
/**
|
||||
* Load type for an error page. These loads are never triggered by users of
|
||||
* Docshell. Instead, Docshell triggers the load itself when a
|
||||
* consumer-triggered load failed.
|
||||
*/
|
||||
LOAD_ERROR_PAGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, LOAD_FLAGS_ERROR_PAGE)
|
||||
|
||||
// NOTE: Adding a new value? Remember to update IsValidLoadType!
|
||||
};
|
||||
static inline bool IsValidLoadType(uint32_t aLoadType)
|
||||
enum LoadType
|
||||
{
|
||||
switch (aLoadType)
|
||||
{
|
||||
LOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||
LOAD_NORMAL_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
|
||||
LOAD_NORMAL_EXTERNAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL),
|
||||
LOAD_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_HISTORY, nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||
LOAD_NORMAL_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||
LOAD_NORMAL_BYPASS_PROXY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
||||
LOAD_NORMAL_BYPASS_PROXY_AND_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
||||
LOAD_NORMAL_ALLOW_MIXED_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||
LOAD_RELOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||
LOAD_RELOAD_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||
LOAD_RELOAD_BYPASS_PROXY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
||||
LOAD_RELOAD_ALLOW_MIXED_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||
LOAD_RELOAD_BYPASS_PROXY_AND_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
||||
LOAD_LINK = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_IS_LINK),
|
||||
LOAD_REFRESH = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_IS_REFRESH),
|
||||
LOAD_RELOAD_CHARSET_CHANGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE),
|
||||
LOAD_BYPASS_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY),
|
||||
LOAD_STOP_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT),
|
||||
LOAD_STOP_CONTENT_AND_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT | nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
|
||||
LOAD_PUSHSTATE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_PUSHSTATE, nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||
LOAD_REPLACE_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||
/**
|
||||
* Load type for an error page. These loads are never triggered by users of
|
||||
* Docshell. Instead, Docshell triggers the load itself when a
|
||||
* consumer-triggered load failed.
|
||||
*/
|
||||
LOAD_ERROR_PAGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, LOAD_FLAGS_ERROR_PAGE)
|
||||
|
||||
// NOTE: Adding a new value? Remember to update IsValidLoadType!
|
||||
};
|
||||
static inline bool
|
||||
IsValidLoadType(uint32_t aLoadType)
|
||||
{
|
||||
switch (aLoadType) {
|
||||
case LOAD_NORMAL:
|
||||
case LOAD_NORMAL_REPLACE:
|
||||
case LOAD_NORMAL_EXTERNAL:
|
||||
@ -97,10 +95,10 @@ static inline bool IsValidLoadType(uint32_t aLoadType)
|
||||
case LOAD_PUSHSTATE:
|
||||
case LOAD_REPLACE_BYPASS_CACHE:
|
||||
case LOAD_ERROR_PAGE:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // MOZILLA_INTERNAL_API
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -11,7 +13,6 @@ nsTransferableHookData::nsTransferableHookData()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsTransferableHookData::~nsTransferableHookData()
|
||||
{
|
||||
}
|
||||
@ -24,33 +25,34 @@ NS_IMPL_ISUPPORTS(nsTransferableHookData, nsIClipboardDragDropHookList)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransferableHookData::AddClipboardDragDropHooks(
|
||||
nsIClipboardDragDropHooks *aOverrides)
|
||||
nsIClipboardDragDropHooks* aOverrides)
|
||||
{
|
||||
NS_ENSURE_ARG(aOverrides);
|
||||
NS_ENSURE_ARG(aOverrides);
|
||||
|
||||
// don't let a hook be added more than once
|
||||
if (mHookList.IndexOfObject(aOverrides) == -1)
|
||||
{
|
||||
if (!mHookList.AppendObject(aOverrides))
|
||||
return NS_ERROR_FAILURE;
|
||||
// don't let a hook be added more than once
|
||||
if (mHookList.IndexOfObject(aOverrides) == -1) {
|
||||
if (!mHookList.AppendObject(aOverrides)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransferableHookData::RemoveClipboardDragDropHooks(
|
||||
nsIClipboardDragDropHooks *aOverrides)
|
||||
nsIClipboardDragDropHooks* aOverrides)
|
||||
{
|
||||
NS_ENSURE_ARG(aOverrides);
|
||||
if (!mHookList.RemoveObject(aOverrides))
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ENSURE_ARG(aOverrides);
|
||||
if (!mHookList.RemoveObject(aOverrides)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTransferableHookData::GetHookEnumerator(nsISimpleEnumerator **aResult)
|
||||
nsTransferableHookData::GetHookEnumerator(nsISimpleEnumerator** aResult)
|
||||
{
|
||||
return NS_NewArrayEnumerator(aResult, mHookList);
|
||||
return NS_NewArrayEnumerator(aResult, mHookList);
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -13,14 +15,14 @@ class nsIClipboardDragDropHooks;
|
||||
class nsTransferableHookData : public nsIClipboardDragDropHookList
|
||||
{
|
||||
public:
|
||||
nsTransferableHookData();
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICLIPBOARDDRAGDROPHOOKLIST
|
||||
nsTransferableHookData();
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICLIPBOARDDRAGDROPHOOKLIST
|
||||
|
||||
protected:
|
||||
virtual ~nsTransferableHookData();
|
||||
virtual ~nsTransferableHookData();
|
||||
|
||||
nsCOMArray<nsIClipboardDragDropHooks> mHookList;
|
||||
nsCOMArray<nsIClipboardDragDropHooks> mHookList;
|
||||
};
|
||||
|
||||
#endif // nsDocShellTransferableHooks_h__
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=2 sts=2
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@ -20,17 +20,18 @@ NS_IMPL_ISUPPORTS(nsDownloadHistory, nsIDownloadHistory)
|
||||
//// nsIDownloadHistory
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDownloadHistory::AddDownload(nsIURI *aSource,
|
||||
nsIURI *aReferrer,
|
||||
nsDownloadHistory::AddDownload(nsIURI* aSource,
|
||||
nsIURI* aReferrer,
|
||||
PRTime aStartTime,
|
||||
nsIURI *aDestination)
|
||||
nsIURI* aDestination)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSource);
|
||||
|
||||
nsCOMPtr<nsIGlobalHistory2> history =
|
||||
do_GetService("@mozilla.org/browser/global-history;2");
|
||||
if (!history)
|
||||
if (!history) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
bool visited;
|
||||
nsresult rv = history->IsVisited(aSource, &visited);
|
||||
@ -38,12 +39,13 @@ nsDownloadHistory::AddDownload(nsIURI *aSource,
|
||||
|
||||
rv = history->AddURI(aSource, false, true, aReferrer);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
if (!visited) {
|
||||
nsCOMPtr<nsIObserverService> os =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
if (os)
|
||||
if (os) {
|
||||
os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=2 sts=2
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -22,7 +23,8 @@ class nsString;
|
||||
/**
|
||||
* Interface used for handling clicks on links
|
||||
*/
|
||||
class nsILinkHandler : public nsISupports {
|
||||
class nsILinkHandler : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILINKHANDLER_IID)
|
||||
|
||||
@ -79,7 +81,7 @@ public:
|
||||
* @param aTargetSpec indicates where the link is targeted (it may be an empty
|
||||
* string)
|
||||
*/
|
||||
NS_IMETHOD OnOverLink(nsIContent* aContent,
|
||||
NS_IMETHOD OnOverLink(nsIContent* aContent,
|
||||
nsIURI* aURLSpec,
|
||||
const char16_t* aTargetSpec) = 0;
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef nsIScrollObserver_h___
|
||||
#define nsIScrollObserver_h___
|
||||
@ -27,13 +28,13 @@ public:
|
||||
* Called when an async panning/zooming transform has started being applied
|
||||
* and passed the scroll offset
|
||||
*/
|
||||
virtual void AsyncPanZoomStarted(const mozilla::CSSIntPoint scrollPos){};
|
||||
virtual void AsyncPanZoomStarted(const mozilla::CSSIntPoint aScrollPos) {};
|
||||
|
||||
/**
|
||||
* Called when an async panning/zooming transform is no longer applied
|
||||
* and passed the scroll offset
|
||||
*/
|
||||
virtual void AsyncPanZoomStopped(const mozilla::CSSIntPoint scrollPos){};
|
||||
virtual void AsyncPanZoomStopped(const mozilla::CSSIntPoint aScrollPos) {};
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollObserver, NS_ISCROLLOBSERVER_IID)
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -16,11 +17,12 @@
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class nsIWebShellServices : public nsISupports {
|
||||
class nsIWebShellServices : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWEB_SHELL_SERVICES_IID)
|
||||
|
||||
NS_IMETHOD ReloadDocument(const char* aCharset = nullptr ,
|
||||
NS_IMETHOD ReloadDocument(const char* aCharset = nullptr ,
|
||||
int32_t aSource = kCharsetUninitialized) = 0;
|
||||
NS_IMETHOD StopDocumentLoad(void) = 0;
|
||||
};
|
||||
@ -29,7 +31,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIWebShellServices, NS_IWEB_SHELL_SERVICES_IID)
|
||||
|
||||
/* Use this macro when declaring classes that implement this interface. */
|
||||
#define NS_DECL_NSIWEBSHELLSERVICES \
|
||||
NS_IMETHOD ReloadDocument(const char *aCharset=nullptr, int32_t aSource=kCharsetUninitialized) MOZ_OVERRIDE; \
|
||||
NS_IMETHOD StopDocumentLoad(void) MOZ_OVERRIDE; \
|
||||
NS_IMETHOD ReloadDocument(const char* aCharset = nullptr, \
|
||||
int32_t aSource = kCharsetUninitialized) MOZ_OVERRIDE; \
|
||||
NS_IMETHOD StopDocumentLoad(void) MOZ_OVERRIDE;
|
||||
|
||||
#endif /* nsIWebShellServices_h___ */
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -16,7 +17,7 @@ NS_IMPL_ISUPPORTS(nsWebNavigationInfo, nsIWebNavigationInfo)
|
||||
|
||||
#define CONTENT_DLF_CONTRACT "@mozilla.org/content/document-loader-factory;1"
|
||||
#define PLUGIN_DLF_CONTRACT \
|
||||
"@mozilla.org/content/plugin/document-loader-factory;1"
|
||||
"@mozilla.org/content/plugin/document-loader-factory;1"
|
||||
|
||||
nsresult
|
||||
nsWebNavigationInfo::Init()
|
||||
@ -38,7 +39,7 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
|
||||
// Note to self: aWebNav could be an nsWebBrowser or an nsDocShell here (or
|
||||
// an nsSHistory, but not much we can do with that). So if we start using
|
||||
// it here, we need to be careful to get to the docshell correctly.
|
||||
|
||||
|
||||
// For now just report what the Gecko-Content-Viewers category has
|
||||
// to say for itself.
|
||||
*aIsTypeSupported = nsIWebNavigationInfo::UNSUPPORTED;
|
||||
@ -55,7 +56,8 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
|
||||
// there's no need to try and find a plugin to handle it.
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebNav));
|
||||
bool allowed;
|
||||
if (docShell && NS_SUCCEEDED(docShell->GetAllowPlugins(&allowed)) && !allowed) {
|
||||
if (docShell &&
|
||||
NS_SUCCEEDED(docShell->GetAllowPlugins(&allowed)) && !allowed) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -84,36 +86,34 @@ nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
|
||||
{
|
||||
NS_PRECONDITION(aIsSupported, "Null out param?");
|
||||
|
||||
|
||||
nsContentUtils::ContentViewerType vtype = nsContentUtils::TYPE_UNSUPPORTED;
|
||||
|
||||
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
|
||||
nsContentUtils::FindInternalContentViewer(aType.get(), &vtype);
|
||||
|
||||
switch (vtype) {
|
||||
case nsContentUtils::TYPE_UNSUPPORTED:
|
||||
*aIsSupported = nsIWebNavigationInfo::UNSUPPORTED;
|
||||
break;
|
||||
case nsContentUtils::TYPE_UNSUPPORTED:
|
||||
*aIsSupported = nsIWebNavigationInfo::UNSUPPORTED;
|
||||
break;
|
||||
|
||||
case nsContentUtils::TYPE_PLUGIN:
|
||||
*aIsSupported = nsIWebNavigationInfo::PLUGIN;
|
||||
break;
|
||||
case nsContentUtils::TYPE_PLUGIN:
|
||||
*aIsSupported = nsIWebNavigationInfo::PLUGIN;
|
||||
break;
|
||||
|
||||
case nsContentUtils::TYPE_UNKNOWN:
|
||||
*aIsSupported = nsIWebNavigationInfo::OTHER;
|
||||
break;
|
||||
|
||||
case nsContentUtils::TYPE_CONTENT:
|
||||
// XXXbz we only need this because images register for the same
|
||||
// contractid as documents, so we can't tell them apart based on
|
||||
// contractid.
|
||||
if (imgLoader::SupportImageWithMimeType(aType.get())) {
|
||||
*aIsSupported = nsIWebNavigationInfo::IMAGE;
|
||||
}
|
||||
else {
|
||||
case nsContentUtils::TYPE_UNKNOWN:
|
||||
*aIsSupported = nsIWebNavigationInfo::OTHER;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case nsContentUtils::TYPE_CONTENT:
|
||||
// XXXbz we only need this because images register for the same
|
||||
// contractid as documents, so we can't tell them apart based on
|
||||
// contractid.
|
||||
if (imgLoader::SupportImageWithMimeType(aType.get())) {
|
||||
*aIsSupported = nsIWebNavigationInfo::IMAGE;
|
||||
} else {
|
||||
*aIsSupported = nsIWebNavigationInfo::OTHER;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@ -21,7 +22,7 @@ class nsWebNavigationInfo MOZ_FINAL : public nsIWebNavigationInfo
|
||||
{
|
||||
public:
|
||||
nsWebNavigationInfo() {}
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIWEBNAVIGATIONINFO
|
||||
@ -30,12 +31,12 @@ public:
|
||||
|
||||
private:
|
||||
~nsWebNavigationInfo() {}
|
||||
|
||||
|
||||
// Check whether aType is supported. If this method throws, the
|
||||
// value of aIsSupported is not changed.
|
||||
nsresult IsTypeSupportedInternal(const nsCString& aType,
|
||||
uint32_t* aIsSupported);
|
||||
|
||||
|
||||
nsCOMPtr<nsICategoryManager> mCategoryManager;
|
||||
};
|
||||
|
||||
|
@ -692,6 +692,7 @@ DOMException::Constructor(GlobalObject& /* unused */,
|
||||
if (name.EqualsASCII(sDOMErrorMsgMap[idx].mName)) {
|
||||
exceptionResult = sDOMErrorMsgMap[idx].mNSResult;
|
||||
exceptionCode = sDOMErrorMsgMap[idx].mCode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -739,11 +740,10 @@ DOMException::Sanitize(JSContext* aCx,
|
||||
// Now it's possible that the stack on retval still starts with
|
||||
// stuff aCx is not supposed to touch; it depends on what's on the
|
||||
// stack right this second. Walk past all of that.
|
||||
while (retval->mLocation && !retval->mLocation->CallerSubsumes(aCx)) {
|
||||
nsCOMPtr<nsIStackFrame> caller;
|
||||
retval->mLocation->GetCaller(getter_AddRefs(caller));
|
||||
retval->mLocation.swap(caller);
|
||||
}
|
||||
nsCOMPtr<nsIStackFrame> stack;
|
||||
nsresult rv = retval->mLocation->GetSanitized(aCx, getter_AddRefs(stack));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
retval->mLocation.swap(stack);
|
||||
}
|
||||
|
||||
return ToJSValue(aCx, retval, aSanitizedValue);
|
||||
|
@ -2609,6 +2609,10 @@ Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem,
|
||||
}
|
||||
|
||||
if (!Preferences::GetBool("media.eme.enabled", false)) {
|
||||
// EME disabled by user, send notification to chrome so UI can
|
||||
// inform user.
|
||||
MediaKeySystemAccess::NotifyObservers(aKeySystem,
|
||||
MediaKeySystemStatus::Api_disabled);
|
||||
p->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return p.forget();
|
||||
}
|
||||
@ -2619,7 +2623,14 @@ Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem,
|
||||
return p.forget();
|
||||
}
|
||||
|
||||
if (!MediaKeySystemAccess::IsKeySystemSupported(aKeySystem)) {
|
||||
MediaKeySystemStatus status = MediaKeySystemAccess::GetKeySystemStatus(aKeySystem);
|
||||
if (status != MediaKeySystemStatus::Available) {
|
||||
if (status != MediaKeySystemStatus::Error) {
|
||||
// Failed due to user disabling something, send a notification to
|
||||
// chrome, so we can show some UI to explain how the user can rectify
|
||||
// the situation.
|
||||
MediaKeySystemAccess::NotifyObservers(aKeySystem, status);
|
||||
}
|
||||
p->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return p.forget();
|
||||
}
|
||||
|
@ -2930,9 +2930,22 @@ nsContentUtils::IsInPrivateBrowsing(nsIDocument* aDoc)
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
bool
|
||||
nsContentUtils::DocumentInactiveForImageLoads(nsIDocument* aDocument)
|
||||
{
|
||||
if (aDocument && !IsChromeDoc(aDocument) && !aDocument->IsResourceDoc()) {
|
||||
nsCOMPtr<nsPIDOMWindow> win =
|
||||
do_QueryInterface(aDocument->GetScopeObject());
|
||||
return !win || !win->GetDocShell();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
imgLoader*
|
||||
nsContentUtils::GetImgLoaderForDocument(nsIDocument* aDoc)
|
||||
{
|
||||
NS_ENSURE_TRUE(!DocumentInactiveForImageLoads(aDoc), nullptr);
|
||||
|
||||
if (!aDoc) {
|
||||
return imgLoader::Singleton();
|
||||
}
|
||||
@ -2942,8 +2955,11 @@ nsContentUtils::GetImgLoaderForDocument(nsIDocument* aDoc)
|
||||
|
||||
// static
|
||||
imgLoader*
|
||||
nsContentUtils::GetImgLoaderForChannel(nsIChannel* aChannel)
|
||||
nsContentUtils::GetImgLoaderForChannel(nsIChannel* aChannel,
|
||||
nsIDocument* aContext)
|
||||
{
|
||||
NS_ENSURE_TRUE(!DocumentInactiveForImageLoads(aContext), nullptr);
|
||||
|
||||
if (!aChannel)
|
||||
return imgLoader::Singleton();
|
||||
nsCOMPtr<nsILoadContext> context;
|
||||
@ -2983,7 +2999,7 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
|
||||
imgLoader* imgLoader = GetImgLoaderForDocument(aLoadingDocument);
|
||||
if (!imgLoader) {
|
||||
// nothing we can do here
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = aLoadingDocument->GetDocumentLoadGroup();
|
||||
|
@ -613,6 +613,11 @@ public:
|
||||
int16_t* aImageBlockingStatus = nullptr,
|
||||
uint32_t aContentPolicyType = nsIContentPolicy::TYPE_IMAGE);
|
||||
|
||||
/**
|
||||
* Returns true if objects in aDocument shouldn't initiate image loads.
|
||||
*/
|
||||
static bool DocumentInactiveForImageLoads(nsIDocument* aDocument);
|
||||
|
||||
/**
|
||||
* Method to start an image load. This does not do any security checks.
|
||||
* This method will attempt to make aURI immutable; a caller that wants to
|
||||
@ -646,7 +651,8 @@ public:
|
||||
* Null document/channel arguments return the public image loader.
|
||||
*/
|
||||
static imgLoader* GetImgLoaderForDocument(nsIDocument* aDoc);
|
||||
static imgLoader* GetImgLoaderForChannel(nsIChannel* aChannel);
|
||||
static imgLoader* GetImgLoaderForChannel(nsIChannel* aChannel,
|
||||
nsIDocument* aContext);
|
||||
|
||||
/**
|
||||
* Returns whether the given URI is in the image cache.
|
||||
|
@ -894,31 +894,6 @@ nsDOMClassInfo::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMClassInfo::Create(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *obj)
|
||||
{
|
||||
NS_WARNING("nsDOMClassInfo::Create Don't call me!");
|
||||
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMClassInfo::PostCreate(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *obj)
|
||||
{
|
||||
NS_WARNING("nsDOMClassInfo::PostCreate Don't call me!");
|
||||
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMClassInfo::PostTransplant(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *obj)
|
||||
{
|
||||
MOZ_CRASH("nsDOMClassInfo::PostTransplant Don't call me!");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMClassInfo::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, jsval *vp,
|
||||
@ -929,15 +904,6 @@ nsDOMClassInfo::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMClassInfo::DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, bool *_retval)
|
||||
{
|
||||
NS_WARNING("nsDOMClassInfo::DelProperty Don't call me!");
|
||||
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMClassInfo::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, jsval *vp,
|
||||
@ -1011,16 +977,6 @@ nsDOMClassInfo::Resolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMClassInfo::Convert(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, uint32_t type, jsval *vp,
|
||||
bool *_retval)
|
||||
{
|
||||
NS_WARNING("nsDOMClassInfo::Convert Don't call me!");
|
||||
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMClassInfo::Finalize(nsIXPConnectWrappedNative *wrapper, JSFreeOp *fop,
|
||||
JSObject *obj)
|
||||
@ -2035,7 +1991,8 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
|
||||
if (aWin->GetDoc()) {
|
||||
aWin->GetDoc()->WarnOnceAbout(nsIDocument::eWindow_Controllers);
|
||||
}
|
||||
JS::Rooted<JSObject*> shim(cx, JS_NewObject(cx, &ControllersShimClass, obj));
|
||||
MOZ_ASSERT(JS_IsGlobalObject(obj));
|
||||
JS::Rooted<JSObject*> shim(cx, JS_NewObject(cx, &ControllersShimClass));
|
||||
if (NS_WARN_IF(!shim)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1322,7 +1322,7 @@ nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX,
|
||||
if (!widget)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return widget->SynthesizeNativeMouseEvent(nsIntPoint(aScreenX, aScreenY),
|
||||
return widget->SynthesizeNativeMouseEvent(LayoutDeviceIntPoint(aScreenX, aScreenY),
|
||||
aNativeMessage, aModifierFlags);
|
||||
}
|
||||
|
||||
@ -1345,8 +1345,8 @@ nsDOMWindowUtils::SendNativeMouseScrollEvent(int32_t aScreenX,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return widget->SynthesizeNativeMouseScrollEvent(nsIntPoint(aScreenX,
|
||||
aScreenY),
|
||||
return widget->SynthesizeNativeMouseScrollEvent(LayoutDeviceIntPoint(aScreenX,
|
||||
aScreenY),
|
||||
aNativeMessage,
|
||||
aDeltaX, aDeltaY, aDeltaZ,
|
||||
aModifierFlags,
|
||||
|
@ -708,6 +708,7 @@ GK_ATOM(onconfigurationchange, "onconfigurationchange")
|
||||
GK_ATOM(onconnect, "onconnect")
|
||||
GK_ATOM(onconnected, "onconnected")
|
||||
GK_ATOM(onconnecting, "onconnecting")
|
||||
GK_ATOM(onconnectionstatechanged, "onconnectionstatechanged")
|
||||
GK_ATOM(oncontextmenu, "oncontextmenu")
|
||||
GK_ATOM(oncopy, "oncopy")
|
||||
GK_ATOM(oncurrentchannelchanged, "oncurrentchannelchanged")
|
||||
|
@ -95,7 +95,7 @@ nsImageLoadingContent::nsImageLoadingContent()
|
||||
mFrameCreateCalled(false),
|
||||
mVisibleCount(0)
|
||||
{
|
||||
if (!nsContentUtils::GetImgLoaderForChannel(nullptr)) {
|
||||
if (!nsContentUtils::GetImgLoaderForChannel(nullptr, nullptr)) {
|
||||
mLoadingEnabled = false;
|
||||
}
|
||||
}
|
||||
@ -347,7 +347,7 @@ nsImageLoadingContent::GetLoadingEnabled(bool *aLoadingEnabled)
|
||||
NS_IMETHODIMP
|
||||
nsImageLoadingContent::SetLoadingEnabled(bool aLoadingEnabled)
|
||||
{
|
||||
if (nsContentUtils::GetImgLoaderForChannel(nullptr)) {
|
||||
if (nsContentUtils::GetImgLoaderForChannel(nullptr, nullptr)) {
|
||||
mLoadingEnabled = aLoadingEnabled;
|
||||
}
|
||||
return NS_OK;
|
||||
@ -629,7 +629,9 @@ already_AddRefed<nsIStreamListener>
|
||||
nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!nsContentUtils::GetImgLoaderForChannel(aChannel)) {
|
||||
imgLoader* loader =
|
||||
nsContentUtils::GetImgLoaderForChannel(aChannel, GetOurOwnerDoc());
|
||||
if (!loader) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return nullptr;
|
||||
}
|
||||
@ -650,7 +652,7 @@ nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
|
||||
// Do the load.
|
||||
nsCOMPtr<nsIStreamListener> listener;
|
||||
nsRefPtr<imgRequestProxy>& req = PrepareNextRequest(eImageLoadType_Normal);
|
||||
nsresult rv = nsContentUtils::GetImgLoaderForChannel(aChannel)->
|
||||
nsresult rv = loader->
|
||||
LoadImageWithChannel(aChannel, this, doc,
|
||||
getter_AddRefs(listener),
|
||||
getter_AddRefs(req));
|
||||
@ -1190,6 +1192,11 @@ nsImageLoadingContent::StringToURI(const nsAString& aSpec,
|
||||
nsresult
|
||||
nsImageLoadingContent::FireEvent(const nsAString& aEventType)
|
||||
{
|
||||
if (nsContentUtils::DocumentInactiveForImageLoads(GetOurOwnerDoc())) {
|
||||
// Don't bother to fire any events, especially error events.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// We have to fire the event asynchronously so that we won't go into infinite
|
||||
// loops in cases when onLoad handlers reset the src and the new src is in
|
||||
// cache.
|
||||
|
@ -23,6 +23,7 @@
|
||||
#endif
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/dom/HTMLImageElement.h"
|
||||
#include "mozilla/dom/HTMLMediaElement.h"
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
@ -466,17 +467,9 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
|
||||
if (aReparentScope) {
|
||||
JS::Rooted<JSObject*> wrapper(cx);
|
||||
if ((wrapper = aNode->GetWrapper())) {
|
||||
if (IsDOMObject(wrapper)) {
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
rv = ReparentWrapper(cx, wrapper);
|
||||
} else {
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
if (xpc) {
|
||||
rv = xpc->ReparentWrappedNativeIfFound(cx, wrapper, aReparentScope, aNode);
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
MOZ_ASSERT(IsDOMObject(wrapper));
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
rv = ReparentWrapper(cx, wrapper);
|
||||
if (NS_FAILED(rv)) {
|
||||
aNode->mNodeInfo.swap(nodeInfo);
|
||||
|
||||
|
@ -774,4 +774,6 @@ skip-if = true # bug 1107443 - code for newly-added test was disabled
|
||||
[test_root_iframe.html]
|
||||
[test_performance_user_timing.html]
|
||||
[test_bug1126851.html]
|
||||
skip-if = buildapp == 'mulet' || buildapp == 'b2g'
|
||||
[test_bug1118689.html]
|
||||
skip-if = buildapp == 'mulet' || buildapp == 'b2g'
|
57
dom/base/test/test_bug1118689.html
Normal file
57
dom/base/test/test_bug1118689.html
Normal file
@ -0,0 +1,57 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1118689
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1118689</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 1118689 **/
|
||||
SimpleTest.requestFlakyTimeout("Just need some random timeout.");
|
||||
|
||||
function test1() {
|
||||
// test 1, check that error handling in data documents is still the same
|
||||
// as it has been for ages.
|
||||
var d = document.implementation.createHTMLDocument();
|
||||
d.body.innerHTML = "<img onerror='ok(false, \"EventHandler shouldn't be called in data document\")'>";
|
||||
d.body.firstChild.addEventListener("error",
|
||||
function() {
|
||||
ok(true, "EventListener should be called in data document");
|
||||
test2();
|
||||
});
|
||||
d.body.firstChild.addEventListener("load",
|
||||
function() {
|
||||
ok(false, "Images in data document shouldn't be loaded");
|
||||
});
|
||||
d.body.firstChild.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP";
|
||||
}
|
||||
|
||||
function test2() {
|
||||
// test 2, check that load event doesn't keep up being dispatched if
|
||||
// window has been closed.
|
||||
var win = window.open('data:text/html,<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP" onload="this.src = this.src">',
|
||||
"", "height=100,width=100");
|
||||
setTimeout(function() {
|
||||
win.close();
|
||||
SimpleTest.finish();
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="test1();">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1118689">Mozilla Bug 1118689</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -152,6 +152,10 @@ DOMInterfaces = {
|
||||
'nativeType': 'mozilla::dom::bluetooth::BluetoothDiscoveryHandle',
|
||||
},
|
||||
|
||||
'BluetoothGatt': {
|
||||
'nativeType': 'mozilla::dom::bluetooth::BluetoothGatt',
|
||||
},
|
||||
|
||||
'BluetoothManager': {
|
||||
'nativeType': 'mozilla::dom::bluetooth::BluetoothManager',
|
||||
},
|
||||
|
@ -394,6 +394,7 @@ class CGDOMJSClass(CGThing):
|
||||
{
|
||||
nullptr, /* lookupProperty */
|
||||
nullptr, /* defineProperty */
|
||||
nullptr, /* hasProperty */
|
||||
nullptr, /* getProperty */
|
||||
nullptr, /* setProperty */
|
||||
nullptr, /* getOwnPropertyDescriptor */
|
||||
@ -2095,8 +2096,8 @@ def methodLength(method):
|
||||
|
||||
def isMaybeExposedIn(member, descriptor):
|
||||
# All we can say for sure is that if this is a worker descriptor
|
||||
# and member is only exposed in windows, then it's not exposed.
|
||||
return not descriptor.workers or member.exposureSet != set(["Window"])
|
||||
# and member is not exposed in any worker, then it's not exposed.
|
||||
return not descriptor.workers or member.isExposedInAnyWorker()
|
||||
|
||||
def clearableCachedAttrs(descriptor):
|
||||
return (m for m in descriptor.interface.members if
|
||||
|
@ -112,9 +112,8 @@ DOMProxyHandler::EnsureExpandoObject(JSContext* cx, JS::Handle<JSObject*> obj)
|
||||
expandoAndGeneration = nullptr;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> parent(cx, js::GetObjectParent(obj));
|
||||
JS::Rooted<JSObject*> expando(cx,
|
||||
JS_NewObjectWithGivenProto(cx, nullptr, JS::NullPtr(), parent));
|
||||
JS_NewObjectWithGivenProto(cx, nullptr, JS::NullPtr()));
|
||||
if (!expando) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "mozilla/dom/Exceptions.h"
|
||||
|
||||
#include "js/GCAPI.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsprf.h"
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
@ -299,6 +300,8 @@ public:
|
||||
NS_IMETHOD GetCaller(nsIStackFrame** aCaller) MOZ_OVERRIDE;
|
||||
NS_IMETHOD GetFormattedStack(nsAString& aStack) MOZ_OVERRIDE;
|
||||
virtual bool CallerSubsumes(JSContext* aCx) MOZ_OVERRIDE;
|
||||
NS_IMETHOD GetSanitized(JSContext* aCx,
|
||||
nsIStackFrame** aSanitized) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual bool IsJSFrame() const MOZ_OVERRIDE {
|
||||
@ -390,15 +393,22 @@ NS_IMETHODIMP JSStackFrame::GetFilename(nsAString& aFilename)
|
||||
JS::Rooted<JSObject*> stack(cx, mStack);
|
||||
JS::ExposeObjectToActiveJS(mStack);
|
||||
JSAutoCompartment ac(cx, stack);
|
||||
|
||||
JS::Rooted<JS::Value> filenameVal(cx);
|
||||
if (!JS_GetProperty(cx, stack, "source", &filenameVal) ||
|
||||
!filenameVal.isString()) {
|
||||
if (!JS_GetProperty(cx, stack, "source", &filenameVal)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (filenameVal.isNull()) {
|
||||
filenameVal = JS_GetEmptyStringValue(cx);
|
||||
}
|
||||
MOZ_ASSERT(filenameVal.isString());
|
||||
|
||||
nsAutoJSString str;
|
||||
if (!str.init(cx, filenameVal.toString())) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mFilename = str;
|
||||
mFilenameInitialized = true;
|
||||
}
|
||||
@ -471,11 +481,15 @@ JSStackFrame::GetLineno(int32_t* aLineNo)
|
||||
JS::ExposeObjectToActiveJS(mStack);
|
||||
JSAutoCompartment ac(cx, stack);
|
||||
JS::Rooted<JS::Value> lineVal(cx);
|
||||
if (!JS_GetProperty(cx, stack, "line", &lineVal) ||
|
||||
!lineVal.isNumber()) {
|
||||
if (!JS_GetProperty(cx, stack, "line", &lineVal)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
mLineno = lineVal.toNumber();
|
||||
if (lineVal.isNumber()) {
|
||||
mLineno = lineVal.toNumber();
|
||||
} else {
|
||||
MOZ_ASSERT(lineVal.isNull());
|
||||
mLineno = 0;
|
||||
}
|
||||
mLinenoInitialized = true;
|
||||
}
|
||||
|
||||
@ -500,11 +514,15 @@ JSStackFrame::GetColNo(int32_t* aColNo)
|
||||
JS::ExposeObjectToActiveJS(mStack);
|
||||
JSAutoCompartment ac(cx, stack);
|
||||
JS::Rooted<JS::Value> colVal(cx);
|
||||
if (!JS_GetProperty(cx, stack, "column", &colVal) ||
|
||||
!colVal.isNumber()) {
|
||||
if (!JS_GetProperty(cx, stack, "column", &colVal)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
mColNo = colVal.toNumber();
|
||||
if (colVal.isNumber()) {
|
||||
mColNo = colVal.toNumber();
|
||||
} else {
|
||||
MOZ_ASSERT(colVal.isNull());
|
||||
mColNo = 0;
|
||||
}
|
||||
mColNoInitialized = true;
|
||||
}
|
||||
|
||||
@ -524,6 +542,35 @@ NS_IMETHODIMP StackFrame::GetSourceLine(nsACString& aSourceLine)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] readonly attribute nsIStackFrame sanitized */
|
||||
NS_IMETHODIMP StackFrame::GetSanitized(JSContext*, nsIStackFrame** aSanitized)
|
||||
{
|
||||
NS_ADDREF(*aSanitized = this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] readonly attribute nsIStackFrame sanitized */
|
||||
NS_IMETHODIMP JSStackFrame::GetSanitized(JSContext* aCx, nsIStackFrame** aSanitized)
|
||||
{
|
||||
// NB: Do _not_ enter the compartment of the SavedFrame object here, because
|
||||
// we are checking against the caller's compartment's principals in
|
||||
// GetFirstSubsumedSavedFrame.
|
||||
|
||||
JS::RootedObject savedFrame(aCx, mStack);
|
||||
JS::ExposeObjectToActiveJS(mStack);
|
||||
|
||||
savedFrame = js::GetFirstSubsumedSavedFrame(aCx, savedFrame);
|
||||
nsCOMPtr<nsIStackFrame> stackFrame;
|
||||
if (savedFrame) {
|
||||
stackFrame = new JSStackFrame(savedFrame);
|
||||
} else {
|
||||
stackFrame = new StackFrame();
|
||||
}
|
||||
|
||||
stackFrame.forget(aSanitized);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIStackFrame caller; */
|
||||
NS_IMETHODIMP JSStackFrame::GetCaller(nsIStackFrame** aCaller)
|
||||
{
|
||||
|
@ -456,8 +456,12 @@ class IDLExposureMixins():
|
||||
self._exposureGlobalNames = set()
|
||||
self.exposureSet = set()
|
||||
self._location = location
|
||||
self._globalScope = None
|
||||
|
||||
def finish(self, scope):
|
||||
assert scope.parentScope is None
|
||||
self._globalScope = scope
|
||||
|
||||
# Verify that our [Exposed] value, if any, makes sense.
|
||||
for globalName in self._exposureGlobalNames:
|
||||
if globalName not in scope.globalNames:
|
||||
@ -492,8 +496,8 @@ class IDLExposureMixins():
|
||||
return len(workerScopes.difference(self.exposureSet)) > 0
|
||||
|
||||
def getWorkerExposureSet(self):
|
||||
# Subclasses that might be exposed in workers should override as needed
|
||||
return set()
|
||||
workerScopes = self._globalScope.globalNameMapping["Worker"]
|
||||
return workerScopes.intersection(self.exposureSet)
|
||||
|
||||
|
||||
class IDLExternalInterface(IDLObjectWithIdentifier, IDLExposureMixins):
|
||||
@ -801,9 +805,13 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
|
||||
|
||||
ctor = self.ctor()
|
||||
if ctor is not None:
|
||||
assert len(ctor._exposureGlobalNames) == 0
|
||||
ctor._exposureGlobalNames.update(self._exposureGlobalNames)
|
||||
ctor.finish(scope)
|
||||
|
||||
for ctor in self.namedConstructors:
|
||||
assert len(ctor._exposureGlobalNames) == 0
|
||||
ctor._exposureGlobalNames.update(self._exposureGlobalNames)
|
||||
ctor.finish(scope)
|
||||
|
||||
# Make a copy of our member list, so things that implement us
|
||||
@ -1110,10 +1118,6 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
|
||||
len(set(m.identifier.name for m in self.members if
|
||||
m.isMethod() and not m.isStatic())) == 1)
|
||||
|
||||
def getWorkerExposureSet(self):
|
||||
workerScopes = self.parentScope.globalNameMapping["Worker"]
|
||||
return workerScopes.intersection(self.exposureSet)
|
||||
|
||||
def inheritanceDepth(self):
|
||||
depth = 0
|
||||
parent = self.parent
|
||||
@ -3056,7 +3060,7 @@ class IDLUndefinedValue(IDLObject):
|
||||
def _getDependentObjects(self):
|
||||
return set()
|
||||
|
||||
class IDLInterfaceMember(IDLObjectWithIdentifier):
|
||||
class IDLInterfaceMember(IDLObjectWithIdentifier, IDLExposureMixins):
|
||||
|
||||
Tags = enum(
|
||||
'Const',
|
||||
@ -3074,13 +3078,9 @@ class IDLInterfaceMember(IDLObjectWithIdentifier):
|
||||
|
||||
def __init__(self, location, identifier, tag):
|
||||
IDLObjectWithIdentifier.__init__(self, location, None, identifier)
|
||||
IDLExposureMixins.__init__(self, location)
|
||||
self.tag = tag
|
||||
self._extendedAttrDict = {}
|
||||
# _exposureGlobalNames are the global names listed in our [Exposed]
|
||||
# extended attribute. exposureSet is the exposure set as defined in the
|
||||
# Web IDL spec: it contains interface names.
|
||||
self._exposureGlobalNames = set()
|
||||
self.exposureSet = set()
|
||||
|
||||
def isMethod(self):
|
||||
return self.tag == IDLInterfaceMember.Tags.Method
|
||||
@ -3104,26 +3104,24 @@ class IDLInterfaceMember(IDLObjectWithIdentifier):
|
||||
return self._extendedAttrDict.get(name, None)
|
||||
|
||||
def finish(self, scope):
|
||||
for globalName in self._exposureGlobalNames:
|
||||
if globalName not in scope.globalNames:
|
||||
raise WebIDLError("Unknown [Exposed] value %s" % globalName,
|
||||
[self.location])
|
||||
globalNameSetToExposureSet(scope, self._exposureGlobalNames,
|
||||
self.exposureSet)
|
||||
self._scope = scope
|
||||
# We better be exposed _somewhere_.
|
||||
if (len(self._exposureGlobalNames) == 0):
|
||||
print self.identifier.name
|
||||
assert len(self._exposureGlobalNames) != 0
|
||||
IDLExposureMixins.finish(self, scope)
|
||||
|
||||
def validate(self):
|
||||
if (self.getExtendedAttribute("Pref") and
|
||||
self.exposureSet != set([self._scope.primaryGlobalName])):
|
||||
self.exposureSet != set([self._globalScope.primaryGlobalName])):
|
||||
raise WebIDLError("[Pref] used on an interface member that is not "
|
||||
"%s-only" % self._scope.primaryGlobalName,
|
||||
"%s-only" % self._globalScope.primaryGlobalName,
|
||||
[self.location])
|
||||
|
||||
if (self.getExtendedAttribute("CheckPermissions") and
|
||||
self.exposureSet != set([self._scope.primaryGlobalName])):
|
||||
self.exposureSet != set([self._globalScope.primaryGlobalName])):
|
||||
raise WebIDLError("[CheckPermissions] used on an interface member "
|
||||
"that is not %s-only" %
|
||||
self._scope.primaryGlobalName,
|
||||
self._globalScope.primaryGlobalName,
|
||||
[self.location])
|
||||
|
||||
if self.isAttr() or self.isMethod():
|
||||
|
@ -196,6 +196,12 @@ extern bool gBluetoothDebugFlag;
|
||||
*/
|
||||
#define REQUEST_MEDIA_PLAYSTATUS_ID "requestmediaplaystatus"
|
||||
|
||||
/**
|
||||
* When a remote BLE device gets connected / disconnected, we'll dispatch an
|
||||
* event
|
||||
*/
|
||||
#define GATT_CONNECTION_STATE_CHANGED_ID "connectionstatechanged"
|
||||
|
||||
// Bluetooth address format: xx:xx:xx:xx:xx:xx (or xx_xx_xx_xx_xx_xx)
|
||||
#define BLUETOOTH_ADDRESS_LENGTH 17
|
||||
#define BLUETOOTH_ADDRESS_NONE "00:00:00:00:00:00"
|
||||
|
@ -4,15 +4,16 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "BluetoothClassOfDevice.h"
|
||||
#include "BluetoothDevice.h"
|
||||
#include "BluetoothReplyRunnable.h"
|
||||
#include "BluetoothService.h"
|
||||
#include "BluetoothUtils.h"
|
||||
|
||||
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
|
||||
#include "mozilla/dom/BluetoothAttributeEvent.h"
|
||||
#include "mozilla/dom/BluetoothDevice2Binding.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothClassOfDevice.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothDevice.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothGatt.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
||||
using namespace mozilla;
|
||||
@ -20,7 +21,10 @@ using namespace mozilla::dom;
|
||||
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(BluetoothDevice, DOMEventTargetHelper, mCod)
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(BluetoothDevice,
|
||||
DOMEventTargetHelper,
|
||||
mCod,
|
||||
mGatt)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothDevice)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
@ -302,6 +306,19 @@ BluetoothDevice::DispatchAttributeEvent(const nsTArray<nsString>& aTypes)
|
||||
DispatchTrustedEvent(event);
|
||||
}
|
||||
|
||||
BluetoothGatt*
|
||||
BluetoothDevice::GetGatt()
|
||||
{
|
||||
NS_ENSURE_TRUE(mType == BluetoothDeviceType::Le ||
|
||||
mType == BluetoothDeviceType::Dual,
|
||||
nullptr);
|
||||
if (!mGatt) {
|
||||
mGatt = new BluetoothGatt(GetOwner(), mAddress);
|
||||
}
|
||||
|
||||
return mGatt;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
BluetoothDevice::WrapObject(JSContext* aContext)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/BluetoothDevice2Binding.h"
|
||||
#include "BluetoothCommon.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothCommon.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
@ -23,6 +23,7 @@ namespace dom {
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
class BluetoothClassOfDevice;
|
||||
class BluetoothGatt;
|
||||
class BluetoothNamedValue;
|
||||
class BluetoothValue;
|
||||
class BluetoothSignal;
|
||||
@ -69,6 +70,8 @@ public:
|
||||
return mType;
|
||||
}
|
||||
|
||||
BluetoothGatt* GetGatt();
|
||||
|
||||
/****************************************************************************
|
||||
* Event Handlers
|
||||
***************************************************************************/
|
||||
@ -173,6 +176,11 @@ private:
|
||||
* Type of this device. Can be unknown/classic/le/dual.
|
||||
*/
|
||||
BluetoothDeviceType mType;
|
||||
|
||||
/**
|
||||
* GATT client object to interact with the remote device.
|
||||
*/
|
||||
nsRefPtr<BluetoothGatt> mGatt;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
217
dom/bluetooth2/BluetoothGatt.cpp
Normal file
217
dom/bluetooth2/BluetoothGatt.cpp
Normal file
@ -0,0 +1,217 @@
|
||||
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#include "BluetoothReplyRunnable.h"
|
||||
#include "BluetoothService.h"
|
||||
#include "BluetoothUtils.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothGatt.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
|
||||
#include "mozilla/dom/BluetoothGattBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "nsIUUIDGenerator.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(BluetoothGatt)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BluetoothGatt,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BluetoothGatt,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothGatt)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(BluetoothGatt, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(BluetoothGatt, DOMEventTargetHelper)
|
||||
|
||||
BluetoothGatt::BluetoothGatt(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aDeviceAddr)
|
||||
: DOMEventTargetHelper(aWindow)
|
||||
, mAppUuid(EmptyString())
|
||||
, mClientIf(0)
|
||||
, mConnectionState(BluetoothConnectionState::Disconnected)
|
||||
, mDeviceAddr(aDeviceAddr)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(!mDeviceAddr.IsEmpty());
|
||||
}
|
||||
|
||||
BluetoothGatt::~BluetoothGatt()
|
||||
{
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
// bs can be null on shutdown, where destruction might happen.
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
if (mClientIf > 0) {
|
||||
nsRefPtr<BluetoothVoidReplyRunnable> result =
|
||||
new BluetoothVoidReplyRunnable(nullptr);
|
||||
bs->UnregisterGattClientInternal(mClientIf, result);
|
||||
}
|
||||
|
||||
bs->UnregisterBluetoothSignalHandler(mAppUuid, this);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGatt::GenerateUuid(nsAString &aUuidString)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIUUIDGenerator> uuidGenerator =
|
||||
do_GetService("@mozilla.org/uuid-generator;1", &rv);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
nsID uuid;
|
||||
rv = uuidGenerator->GenerateUUIDInPlace(&uuid);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
// Build a string in {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} format
|
||||
char uuidBuffer[NSID_LENGTH];
|
||||
uuid.ToProvidedString(uuidBuffer);
|
||||
NS_ConvertASCIItoUTF16 uuidString(uuidBuffer);
|
||||
|
||||
// Remove {} and the null terminator
|
||||
aUuidString.Assign(Substring(uuidString, 1, NSID_LENGTH - 3));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGatt::DisconnectFromOwner()
|
||||
{
|
||||
DOMEventTargetHelper::DisconnectFromOwner();
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
if (mClientIf > 0) {
|
||||
nsRefPtr<BluetoothVoidReplyRunnable> result =
|
||||
new BluetoothVoidReplyRunnable(nullptr);
|
||||
bs->UnregisterGattClientInternal(mClientIf, result);
|
||||
}
|
||||
|
||||
bs->UnregisterBluetoothSignalHandler(mAppUuid, this);
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
BluetoothGatt::Connect(ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
|
||||
if (!global) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
mConnectionState == BluetoothConnectionState::Disconnected,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
if (mAppUuid.IsEmpty()) {
|
||||
GenerateUuid(mAppUuid);
|
||||
BT_ENSURE_TRUE_REJECT(!mAppUuid.IsEmpty(),
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
bs->RegisterBluetoothSignalHandler(mAppUuid, this);
|
||||
}
|
||||
|
||||
UpdateConnectionState(BluetoothConnectionState::Connecting);
|
||||
nsRefPtr<BluetoothReplyRunnable> result =
|
||||
new BluetoothVoidReplyRunnable(nullptr /* DOMRequest */,
|
||||
promise,
|
||||
NS_LITERAL_STRING("ConnectGattClient"));
|
||||
bs->ConnectGattClientInternal(mAppUuid,
|
||||
mDeviceAddr,
|
||||
result);
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
BluetoothGatt::Disconnect(ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
|
||||
if (!global) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
mConnectionState == BluetoothConnectionState::Connected,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
UpdateConnectionState(BluetoothConnectionState::Disconnecting);
|
||||
nsRefPtr<BluetoothReplyRunnable> result =
|
||||
new BluetoothVoidReplyRunnable(nullptr /* DOMRequest */,
|
||||
promise,
|
||||
NS_LITERAL_STRING("DisconnectGattClient"));
|
||||
bs->DisconnectGattClientInternal(mAppUuid, mDeviceAddr, result);
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGatt::UpdateConnectionState(BluetoothConnectionState aState)
|
||||
{
|
||||
BT_API2_LOGR("GATT connection state changes to: %d", int(aState));
|
||||
mConnectionState = aState;
|
||||
|
||||
// Dispatch connectionstatechanged event to application
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
nsresult rv = NS_NewDOMEvent(getter_AddRefs(event), this, nullptr, nullptr);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
rv = event->InitEvent(NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
|
||||
false,
|
||||
false);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
DispatchTrustedEvent(event);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGatt::Notify(const BluetoothSignal& aData)
|
||||
{
|
||||
BT_LOGD("[D] %s", NS_ConvertUTF16toUTF8(aData.name()).get());
|
||||
|
||||
BluetoothValue v = aData.value();
|
||||
if (aData.name().EqualsLiteral("ClientRegistered")) {
|
||||
MOZ_ASSERT(v.type() == BluetoothValue::Tuint32_t);
|
||||
mClientIf = v.get_uint32_t();
|
||||
} else if (aData.name().EqualsLiteral("ClientUnregistered")) {
|
||||
mClientIf = 0;
|
||||
} else if (aData.name().EqualsLiteral(GATT_CONNECTION_STATE_CHANGED_ID)) {
|
||||
MOZ_ASSERT(v.type() == BluetoothValue::Tbool);
|
||||
|
||||
BluetoothConnectionState state =
|
||||
v.get_bool() ? BluetoothConnectionState::Connected
|
||||
: BluetoothConnectionState::Disconnected;
|
||||
UpdateConnectionState(state);
|
||||
} else {
|
||||
BT_WARNING("Not handling GATT signal: %s",
|
||||
NS_ConvertUTF16toUTF8(aData.name()).get());
|
||||
}
|
||||
}
|
||||
|
||||
JSObject*
|
||||
BluetoothGatt::WrapObject(JSContext* aContext)
|
||||
{
|
||||
return BluetoothGattBinding::Wrap(aContext, this);
|
||||
}
|
116
dom/bluetooth2/BluetoothGatt.h
Normal file
116
dom/bluetooth2/BluetoothGatt.h
Normal file
@ -0,0 +1,116 @@
|
||||
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_bluetooth_bluetoothgatt_h__
|
||||
#define mozilla_dom_bluetooth_bluetoothgatt_h__
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/BluetoothGattBinding.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothCommon.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class Promise;
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
class BluetoothReplyRunnable;
|
||||
class BluetoothService;
|
||||
class BluetoothSignal;
|
||||
class BluetoothValue;
|
||||
|
||||
class BluetoothGatt MOZ_FINAL : public DOMEventTargetHelper
|
||||
, public BluetoothSignalObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BluetoothGatt, DOMEventTargetHelper)
|
||||
|
||||
/****************************************************************************
|
||||
* Attribute Getters
|
||||
***************************************************************************/
|
||||
BluetoothConnectionState ConnectionState() const
|
||||
{
|
||||
return mConnectionState;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Event Handlers
|
||||
***************************************************************************/
|
||||
IMPL_EVENT_HANDLER(connectionstatechanged);
|
||||
|
||||
/****************************************************************************
|
||||
* Methods (Web API Implementation)
|
||||
***************************************************************************/
|
||||
already_AddRefed<Promise> Connect(ErrorResult& aRv);
|
||||
already_AddRefed<Promise> Disconnect(ErrorResult& aRv);
|
||||
|
||||
/****************************************************************************
|
||||
* Others
|
||||
***************************************************************************/
|
||||
void Notify(const BluetoothSignal& aParam); // BluetoothSignalObserver
|
||||
|
||||
nsPIDOMWindow* GetParentObject() const
|
||||
{
|
||||
return GetOwner();
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
virtual void DisconnectFromOwner() MOZ_OVERRIDE;
|
||||
|
||||
BluetoothGatt(nsPIDOMWindow* aOwner,
|
||||
const nsAString& aDeviceAddr);
|
||||
|
||||
private:
|
||||
~BluetoothGatt();
|
||||
|
||||
/**
|
||||
* Update mConnectionState to aState and fire
|
||||
* connectionstatechanged event to the application.
|
||||
*
|
||||
* @param aState [in] New connection state
|
||||
*/
|
||||
void UpdateConnectionState(BluetoothConnectionState aState);
|
||||
|
||||
/**
|
||||
* Generate a random uuid.
|
||||
*
|
||||
* @param aUuidString [out] String to store the generated uuid.
|
||||
*/
|
||||
void GenerateUuid(nsAString &aUuidString);
|
||||
|
||||
/****************************************************************************
|
||||
* Variables
|
||||
***************************************************************************/
|
||||
/**
|
||||
* Random generated UUID of this GATT client.
|
||||
*/
|
||||
nsString mAppUuid;
|
||||
|
||||
/**
|
||||
* Id of the GATT client interface given by bluetooth stack.
|
||||
* 0 if the client is not registered yet, nonzero otherwise.
|
||||
*/
|
||||
int mClientIf;
|
||||
|
||||
/**
|
||||
* Connection state of this remote device.
|
||||
*/
|
||||
BluetoothConnectionState mConnectionState;
|
||||
|
||||
/**
|
||||
* Address of the remote device.
|
||||
*/
|
||||
nsString mDeviceAddr;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
||||
#endif
|
@ -307,6 +307,31 @@ public:
|
||||
SendInputMessage(const nsAString& aDeviceAddresses,
|
||||
const nsAString& aMessage) = 0;
|
||||
|
||||
/**
|
||||
* Connect to a remote GATT server. (platform specific implementation)
|
||||
*/
|
||||
virtual void
|
||||
ConnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Disconnect GATT client from a remote GATT server.
|
||||
* (platform specific implementation)
|
||||
*/
|
||||
virtual void
|
||||
DisconnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
* Unregister a GATT client. (platform specific implementation)
|
||||
*/
|
||||
virtual void
|
||||
UnregisterGattClientInternal(int aClientIf,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
|
||||
bool
|
||||
IsEnabled() const
|
||||
{
|
||||
|
@ -40,6 +40,30 @@ UuidToString(const BluetoothUuid& aUuid, nsAString& aString)
|
||||
aString.AssignLiteral(uuidStr);
|
||||
}
|
||||
|
||||
void
|
||||
StringToUuid(const char* aString, BluetoothUuid& aUuid)
|
||||
{
|
||||
uint32_t uuid0, uuid4;
|
||||
uint16_t uuid1, uuid2, uuid3, uuid5;
|
||||
|
||||
sscanf(aString, "%08x-%04hx-%04hx-%04hx-%08x%04hx",
|
||||
&uuid0, &uuid1, &uuid2, &uuid3, &uuid4, &uuid5);
|
||||
|
||||
uuid0 = htonl(uuid0);
|
||||
uuid1 = htons(uuid1);
|
||||
uuid2 = htons(uuid2);
|
||||
uuid3 = htons(uuid3);
|
||||
uuid4 = htonl(uuid4);
|
||||
uuid5 = htons(uuid5);
|
||||
|
||||
memcpy(&aUuid.mUuid[0], &uuid0, 4);
|
||||
memcpy(&aUuid.mUuid[4], &uuid1, 2);
|
||||
memcpy(&aUuid.mUuid[6], &uuid2, 2);
|
||||
memcpy(&aUuid.mUuid[8], &uuid3, 2);
|
||||
memcpy(&aUuid.mUuid[10], &uuid4, 4);
|
||||
memcpy(&aUuid.mUuid[14], &uuid5, 2);
|
||||
}
|
||||
|
||||
bool
|
||||
SetJsObject(JSContext* aContext,
|
||||
const BluetoothValue& aValue,
|
||||
|
@ -19,6 +19,14 @@ class BluetoothReplyRunnable;
|
||||
void
|
||||
UuidToString(const BluetoothUuid& aUuid, nsAString& aString);
|
||||
|
||||
/**
|
||||
* Convert xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx uuid string to BluetoothUuid object.
|
||||
* This utility function is used by gecko internal only to convert uuid string
|
||||
* created by gecko back to BluetoothUuid representation.
|
||||
*/
|
||||
void
|
||||
StringToUuid(const char* aString, BluetoothUuid& aUuid);
|
||||
|
||||
bool
|
||||
SetJsObject(JSContext* aContext,
|
||||
const BluetoothValue& aValue,
|
||||
|
@ -5,16 +5,28 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "BluetoothGattManager.h"
|
||||
#include "BluetoothCommon.h"
|
||||
#include "BluetoothUtils.h"
|
||||
#include "BluetoothInterface.h"
|
||||
|
||||
#include "BluetoothCommon.h"
|
||||
#include "BluetoothInterface.h"
|
||||
#include "BluetoothReplyRunnable.h"
|
||||
#include "BluetoothService.h"
|
||||
#include "BluetoothUtils.h"
|
||||
#include "MainThreadUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "MainThreadUtils.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
#define ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(runnable) \
|
||||
do { \
|
||||
if (!sBluetoothGattInterface) { \
|
||||
NS_NAMED_LITERAL_STRING(errorStr, \
|
||||
"BluetoothGattClientInterface is not ready"); \
|
||||
DispatchBluetoothReply(runnable, BluetoothValue(), errorStr); \
|
||||
return; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
using namespace mozilla;
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
|
||||
@ -26,9 +38,58 @@ namespace {
|
||||
|
||||
bool BluetoothGattManager::mInShutdown = false;
|
||||
|
||||
/*
|
||||
* Static functions
|
||||
*/
|
||||
class BluetoothGattClient;
|
||||
static StaticAutoPtr<nsTArray<nsRefPtr<BluetoothGattClient> > > sClients;
|
||||
|
||||
class BluetoothGattClient MOZ_FINAL : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
BluetoothGattClient(const nsAString& aAppUuid, const nsAString& aDeviceAddr)
|
||||
: mAppUuid(aAppUuid)
|
||||
, mDeviceAddr(aDeviceAddr)
|
||||
, mClientIf(0)
|
||||
, mConnId(0)
|
||||
{ }
|
||||
|
||||
~BluetoothGattClient()
|
||||
{
|
||||
mConnectRunnable = nullptr;
|
||||
mDisconnectRunnable = nullptr;
|
||||
mUnregisterClientRunnable = nullptr;
|
||||
}
|
||||
|
||||
nsString mAppUuid;
|
||||
nsString mDeviceAddr;
|
||||
int mClientIf;
|
||||
int mConnId;
|
||||
nsRefPtr<BluetoothReplyRunnable> mConnectRunnable;
|
||||
nsRefPtr<BluetoothReplyRunnable> mDisconnectRunnable;
|
||||
nsRefPtr<BluetoothReplyRunnable> mUnregisterClientRunnable;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS0(BluetoothGattClient)
|
||||
|
||||
class UuidComparator
|
||||
{
|
||||
public:
|
||||
bool Equals(const nsRefPtr<BluetoothGattClient>& aClient,
|
||||
const nsAString& aAppUuid) const
|
||||
{
|
||||
return aClient->mAppUuid.Equals(aAppUuid);
|
||||
}
|
||||
};
|
||||
|
||||
class ClientIfComparator
|
||||
{
|
||||
public:
|
||||
bool Equals(const nsRefPtr<BluetoothGattClient>& aClient,
|
||||
int aClientIf) const
|
||||
{
|
||||
return aClient->mClientIf == aClientIf;
|
||||
}
|
||||
};
|
||||
|
||||
BluetoothGattManager*
|
||||
BluetoothGattManager::Get()
|
||||
@ -103,6 +164,10 @@ BluetoothGattManager::InitGattInterface(BluetoothProfileResultHandler* aRes)
|
||||
sBluetoothGattInterface->GetBluetoothGattClientInterface();
|
||||
NS_ENSURE_TRUE_VOID(sBluetoothGattClientInterface);
|
||||
|
||||
if (!sClients) {
|
||||
sClients = new nsTArray<nsRefPtr<BluetoothGattClient> >;
|
||||
}
|
||||
|
||||
BluetoothGattManager* gattManager = BluetoothGattManager::Get();
|
||||
sBluetoothGattInterface->Init(gattManager,
|
||||
new InitGattResultHandler(aRes));
|
||||
@ -129,6 +194,8 @@ public:
|
||||
{
|
||||
sBluetoothGattClientInterface = nullptr;
|
||||
sBluetoothGattInterface = nullptr;
|
||||
sClients = nullptr;
|
||||
|
||||
if (mRes) {
|
||||
mRes->Deinit();
|
||||
}
|
||||
@ -176,6 +243,265 @@ BluetoothGattManager::DeinitGattInterface(BluetoothProfileResultHandler* aRes)
|
||||
}
|
||||
}
|
||||
|
||||
class BluetoothGattManager::RegisterClientResultHandler MOZ_FINAL
|
||||
: public BluetoothGattClientResultHandler
|
||||
{
|
||||
public:
|
||||
RegisterClientResultHandler(BluetoothGattClient* aClient)
|
||||
: mClient(aClient)
|
||||
{
|
||||
MOZ_ASSERT(mClient);
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
|
||||
{
|
||||
BT_WARNING("BluetoothGattClientInterface::RegisterClient failed: %d",
|
||||
(int)aStatus);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
// Notify BluetoothGatt for client disconnected
|
||||
BluetoothSignal signal(
|
||||
NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
|
||||
mClient->mAppUuid,
|
||||
BluetoothValue(false)); // Disconnected
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
// Reject the connect request
|
||||
if (mClient->mConnectRunnable) {
|
||||
NS_NAMED_LITERAL_STRING(errorStr, "Register GATT client failed");
|
||||
DispatchBluetoothReply(mClient->mConnectRunnable,
|
||||
BluetoothValue(),
|
||||
errorStr);
|
||||
mClient->mConnectRunnable = nullptr;
|
||||
}
|
||||
|
||||
sClients->RemoveElement(mClient);
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<BluetoothGattClient> mClient;
|
||||
};
|
||||
|
||||
class BluetoothGattManager::UnregisterClientResultHandler MOZ_FINAL
|
||||
: public BluetoothGattClientResultHandler
|
||||
{
|
||||
public:
|
||||
UnregisterClientResultHandler(BluetoothGattClient* aClient)
|
||||
: mClient(aClient)
|
||||
{
|
||||
MOZ_ASSERT(mClient);
|
||||
}
|
||||
|
||||
void UnregisterClient() MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(mClient->mUnregisterClientRunnable);
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
// Notify BluetoothGatt to clear the clientIf
|
||||
BluetoothSignal signal(
|
||||
NS_LITERAL_STRING("ClientUnregistered"),
|
||||
mClient->mAppUuid,
|
||||
BluetoothValue(true));
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
// Resolve the unregister request
|
||||
DispatchBluetoothReply(mClient->mUnregisterClientRunnable,
|
||||
BluetoothValue(true),
|
||||
EmptyString());
|
||||
mClient->mUnregisterClientRunnable = nullptr;
|
||||
|
||||
sClients->RemoveElement(mClient);
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
|
||||
{
|
||||
BT_WARNING("BluetoothGattClientInterface::UnregisterClient failed: %d",
|
||||
(int)aStatus);
|
||||
MOZ_ASSERT(mClient->mUnregisterClientRunnable);
|
||||
|
||||
// Reject the unregister request
|
||||
NS_NAMED_LITERAL_STRING(errorStr, "Unregister GATT client failed");
|
||||
DispatchBluetoothReply(mClient->mUnregisterClientRunnable,
|
||||
BluetoothValue(),
|
||||
errorStr);
|
||||
mClient->mUnregisterClientRunnable = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<BluetoothGattClient> mClient;
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothGattManager::UnregisterClient(int aClientIf,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aRunnable);
|
||||
|
||||
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
|
||||
|
||||
size_t index = sClients->IndexOf(aClientIf, 0 /* Start */,
|
||||
ClientIfComparator());
|
||||
|
||||
// Reject the unregister request if the client is not found
|
||||
if (index == sClients->NoIndex) {
|
||||
NS_NAMED_LITERAL_STRING(errorStr, "Unregister GATT client failed");
|
||||
DispatchBluetoothReply(aRunnable,
|
||||
BluetoothValue(),
|
||||
errorStr);
|
||||
return;
|
||||
}
|
||||
|
||||
nsRefPtr<BluetoothGattClient> client = sClients->ElementAt(index);
|
||||
client->mUnregisterClientRunnable = aRunnable;
|
||||
|
||||
sBluetoothGattClientInterface->UnregisterClient(
|
||||
aClientIf,
|
||||
new UnregisterClientResultHandler(client));
|
||||
}
|
||||
|
||||
class BluetoothGattManager::ConnectResultHandler MOZ_FINAL
|
||||
: public BluetoothGattClientResultHandler
|
||||
{
|
||||
public:
|
||||
ConnectResultHandler(BluetoothGattClient* aClient)
|
||||
: mClient(aClient)
|
||||
{
|
||||
MOZ_ASSERT(mClient);
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
|
||||
{
|
||||
BT_WARNING("BluetoothGattClientInterface::Connect failed: %d",
|
||||
(int)aStatus);
|
||||
MOZ_ASSERT(mClient->mConnectRunnable);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
// Notify BluetoothGatt for client disconnected
|
||||
BluetoothSignal signal(
|
||||
NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
|
||||
mClient->mAppUuid,
|
||||
BluetoothValue(false)); // Disconnected
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
// Reject the connect request
|
||||
NS_NAMED_LITERAL_STRING(errorStr, "Connect failed");
|
||||
DispatchBluetoothReply(mClient->mConnectRunnable,
|
||||
BluetoothValue(),
|
||||
errorStr);
|
||||
mClient->mConnectRunnable = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<BluetoothGattClient> mClient;
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothGattManager::Connect(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddr,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aRunnable);
|
||||
|
||||
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
|
||||
|
||||
size_t index = sClients->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
|
||||
if (index == sClients->NoIndex) {
|
||||
index = sClients->Length();
|
||||
sClients->AppendElement(new BluetoothGattClient(aAppUuid, aDeviceAddr));
|
||||
}
|
||||
|
||||
nsRefPtr<BluetoothGattClient> client = sClients->ElementAt(index);
|
||||
client->mConnectRunnable = aRunnable;
|
||||
|
||||
if (client->mClientIf > 0) {
|
||||
sBluetoothGattClientInterface->Connect(client->mClientIf,
|
||||
aDeviceAddr,
|
||||
true, // direct connect
|
||||
new ConnectResultHandler(client));
|
||||
} else {
|
||||
BluetoothUuid uuid;
|
||||
StringToUuid(NS_ConvertUTF16toUTF8(aAppUuid).get(), uuid);
|
||||
|
||||
// connect will be proceeded after client registered
|
||||
sBluetoothGattClientInterface->RegisterClient(
|
||||
uuid, new RegisterClientResultHandler(client));
|
||||
}
|
||||
}
|
||||
|
||||
class BluetoothGattManager::DisconnectResultHandler MOZ_FINAL
|
||||
: public BluetoothGattClientResultHandler
|
||||
{
|
||||
public:
|
||||
DisconnectResultHandler(BluetoothGattClient* aClient)
|
||||
: mClient(aClient)
|
||||
{
|
||||
MOZ_ASSERT(mClient);
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE
|
||||
{
|
||||
BT_WARNING("BluetoothGattClientInterface::Disconnect failed: %d",
|
||||
(int)aStatus);
|
||||
MOZ_ASSERT(mClient->mDisconnectRunnable);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
// Notify BluetoothGatt that the client remains connected
|
||||
BluetoothSignal signal(
|
||||
NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
|
||||
mClient->mAppUuid,
|
||||
BluetoothValue(true)); // Connected
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
// Reject the disconnect request
|
||||
NS_NAMED_LITERAL_STRING(errorStr, "Disconnect failed");
|
||||
DispatchBluetoothReply(mClient->mDisconnectRunnable,
|
||||
BluetoothValue(),
|
||||
errorStr);
|
||||
mClient->mDisconnectRunnable = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<BluetoothGattClient> mClient;
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothGattManager::Disconnect(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddr,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aRunnable);
|
||||
|
||||
ENSURE_GATT_CLIENT_INTF_IS_READY_VOID(aRunnable);
|
||||
|
||||
size_t index = sClients->IndexOf(aAppUuid, 0 /* Start */, UuidComparator());
|
||||
|
||||
// Reject the disconnect request if the client is not found
|
||||
if (index == sClients->NoIndex) {
|
||||
NS_NAMED_LITERAL_STRING(errorStr, "Disconnect failed");
|
||||
DispatchBluetoothReply(aRunnable, BluetoothValue(), errorStr);
|
||||
return;
|
||||
}
|
||||
|
||||
nsRefPtr<BluetoothGattClient> client = sClients->ElementAt(index);
|
||||
client->mDisconnectRunnable = aRunnable;
|
||||
|
||||
sBluetoothGattClientInterface->Disconnect(
|
||||
client->mClientIf,
|
||||
aDeviceAddr,
|
||||
client->mConnId,
|
||||
new DisconnectResultHandler(client));
|
||||
}
|
||||
|
||||
//
|
||||
// Notification Handlers
|
||||
//
|
||||
@ -183,7 +509,60 @@ void
|
||||
BluetoothGattManager::RegisterClientNotification(int aStatus,
|
||||
int aClientIf,
|
||||
const BluetoothUuid& aAppUuid)
|
||||
{ }
|
||||
{
|
||||
BT_API2_LOGR("Client Registered, clientIf = %d", aClientIf);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsString uuid;
|
||||
UuidToString(aAppUuid, uuid);
|
||||
|
||||
size_t index = sClients->IndexOf(uuid, 0 /* Start */, UuidComparator());
|
||||
NS_ENSURE_TRUE_VOID(index != sClients->NoIndex);
|
||||
nsRefPtr<BluetoothGattClient> client = sClients->ElementAt(index);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
if (aStatus) { // operation failed
|
||||
BT_API2_LOGR(
|
||||
"RegisterClient failed, clientIf = %d, status = %d, appUuid = %s",
|
||||
aClientIf, aStatus, NS_ConvertUTF16toUTF8(uuid).get());
|
||||
|
||||
// Notify BluetoothGatt for client disconnected
|
||||
BluetoothSignal signal(
|
||||
NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
|
||||
uuid, BluetoothValue(false)); // Disconnected
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
// Reject the connect request
|
||||
if (client->mConnectRunnable) {
|
||||
NS_NAMED_LITERAL_STRING(errorStr,
|
||||
"Connect failed due to registration failed");
|
||||
DispatchBluetoothReply(client->mConnectRunnable,
|
||||
BluetoothValue(),
|
||||
errorStr);
|
||||
client->mConnectRunnable = nullptr;
|
||||
}
|
||||
|
||||
sClients->RemoveElement(client);
|
||||
return;
|
||||
}
|
||||
|
||||
client->mClientIf = aClientIf;
|
||||
|
||||
// Notify BluetoothGatt to update the clientIf
|
||||
BluetoothSignal signal(
|
||||
NS_LITERAL_STRING("ClientRegistered"),
|
||||
uuid, BluetoothValue(uint32_t(aClientIf)));
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
// Client just registered, proceed remaining connect request.
|
||||
if (client->mConnectRunnable) {
|
||||
sBluetoothGattClientInterface->Connect(
|
||||
aClientIf, client->mDeviceAddr, true /* direct connect */,
|
||||
new ConnectResultHandler(client));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattManager::ScanResultNotification(
|
||||
@ -195,15 +574,114 @@ void
|
||||
BluetoothGattManager::ConnectNotification(int aConnId,
|
||||
int aStatus,
|
||||
int aClientIf,
|
||||
const nsAString& aBdAddr)
|
||||
{ }
|
||||
const nsAString& aDeviceAddr)
|
||||
{
|
||||
BT_API2_LOGR();
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
size_t index = sClients->IndexOf(aClientIf, 0 /* Start */,
|
||||
ClientIfComparator());
|
||||
NS_ENSURE_TRUE_VOID(index != sClients->NoIndex);
|
||||
nsRefPtr<BluetoothGattClient> client = sClients->ElementAt(index);
|
||||
|
||||
if (aStatus) { // operation failed
|
||||
BT_API2_LOGR("Connect failed, clientIf = %d, connId = %d, status = %d",
|
||||
aClientIf, aConnId, aStatus);
|
||||
|
||||
// Notify BluetoothGatt that the client remains disconnected
|
||||
BluetoothSignal signal(
|
||||
NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
|
||||
client->mAppUuid,
|
||||
BluetoothValue(false)); // Disconnected
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
// Reject the connect request
|
||||
if (client->mConnectRunnable) {
|
||||
NS_NAMED_LITERAL_STRING(errorStr, "Connect failed");
|
||||
DispatchBluetoothReply(client->mConnectRunnable,
|
||||
BluetoothValue(),
|
||||
errorStr);
|
||||
client->mConnectRunnable = nullptr;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
client->mConnId = aConnId;
|
||||
|
||||
// Notify BluetoothGatt for client connected
|
||||
BluetoothSignal signal(
|
||||
NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
|
||||
client->mAppUuid,
|
||||
BluetoothValue(true)); // Connected
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
// Resolve the connect request
|
||||
if (client->mConnectRunnable) {
|
||||
DispatchBluetoothReply(client->mConnectRunnable,
|
||||
BluetoothValue(true),
|
||||
EmptyString());
|
||||
client->mConnectRunnable = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattManager::DisconnectNotification(int aConnId,
|
||||
int aStatus,
|
||||
int aClientIf,
|
||||
const nsAString& aBdAddr)
|
||||
{ }
|
||||
const nsAString& aDeviceAddr)
|
||||
{
|
||||
BT_API2_LOGR();
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
||||
size_t index = sClients->IndexOf(aClientIf, 0 /* Start */,
|
||||
ClientIfComparator());
|
||||
NS_ENSURE_TRUE_VOID(index != sClients->NoIndex);
|
||||
nsRefPtr<BluetoothGattClient> client = sClients->ElementAt(index);
|
||||
|
||||
if (aStatus) { // operation failed
|
||||
// Notify BluetoothGatt that the client remains connected
|
||||
BluetoothSignal signal(
|
||||
NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
|
||||
client->mAppUuid,
|
||||
BluetoothValue(true)); // Connected
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
// Reject the disconnect request
|
||||
if (client->mDisconnectRunnable) {
|
||||
NS_NAMED_LITERAL_STRING(errorStr, "Disconnect failed");
|
||||
DispatchBluetoothReply(client->mDisconnectRunnable,
|
||||
BluetoothValue(),
|
||||
errorStr);
|
||||
client->mDisconnectRunnable = nullptr;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
client->mConnId = 0;
|
||||
|
||||
// Notify BluetoothGatt for client disconnected
|
||||
BluetoothSignal signal(
|
||||
NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
|
||||
client->mAppUuid,
|
||||
BluetoothValue(false)); // Disconnected
|
||||
bs->DistributeSignal(signal);
|
||||
|
||||
// Resolve the disconnect request
|
||||
if (client->mDisconnectRunnable) {
|
||||
DispatchBluetoothReply(client->mDisconnectRunnable,
|
||||
BluetoothValue(true),
|
||||
EmptyString());
|
||||
client->mDisconnectRunnable = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattManager::SearchCompleteNotification(int aConnId, int aStatus)
|
||||
|
@ -12,6 +12,9 @@
|
||||
#include "BluetoothProfileManagerBase.h"
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
class BluetoothReplyRunnable;
|
||||
|
||||
class BluetoothGattManager MOZ_FINAL : public nsIObserver
|
||||
, public BluetoothGattNotificationHandler
|
||||
{
|
||||
@ -24,10 +27,25 @@ public:
|
||||
static void DeinitGattInterface(BluetoothProfileResultHandler* aRes);
|
||||
virtual ~BluetoothGattManager();
|
||||
|
||||
void Connect(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddr,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
void Disconnect(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddr,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
void UnregisterClient(int aClientIf,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
private:
|
||||
class CleanupResultHandler;
|
||||
class CleanupResultHandlerRunnable;
|
||||
class InitGattResultHandler;
|
||||
class RegisterClientResultHandler;
|
||||
class UnregisterClientResultHandler;
|
||||
class ConnectResultHandler;
|
||||
class DisconnectResultHandler;
|
||||
|
||||
BluetoothGattManager();
|
||||
|
||||
|
@ -55,6 +55,15 @@
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define ENSURE_GATT_MGR_IS_READY_VOID(gatt, runnable) \
|
||||
do { \
|
||||
if (!gatt) { \
|
||||
NS_NAMED_LITERAL_STRING(replyError, "GattManager is not ready"); \
|
||||
DispatchBluetoothReply(runnable, BluetoothValue(), replyError); \
|
||||
return; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::ipc;
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
@ -1107,6 +1116,54 @@ BluetoothServiceBluedroid::ToggleCalls(BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// GATT Client
|
||||
//
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::ConnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
|
||||
|
||||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
gatt->Connect(aAppUuid, aDeviceAddress, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::DisconnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
|
||||
|
||||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
gatt->Disconnect(aAppUuid, aDeviceAddress, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::UnregisterGattClientInternal(
|
||||
int aClientIf, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
|
||||
|
||||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
gatt->UnregisterClient(aClientIf, aRunnable);
|
||||
}
|
||||
|
||||
//
|
||||
// Bluetooth notifications
|
||||
//
|
||||
|
@ -170,6 +170,24 @@ public:
|
||||
SendInputMessage(const nsAString& aDeviceAddresses,
|
||||
const nsAString& aMessage) MOZ_OVERRIDE;
|
||||
|
||||
//
|
||||
// GATT Client
|
||||
//
|
||||
|
||||
virtual void
|
||||
ConnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
virtual void
|
||||
DisconnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
virtual void
|
||||
UnregisterGattClientInternal(int aClientIf,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
//
|
||||
// Bluetooth notifications
|
||||
//
|
||||
|
@ -4266,3 +4266,23 @@ BluetoothDBusService::UpdateNotification(ControlEventId aEventId,
|
||||
Task* task = new UpdateNotificationTask(deviceAddress, aEventId, aData);
|
||||
DispatchToDBusThread(task);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::ConnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::DisconnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::UnregisterGattClientInternal(
|
||||
int aClientIf, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
@ -184,6 +184,20 @@ public:
|
||||
virtual nsresult
|
||||
SendInputMessage(const nsAString& aDeviceAddresses,
|
||||
const nsAString& aMessage) MOZ_OVERRIDE;
|
||||
|
||||
virtual void
|
||||
ConnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
virtual void
|
||||
DisconnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
virtual void
|
||||
UnregisterGattClientInternal(int aClientIf,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
nsresult SendGetPropertyMessage(const nsAString& aPath,
|
||||
const char* aInterface,
|
||||
|
@ -250,6 +250,12 @@ BluetoothParent::RecvPBluetoothRequestConstructor(
|
||||
return actor->DoRequest(aRequest.get_SendMetaDataRequest());
|
||||
case Request::TSendPlayStatusRequest:
|
||||
return actor->DoRequest(aRequest.get_SendPlayStatusRequest());
|
||||
case Request::TConnectGattClientRequest:
|
||||
return actor->DoRequest(aRequest.get_ConnectGattClientRequest());
|
||||
case Request::TDisconnectGattClientRequest:
|
||||
return actor->DoRequest(aRequest.get_DisconnectGattClientRequest());
|
||||
case Request::TUnregisterGattClientRequest:
|
||||
return actor->DoRequest(aRequest.get_UnregisterGattClientRequest());
|
||||
default:
|
||||
MOZ_CRASH("Unknown type!");
|
||||
}
|
||||
@ -684,3 +690,41 @@ BluetoothRequestParent::DoRequest(const SendPlayStatusRequest& aRequest)
|
||||
mReplyRunnable.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRequestParent::DoRequest(const ConnectGattClientRequest& aRequest)
|
||||
{
|
||||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TConnectGattClientRequest);
|
||||
|
||||
mService->ConnectGattClientInternal(aRequest.appUuid(),
|
||||
aRequest.deviceAddress(),
|
||||
mReplyRunnable.get());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRequestParent::DoRequest(const DisconnectGattClientRequest& aRequest)
|
||||
{
|
||||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TDisconnectGattClientRequest);
|
||||
|
||||
mService->DisconnectGattClientInternal(aRequest.appUuid(),
|
||||
aRequest.deviceAddress(),
|
||||
mReplyRunnable.get());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
BluetoothRequestParent::DoRequest(const UnregisterGattClientRequest& aRequest)
|
||||
{
|
||||
MOZ_ASSERT(mService);
|
||||
MOZ_ASSERT(mRequestType == Request::TUnregisterGattClientRequest);
|
||||
|
||||
mService->UnregisterGattClientInternal(aRequest.clientIf(),
|
||||
mReplyRunnable.get());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -216,6 +216,15 @@ protected:
|
||||
|
||||
bool
|
||||
DoRequest(const SendPlayStatusRequest& aRequest);
|
||||
|
||||
bool
|
||||
DoRequest(const ConnectGattClientRequest& aRequest);
|
||||
|
||||
bool
|
||||
DoRequest(const DisconnectGattClientRequest& aRequest);
|
||||
|
||||
bool
|
||||
DoRequest(const UnregisterGattClientRequest& aRequest);
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
@ -141,7 +141,7 @@ BluetoothServiceChildProcess::GetPairedDevicePropertiesInternal(
|
||||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::FetchUuidsInternal(
|
||||
const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aDeviceAddress, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, FetchUuidsRequest(nsString(aDeviceAddress)));
|
||||
return NS_OK;
|
||||
@ -379,6 +379,31 @@ BluetoothServiceChildProcess::SendPlayStatus(int64_t aDuration,
|
||||
nsString(aPlayStatus)));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::ConnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, ConnectGattClientRequest(nsString(aAppUuid),
|
||||
nsString(aDeviceAddress)));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::DisconnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
DisconnectGattClientRequest(nsString(aAppUuid), nsString(aDeviceAddress)));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::UnregisterGattClientInternal(
|
||||
int aClientIf, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, UnregisterGattClientRequest(aClientIf));
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothServiceChildProcess::HandleStartup()
|
||||
{
|
||||
|
@ -192,6 +192,20 @@ public:
|
||||
SendInputMessage(const nsAString& aDeviceAddresses,
|
||||
const nsAString& aMessage) MOZ_OVERRIDE;
|
||||
|
||||
virtual void
|
||||
ConnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
virtual void
|
||||
DisconnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
virtual void
|
||||
UnregisterGattClientInternal(int aClientIf,
|
||||
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
BluetoothServiceChildProcess();
|
||||
virtual ~BluetoothServiceChildProcess();
|
||||
|
@ -176,6 +176,23 @@ struct SendPlayStatusRequest
|
||||
nsString playStatus;
|
||||
};
|
||||
|
||||
struct ConnectGattClientRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString deviceAddress;
|
||||
};
|
||||
|
||||
struct DisconnectGattClientRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString deviceAddress;
|
||||
};
|
||||
|
||||
struct UnregisterGattClientRequest
|
||||
{
|
||||
int clientIf;
|
||||
};
|
||||
|
||||
union Request
|
||||
{
|
||||
GetAdaptersRequest;
|
||||
@ -208,6 +225,9 @@ union Request
|
||||
ToggleCallsRequest;
|
||||
SendMetaDataRequest;
|
||||
SendPlayStatusRequest;
|
||||
ConnectGattClientRequest;
|
||||
DisconnectGattClientRequest;
|
||||
UnregisterGattClientRequest;
|
||||
};
|
||||
|
||||
protocol PBluetooth
|
||||
|
@ -10,6 +10,7 @@ if CONFIG['MOZ_B2G_BT']:
|
||||
'BluetoothClassOfDevice.cpp',
|
||||
'BluetoothDevice.cpp',
|
||||
'BluetoothDiscoveryHandle.cpp',
|
||||
'BluetoothGatt.cpp',
|
||||
'BluetoothHidManager.cpp',
|
||||
'BluetoothInterface.cpp',
|
||||
'BluetoothManager.cpp',
|
||||
@ -122,6 +123,7 @@ EXPORTS.mozilla.dom.bluetooth += [
|
||||
'BluetoothCommon.h',
|
||||
'BluetoothDevice.h',
|
||||
'BluetoothDiscoveryHandle.h',
|
||||
'BluetoothGatt.h',
|
||||
'BluetoothManager.h',
|
||||
'BluetoothPairingHandle.h',
|
||||
'BluetoothPairingListener.h',
|
||||
|
@ -113,7 +113,8 @@ BrowserElementChild.prototype = {
|
||||
.addProgressListener(this._progressListener,
|
||||
Ci.nsIWebProgress.NOTIFY_LOCATION |
|
||||
Ci.nsIWebProgress.NOTIFY_SECURITY |
|
||||
Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
|
||||
Ci.nsIWebProgress.NOTIFY_STATE_WINDOW |
|
||||
Ci.nsIWebProgress.NOTIFY_PROGRESS);
|
||||
|
||||
docShell.QueryInterface(Ci.nsIWebNavigation)
|
||||
.sessionHistory = Cc["@mozilla.org/browser/shistory;1"]
|
||||
@ -1371,8 +1372,12 @@ BrowserElementChild.prototype = {
|
||||
},
|
||||
|
||||
onStatusChange: function(webProgress, request, status, message) {},
|
||||
|
||||
onProgressChange: function(webProgress, request, curSelfProgress,
|
||||
maxSelfProgress, curTotalProgress, maxTotalProgress) {},
|
||||
maxSelfProgress, curTotalProgress, maxTotalProgress) {
|
||||
sendAsyncMsg('loadprogresschanged', { curTotalProgress: curTotalProgress,
|
||||
maxTotalProgress: maxTotalProgress });
|
||||
},
|
||||
},
|
||||
|
||||
// Expose the message manager for WebApps and others.
|
||||
|
@ -181,6 +181,7 @@ BrowserElementParent.prototype = {
|
||||
"hello": this._recvHello,
|
||||
"loadstart": this._fireProfiledEventFromMsg,
|
||||
"loadend": this._fireProfiledEventFromMsg,
|
||||
"loadprogresschanged": this._fireEventFromMsg,
|
||||
"close": this._fireEventFromMsg,
|
||||
"error": this._fireEventFromMsg,
|
||||
"firstpaint": this._fireProfiledEventFromMsg,
|
||||
|
@ -13,7 +13,8 @@ function runTest() {
|
||||
// Load emptypage1 into the iframe, wait for that to finish loading, then
|
||||
// call runTest2.
|
||||
//
|
||||
// This should trigger loadstart, locationchange, and loadend events.
|
||||
// This should trigger loadstart, locationchange, loadprogresschanged and
|
||||
// loadend events.
|
||||
|
||||
var seenLoadEnd = false;
|
||||
var seenLoadStart = false;
|
||||
@ -74,6 +75,7 @@ function runTest2() {
|
||||
var seenLoadStart = false;
|
||||
var seenLoadEnd = false;
|
||||
var seenLocationChange = false;
|
||||
var seenLoadProgressChanged = false;
|
||||
|
||||
// Add this event listener to the document; the events should bubble.
|
||||
document.addEventListener('mozbrowserloadstart', function(e) {
|
||||
@ -103,6 +105,14 @@ function runTest2() {
|
||||
is(e.detail.backgroundColor, 'transparent', 'Expected background color reported')
|
||||
});
|
||||
|
||||
iframe.addEventListener('mozbrowserloadprogresschanged', function(e) {
|
||||
ok(e.isTrusted, 'Event should be trusted.');
|
||||
seenLoadProgressChanged = true;
|
||||
ok(seenLoadStart, 'Load end after load start.');
|
||||
ok(seenLocationChange, 'Load end after location change.');
|
||||
ok(!seenLoadEnd, 'Load end after load progress.');
|
||||
});
|
||||
|
||||
iframe.src = browserElementTestHelpers.emptyPage2;
|
||||
|
||||
function waitForAllCallbacks() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Mozilla Foundation
|
||||
* Copyright (C) 2012-2015 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -40,14 +40,15 @@ DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_1080P, "1080p")
|
||||
* profiles may have more than one resolution, depending on the camera.
|
||||
*/
|
||||
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("fwvga", 864, 480)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("fwvga", 854, 480)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("wvga", 800, 480)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("wvga", 768, 480)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("vga", 640, 480)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("hvga", 480, 320)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("wqvga", 400, 240)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("qvga", 320, 240)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("4kuhd", 3840, 2160)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("fwvga", 864, 480)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("fwvga", 854, 480)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("wvga", 800, 480)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("wvga", 768, 480)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("vga", 640, 480)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("hvga", 480, 320)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("wqvga", 400, 240)
|
||||
DEF_GONK_RECORDER_PROFILE_DETECT("qvga", 320, 240)
|
||||
|
||||
#undef DEF_GONK_RECORDER_PROFILE
|
||||
#undef DEF_GONK_RECORDER_PROFILE_DETECT
|
||||
|
@ -505,7 +505,7 @@ IsFeatureInBlacklist(const nsCOMPtr<nsIGfxInfo>& gfxInfo, int32_t feature)
|
||||
|
||||
static already_AddRefed<GLContext>
|
||||
CreateHeadlessNativeGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
|
||||
WebGLContext* webgl)
|
||||
bool requireCompatProfile, WebGLContext* webgl)
|
||||
{
|
||||
if (!forceEnabled &&
|
||||
IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_OPENGL))
|
||||
@ -515,7 +515,7 @@ CreateHeadlessNativeGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<GLContext> gl = gl::GLContextProvider::CreateHeadless();
|
||||
nsRefPtr<GLContext> gl = gl::GLContextProvider::CreateHeadless(requireCompatProfile);
|
||||
if (!gl) {
|
||||
webgl->GenerateWarning("Error during native OpenGL init.");
|
||||
return nullptr;
|
||||
@ -530,7 +530,7 @@ CreateHeadlessNativeGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
|
||||
// Eventually, we want to be able to pick ANGLE-EGL or native EGL.
|
||||
static already_AddRefed<GLContext>
|
||||
CreateHeadlessANGLE(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
|
||||
WebGLContext* webgl)
|
||||
bool requireCompatProfile, WebGLContext* webgl)
|
||||
{
|
||||
nsRefPtr<GLContext> gl;
|
||||
|
||||
@ -543,7 +543,7 @@ CreateHeadlessANGLE(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gl = gl::GLContextProviderEGL::CreateHeadless();
|
||||
gl = gl::GLContextProviderEGL::CreateHeadless(requireCompatProfile);
|
||||
if (!gl) {
|
||||
webgl->GenerateWarning("Error during ANGLE OpenGL init.");
|
||||
return nullptr;
|
||||
@ -555,13 +555,13 @@ CreateHeadlessANGLE(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
|
||||
}
|
||||
|
||||
static already_AddRefed<GLContext>
|
||||
CreateHeadlessEGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
|
||||
CreateHeadlessEGL(bool forceEnabled, bool requireCompatProfile,
|
||||
WebGLContext* webgl)
|
||||
{
|
||||
nsRefPtr<GLContext> gl;
|
||||
|
||||
#ifdef ANDROID
|
||||
gl = gl::GLContextProviderEGL::CreateHeadless();
|
||||
gl = gl::GLContextProviderEGL::CreateHeadless(requireCompatProfile);
|
||||
if (!gl) {
|
||||
webgl->GenerateWarning("Error during EGL OpenGL init.");
|
||||
return nullptr;
|
||||
@ -583,16 +583,22 @@ CreateHeadlessGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
|
||||
if (PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL"))
|
||||
disableANGLE = true;
|
||||
|
||||
bool requireCompatProfile = webgl->IsWebGL2() ? false : true;
|
||||
|
||||
nsRefPtr<GLContext> gl;
|
||||
|
||||
if (preferEGL)
|
||||
gl = CreateHeadlessEGL(forceEnabled, gfxInfo, webgl);
|
||||
gl = CreateHeadlessEGL(forceEnabled, requireCompatProfile, webgl);
|
||||
|
||||
if (!gl && !disableANGLE)
|
||||
gl = CreateHeadlessANGLE(forceEnabled, gfxInfo, webgl);
|
||||
if (!gl && !disableANGLE) {
|
||||
gl = CreateHeadlessANGLE(forceEnabled, gfxInfo, requireCompatProfile,
|
||||
webgl);
|
||||
}
|
||||
|
||||
if (!gl)
|
||||
gl = CreateHeadlessNativeGL(forceEnabled, gfxInfo, webgl);
|
||||
if (!gl) {
|
||||
gl = CreateHeadlessNativeGL(forceEnabled, gfxInfo,
|
||||
requireCompatProfile, webgl);
|
||||
}
|
||||
|
||||
return gl.forget();
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user