~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/dom/src/base/nsGlobalWindow.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
2
/* ***** BEGIN LICENSE BLOCK *****
 
3
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
 
4
 *
 
5
 * The contents of this file are subject to the Netscape Public License
 
6
 * Version 1.1 (the "License"); you may not use this file except in
 
7
 * compliance with the License. You may obtain a copy of the License at
 
8
 * http://www.mozilla.org/NPL/
 
9
 *
 
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.
 
14
 *
 
15
 * The Original Code is mozilla.org code.
 
16
 *
 
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.
 
21
 *
 
22
 * Contributor(s):
 
23
 *   Travis Bogard <travis@netscape.com>
 
24
 *   Dan Rosen <dr@netscape.com>
 
25
 *   Vidur Apparao <vidur@netscape.com>
 
26
 *   Johnny Stenback <jst@netscape.com>
 
27
 *
 
28
 *
 
29
 * Alternatively, the contents of this file may be used under the terms of
 
30
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
31
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
32
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
33
 * of those above. If you wish to allow use of your version of this file only
 
34
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
35
 * use your version of this file under the terms of the NPL, indicate your
 
36
 * decision by deleting the provisions above and replace them with the notice
 
37
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
38
 * the provisions above, a recipient may use your version of this file under
 
39
 * the terms of any one of the NPL, the GPL or the LGPL.
 
40
 *
 
41
 * ***** END LICENSE BLOCK ***** */
 
42
 
 
43
#ifndef nsGlobalWindow_h___
 
44
#define nsGlobalWindow_h___
 
45
 
 
46
// Local Includes
 
47
// Helper Classes
 
48
#include "nsCOMPtr.h"
 
49
#include "nsAutoPtr.h"
 
50
#include "nsWeakReference.h"
 
51
#include "nsHashtable.h"
 
52
 
 
53
// Interfaces Needed
 
54
#include "nsDOMWindowList.h"
 
55
#include "nsIBaseWindow.h"
 
56
#include "nsIBrowserDOMWindow.h"
 
57
#include "nsIChromeEventHandler.h"
 
58
#include "nsIControllers.h"
 
59
#include "nsIObserver.h"
 
60
#include "nsIDocShellTreeOwner.h"
 
61
#include "nsIDocShellTreeItem.h"
 
62
#include "nsIDOMViewCSS.h"
 
63
#include "nsIDOMEventReceiver.h"
 
64
#include "nsIDOM3EventTarget.h"
 
65
#include "nsIDOMNavigator.h"
 
66
#include "nsIDOMNSLocation.h"
 
67
#include "nsIDOMWindowInternal.h"
 
68
#include "nsIInterfaceRequestor.h"
 
69
#include "nsIInterfaceRequestorUtils.h"
 
70
#include "nsIDOMJSWindow.h"
 
71
#include "nsIDOMChromeWindow.h"
 
72
#include "nsIScriptGlobalObject.h"
 
73
#include "nsIScriptObjectPrincipal.h"
 
74
#include "nsITimer.h"
 
75
#include "nsIWebBrowserChrome.h"
 
76
#include "nsPIDOMWindow.h"
 
77
#include "nsIScriptSecurityManager.h"
 
78
#include "nsIEventListenerManager.h"
 
79
#include "nsIDOMDocument.h"
 
80
#include "nsIDOMCrypto.h"
 
81
#include "nsIDOMPkcs11.h"
 
82
#include "nsIPrincipal.h"
 
83
#include "nsPluginArray.h"
 
84
#include "nsMimeTypeArray.h"
 
85
#include "nsIXPCScriptable.h"
 
86
#include "nsPoint.h"
 
87
#include "nsSize.h"
 
88
 
 
89
#define DEFAULT_HOME_PAGE "www.mozilla.org"
 
90
#define PREF_BROWSER_STARTUP_HOMEPAGE "browser.startup.homepage"
 
91
 
 
92
class nsIDOMBarProp;
 
