nsTransferable.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /*
  6. Notes to self:
  7. - at some point, strings will be accessible from JS, so we won't have to wrap
  8. flavors in an nsISupportsCString. Until then, we're kinda stuck with
  9. this crappy API of nsIArrays.
  10. */
  11. #include "nsTransferable.h"
  12. #include "nsArray.h"
  13. #include "nsArrayUtils.h"
  14. #include "nsString.h"
  15. #include "nsReadableUtils.h"
  16. #include "nsTArray.h"
  17. #include "nsIFormatConverter.h"
  18. #include "nsIContentPolicy.h"
  19. #include "nsIComponentManager.h"
  20. #include "nsCOMPtr.h"
  21. #include "nsXPCOM.h"
  22. #include "nsISupportsPrimitives.h"
  23. #include "nsMemory.h"
  24. #include "nsPrimitiveHelpers.h"
  25. #include "nsXPIDLString.h"
  26. #include "nsDirectoryServiceDefs.h"
  27. #include "nsDirectoryService.h"
  28. #include "nsCRT.h"
  29. #include "nsNetUtil.h"
  30. #include "nsIDOMNode.h"
  31. #include "nsIOutputStream.h"
  32. #include "nsIInputStream.h"
  33. #include "nsIWeakReferenceUtils.h"
  34. #include "nsIFile.h"
  35. #include "nsILoadContext.h"
  36. #include "mozilla/UniquePtr.h"
  37. NS_IMPL_ISUPPORTS(nsTransferable, nsITransferable)
  38. size_t GetDataForFlavor (const nsTArray<DataStruct>& aArray,
  39. const char* aDataFlavor)
  40. {
  41. for (size_t i = 0 ; i < aArray.Length () ; ++i) {
  42. if (aArray[i].GetFlavor().Equals (aDataFlavor))
  43. return i;
  44. }
  45. return aArray.NoIndex;
  46. }
  47. //-------------------------------------------------------------------------
  48. DataStruct::~DataStruct()
  49. {
  50. if (mCacheFileName) free(mCacheFileName);
  51. }
  52. //-------------------------------------------------------------------------
  53. void
  54. DataStruct::SetData ( nsISupports* aData, uint32_t aDataLen, bool aIsPrivateData )
  55. {
  56. // Now, check to see if we consider the data to be "too large"
  57. // as well as ensuring that private browsing mode is disabled
  58. if (aDataLen > kLargeDatasetSize && !aIsPrivateData) {
  59. // if so, cache it to disk instead of memory
  60. if ( NS_SUCCEEDED(WriteCache(aData, aDataLen)) )
  61. return;
  62. else
  63. NS_WARNING("Oh no, couldn't write data to the cache file");
  64. }
  65. mData = aData;
  66. mDataLen = aDataLen;
  67. }
  68. //-------------------------------------------------------------------------
  69. void
  70. DataStruct::GetData ( nsISupports** aData, uint32_t *aDataLen )
  71. {
  72. // check here to see if the data is cached on disk
  73. if ( !mData && mCacheFileName ) {
  74. // if so, read it in and pass it back
  75. // ReadCache creates memory and copies the data into it.
  76. if ( NS_SUCCEEDED(ReadCache(aData, aDataLen)) )
  77. return;
  78. else {
  79. // oh shit, something went horribly wrong here.
  80. NS_WARNING("Oh no, couldn't read data in from the cache file");
  81. *aData = nullptr;
  82. *aDataLen = 0;
  83. return;
  84. }
  85. }
  86. *aData = mData;
  87. if ( mData )
  88. NS_ADDREF(*aData);
  89. *aDataLen = mDataLen;
  90. }
  91. //-------------------------------------------------------------------------
  92. already_AddRefed<nsIFile>
  93. DataStruct::GetFileSpec(const char* aFileName)
  94. {
  95. nsCOMPtr<nsIFile> cacheFile;
  96. NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(cacheFile));
  97. if (!cacheFile)
  98. return nullptr;
  99. // if the param aFileName contains a name we should use that
  100. // because the file probably already exists
  101. // otherwise create a unique name
  102. if (!aFileName) {
  103. cacheFile->AppendNative(NS_LITERAL_CSTRING("clipboardcache"));
  104. nsresult rv = cacheFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
  105. if (NS_FAILED(rv))
  106. return nullptr;
  107. } else {
  108. cacheFile->AppendNative(nsDependentCString(aFileName));
  109. }
  110. return cacheFile.forget();
  111. }
  112. //-------------------------------------------------------------------------
  113. nsresult
  114. DataStruct::WriteCache(nsISupports* aData, uint32_t aDataLen)
  115. {
  116. // Get a new path and file to the temp directory
  117. nsCOMPtr<nsIFile> cacheFile = GetFileSpec(mCacheFileName);
  118. if (cacheFile) {
  119. // remember the file name
  120. if (!mCacheFileName) {
  121. nsXPIDLCString fName;
  122. cacheFile->GetNativeLeafName(fName);
  123. mCacheFileName = strdup(fName);
  124. }
  125. // write out the contents of the clipboard
  126. // to the file
  127. //uint32_t bytes;
  128. nsCOMPtr<nsIOutputStream> outStr;
  129. NS_NewLocalFileOutputStream(getter_AddRefs(outStr),
  130. cacheFile);
  131. if (!outStr) return NS_ERROR_FAILURE;
  132. void* buff = nullptr;
  133. nsPrimitiveHelpers::CreateDataFromPrimitive ( mFlavor.get(), aData, &buff, aDataLen );
  134. if ( buff ) {
  135. uint32_t ignored;
  136. outStr->Write(reinterpret_cast<char*>(buff), aDataLen, &ignored);
  137. free(buff);
  138. return NS_OK;
  139. }
  140. }
  141. return NS_ERROR_FAILURE;
  142. }
  143. //-------------------------------------------------------------------------
  144. nsresult
  145. DataStruct::ReadCache(nsISupports** aData, uint32_t* aDataLen)
  146. {
  147. // if we don't have a cache filename we are out of luck
  148. if (!mCacheFileName)
  149. return NS_ERROR_FAILURE;
  150. // get the path and file name
  151. nsCOMPtr<nsIFile> cacheFile = GetFileSpec(mCacheFileName);
  152. bool exists;
  153. if ( cacheFile && NS_SUCCEEDED(cacheFile->Exists(&exists)) && exists ) {
  154. // get the size of the file
  155. int64_t fileSize;
  156. int64_t max32 = 0xFFFFFFFF;
  157. cacheFile->GetFileSize(&fileSize);
  158. if (fileSize > max32)
  159. return NS_ERROR_OUT_OF_MEMORY;
  160. uint32_t size = uint32_t(fileSize);
  161. // create new memory for the large clipboard data
  162. auto data = mozilla::MakeUnique<char[]>(size);
  163. if ( !data )
  164. return NS_ERROR_OUT_OF_MEMORY;
  165. // now read it all in
  166. nsCOMPtr<nsIInputStream> inStr;
  167. NS_NewLocalFileInputStream( getter_AddRefs(inStr),
  168. cacheFile);
  169. if (!cacheFile) return NS_ERROR_FAILURE;
  170. nsresult rv = inStr->Read(data.get(), fileSize, aDataLen);
  171. // make sure we got all the data ok
  172. if (NS_SUCCEEDED(rv) && *aDataLen == size) {
  173. nsPrimitiveHelpers::CreatePrimitiveForData(mFlavor.get(), data.get(),
  174. fileSize, aData);
  175. return *aData ? NS_OK : NS_ERROR_FAILURE;
  176. }
  177. // zero the return params
  178. *aData = nullptr;
  179. *aDataLen = 0;
  180. }
  181. return NS_ERROR_FAILURE;
  182. }
  183. //-------------------------------------------------------------------------
  184. //
  185. // Transferable constructor
  186. //
  187. //-------------------------------------------------------------------------
  188. nsTransferable::nsTransferable()
  189. : mPrivateData(false)
  190. , mContentPolicyType(nsIContentPolicy::TYPE_OTHER)
  191. #ifdef DEBUG
  192. , mInitialized(false)
  193. #endif
  194. {
  195. }
  196. //-------------------------------------------------------------------------
  197. //
  198. // Transferable destructor
  199. //
  200. //-------------------------------------------------------------------------
  201. nsTransferable::~nsTransferable()
  202. {
  203. }
  204. NS_IMETHODIMP
  205. nsTransferable::Init(nsILoadContext* aContext)
  206. {
  207. MOZ_ASSERT(!mInitialized);
  208. if (aContext) {
  209. mPrivateData = aContext->UsePrivateBrowsing();
  210. }
  211. #ifdef DEBUG
  212. mInitialized = true;
  213. #endif
  214. return NS_OK;
  215. }
  216. //
  217. // GetTransferDataFlavors
  218. //
  219. // Returns a copy of the internal list of flavors. This does NOT take into
  220. // account any converter that may be registered. This list consists of
  221. // nsISupportsCString objects so that the flavor list can be accessed from JS.
  222. //
  223. already_AddRefed<nsIMutableArray>
  224. nsTransferable::GetTransferDataFlavors()
  225. {
  226. MOZ_ASSERT(mInitialized);
  227. nsCOMPtr<nsIMutableArray> array = nsArray::Create();
  228. for (size_t i = 0; i < mDataArray.Length(); ++i) {
  229. DataStruct& data = mDataArray.ElementAt(i);
  230. nsCOMPtr<nsISupportsCString> flavorWrapper = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID);
  231. if ( flavorWrapper ) {
  232. flavorWrapper->SetData ( data.GetFlavor() );
  233. nsCOMPtr<nsISupports> genericWrapper ( do_QueryInterface(flavorWrapper) );
  234. array->AppendElement( genericWrapper, /*weak =*/ false );
  235. }
  236. }
  237. return array.forget();
  238. }
  239. //
  240. // GetTransferData
  241. //
  242. // Returns the data of the requested flavor, obtained from either having the data on hand or
  243. // using a converter to get it. The data is wrapped in a nsISupports primitive so that it is
  244. // accessible from JS.
  245. //
  246. NS_IMETHODIMP
  247. nsTransferable::GetTransferData(const char *aFlavor, nsISupports **aData, uint32_t *aDataLen)
  248. {
  249. MOZ_ASSERT(mInitialized);
  250. NS_ENSURE_ARG_POINTER(aFlavor && aData && aDataLen);
  251. nsresult rv = NS_OK;
  252. nsCOMPtr<nsISupports> savedData;
  253. // first look and see if the data is present in one of the intrinsic flavors
  254. for (size_t i = 0; i < mDataArray.Length(); ++i) {
  255. DataStruct& data = mDataArray.ElementAt(i);
  256. if ( data.GetFlavor().Equals(aFlavor) ) {
  257. nsCOMPtr<nsISupports> dataBytes;
  258. uint32_t len;
  259. data.GetData(getter_AddRefs(dataBytes), &len);
  260. if (len == kFlavorHasDataProvider && dataBytes) {
  261. // do we have a data provider?
  262. nsCOMPtr<nsIFlavorDataProvider> dataProvider = do_QueryInterface(dataBytes);
  263. if (dataProvider) {
  264. rv = dataProvider->GetFlavorData(this, aFlavor,
  265. getter_AddRefs(dataBytes), &len);
  266. if (NS_FAILED(rv))
  267. break; // the provider failed. fall into the converter code below.
  268. }
  269. }
  270. if (dataBytes && len > 0) { // XXXmats why is zero length not ok?
  271. *aDataLen = len;
  272. dataBytes.forget(aData);
  273. return NS_OK;
  274. }
  275. savedData = dataBytes; // return this if format converter fails
  276. break;
  277. }
  278. }
  279. bool found = false;
  280. // if not, try using a format converter to get the requested flavor
  281. if ( mFormatConv ) {
  282. for (size_t i = 0; i < mDataArray.Length(); ++i) {
  283. DataStruct& data = mDataArray.ElementAt(i);
  284. bool canConvert = false;
  285. mFormatConv->CanConvert(data.GetFlavor().get(), aFlavor, &canConvert);
  286. if ( canConvert ) {
  287. nsCOMPtr<nsISupports> dataBytes;
  288. uint32_t len;
  289. data.GetData(getter_AddRefs(dataBytes), &len);
  290. if (len == kFlavorHasDataProvider && dataBytes) {
  291. // do we have a data provider?
  292. nsCOMPtr<nsIFlavorDataProvider> dataProvider = do_QueryInterface(dataBytes);
  293. if (dataProvider) {
  294. rv = dataProvider->GetFlavorData(this, aFlavor,
  295. getter_AddRefs(dataBytes), &len);
  296. if (NS_FAILED(rv))
  297. break; // give up
  298. }
  299. }
  300. mFormatConv->Convert(data.GetFlavor().get(), dataBytes, len, aFlavor, aData, aDataLen);
  301. found = true;
  302. break;
  303. }
  304. }
  305. }
  306. // for backward compatibility
  307. if (!found) {
  308. savedData.forget(aData);
  309. *aDataLen = 0;
  310. }
  311. return found ? NS_OK : NS_ERROR_FAILURE;
  312. }
  313. //
  314. // GetAnyTransferData
  315. //
  316. // Returns the data of the first flavor found. Caller is responsible for deleting the
  317. // flavor string.
  318. //
  319. NS_IMETHODIMP
  320. nsTransferable::GetAnyTransferData(nsACString& aFlavor, nsISupports **aData,
  321. uint32_t *aDataLen)
  322. {
  323. MOZ_ASSERT(mInitialized);
  324. NS_ENSURE_ARG_POINTER(aData && aDataLen);
  325. for (size_t i = 0; i < mDataArray.Length(); ++i) {
  326. DataStruct& data = mDataArray.ElementAt(i);
  327. if (data.IsDataAvailable()) {
  328. aFlavor.Assign(data.GetFlavor());
  329. data.GetData(aData, aDataLen);
  330. return NS_OK;
  331. }
  332. }
  333. return NS_ERROR_FAILURE;
  334. }
  335. //
  336. // SetTransferData
  337. //
  338. //
  339. //
  340. NS_IMETHODIMP
  341. nsTransferable::SetTransferData(const char *aFlavor, nsISupports *aData, uint32_t aDataLen)
  342. {
  343. MOZ_ASSERT(mInitialized);
  344. NS_ENSURE_ARG(aFlavor);
  345. // first check our intrinsic flavors to see if one has been registered.
  346. for (size_t i = 0; i < mDataArray.Length(); ++i) {
  347. DataStruct& data = mDataArray.ElementAt(i);
  348. if ( data.GetFlavor().Equals(aFlavor) ) {
  349. data.SetData ( aData, aDataLen, mPrivateData );
  350. return NS_OK;
  351. }
  352. }
  353. // if not, try using a format converter to find a flavor to put the data in
  354. if ( mFormatConv ) {
  355. for (size_t i = 0; i < mDataArray.Length(); ++i) {
  356. DataStruct& data = mDataArray.ElementAt(i);
  357. bool canConvert = false;
  358. mFormatConv->CanConvert(aFlavor, data.GetFlavor().get(), &canConvert);
  359. if ( canConvert ) {
  360. nsCOMPtr<nsISupports> ConvertedData;
  361. uint32_t ConvertedLen;
  362. mFormatConv->Convert(aFlavor, aData, aDataLen, data.GetFlavor().get(), getter_AddRefs(ConvertedData), &ConvertedLen);
  363. data.SetData(ConvertedData, ConvertedLen, mPrivateData);
  364. return NS_OK;
  365. }
  366. }
  367. }
  368. // Can't set data neither directly nor through converter. Just add this flavor and try again
  369. nsresult result = NS_ERROR_FAILURE;
  370. if ( NS_SUCCEEDED(AddDataFlavor(aFlavor)) )
  371. result = SetTransferData (aFlavor, aData, aDataLen);
  372. return result;
  373. }
  374. //
  375. // AddDataFlavor
  376. //
  377. // Adds a data flavor to our list with no data. Error if it already exists.
  378. //
  379. NS_IMETHODIMP
  380. nsTransferable::AddDataFlavor(const char *aDataFlavor)
  381. {
  382. MOZ_ASSERT(mInitialized);
  383. if (GetDataForFlavor (mDataArray, aDataFlavor) != mDataArray.NoIndex)
  384. return NS_ERROR_FAILURE;
  385. // Create a new "slot" for the data
  386. mDataArray.AppendElement(DataStruct ( aDataFlavor ));
  387. return NS_OK;
  388. }
  389. //
  390. // RemoveDataFlavor
  391. //
  392. // Removes a data flavor (and causes the data to be destroyed). Error if
  393. // the requested flavor is not present.
  394. //
  395. NS_IMETHODIMP
  396. nsTransferable::RemoveDataFlavor(const char *aDataFlavor)
  397. {
  398. MOZ_ASSERT(mInitialized);
  399. size_t idx = GetDataForFlavor(mDataArray, aDataFlavor);
  400. if (idx != mDataArray.NoIndex) {
  401. mDataArray.RemoveElementAt (idx);
  402. return NS_OK;
  403. }
  404. return NS_ERROR_FAILURE;
  405. }
  406. /**
  407. *
  408. *
  409. */
  410. NS_IMETHODIMP
  411. nsTransferable::IsLargeDataSet(bool *_retval)
  412. {
  413. MOZ_ASSERT(mInitialized);
  414. NS_ENSURE_ARG_POINTER(_retval);
  415. *_retval = false;
  416. return NS_OK;
  417. }
  418. /**
  419. *
  420. *
  421. */
  422. NS_IMETHODIMP nsTransferable::SetConverter(nsIFormatConverter * aConverter)
  423. {
  424. MOZ_ASSERT(mInitialized);
  425. mFormatConv = aConverter;
  426. return NS_OK;
  427. }
  428. /**
  429. *
  430. *
  431. */
  432. NS_IMETHODIMP nsTransferable::GetConverter(nsIFormatConverter * *aConverter)
  433. {
  434. MOZ_ASSERT(mInitialized);
  435. NS_ENSURE_ARG_POINTER(aConverter);
  436. *aConverter = mFormatConv;
  437. NS_IF_ADDREF(*aConverter);
  438. return NS_OK;
  439. }
  440. //
  441. // FlavorsTransferableCanImport
  442. //
  443. // Computes a list of flavors that the transferable can accept into it, either through
  444. // intrinsic knowledge or input data converters.
  445. //
  446. NS_IMETHODIMP
  447. nsTransferable::FlavorsTransferableCanImport(nsIArray **_retval)
  448. {
  449. MOZ_ASSERT(mInitialized);
  450. NS_ENSURE_ARG_POINTER(_retval);
  451. // Get the flavor list, and on to the end of it, append the list of flavors we
  452. // can also get to through a converter. This is so that we can just walk the list
  453. // in one go, looking for the desired flavor.
  454. nsCOMPtr<nsIMutableArray> array = GetTransferDataFlavors();
  455. nsCOMPtr<nsIFormatConverter> converter;
  456. GetConverter(getter_AddRefs(converter));
  457. if ( converter ) {
  458. nsCOMPtr<nsIArray> convertedList;
  459. converter->GetInputDataFlavors(getter_AddRefs(convertedList));
  460. if ( convertedList ) {
  461. uint32_t importListLen;
  462. convertedList->GetLength(&importListLen);
  463. for (uint32_t i = 0; i < importListLen; ++i ) {
  464. nsCOMPtr<nsISupportsCString> flavorWrapper =
  465. do_QueryElementAt(convertedList, i);
  466. nsAutoCString flavorStr;
  467. flavorWrapper->GetData( flavorStr );
  468. if (GetDataForFlavor (mDataArray, flavorStr.get())
  469. == mDataArray.NoIndex) // Don't append if already in intrinsic list
  470. array->AppendElement (flavorWrapper, /*weak =*/ false);
  471. } // foreach flavor that can be converted to
  472. }
  473. } // if a converter exists
  474. array.forget(_retval);
  475. return NS_OK;
  476. } // FlavorsTransferableCanImport
  477. //
  478. // FlavorsTransferableCanExport
  479. //
  480. // Computes a list of flavors that the transferable can export, either through
  481. // intrinsic knowledge or output data converters.
  482. //
  483. NS_IMETHODIMP
  484. nsTransferable::FlavorsTransferableCanExport(nsIArray **_retval)
  485. {
  486. MOZ_ASSERT(mInitialized);
  487. NS_ENSURE_ARG_POINTER(_retval);
  488. // Get the flavor list, and on to the end of it, append the list of flavors we
  489. // can also get to through a converter. This is so that we can just walk the list
  490. // in one go, looking for the desired flavor.
  491. nsCOMPtr<nsIMutableArray> array = GetTransferDataFlavors();
  492. nsCOMPtr<nsIFormatConverter> converter;
  493. GetConverter(getter_AddRefs(converter));
  494. if ( converter ) {
  495. nsCOMPtr<nsIArray> convertedList;
  496. converter->GetOutputDataFlavors(getter_AddRefs(convertedList));
  497. if ( convertedList ) {
  498. uint32_t importListLen;
  499. convertedList->GetLength(&importListLen);
  500. for ( uint32_t i=0; i < importListLen; ++i ) {
  501. nsCOMPtr<nsISupportsCString> flavorWrapper =
  502. do_QueryElementAt(convertedList, i);
  503. nsAutoCString flavorStr;
  504. flavorWrapper->GetData( flavorStr );
  505. if (GetDataForFlavor (mDataArray, flavorStr.get())
  506. == mDataArray.NoIndex) // Don't append if already in intrinsic list
  507. array->AppendElement (flavorWrapper, /*weak =*/ false);
  508. } // foreach flavor that can be converted to
  509. }
  510. } // if a converter exists
  511. array.forget(_retval);
  512. return NS_OK;
  513. } // FlavorsTransferableCanExport
  514. NS_IMETHODIMP
  515. nsTransferable::GetIsPrivateData(bool *aIsPrivateData)
  516. {
  517. MOZ_ASSERT(mInitialized);
  518. NS_ENSURE_ARG_POINTER(aIsPrivateData);
  519. *aIsPrivateData = mPrivateData;
  520. return NS_OK;
  521. }
  522. NS_IMETHODIMP
  523. nsTransferable::SetIsPrivateData(bool aIsPrivateData)
  524. {
  525. MOZ_ASSERT(mInitialized);
  526. mPrivateData = aIsPrivateData;
  527. return NS_OK;
  528. }
  529. NS_IMETHODIMP
  530. nsTransferable::GetRequestingPrincipal(nsIPrincipal** outRequestingPrincipal)
  531. {
  532. NS_IF_ADDREF(*outRequestingPrincipal = mRequestingPrincipal);
  533. return NS_OK;
  534. }
  535. NS_IMETHODIMP
  536. nsTransferable::SetRequestingPrincipal(nsIPrincipal* aRequestingPrincipal)
  537. {
  538. mRequestingPrincipal = aRequestingPrincipal;
  539. return NS_OK;
  540. }
  541. NS_IMETHODIMP
  542. nsTransferable::GetContentPolicyType(nsContentPolicyType* outContentPolicyType)
  543. {
  544. NS_ENSURE_ARG_POINTER(outContentPolicyType);
  545. *outContentPolicyType = mContentPolicyType;
  546. return NS_OK;
  547. }
  548. NS_IMETHODIMP
  549. nsTransferable::SetContentPolicyType(nsContentPolicyType aContentPolicyType)
  550. {
  551. mContentPolicyType = aContentPolicyType;
  552. return NS_OK;
  553. }