dom/telephony/Telephony.h

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=8 sts=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
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef mozilla_dom_telephony_telephony_h__
     8 #define mozilla_dom_telephony_telephony_h__
    10 #include "mozilla/dom/BindingDeclarations.h"
    11 #include "mozilla/dom/Promise.h"
    12 #include "mozilla/dom/telephony/TelephonyCommon.h"
    14 #include "nsITelephonyProvider.h"
    16 // Need to include TelephonyCall.h because we have inline methods that
    17 // assume they see the definition of TelephonyCall.
    18 #include "TelephonyCall.h"
    20 class nsPIDOMWindow;
    22 namespace mozilla {
    23 namespace dom {
    25 class OwningTelephonyCallOrTelephonyCallGroup;
    27 class Telephony MOZ_FINAL : public DOMEventTargetHelper
    28 {
    29   /**
    30    * Class Telephony doesn't actually inherit nsITelephonyListener.
    31    * Instead, it owns an nsITelephonyListener derived instance mListener
    32    * and passes it to nsITelephonyProvider. The onreceived events are first
    33    * delivered to mListener and then forwarded to its owner, Telephony. See
    34    * also bug 775997 comment #51.
    35    */
    36   class Listener;
    38   class Callback;
    39   friend class Callback;
    41   class EnumerationAck;
    42   friend class EnumerationAck;
    44   nsCOMPtr<nsITelephonyProvider> mProvider;
    45   nsRefPtr<Listener> mListener;
    47   TelephonyCall* mActiveCall;
    48   nsTArray<nsRefPtr<TelephonyCall> > mCalls;
    49   nsRefPtr<CallsList> mCallsList;
    51   nsRefPtr<TelephonyCallGroup> mGroup;
    53   bool mEnumerated;
    55 public:
    56   NS_DECL_ISUPPORTS_INHERITED
    57   NS_DECL_NSITELEPHONYLISTENER
    58   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
    59   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(Telephony,
    60                                            DOMEventTargetHelper)
    62   nsPIDOMWindow*
    63   GetParentObject() const
    64   {
    65     return GetOwner();
    66   }
    68   // WrapperCache
    69   virtual JSObject*
    70   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    72   // WebIDL
    73   already_AddRefed<Promise>
    74   Dial(const nsAString& aNumber, const Optional<uint32_t>& aServiceId);
    76   already_AddRefed<Promise>
    77   DialEmergency(const nsAString& aNumber, const Optional<uint32_t>& aServiceId);
    79   void
    80   StartTone(const nsAString& aDTMFChar, const Optional<uint32_t>& aServiceId,
    81             ErrorResult& aRv);
    83   void
    84   StopTone(const Optional<uint32_t>& aServiceId, ErrorResult& aRv);
    86   bool
    87   GetMuted(ErrorResult& aRv) const;
    89   void
    90   SetMuted(bool aMuted, ErrorResult& aRv);
    92   bool
    93   GetSpeakerEnabled(ErrorResult& aRv) const;
    95   void
    96   SetSpeakerEnabled(bool aEnabled, ErrorResult& aRv);
    98   void
    99   GetActive(Nullable<OwningTelephonyCallOrTelephonyCallGroup>& aValue);
   101   already_AddRefed<CallsList>
   102   Calls() const;
   104   already_AddRefed<TelephonyCallGroup>
   105   ConferenceGroup() const;
   107   IMPL_EVENT_HANDLER(incoming)
   108   IMPL_EVENT_HANDLER(callschanged)
   109   IMPL_EVENT_HANDLER(remoteheld)
   110   IMPL_EVENT_HANDLER(remoteresumed)
   112   static already_AddRefed<Telephony>
   113   Create(nsPIDOMWindow* aOwner, ErrorResult& aRv);
   115   void
   116   AddCall(TelephonyCall* aCall)
   117   {
   118     NS_ASSERTION(!mCalls.Contains(aCall), "Already know about this one!");
   119     mCalls.AppendElement(aCall);
   120     UpdateActiveCall(aCall, IsActiveState(aCall->CallState()));
   121     NotifyCallsChanged(aCall);
   122   }
   124   void
   125   RemoveCall(TelephonyCall* aCall)
   126   {
   127     NS_ASSERTION(mCalls.Contains(aCall), "Didn't know about this one!");
   128     mCalls.RemoveElement(aCall);
   129     UpdateActiveCall(aCall, false);
   130     NotifyCallsChanged(aCall);
   131   }
   133   nsITelephonyProvider*
   134   Provider() const
   135   {
   136     return mProvider;
   137   }
   139   const nsTArray<nsRefPtr<TelephonyCall> >&
   140   CallsArray() const
   141   {
   142     return mCalls;
   143   }
   145   virtual void EventListenerAdded(nsIAtom* aType) MOZ_OVERRIDE;
   147 private:
   148   Telephony(nsPIDOMWindow* aOwner);
   149   ~Telephony();
   151   void
   152   Shutdown();
   154   static bool
   155   IsValidNumber(const nsAString& aNumber);
   157   static uint32_t
   158   GetNumServices();
   160   static bool
   161   IsValidServiceId(uint32_t aServiceId);
   163   static bool
   164   IsActiveState(uint16_t aCallState);
   166   uint32_t
   167   ProvidedOrDefaultServiceId(const Optional<uint32_t>& aServiceId);
   169   bool
   170   HasDialingCall();
   172   bool
   173   MatchActiveCall(TelephonyCall* aCall);
   175   already_AddRefed<Promise>
   176   DialInternal(uint32_t aServiceId, const nsAString& aNumber, bool isEmergency);
   178   already_AddRefed<TelephonyCall>
   179   CreateNewDialingCall(uint32_t aServiceId, const nsAString& aNumber);
   181   nsresult
   182   NotifyCallsChanged(TelephonyCall* aCall);
   184   nsresult
   185   DispatchCallEvent(const nsAString& aType, TelephonyCall* aCall);
   187   void
   188   EnqueueEnumerationAck();
   190   void
   191   UpdateActiveCall(TelephonyCall* aCall, bool aIsActive);
   193   already_AddRefed<TelephonyCall>
   194   GetCall(uint32_t aServiceId, uint32_t aCallIndex);
   196   already_AddRefed<TelephonyCall>
   197   GetOutgoingCall();
   199   already_AddRefed<TelephonyCall>
   200   GetCallFromEverywhere(uint32_t aServiceId, uint32_t aCallIndex);
   201 };
   203 } // namespace dom
   204 } // namespace mozilla
   206 #endif // mozilla_dom_telephony_telephony_h__

mercurial