widget/cocoa/nsPrintOptionsX.mm

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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/. */
     6 #include "nsCOMPtr.h"
     7 #include "nsIServiceManager.h"
     8 #include "nsPrintOptionsX.h"
     9 #include "nsPrintSettingsX.h"
    11 nsPrintOptionsX::nsPrintOptionsX()
    12 {
    13 }
    15 nsPrintOptionsX::~nsPrintOptionsX()
    16 {
    17 }
    19 nsresult
    20 nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, uint32_t aFlags)
    21 {
    22   nsresult rv;
    24   rv = nsPrintOptions::ReadPrefs(aPS, aPrinterName, aFlags);
    25   NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed");
    27   nsRefPtr<nsPrintSettingsX> printSettingsX(do_QueryObject(aPS));
    28   if (!printSettingsX)
    29     return NS_ERROR_NO_INTERFACE;
    30   rv = printSettingsX->ReadPageFormatFromPrefs();
    32   return rv;
    33 }
    35 nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval)
    36 {
    37   nsresult rv;
    38   *_retval = nullptr;
    40   nsPrintSettingsX* printSettings = new nsPrintSettingsX; // does not initially ref count
    41   NS_ENSURE_TRUE(printSettings, NS_ERROR_OUT_OF_MEMORY);
    42   NS_ADDREF(*_retval = printSettings);
    44   rv = printSettings->Init();
    45   if (NS_FAILED(rv)) {
    46     NS_RELEASE(*_retval);
    47     return rv;
    48   }
    50   InitPrintSettingsFromPrefs(*_retval, false, nsIPrintSettings::kInitSaveAll);
    51   return rv;
    52 }
    54 nsresult
    55 nsPrintOptionsX::WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, uint32_t aFlags)
    56 {
    57   nsresult rv;
    59   rv = nsPrintOptions::WritePrefs(aPS, aPrinterName, aFlags);
    60   NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed");
    62   nsRefPtr<nsPrintSettingsX> printSettingsX(do_QueryObject(aPS));
    63   if (!printSettingsX)
    64     return NS_ERROR_NO_INTERFACE;
    65   rv = printSettingsX->WritePageFormatToPrefs();
    66   NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintSettingsX::WritePageFormatToPrefs() failed");
    68   return NS_OK;
    69 }

mercurial