1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/base/nsContentPermissionHelper.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,84 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef nsContentPermissionHelper_h 1.9 +#define nsContentPermissionHelper_h 1.10 + 1.11 +#include "nsIContentPermissionPrompt.h" 1.12 +#include "nsTArray.h" 1.13 +#include "nsIMutableArray.h" 1.14 + 1.15 +class nsContentPermissionRequestProxy; 1.16 + 1.17 +// Forward declare IPC::Principal here which is defined in 1.18 +// PermissionMessageUtils.h. Include this file will transitively includes 1.19 +// "windows.h" and it defines 1.20 +// #define CreateEvent CreateEventW 1.21 +// #define LoadImage LoadImageW 1.22 +// That will mess up windows build. 1.23 +namespace IPC { 1.24 +class Principal; 1.25 +} 1.26 + 1.27 +namespace mozilla { 1.28 +namespace dom { 1.29 + 1.30 +class Element; 1.31 +class PermissionRequest; 1.32 +class ContentPermissionRequestParent; 1.33 +class PContentPermissionRequestParent; 1.34 + 1.35 +class ContentPermissionType : public nsIContentPermissionType 1.36 +{ 1.37 +public: 1.38 + NS_DECL_ISUPPORTS 1.39 + NS_DECL_NSICONTENTPERMISSIONTYPE 1.40 + 1.41 + ContentPermissionType(const nsACString& aType, 1.42 + const nsACString& aAccess, 1.43 + const nsTArray<nsString>& aOptions); 1.44 + virtual ~ContentPermissionType(); 1.45 + 1.46 +protected: 1.47 + nsCString mType; 1.48 + nsCString mAccess; 1.49 + nsTArray<nsString> mOptions; 1.50 +}; 1.51 + 1.52 +uint32_t ConvertPermissionRequestToArray(nsTArray<PermissionRequest>& aSrcArray, 1.53 + nsIMutableArray* aDesArray); 1.54 + 1.55 +nsresult CreatePermissionArray(const nsACString& aType, 1.56 + const nsACString& aAccess, 1.57 + const nsTArray<nsString>& aOptions, 1.58 + nsIArray** aTypesArray); 1.59 + 1.60 +PContentPermissionRequestParent* 1.61 +CreateContentPermissionRequestParent(const nsTArray<PermissionRequest>& aRequests, 1.62 + Element* element, 1.63 + const IPC::Principal& principal); 1.64 + 1.65 +} // namespace dom 1.66 +} // namespace mozilla 1.67 + 1.68 +class nsContentPermissionRequestProxy : public nsIContentPermissionRequest 1.69 +{ 1.70 + public: 1.71 + NS_DECL_ISUPPORTS 1.72 + NS_DECL_NSICONTENTPERMISSIONREQUEST 1.73 + 1.74 + nsContentPermissionRequestProxy(); 1.75 + virtual ~nsContentPermissionRequestProxy(); 1.76 + 1.77 + nsresult Init(const nsTArray<mozilla::dom::PermissionRequest>& requests, 1.78 + mozilla::dom::ContentPermissionRequestParent* parent); 1.79 + void OnParentDestroyed(); 1.80 + 1.81 + private: 1.82 + // Non-owning pointer to the ContentPermissionRequestParent object which owns this proxy. 1.83 + mozilla::dom::ContentPermissionRequestParent* mParent; 1.84 + nsTArray<mozilla::dom::PermissionRequest> mPermissionRequests; 1.85 +}; 1.86 + 1.87 +#endif // nsContentPermissionHelper_h