Tue, 06 Jan 2015 21:39:09 +0100
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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "mozilla/dom/CommandEvent.h" |
michael@0 | 7 | #include "mozilla/MiscEvents.h" |
michael@0 | 8 | #include "prtime.h" |
michael@0 | 9 | |
michael@0 | 10 | namespace mozilla { |
michael@0 | 11 | namespace dom { |
michael@0 | 12 | |
michael@0 | 13 | CommandEvent::CommandEvent(EventTarget* aOwner, |
michael@0 | 14 | nsPresContext* aPresContext, |
michael@0 | 15 | WidgetCommandEvent* aEvent) |
michael@0 | 16 | : Event(aOwner, aPresContext, |
michael@0 | 17 | aEvent ? aEvent : |
michael@0 | 18 | new WidgetCommandEvent(false, nullptr, nullptr, nullptr)) |
michael@0 | 19 | { |
michael@0 | 20 | mEvent->time = PR_Now(); |
michael@0 | 21 | if (aEvent) { |
michael@0 | 22 | mEventIsInternal = false; |
michael@0 | 23 | } else { |
michael@0 | 24 | mEventIsInternal = true; |
michael@0 | 25 | } |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | NS_INTERFACE_MAP_BEGIN(CommandEvent) |
michael@0 | 29 | NS_INTERFACE_MAP_ENTRY(nsIDOMCommandEvent) |
michael@0 | 30 | NS_INTERFACE_MAP_END_INHERITING(Event) |
michael@0 | 31 | |
michael@0 | 32 | NS_IMPL_ADDREF_INHERITED(CommandEvent, Event) |
michael@0 | 33 | NS_IMPL_RELEASE_INHERITED(CommandEvent, Event) |
michael@0 | 34 | |
michael@0 | 35 | NS_IMETHODIMP |
michael@0 | 36 | CommandEvent::GetCommand(nsAString& aCommand) |
michael@0 | 37 | { |
michael@0 | 38 | nsIAtom* command = mEvent->AsCommandEvent()->command; |
michael@0 | 39 | if (command) { |
michael@0 | 40 | command->ToString(aCommand); |
michael@0 | 41 | } else { |
michael@0 | 42 | aCommand.Truncate(); |
michael@0 | 43 | } |
michael@0 | 44 | return NS_OK; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | NS_IMETHODIMP |
michael@0 | 48 | CommandEvent::InitCommandEvent(const nsAString& aTypeArg, |
michael@0 | 49 | bool aCanBubbleArg, |
michael@0 | 50 | bool aCancelableArg, |
michael@0 | 51 | const nsAString& aCommand) |
michael@0 | 52 | { |
michael@0 | 53 | nsresult rv = Event::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg); |
michael@0 | 54 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 55 | |
michael@0 | 56 | mEvent->AsCommandEvent()->command = do_GetAtom(aCommand); |
michael@0 | 57 | return NS_OK; |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | } // namespace dom |
michael@0 | 61 | } // namespace mozilla |
michael@0 | 62 | |
michael@0 | 63 | using namespace mozilla; |
michael@0 | 64 | using namespace mozilla::dom; |
michael@0 | 65 | |
michael@0 | 66 | nsresult |
michael@0 | 67 | NS_NewDOMCommandEvent(nsIDOMEvent** aInstancePtrResult, |
michael@0 | 68 | EventTarget* aOwner, |
michael@0 | 69 | nsPresContext* aPresContext, |
michael@0 | 70 | WidgetCommandEvent* aEvent) |
michael@0 | 71 | { |
michael@0 | 72 | CommandEvent* it = new CommandEvent(aOwner, aPresContext, aEvent); |
michael@0 | 73 | NS_ADDREF(it); |
michael@0 | 74 | *aInstancePtrResult = static_cast<Event*>(it); |
michael@0 | 75 | return NS_OK; |
michael@0 | 76 | } |