LCOV - code coverage report
Current view: directory - dom/base - nsContentPermissionHelper.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 69 0 0.0 %
Date: 2012-06-02 Functions: 19 0 0.0 %

       1                 : /* ***** BEGIN LICENSE BLOCK *****
       2                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       3                 :  *
       4                 :  * The contents of this file are subject to the Mozilla Public License Version
       5                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       6                 :  * the License. You may obtain a copy of the License at
       7                 :  * http://www.mozilla.org/MPL/
       8                 :  *
       9                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      10                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      11                 :  * for the specific language governing rights and limitations under the
      12                 :  * License.
      13                 :  *
      14                 :  * The Original Code is mozilla.org code.
      15                 :  *
      16                 :  * The Initial Developer of the Original Code is
      17                 :  *  The Mozilla Foundation
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *  Doug Turner <dougt@mozilla.com>  (Original Author)
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #include "nsContentPermissionHelper.h"
      39                 : #include "nsIContentPermissionPrompt.h"
      40                 : #include "nsCOMPtr.h"
      41                 : #include "nsIDOMWindow.h"
      42                 : #include "nsIDOMElement.h"
      43                 : 
      44                 : #include "mozilla/unused.h"
      45                 : 
      46                 : using mozilla::unused;          // <snicker>
      47                 : 
      48               0 : nsContentPermissionRequestProxy::nsContentPermissionRequestProxy()
      49                 : {
      50               0 :   MOZ_COUNT_CTOR(nsContentPermissionRequestProxy);
      51               0 : }
      52                 : 
      53               0 : nsContentPermissionRequestProxy::~nsContentPermissionRequestProxy()
      54                 : {
      55               0 :   MOZ_COUNT_DTOR(nsContentPermissionRequestProxy);
      56               0 : }
      57                 : 
      58                 : nsresult
      59               0 : nsContentPermissionRequestProxy::Init(const nsACString & type,
      60                 :                                                       mozilla::dom::ContentPermissionRequestParent* parent)
      61                 : {
      62               0 :   NS_ASSERTION(parent, "null parent");
      63               0 :   mParent = parent;
      64               0 :   mType   = type;
      65                 : 
      66               0 :   nsCOMPtr<nsIContentPermissionPrompt> prompt = do_GetService(NS_CONTENT_PERMISSION_PROMPT_CONTRACTID);
      67               0 :   if (!prompt) {
      68               0 :     return NS_ERROR_FAILURE;
      69                 :   }
      70                 : 
      71               0 :   prompt->Prompt(this);
      72               0 :   return NS_OK;
      73                 : }
      74                 : 
      75                 : void
      76               0 : nsContentPermissionRequestProxy::OnParentDestroyed()
      77                 : {
      78               0 :   mParent = nsnull;
      79               0 : }
      80                 : 
      81               0 : NS_IMPL_ISUPPORTS1(nsContentPermissionRequestProxy, nsIContentPermissionRequest);
      82                 : 
      83                 : NS_IMETHODIMP
      84               0 : nsContentPermissionRequestProxy::GetType(nsACString & aType)
      85                 : {
      86               0 :   aType = mType;
      87               0 :   return NS_OK;
      88                 : }
      89                 : 
      90                 : NS_IMETHODIMP
      91               0 : nsContentPermissionRequestProxy::GetWindow(nsIDOMWindow * *aRequestingWindow)
      92                 : {
      93               0 :   NS_ENSURE_ARG_POINTER(aRequestingWindow);
      94               0 :   *aRequestingWindow = nsnull; // ipc doesn't have a window
      95               0 :   return NS_OK;
      96                 : }
      97                 : 
      98                 : NS_IMETHODIMP
      99               0 : nsContentPermissionRequestProxy::GetUri(nsIURI * *aRequestingURI)
     100                 : {
     101               0 :   NS_ENSURE_ARG_POINTER(aRequestingURI);
     102               0 :   if (mParent == nsnull)
     103               0 :     return NS_ERROR_FAILURE;
     104                 : 
     105               0 :   NS_ADDREF(*aRequestingURI = mParent->mURI);
     106               0 :   return NS_OK;
     107                 : }
     108                 : 
     109                 : NS_IMETHODIMP
     110               0 : nsContentPermissionRequestProxy::GetElement(nsIDOMElement * *aRequestingElement)
     111                 : {
     112               0 :   NS_ENSURE_ARG_POINTER(aRequestingElement);
     113               0 :   if (mParent == nsnull)
     114               0 :     return NS_ERROR_FAILURE;
     115               0 :   NS_ADDREF(*aRequestingElement = mParent->mElement);
     116               0 :   return NS_OK;
     117                 : }
     118                 : 
     119                 : NS_IMETHODIMP
     120               0 : nsContentPermissionRequestProxy::Cancel()
     121                 : {
     122               0 :   if (mParent == nsnull)
     123               0 :     return NS_ERROR_FAILURE;
     124               0 :   unused << mozilla::dom::ContentPermissionRequestParent::Send__delete__(mParent, false);
     125               0 :   mParent = nsnull;
     126               0 :   return NS_OK;
     127                 : }
     128                 : 
     129                 : NS_IMETHODIMP
     130               0 : nsContentPermissionRequestProxy::Allow()
     131                 : {
     132               0 :   if (mParent == nsnull)
     133               0 :     return NS_ERROR_FAILURE;
     134               0 :   unused << mozilla::dom::ContentPermissionRequestParent::Send__delete__(mParent, true);
     135               0 :   mParent = nsnull;
     136               0 :   return NS_OK;
     137                 : }
     138                 : 
     139                 : namespace mozilla {
     140                 : namespace dom {
     141                 : 
     142               0 : ContentPermissionRequestParent::ContentPermissionRequestParent(const nsACString& aType,
     143                 :                                                                nsIDOMElement *aElement,
     144               0 :                                                                const IPC::URI& aUri)
     145                 : {
     146               0 :   MOZ_COUNT_CTOR(ContentPermissionRequestParent);
     147                 :   
     148               0 :   mURI       = aUri;
     149               0 :   mElement   = aElement;
     150               0 :   mType      = aType;
     151               0 : }
     152                 : 
     153               0 : ContentPermissionRequestParent::~ContentPermissionRequestParent()
     154                 : {
     155               0 :   MOZ_COUNT_DTOR(ContentPermissionRequestParent);
     156               0 : }
     157                 : 
     158                 : bool
     159               0 : ContentPermissionRequestParent::Recvprompt()
     160                 : {
     161               0 :   mProxy = new nsContentPermissionRequestProxy();
     162               0 :   NS_ASSERTION(mProxy, "Alloc of request proxy failed");
     163               0 :   if (NS_FAILED(mProxy->Init(mType, this)))
     164               0 :     mProxy->Cancel();
     165               0 :   return true;
     166                 : }
     167                 : 
     168                 : void
     169               0 : ContentPermissionRequestParent::ActorDestroy(ActorDestroyReason why)
     170                 : {
     171               0 :   mProxy->OnParentDestroyed();
     172               0 : }
     173                 : 
     174                 : } // namespace dom
     175                 : } // namespace mozilla

Generated by: LCOV version 1.7