dom/base/DOMError.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "mozilla/dom/DOMError.h"
     8 #include "mozilla/dom/DOMErrorBinding.h"
     9 #include "mozilla/dom/DOMException.h"
    10 #include "nsPIDOMWindow.h"
    12 namespace mozilla {
    13 namespace dom {
    15 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DOMError, mWindow)
    16 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMError)
    17 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMError)
    18 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMError)
    19   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
    20   NS_INTERFACE_MAP_ENTRY(nsISupports)
    21 NS_INTERFACE_MAP_END
    23 DOMError::DOMError(nsPIDOMWindow* aWindow)
    24   : mWindow(aWindow)
    25 {
    26   SetIsDOMBinding();
    27 }
    29 DOMError::DOMError(nsPIDOMWindow* aWindow, nsresult aValue)
    30   : mWindow(aWindow)
    31 {
    32   nsCString name, message;
    33   NS_GetNameAndMessageForDOMNSResult(aValue, name, message);
    35   CopyUTF8toUTF16(name, mName);
    36   CopyUTF8toUTF16(message, mMessage);
    38   SetIsDOMBinding();
    39 }
    41 DOMError::DOMError(nsPIDOMWindow* aWindow, const nsAString& aName)
    42   : mWindow(aWindow)
    43   , mName(aName)
    44 {
    45   SetIsDOMBinding();
    46 }
    48 DOMError::DOMError(nsPIDOMWindow* aWindow, const nsAString& aName,
    49                    const nsAString& aMessage)
    50   : mWindow(aWindow)
    51   , mName(aName)
    52   , mMessage(aMessage)
    53 {
    54   SetIsDOMBinding();
    55 }
    57 DOMError::~DOMError()
    58 {
    59 }
    61 JSObject*
    62 DOMError::WrapObject(JSContext* aCx)
    63 {
    64   return DOMErrorBinding::Wrap(aCx, this);
    65 }
    67 /* static */ already_AddRefed<DOMError>
    68 DOMError::Constructor(const GlobalObject& aGlobal,
    69                       const nsAString& aName, const nsAString& aMessage,
    70                       ErrorResult& aRv)
    71 {
    72   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
    74   // Window is null for chrome code.
    76   nsRefPtr<DOMError> ret = new DOMError(window, aName, aMessage);
    77   return ret.forget();
    78 }
    80 } // namespace dom
    81 } // namespace mozilla

mercurial