accessible/src/windows/sdn/sdnDocAccessible.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "sdnDocAccessible.h"
michael@0 8
michael@0 9 #include "ISimpleDOMDocument_i.c"
michael@0 10
michael@0 11 using namespace mozilla;
michael@0 12 using namespace mozilla::a11y;
michael@0 13
michael@0 14 ////////////////////////////////////////////////////////////////////////////////
michael@0 15 // sdnDocAccessible
michael@0 16 ////////////////////////////////////////////////////////////////////////////////
michael@0 17
michael@0 18 IMPL_IUNKNOWN_QUERY_HEAD(sdnDocAccessible)
michael@0 19 IMPL_IUNKNOWN_QUERY_IFACE(ISimpleDOMDocument)
michael@0 20 IMPL_IUNKNOWN_QUERY_TAIL_AGGREGATED(mAccessible)
michael@0 21
michael@0 22 STDMETHODIMP
michael@0 23 sdnDocAccessible::get_URL(BSTR __RPC_FAR* aURL)
michael@0 24 {
michael@0 25 A11Y_TRYBLOCK_BEGIN
michael@0 26
michael@0 27 if (!aURL)
michael@0 28 return E_INVALIDARG;
michael@0 29 *aURL = nullptr;
michael@0 30
michael@0 31 if (mAccessible->IsDefunct())
michael@0 32 return CO_E_OBJNOTCONNECTED;
michael@0 33
michael@0 34 nsAutoString URL;
michael@0 35 nsresult rv = mAccessible->GetURL(URL);
michael@0 36 if (NS_FAILED(rv))
michael@0 37 return E_FAIL;
michael@0 38
michael@0 39 if (URL.IsEmpty())
michael@0 40 return S_FALSE;
michael@0 41
michael@0 42 *aURL = ::SysAllocStringLen(URL.get(), URL.Length());
michael@0 43 return *aURL ? S_OK : E_OUTOFMEMORY;
michael@0 44
michael@0 45 A11Y_TRYBLOCK_END
michael@0 46 }
michael@0 47
michael@0 48 STDMETHODIMP
michael@0 49 sdnDocAccessible::get_title(BSTR __RPC_FAR* aTitle)
michael@0 50 {
michael@0 51 A11Y_TRYBLOCK_BEGIN
michael@0 52
michael@0 53 if (!aTitle)
michael@0 54 return E_INVALIDARG;
michael@0 55 *aTitle = nullptr;
michael@0 56
michael@0 57 if (mAccessible->IsDefunct())
michael@0 58 return CO_E_OBJNOTCONNECTED;
michael@0 59
michael@0 60 nsAutoString title;
michael@0 61 nsresult rv = mAccessible->GetTitle(title);
michael@0 62 if (NS_FAILED(rv))
michael@0 63 return E_FAIL;
michael@0 64
michael@0 65 *aTitle = ::SysAllocStringLen(title.get(), title.Length());
michael@0 66 return *aTitle ? S_OK : E_OUTOFMEMORY;
michael@0 67
michael@0 68 A11Y_TRYBLOCK_END
michael@0 69 }
michael@0 70
michael@0 71 STDMETHODIMP
michael@0 72 sdnDocAccessible::get_mimeType(BSTR __RPC_FAR* aMimeType)
michael@0 73 {
michael@0 74 A11Y_TRYBLOCK_BEGIN
michael@0 75
michael@0 76 if (!aMimeType)
michael@0 77 return E_INVALIDARG;
michael@0 78 *aMimeType = nullptr;
michael@0 79
michael@0 80 if (mAccessible->IsDefunct())
michael@0 81 return CO_E_OBJNOTCONNECTED;
michael@0 82
michael@0 83 nsAutoString mimeType;
michael@0 84 nsresult rv = mAccessible->GetMimeType(mimeType);
michael@0 85 if (NS_FAILED(rv))
michael@0 86 return E_FAIL;
michael@0 87
michael@0 88 if (mimeType.IsEmpty())
michael@0 89 return S_FALSE;
michael@0 90
michael@0 91 *aMimeType = ::SysAllocStringLen(mimeType.get(), mimeType.Length());
michael@0 92 return *aMimeType ? S_OK : E_OUTOFMEMORY;
michael@0 93
michael@0 94 A11Y_TRYBLOCK_END
michael@0 95 }
michael@0 96
michael@0 97 STDMETHODIMP
michael@0 98 sdnDocAccessible::get_docType(BSTR __RPC_FAR* aDocType)
michael@0 99 {
michael@0 100 A11Y_TRYBLOCK_BEGIN
michael@0 101
michael@0 102 if (!aDocType)
michael@0 103 return E_INVALIDARG;
michael@0 104 *aDocType = nullptr;
michael@0 105
michael@0 106 if (mAccessible->IsDefunct())
michael@0 107 return CO_E_OBJNOTCONNECTED;
michael@0 108
michael@0 109 nsAutoString docType;
michael@0 110 nsresult rv = mAccessible->GetDocType(docType);
michael@0 111 if (NS_FAILED(rv))
michael@0 112 return E_FAIL;
michael@0 113
michael@0 114 if (docType.IsEmpty())
michael@0 115 return S_FALSE;
michael@0 116
michael@0 117 *aDocType = ::SysAllocStringLen(docType.get(), docType.Length());
michael@0 118 return *aDocType ? S_OK : E_OUTOFMEMORY;
michael@0 119
michael@0 120 A11Y_TRYBLOCK_END
michael@0 121 }
michael@0 122
michael@0 123 STDMETHODIMP
michael@0 124 sdnDocAccessible::get_nameSpaceURIForID(short aNameSpaceID,
michael@0 125 BSTR __RPC_FAR* aNameSpaceURI)
michael@0 126 {
michael@0 127 A11Y_TRYBLOCK_BEGIN
michael@0 128
michael@0 129 if (!aNameSpaceURI)
michael@0 130 return E_INVALIDARG;
michael@0 131 *aNameSpaceURI = nullptr;
michael@0 132
michael@0 133 if (mAccessible->IsDefunct())
michael@0 134 return CO_E_OBJNOTCONNECTED;
michael@0 135
michael@0 136 if (aNameSpaceID < 0)
michael@0 137 return E_INVALIDARG; // -1 is kNameSpaceID_Unknown
michael@0 138
michael@0 139 nsAutoString nameSpaceURI;
michael@0 140 nsresult rv = mAccessible->GetNameSpaceURIForID(aNameSpaceID, nameSpaceURI);
michael@0 141 if (NS_FAILED(rv))
michael@0 142 return E_FAIL;
michael@0 143
michael@0 144 if (nameSpaceURI.IsEmpty())
michael@0 145 return S_FALSE;
michael@0 146
michael@0 147 *aNameSpaceURI = ::SysAllocStringLen(nameSpaceURI.get(),
michael@0 148 nameSpaceURI.Length());
michael@0 149
michael@0 150 return *aNameSpaceURI ? S_OK : E_OUTOFMEMORY;
michael@0 151
michael@0 152 A11Y_TRYBLOCK_END
michael@0 153 }
michael@0 154
michael@0 155 STDMETHODIMP
michael@0 156 sdnDocAccessible::put_alternateViewMediaTypes(BSTR __RPC_FAR* aCommaSeparatedMediaTypes)
michael@0 157 {
michael@0 158 A11Y_TRYBLOCK_BEGIN
michael@0 159
michael@0 160 if (!aCommaSeparatedMediaTypes)
michael@0 161 return E_INVALIDARG;
michael@0 162 *aCommaSeparatedMediaTypes = nullptr;
michael@0 163
michael@0 164 return mAccessible->IsDefunct() ? CO_E_OBJNOTCONNECTED : E_NOTIMPL;
michael@0 165
michael@0 166 A11Y_TRYBLOCK_END
michael@0 167 }

mercurial