LCOV - code coverage report
Current view: directory - image/decoders/icon - nsIconProtocolHandler.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 36 15 41.7 %
Date: 2012-06-02 Functions: 12 8 66.7 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2                 :  *
       3                 :  * ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is mozilla.org code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  * Brian Ryner.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 2000
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   Scott MacGregor <mscott@netscape.com>
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : #include "nsIconChannel.h"
      41                 : #include "nsIconURI.h"
      42                 : #include "nsIconProtocolHandler.h"
      43                 : #include "nsIURL.h"
      44                 : #include "nsCRT.h"
      45                 : #include "nsCOMPtr.h"
      46                 : #include "nsIComponentManager.h"
      47                 : #include "nsIServiceManager.h"
      48                 : #include "nsNetCID.h"
      49                 : 
      50                 : ////////////////////////////////////////////////////////////////////////////////
      51                 : 
      52            1419 : nsIconProtocolHandler::nsIconProtocolHandler() 
      53                 : {
      54            1419 : }
      55                 : 
      56            2838 : nsIconProtocolHandler::~nsIconProtocolHandler() 
      57            5676 : {}
      58                 : 
      59           31740 : NS_IMPL_ISUPPORTS2(nsIconProtocolHandler, nsIProtocolHandler, nsISupportsWeakReference)
      60                 : 
      61                 :     
      62                 : ////////////////////////////////////////////////////////////////////////////////
      63                 : // nsIProtocolHandler methods:
      64                 : 
      65               0 : NS_IMETHODIMP nsIconProtocolHandler::GetScheme(nsACString &result) 
      66                 : {
      67               0 :   result = "moz-icon";
      68               0 :   return NS_OK;
      69                 : }
      70                 : 
      71               0 : NS_IMETHODIMP nsIconProtocolHandler::GetDefaultPort(PRInt32 *result) 
      72                 : {
      73               0 :   *result = 0;
      74               0 :   return NS_OK;
      75                 : }
      76                 : 
      77               0 : NS_IMETHODIMP nsIconProtocolHandler::AllowPort(PRInt32 port, const char *scheme, bool *_retval)
      78                 : {
      79                 :     // don't override anything.  
      80               0 :     *_retval = false;
      81               0 :     return NS_OK;
      82                 : }
      83                 : 
      84            1624 : NS_IMETHODIMP nsIconProtocolHandler::GetProtocolFlags(PRUint32 *result)
      85                 : {
      86                 :   *result = URI_NORELATIVE | URI_NOAUTH | URI_IS_UI_RESOURCE |
      87            1624 :             URI_IS_LOCAL_RESOURCE;
      88            1624 :   return NS_OK;
      89                 : }
      90                 : 
      91            1634 : NS_IMETHODIMP nsIconProtocolHandler::NewURI(const nsACString &aSpec,
      92                 :                                             const char *aOriginCharset, // ignored
      93                 :                                             nsIURI *aBaseURI,
      94                 :                                             nsIURI **result) 
      95                 : {
      96                 :   
      97            3268 :   nsCOMPtr<nsIURI> uri = new nsMozIconURI();
      98            1634 :   if (!uri) return NS_ERROR_OUT_OF_MEMORY;
      99                 : 
     100            1634 :   nsresult rv = uri->SetSpec(aSpec);
     101            1634 :   if (NS_FAILED(rv)) return rv;
     102                 : 
     103            1630 :   NS_ADDREF(*result = uri);
     104            1630 :   return NS_OK;
     105                 : }
     106                 : 
     107               0 : NS_IMETHODIMP nsIconProtocolHandler::NewChannel(nsIURI* url, nsIChannel* *result)
     108                 : {
     109               0 :   NS_ENSURE_ARG_POINTER(url);
     110               0 :   nsIconChannel* channel = new nsIconChannel;
     111               0 :   if (!channel)
     112               0 :     return NS_ERROR_OUT_OF_MEMORY;
     113               0 :   NS_ADDREF(channel);
     114                 : 
     115               0 :   nsresult rv = channel->Init(url);
     116               0 :   if (NS_FAILED(rv)) {
     117               0 :     NS_RELEASE(channel);
     118               0 :     return rv;
     119                 :   }
     120                 : 
     121               0 :   *result = channel;
     122               0 :   return NS_OK;
     123                 : }
     124                 : 
     125                 : ////////////////////////////////////////////////////////////////////////////////

Generated by: LCOV version 1.7