2011-07-17 12:09:13 -07:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-01-06 22:21:26 -08:00
|
|
|
|
2011-07-17 12:09:13 -07:00
|
|
|
#ifndef mozilla_dom_workers_navigator_h__
|
|
|
|
#define mozilla_dom_workers_navigator_h__
|
|
|
|
|
|
|
|
#include "Workers.h"
|
2014-09-23 12:11:18 -07:00
|
|
|
#include "RuntimeService.h"
|
2013-09-23 10:25:00 -07:00
|
|
|
#include "nsString.h"
|
2013-09-29 21:15:37 -07:00
|
|
|
#include "nsWrapperCache.h"
|
2011-07-17 12:09:13 -07:00
|
|
|
|
2014-02-24 05:57:15 -08:00
|
|
|
// Need this to use Navigator::HasDataStoreSupport() in
|
|
|
|
// WorkerNavigatorBinding.cpp
|
|
|
|
#include "mozilla/dom/Navigator.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Promise;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-17 12:09:13 -07:00
|
|
|
BEGIN_WORKERS_NAMESPACE
|
|
|
|
|
2013-09-29 21:15:37 -07:00
|
|
|
class WorkerNavigator MOZ_FINAL : public nsWrapperCache
|
2013-07-24 00:38:23 -07:00
|
|
|
{
|
2014-09-23 12:11:18 -07:00
|
|
|
typedef struct RuntimeService::NavigatorProperties NavigatorProperties;
|
|
|
|
|
|
|
|
NavigatorProperties mProperties;
|
2013-11-19 15:08:50 -08:00
|
|
|
bool mOnline;
|
2013-07-24 00:38:23 -07:00
|
|
|
|
2014-09-23 12:11:18 -07:00
|
|
|
WorkerNavigator(const NavigatorProperties& aProperties,
|
2013-11-19 15:08:50 -08:00
|
|
|
bool aOnline)
|
2014-09-23 12:11:18 -07:00
|
|
|
: mProperties(aProperties)
|
2013-11-19 15:08:50 -08:00
|
|
|
, mOnline(aOnline)
|
2013-07-24 00:38:23 -07:00
|
|
|
{
|
2013-09-29 21:15:37 -07:00
|
|
|
MOZ_COUNT_CTOR(WorkerNavigator);
|
2013-07-24 00:38:23 -07:00
|
|
|
}
|
|
|
|
|
2014-06-23 12:56:07 -07:00
|
|
|
~WorkerNavigator()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(WorkerNavigator);
|
|
|
|
}
|
|
|
|
|
2013-07-24 00:38:23 -07:00
|
|
|
public:
|
2013-09-29 21:15:37 -07:00
|
|
|
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WorkerNavigator)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WorkerNavigator)
|
|
|
|
|
2013-07-24 00:38:23 -07:00
|
|
|
static already_AddRefed<WorkerNavigator>
|
2013-11-19 15:08:50 -08:00
|
|
|
Create(bool aOnLine);
|
2013-07-24 00:38:23 -07:00
|
|
|
|
2013-09-29 21:15:37 -07:00
|
|
|
virtual JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 07:13:33 -07:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) MOZ_OVERRIDE;
|
2011-07-17 12:09:13 -07:00
|
|
|
|
2013-09-29 21:15:37 -07:00
|
|
|
nsISupports* GetParentObject() const {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2011-07-17 12:09:13 -07:00
|
|
|
|
2013-11-20 06:29:01 -08:00
|
|
|
void GetAppCodeName(nsString& aAppCodeName) const
|
|
|
|
{
|
|
|
|
aAppCodeName.AssignLiteral("Mozilla");
|
|
|
|
}
|
2014-09-23 12:11:18 -07:00
|
|
|
void GetAppName(nsString& aAppName) const;
|
2013-11-19 15:08:50 -08:00
|
|
|
|
2014-09-23 12:11:18 -07:00
|
|
|
void GetAppVersion(nsString& aAppVersion) const;
|
|
|
|
|
|
|
|
void GetPlatform(nsString& aPlatform) const;
|
2013-11-19 15:08:50 -08:00
|
|
|
|
2013-11-20 06:29:01 -08:00
|
|
|
void GetProduct(nsString& aProduct) const
|
|
|
|
{
|
|
|
|
aProduct.AssignLiteral("Gecko");
|
|
|
|
}
|
2014-09-23 12:11:18 -07:00
|
|
|
|
2013-11-20 06:29:01 -08:00
|
|
|
bool TaintEnabled() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-11-19 15:08:50 -08:00
|
|
|
|
2014-09-05 07:26:34 -07:00
|
|
|
void GetLanguage(nsString& aLanguage) const
|
|
|
|
{
|
2014-09-23 12:11:18 -07:00
|
|
|
if (mProperties.mLanguages.Length() >= 1) {
|
|
|
|
aLanguage.Assign(mProperties.mLanguages[0]);
|
2014-09-05 07:26:34 -07:00
|
|
|
} else {
|
|
|
|
aLanguage.Truncate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetLanguages(nsTArray<nsString>& aLanguages) const
|
|
|
|
{
|
2014-09-23 12:11:18 -07:00
|
|
|
aLanguages = mProperties.mLanguages;
|
2014-09-05 07:26:34 -07:00
|
|
|
}
|
|
|
|
|
2014-09-24 09:09:50 -07:00
|
|
|
void GetUserAgent(nsString& aUserAgent) const;
|
2013-11-19 15:08:50 -08:00
|
|
|
|
|
|
|
bool OnLine() const
|
|
|
|
{
|
|
|
|
return mOnline;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Worker thread only!
|
|
|
|
void SetOnLine(bool aOnline)
|
|
|
|
{
|
|
|
|
mOnline = aOnline;
|
|
|
|
}
|
2014-02-24 05:57:15 -08:00
|
|
|
|
2014-09-05 07:26:34 -07:00
|
|
|
void SetLanguages(const nsTArray<nsString>& aLanguages);
|
|
|
|
|
2014-02-24 05:57:15 -08:00
|
|
|
already_AddRefed<Promise> GetDataStores(JSContext* aCx,
|
|
|
|
const nsAString& aName,
|
2014-07-16 20:53:23 -07:00
|
|
|
const nsAString& aOwner,
|
2014-02-24 05:57:15 -08:00
|
|
|
ErrorResult& aRv);
|
2013-09-29 19:41:23 -07:00
|
|
|
};
|
2013-09-29 21:15:37 -07:00
|
|
|
|
2011-07-17 12:09:13 -07:00
|
|
|
END_WORKERS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_workers_navigator_h__
|