93
class nsIDocument;
 
94
class nsIContent;
 
95
class nsIPresContext;
 
96
class nsIDOMEvent;
 
97
class nsIScrollableView;
 
98
 
 
99
typedef struct nsTimeoutImpl nsTimeoutImpl;
 
100
 
 
101
class BarPropImpl;
 
102
class LocationImpl;
 
103
class NavigatorImpl;
 
104
class ScreenImpl;
 
105
class HistoryImpl;
 
106
class nsIDocShellLoadInfo;
 
107
 
 
108
//*****************************************************************************
 
109
// GlobalWindowImpl: Global Object for Scripting
 
110
//*****************************************************************************
 
111
// Beware that all scriptable interfaces implemented by
 
112
// GlobalWindowImpl will be reachable from JS, if you make this class
 
113
// implement new interfaces you better know what you're
 
114
// doing. Security wise this is very sensitive code. --
 
115
// jst@netscape.com
 
116
 
 
117
 
 
118
class GlobalWindowImpl : public nsIScriptGlobalObject,
 
119
                         public nsIDOMWindowInternal,
 
120
                         public nsIDOMJSWindow,
 
121
                         public nsIScriptObjectPrincipal,
 
122
                         public nsIDOMEventReceiver,
 
123
                         public nsIDOM3EventTarget,
 
124
                         public nsPIDOMWindow,
 
125
                         public nsIDOMViewCSS,
 
126
                         public nsSupportsWeakReference,
 
127
                         public nsIInterfaceRequestor
 
128
{
 
129
public:
 
130
  // nsISupports
 
131
  NS_DECL_ISUPPORTS
 
132
 
 
133
  // nsIScriptGlobalObject
 
134
  virtual void SetContext(nsIScriptContext *aContext);
 
135
  virtual nsIScriptContext *GetContext();
 
136
  virtual nsresult SetNewDocument(nsIDOMDocument *aDocument,
 
137
                                  PRBool aRemoveEventListeners,
 
138
                                  PRBool aClearScopeHint);
 
139
  virtual void SetDocShell(nsIDocShell* aDocShell);
 
140
  virtual nsIDocShell *GetDocShell();
 
141
  virtual void SetOpenerWindow(nsIDOMWindowInternal *aOpener);
 
142
  virtual void SetGlobalObjectOwner(nsIScriptGlobalObjectOwner* aOwner);
 
143
  virtual nsIScriptGlobalObjectOwner *GetGlobalObjectOwner();
 
144
  virtual nsresult HandleDOMEvent(nsIPresContext* aPresContext,
 
145
                                  nsEvent* aEvent, nsIDOMEvent** aDOMEvent,
 
146
                                  PRUint32 aFlags,
 
147
                                  nsEventStatus* aEventStatus);
 
148
  virtual JSObject *GetGlobalJSObject();
 
149
  virtual void OnFinalize(JSObject *aJSObject);
 
150
  virtual void SetScriptsEnabled(PRBool aEnabled, PRBool aFireTimeouts);
 
151
 
 
152
  // nsIScriptObjectPrincipal
 
153
  NS_IMETHOD GetPrincipalObsolete(nsIPrincipalObsolete **prin);
 
154
  NS_IMETHOD GetPrincipal(nsIPrincipal **prin);
 
155
 
 
156
  // nsIDOMWindow
 
157
  NS_DECL_NSIDOMWINDOW
 
158
 
 
159
  // nsIDOMWindow2
 
160
  NS_DECL_NSIDOMWINDOW2
 
161
 
 
162
  // nsIDOMWindowInternal
 
163
  NS_DECL_NSIDOMWINDOWINTERNAL
 
164
 
 
165
  // nsIDOMJSWindow
 
166
  NS_DECL_NSIDOMJSWINDOW
 
167
 
 
168
  // nsIDOMEventTarget
 
169
  NS_DECL_NSIDOMEVENTTARGET
 
170
 
 
171
  // nsIDOM3EventTarget
 
172
  NS_DECL_NSIDOM3EVENTTARGET
 
173
 
 
174
  // nsIDOMEventReceiver
 
175
  NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener,
 
176
                                   const nsIID& aIID);
 
