Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / embedding / browser / activex / src / plugin / XPCBrowser.cpp
blob269b50bd716e88360fd70b771e75e9f503ba123a
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Adam Lock <adamlock@netscape.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "StdAfx.h"
41 #include "npapi.h"
43 #include "nsCOMPtr.h"
44 #include "nsIInterfaceRequestorUtils.h"
45 #include "nsServiceManagerUtils.h"
46 #include "nsStringAPI.h"
47 #include "nsIPrefBranch.h"
48 #include "nsIPrefService.h"
49 #include "nsMemory.h"
52 #include "XPCBrowser.h"
55 IEBrowser::IEBrowser()
59 IEBrowser::~IEBrowser()
63 HRESULT IEBrowser::Init(PluginInstanceData *pData)
65 mData = pData;
66 // Get the location URL
67 NPN_GetValue(mData->pPluginInstance, NPNVDOMWindow,
68 static_cast<nsIDOMWindow **>(getter_AddRefs(mDOMWindow)));
69 if (mDOMWindow)
71 mWebNavigation = do_GetInterface(mDOMWindow);
73 return S_OK;
77 nsresult IEBrowser::GetWebNavigation(nsIWebNavigation **aWebNav)
79 NS_ENSURE_ARG_POINTER(aWebNav);
80 *aWebNav = mWebNavigation;
81 NS_IF_ADDREF(*aWebNav);
82 return (*aWebNav) ? NS_OK : NS_ERROR_FAILURE;
85 // Return the nsIDOMWindow object
86 nsresult IEBrowser::GetDOMWindow(nsIDOMWindow **aDOMWindow)
88 NS_ENSURE_ARG_POINTER(aDOMWindow);
89 *aDOMWindow = mDOMWindow;
90 NS_IF_ADDREF(*aDOMWindow);
91 return (*aDOMWindow) ? NS_OK : NS_ERROR_FAILURE;
94 // Return the nsIPrefBranch object
95 nsresult IEBrowser::GetPrefs(nsIPrefBranch **aPrefBranch)
97 return CallGetService(NS_PREFSERVICE_CONTRACTID, aPrefBranch);
100 // Return the valid state of the browser
101 PRBool IEBrowser::BrowserIsValid()
103 return mWebNavigation ? PR_TRUE : PR_FALSE;