blob: 4b5d8e4670c77ba4700716f5c63392bef90df377 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* Copyright © Christopher Blizzard
* Copyright © 2006 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* ---------------------------------------------------------------------------
* Derived from Mozilla.org code, which had the following attributions:
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright © Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright © 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* ---------------------------------------------------------------------------
*
* $Id$
*/
#include <mozilla-config.h>
#include <config.h>
#include <stdlib.h>
#include "nsIDocShell.h"
#include "nsIWebProgress.h"
#include "nsIWebBrowserStream.h"
#include "nsIWidget.h"
// all of our local includes
#include "GeckoSingle.h"
#include "EmbedWindow.h"
#include "gecko-init.h"
#include "gecko-init-private.h"
GSList *GeckoSingle::sWindowList = nsnull;
PRUint32 GeckoSingle::sWidgetCount = 0;
GeckoSingle::GeckoSingle()
{
}
GeckoSingle::~GeckoSingle()
{
}
/* static */
GeckoBrowser *
GeckoSingle::FindPrivateForBrowser(nsIWebBrowserChrome *aBrowser)
{
// This function doesn't get called very often at all ( only when
// creating a new window ) so it's OK to walk the list of open
// windows.
for (GSList *l = sWindowList; l != NULL; l = l->next) {
GeckoBrowser *tmpPrivate = static_cast<GeckoBrowser *>(l->data);
// get the browser object for that window
nsIWebBrowserChrome *chrome = static_cast<nsIWebBrowserChrome *>
(tmpPrivate->mWindow);
if (chrome == aBrowser)
return tmpPrivate;
}
return nsnull;
}
/* static */
void
GeckoSingle::ReparentToOffscreen (GtkWidget* aWidget)
{
gecko_reparent_to_offscreen (aWidget);
}
/* static */
void
GeckoSingle::AddBrowser(GeckoBrowser *aBrowser)
{
PushStartup();
sWindowList = g_slist_prepend (sWindowList, aBrowser);
}
/* static */
void
GeckoSingle::RemoveBrowser(GeckoBrowser *aBrowser)
{
sWindowList = g_slist_remove (sWindowList, aBrowser);
PopStartup();
}
/* static */
void
GeckoSingle::PushStartup()
{
GeckoSingle::sWidgetCount++;
}
/* static */
void
GeckoSingle::PopStartup()
{
GeckoSingle::sWidgetCount--;
if (GeckoSingle::sWidgetCount == 0) {
gecko_shutdown();
#ifdef XPCOM_GLUE
XPCOMGlueShutdown();
#endif
}
}
|