177
  NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener,
 
178
                                      const nsIID& aIID);
 
179
  NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
 
180
  NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
 
181
  NS_IMETHOD GetSystemEventGroup(nsIDOMEventGroup** aGroup);
 
182
 
 
183
  // nsPIDOMWindow
 
184
  NS_IMETHOD GetPrivateParent(nsPIDOMWindow** aResult);
 
185
  NS_IMETHOD GetPrivateRoot(nsIDOMWindowInternal** aResult);
 
186
  NS_IMETHOD GetObjectProperty(const PRUnichar* aProperty,
 
187
                               nsISupports** aObject);
 
188
  NS_IMETHOD Activate();
 
189
  NS_IMETHOD Deactivate();
 
190
  NS_IMETHOD GetChromeEventHandler(nsIChromeEventHandler** aHandler);
 
191
  NS_IMETHOD HasMutationListeners(PRUint32 aMutationEventType,
 
192
                                  PRBool* aResult);
 
193
  NS_IMETHOD SetMutationListeners(PRUint32 aEventType);
 
194
  NS_IMETHOD GetRootFocusController(nsIFocusController** aResult);
 
195
  NS_IMETHOD GetExtantDocument(nsIDOMDocument** aDocument);
 
196
 
 
197
  NS_IMETHOD ReallyCloseWindow();
 
198
  NS_IMETHOD IsLoadingOrRunningTimeout(PRBool* aResult);
 
199
  NS_IMETHOD IsPopupSpamWindow(PRBool *aResult);
 
200
  NS_IMETHOD SetPopupSpamWindow(PRBool aPopup);
 
201
 
 
202
  NS_IMETHOD GetFrameElementInternal(nsIDOMElement** aFrameElement);
 
203
  NS_IMETHOD SetFrameElementInternal(nsIDOMElement* aFrameElement);
 
204
  NS_IMETHOD SetOpenerScriptURL(nsIURI* aURI);
 
205
 
 
206
  virtual NS_HIDDEN_(PopupControlState) PushPopupControlState(PopupControlState state) const;
 
207
  virtual NS_HIDDEN_(void) PopPopupControlState(PopupControlState state) const;
 
208
  virtual NS_HIDDEN_(PopupControlState) GetPopupControlState() const;
 
209
  virtual NS_HIDDEN_(OpenAllowValue) GetOpenAllow(const nsAString &aName);
 
210
  virtual NS_HIDDEN_(PRBool) IsHandlingResizeEvent() const;
 
211
 
 
212
  // nsIDOMViewCSS
 
213
  NS_DECL_NSIDOMVIEWCSS
 
214
 
 
215
  // nsIDOMAbstractView
 
216
  NS_DECL_NSIDOMABSTRACTVIEW
 
217
 
 
218
  // nsIInterfaceRequestor
 
219
  NS_DECL_NSIINTERFACEREQUESTOR
 
220
 
 
221
  // Object Management
 
222
  GlobalWindowImpl();
 
223
 
 
224
  static void ShutDown();
 
225
  static PRBool IsCallerChrome();
 
226
 
 
227
protected:
 
228
  // Object Management
 
229
  virtual ~GlobalWindowImpl();
 
230
  void CleanUp();
 
231
  void ClearControllers();
 
232
 
 
233
  // Get the parent, returns null if this is a toplevel window
 
234
  nsIDOMWindowInternal *GetParentInternal();
 
235
 
 
236
  // Window Control Functions
 
237
  NS_IMETHOD OpenInternal(const nsAString& aUrl,
 
238
                          const nsAString& aName,
 
239
                          const nsAString& aOptions,
 
240
                          PRBool aDialog, jsval *argv, PRUint32 argc,
 
241
                          nsISupports *aExtraArgument, nsIDOMWindow **aReturn);
 
