dom/workers/Navigator.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     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 #ifndef mozilla_dom_workers_navigator_h__
     7 #define mozilla_dom_workers_navigator_h__
     9 #include "Workers.h"
    10 #include "RuntimeService.h"
    11 #include "nsString.h"
    12 #include "nsWrapperCache.h"
    14 BEGIN_WORKERS_NAMESPACE
    16 class WorkerNavigator MOZ_FINAL : public nsWrapperCache
    17 {
    18   typedef struct RuntimeService::NavigatorProperties NavigatorProperties;
    20   NavigatorProperties mProperties;
    21   bool mOnline;
    23   WorkerNavigator(const NavigatorProperties& aProperties,
    24                   bool aOnline)
    25     : mProperties(aProperties)
    26     , mOnline(aOnline)
    27   {
    28     MOZ_COUNT_CTOR(WorkerNavigator);
    29     SetIsDOMBinding();
    30   }
    32 public:
    34   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerNavigator)
    35   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WorkerNavigator)
    37   static already_AddRefed<WorkerNavigator>
    38   Create(bool aOnLine);
    40   virtual JSObject*
    41   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    43   nsISupports* GetParentObject() const {
    44     return nullptr;
    45   }
    47   ~WorkerNavigator()
    48   {
    49     MOZ_COUNT_DTOR(WorkerNavigator);
    50   }
    52   void GetAppCodeName(nsString& aAppCodeName) const
    53   {
    54     aAppCodeName.AssignLiteral("Mozilla");
    55   }
    56   void GetAppName(nsString& aAppName) const;
    58   void GetAppVersion(nsString& aAppVersion) const;
    60   void GetPlatform(nsString& aPlatform) const;
    62   void GetProduct(nsString& aProduct) const
    63   {
    64     aProduct.AssignLiteral("Gecko");
    65   }
    67   bool TaintEnabled() const
    68   {
    69     return false;
    70   }
    72   void GetUserAgent(nsString& aUserAgent) const
    73   {
    74     aUserAgent = mProperties.mUserAgent;
    75   }
    77   bool OnLine() const
    78   {
    79     return mOnline;
    80   }
    82   // Worker thread only!
    83   void SetOnLine(bool aOnline)
    84   {
    85     mOnline = aOnline;
    86   }
    87 };
    89 END_WORKERS_NAMESPACE
    91 #endif // mozilla_dom_workers_navigator_h__

mercurial