242
  static void CloseWindow(nsISupports* aWindow);
 
243
 
 
244
  // Timeout Functions
 
245
  nsresult SetTimeoutOrInterval(PRBool aIsInterval, PRInt32* aReturn);
 
246
  void RunTimeout(nsTimeoutImpl *aTimeout);
 
247
  nsresult ClearTimeoutOrInterval();
 
248
  void ClearAllTimeouts();
 
249
  void InsertTimeoutIntoList(nsTimeoutImpl **aInsertionPoint,
 
250
                             nsTimeoutImpl *aTimeout);
 
251
  static void TimerCallback(nsITimer *aTimer, void *aClosure);
 
252
 
 
253
  // Helper Functions
 
254
  nsresult GetTreeOwner(nsIDocShellTreeOwner** aTreeOwner);
 
255
  nsresult GetTreeOwner(nsIBaseWindow** aTreeOwner);
 
256
  nsresult GetWebBrowserChrome(nsIWebBrowserChrome** aBrowserChrome);
 
257
  nsresult GetScrollInfo(nsIScrollableView** aScrollableView, float* aP2T,
 
258
                         float* aT2P);
 
259
  nsresult SecurityCheckURL(const char *aURL);
 
260
  nsresult BuildURIfromBase(const char *aURL,
 
261
                            nsIURI **aBuiltURI,
 
262
                            PRBool *aFreeSecurityPass, JSContext **aCXused);
 
263
  PopupControlState CheckForAbusePoint();
 
264
  OpenAllowValue CheckOpenAllow(PopupControlState aAbuseLevel,
 
265
                          const nsAString &aName);
 
266
  void     FireAbuseEvents(PRBool aBlocked, PRBool aWindow,
 
267
                           const nsAString &aPopupURL,
 
268
                           const nsAString &aPopupWindowFeatures);
 
269
 
 
270
  void FlushPendingNotifications(PRBool aFlushReflows);
 
271
  void EnsureReflowFlushAndPaint();
 
272
  nsresult CheckSecurityWidthAndHeight(PRInt32* width, PRInt32* height);
 
273
  nsresult CheckSecurityLeftAndTop(PRInt32* left, PRInt32* top);
 
274
  static nsresult CheckSecurityIsChromeCaller(PRBool *isChrome);
 
275
  static PRBool CanSetProperty(const char *aPrefName);
 
276
 
 
277
  void MakeScriptDialogTitle(const nsAString &aInTitle, nsAString &aOutTitle);
 
278
 
 
279
  // Helper for window.find()
 
280
  nsresult FindInternal(const nsAString& aStr, PRBool caseSensitive,
 
281
                       PRBool backwards, PRBool wrapAround, PRBool wholeWord, 
 
282
                       PRBool searchInFrames, PRBool showDialog, 
 
283
                       PRBool *aReturn);
 
284
 
 
285
  nsresult ConvertCharset(const nsAString& aStr, char** aDest);
 
286
 
 
287
  PRBool   GetBlurSuppression();
 
288
 
 
289
  nsresult GetScrollXY(PRInt32* aScrollX, PRInt32* aScrollY);
 
290
  nsresult GetScrollMaxXY(PRInt32* aScrollMaxX, PRInt32* aScrollMaxY);
 
291
 
 
292
  PRBool IsFrame()
 
293
  {
 
294
    return GetParentInternal() != nsnull;
 
295
  }
 
296
 
 
297
  PRBool DispatchCustomEvent(const char *aEventName);
 
298
 
 
299
  // When adding new member variables, be careful not to create cycles
 
300
  // through JavaScript.  If there is any chance that a member variable
 
301
  // could own objects that are implemented in JavaScript, then those
 
302
  // objects will keep the global object (this object) alive.  To prevent
 
303
  // these cycles, ownership of such members must be released in
 
304
  // |CleanUp| and |SetDocShell|.
 
305
  nsCOMPtr<nsIScriptContext>    mContext;
 
306
  nsCOMPtr<nsIDOMDocument>      mDocument;
 
307
  nsCOMPtr<nsIDOMWindowInternal> mOpener;
 
308
  nsCOMPtr<nsIControllers>      mControllers;
 
309
  nsCOMPtr<nsIEventListenerManager> mListenerManager;
 
310
  JSObject*                     mJSObject;
 
311
  nsRefPtr<NavigatorImpl>       mNavigator;
 
312
  nsRefPtr<ScreenImpl>          mScreen;
 
313
  nsRefPtr<HistoryImpl>         mHistory;
 
314
  nsRefPtr<nsDOMWindowList>     mFrames;
 
315
  nsRefPtr<LocationImpl>        mLocation;
 
316
  nsRefPtr<BarPropImpl>         mMenubar;
 
317
  nsRefPtr<BarPropImpl>         mToolbar;
 
318
  nsRefPtr<BarPropImpl>         mLocationbar;
 
319
  nsRefPtr<BarPropImpl>         mPersonalbar;
 
320
  nsRefPtr<BarPropImpl>         mStatusbar;
 
321
  nsRefPtr<BarPropImpl>         mScrollbars;
 
322
  nsCOMPtr<nsIWeakReference>    mWindowUtils;
 
323
  nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow; // held for DOMWindowUtils
 
324
  nsTimeoutImpl*                mTimeouts;
 
325
  nsTimeoutImpl**               mTimeoutInsertionPoint;
 
326
  nsTimeoutImpl*                mRunningTimeout;
 
327
  PRUint32                      mTimeoutPublicIdCounter;
 
328
  PRUint32                      mTimeoutFiringDepth;
 
329
  PRPackedBool                  mFirstDocumentLoad;
 
330
  PRPackedBool                  mIsScopeClear;
 
331
  PRPackedBool                  mIsDocumentLoaded; // true between onload and onunload events
 
332
  PRPackedBool                  mFullScreen;
 
333
  PRPackedBool                  mIsClosed;
 
334
  PRPackedBool                  mOpenerWasCleared;
 
335
  PRPackedBool                  mIsPopupSpam;
 
336
  PRPackedBool                  mIsHandlingResizeEvent;
 
337
  nsString                      mStatus;
 
338
  nsString                      mDefaultStatus;
 
339
 
 
340
  nsIScriptGlobalObjectOwner*   mGlobalObjectOwner; // Weak Reference
 
341
  nsIDocShell*                  mDocShell;  // Weak Reference
 
342
  nsEvent*                      mCurrentEvent;
 
343
  PRUint32                      mMutationBits;
 
344
  nsCOMPtr<nsIChromeEventHandler> mChromeEventHandler; // [Strong] We break it when we get torn down.
 
345
  nsCOMPtr<nsIDOMCrypto>        mCrypto;
 
346
  nsCOMPtr<nsIDOMPkcs11>        mPkcs11;
 
347
  nsCOMPtr<nsIPrincipal>        mDocumentPrincipal;
 
348
  nsCOMPtr<nsIURI>              mOpenerScriptURL; // Used to determine whether to clear scope
 
349
 
 
350
  // XXX We need mNavigatorHolder because we make two SetNewDocument()
 
351
  // calls when transitioning from page to page. This keeps a reference
 
352
  // to the JSObject holder for the navigator object in between
 
353
  // SetNewDocument() calls so that the JSObject doesn't get garbage
 
354
  // collected in between these calls.
 
355
  // See bug 163645 for more on why we need this and bug 209607 for info
 
356
  // on how we can remove the need for this.
 
357
  nsCOMPtr<nsIXPConnectJSObjectHolder> mNavigatorHolder;
 
358
 
 
359
  nsIDOMElement*                mFrameElement; // WEAK
 
360
 
 
361
  friend class nsDOMScriptableHelper;
 
362
  friend class nsDOMWindowUtils;
 
363
  static nsIXPConnect *sXPConnect;
 
364
  static nsIScriptSecurityManager *sSecMan;
 
365
  static nsIFactory *sComputedDOMStyleFactory;
 
366
};
 
367
 
 
368
/*
 
369
 * nsGlobalChromeWindow inherits from GlobalWindowImpl. It is the global
 
370
 * object created for a Chrome Window only.
 
371
 */
 
372
class nsGlobalChromeWindow : public GlobalWindowImpl,
 
373
                             public nsIDOMChromeWindow
 
374
{
 
375
public:
 
376
  // nsISupports
 
377
  NS_DECL_ISUPPORTS_INHERITED
 
378
 
 
379
  // nsIDOMChromeWindow interface
 
380
  NS_DECL_NSIDOMCHROMEWINDOW
 
381
 
 
382
protected:
 
383
  nsresult GetMainWidget(nsIWidget** aMainWidget);
 
384
 
 
385
  nsString mTitle;
 
386
};
 
387
 
 
388
/*
 
389
 * Timeout struct that holds information about each JavaScript
 
390
 * timeout.
 
391
 */
 
392
struct nsTimeoutImpl
 
393
{
 
394
  nsTimeoutImpl()
 
395
  {
 
396
#ifdef DEBUG_jst
 
397
    {
 
398
      extern PRInt32 gTimeoutCnt;
 
399
 
 
400
      ++gTimeoutCnt;
 
401
    }
 
402
#endif
 
403
 
 
404
    memset(this, 0, sizeof(*this));
 
405
 
 
406
    MOZ_COUNT_CTOR(nsTimeoutImpl);
 
407
  }
 
408
 
 
409
  ~nsTimeoutImpl()
 
410
  {
 
411
#ifdef DEBUG_jst
 
412
    {
 
413
      extern PRInt32 gTimeoutCnt;
 
414
 
 
415
      --gTimeoutCnt;
 
416
    }
 
417
#endif
 
418
 
 
419
    MOZ_COUNT_DTOR(nsTimeoutImpl);
 
420
  }
 
421
 
 
422
  void Release(nsIScriptContext* aContext);
 
423
  void AddRef();
 
424
 
 
425
  // Window for which this timeout fires
 
426
  GlobalWindowImpl *mWindow;
 
427
 
 
428
  // The JS expression to evaluate or function to call, if !mExpr
 
429
  JSString *mExpr;
 
430
  JSObject *mFunObj;
 
431
 
 
432
  // The actual timer object
 
433
  nsCOMPtr<nsITimer> mTimer;
 
434
 
 
435
  // Function actual arguments and argument count
 
436
  jsval *mArgv;
 
437
  PRUint16 mArgc;
 
438
 
 
439
  // True if the timeout was cleared
 
440
  PRPackedBool mCleared;
 
441
 
 
442
  // True if this is one of the timeouts that are currently running
 
443
  PRPackedBool mRunning;
 
444
 
 
445
  // Returned as value of setTimeout()
 
446
  PRUint32 mPublicId;
 
447
 
 
448
  // Non-zero if repetitive timeout
 
449
  PRInt32 mInterval;
 
450
 
 
451
  // Nominal time to run this timeout
 
452
  PRInt64 mWhen;
 
453
 
 
454
  // Principal with which to execute
 
455
  nsCOMPtr<nsIPrincipal> mPrincipal;
 
456
 
 
457
  // filename, line number and JS language version string of the
 
458
  // caller of setTimeout()
 
459
  char *mFileName;
 
460
  PRUint32 mLineNo;
 
461
  const char *mVersion;
 
462
 
 
463
  // stack depth at which timeout is firing
 
464
  PRUint32 mFiringDepth;
 
465
 
 
466
  // Pointer to the next timeout in the linked list of scheduled
 
467
  // timeouts
 
468
  nsTimeoutImpl *mNext;
 
469
 
 
470
  // The popup state at timeout creation time if not created from
 
471
  // another timeout
 
472
  PopupControlState mPopupState;
 
473
 
 
474
private:
 
475
  // reference count for shared usage
 
476
  PRInt32 mRefCnt;
 
477
};
 
478
 
 
479
//*****************************************************************************
 
480
// NavigatorImpl: Script "navigator" object
 
481
//*****************************************************************************
 
482
 
 
483
class NavigatorImpl : public nsIDOMNavigator,
 
484
                      public nsIDOMJSNavigator
 
485
{
 
486
public:
 
487
  NavigatorImpl(nsIDocShell *aDocShell);
 
488
  virtual ~NavigatorImpl();
 
489
 
 
490
  NS_DECL_ISUPPORTS
 
491
  NS_DECL_NSIDOMNAVIGATOR
 
492
  NS_DECL_NSIDOMJSNAVIGATOR
 
493
  
 
494
  void SetDocShell(nsIDocShell *aDocShell);
 
495
  void LoadingNewDocument();
 
496
  nsresult RefreshMIMEArray();
 
497
 
 
498
protected:
 
499
  nsRefPtr<MimeTypeArrayImpl> mMimeTypes;
 
500
  nsRefPtr<PluginArrayImpl> mPlugins;
 
501
  nsIDocShell* mDocShell; // weak reference
 
502
 
 
503
  static jsval       sPrefInternal_id;
 
504
};
 
505
 
 
506
class nsIURI;
 
507
 
 
508
//*****************************************************************************
 
509
// LocationImpl: Script "location" object
 
510
//*****************************************************************************
 
511
 
 
512
class LocationImpl : public nsIDOMLocation,
 
513
                     public nsIDOMNSLocation
 
514
{
 
515
public:
 
516
  LocationImpl(nsIDocShell *aDocShell);
 
517
  virtual ~LocationImpl();
 
518
 
 
519
  NS_DECL_ISUPPORTS
 
520
 
 
521
  void SetDocShell(nsIDocShell *aDocShell);
 
522
 
 
523
  // nsIDOMLocation
 
524
  NS_DECL_NSIDOMLOCATION
 
525
 
 
526
  // nsIDOMNSLocation
 
527
  NS_DECL_NSIDOMNSLOCATION
 
528
 
 
529
protected:
 
530
  // In the case of jar: uris, we sometimes want the place the jar was
 
531
  // fetched from as the URI instead of the jar: uri itself.  Pass in
 
532
  // PR_TRUE for aGetInnermostURI when that's the case.
 
533
  nsresult GetURI(nsIURI** aURL, PRBool aGetInnermostURI = PR_FALSE);
 
534
  nsresult GetWritableURI(nsIURI** aURL);
 
535
  nsresult SetURI(nsIURI* aURL);
 
536
  nsresult SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
 
537
                           PRBool aReplace);
 
538
  nsresult SetHrefWithContext(JSContext* cx, const nsAString& aHref,
 
539
                              PRBool aReplace);
 
540
 
 
541
  nsresult GetSourceURL(JSContext* cx, nsIURI** sourceURL);
 
542
  nsresult GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL);
 
543
  nsresult GetSourceDocument(JSContext* cx, nsIDocument** aDocument);
 
544
 
 
545
  nsresult CheckURL(nsIURI *url, nsIDocShellLoadInfo** aLoadInfo);
 
546
  nsresult FindUsableBaseURI(nsIURI * aBaseURI, nsIDocShell * aParent, nsIURI ** aUsableURI);
 
547
 
 
548
  nsIDocShell *mDocShell; // Weak Reference
 
549
};
 
550
 
 
551
/* factory function */
 
552
nsresult NS_NewScriptGlobalObject(PRBool aIsChrome,
 
553
                                  nsIScriptGlobalObject **aResult);
 
554
 
 
555
#endif /* nsGlobalWindow_h___ */