Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/xpfe/appshell/nsContentTreeOwner.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
 * vim: set ts=2 sw=2 et tw=79:
3
 *
4
 * This Source Code Form is subject to the terms of the Mozilla Public
5
 * License, v. 2.0. If a copy of the MPL was not distributed with this
6
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8
// Local Includes
9
#include "nsContentTreeOwner.h"
10
#include "nsXULWindow.h"
11
12
// Helper Classes
13
#include "nsIServiceManager.h"
14
#include "nsAutoPtr.h"
15
16
// Interfaces needed to be included
17
#include "nsIDOMWindow.h"
18
#include "nsIDOMChromeWindow.h"
19
#include "nsIBrowserDOMWindow.h"
20
#include "nsIEmbeddingSiteWindow.h"
21
#include "nsIPrompt.h"
22
#include "nsIAuthPrompt.h"
23
#include "nsIWindowMediator.h"
24
#include "nsIXULBrowserWindow.h"
25
#include "nsIPrincipal.h"
26
#include "nsIURIFixup.h"
27
#include "nsCDefaultURIFixup.h"
28
#include "nsIWebNavigation.h"
29
#include "nsDocShellCID.h"
30
#include "nsIExternalURLHandlerService.h"
31
#include "nsIMIMEInfo.h"
32
#include "nsIWidget.h"
33
#include "nsWindowWatcher.h"
34
#include "mozilla/BrowserElementParent.h"
35
#include "mozilla/NullPrincipal.h"
36
#include "nsDocShellLoadInfo.h"
37
38
#include "nsIScriptObjectPrincipal.h"
39
#include "nsIURI.h"
40
#include "nsIDocument.h"
41
#if defined(XP_MACOSX)
42
#include "nsThreadUtils.h"
43
#endif
44
45
#include "mozilla/Preferences.h"
46
#include "mozilla/dom/Element.h"
47
#include "mozilla/dom/ScriptSettings.h"
48
49
using namespace mozilla;
50
51
//*****************************************************************************
52
//*** nsSiteWindow declaration
53
//*****************************************************************************
54
55
class nsSiteWindow : public nsIEmbeddingSiteWindow
56
{
57
  // nsSiteWindow shares a lifetime with nsContentTreeOwner, and proxies it's
58
  // AddRef and Release calls to said object.
59
  // When nsContentTreeOwner is destroyed, nsSiteWindow will be destroyed as well.
60
  // nsContentTreeOwner is a friend class of nsSiteWindow such that it can call
61
  // nsSiteWindow's destructor, which is private, as public destructors
62
  // on reference counted classes are generally unsafe.
63
  friend class nsContentTreeOwner;
64
65
public:
66
  explicit nsSiteWindow(nsContentTreeOwner *aAggregator);
67
68
  NS_DECL_ISUPPORTS_INHERITED
69
  NS_DECL_NSIEMBEDDINGSITEWINDOW
70
71
private:
72
  virtual ~nsSiteWindow();
73
  nsContentTreeOwner *mAggregator;
74
};
75
76
//*****************************************************************************
77
//***    nsContentTreeOwner: Object Management
78
//*****************************************************************************
79
80
nsContentTreeOwner::nsContentTreeOwner(bool fPrimary) : mXULWindow(nullptr),
81
   mPrimary(fPrimary), mContentTitleSetting(false)
82
0
{
83
0
  // note if this fails, QI on nsIEmbeddingSiteWindow(2) will simply fail
84
0
  mSiteWindow = new nsSiteWindow(this);
85
0
}
86
87
nsContentTreeOwner::~nsContentTreeOwner()
88
0
{
89
0
  delete mSiteWindow;
90
0
}
91
92
//*****************************************************************************
93
// nsContentTreeOwner::nsISupports
94
//*****************************************************************************
95
96
NS_IMPL_ADDREF(nsContentTreeOwner)
97
NS_IMPL_RELEASE(nsContentTreeOwner)
98
99
0
NS_INTERFACE_MAP_BEGIN(nsContentTreeOwner)
100
0
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellTreeOwner)
101
0
   NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeOwner)
102
0
   NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
103
0
   NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
104
0
   NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome2)
105
0
   NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome3)
106
0
   NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
107
0
   NS_INTERFACE_MAP_ENTRY(nsIWindowProvider)
108
0
   // NOTE: This is using aggregation because there are some properties and
109
0
   // method on nsIBaseWindow (which we implement) and on
110
0
   // nsIEmbeddingSiteWindow (which we also implement) that have the same name.
111
0
   // And it just so happens that we want different behavior for these methods
112
0
   // and properties depending on the interface through which they're called
113
0
   // (SetFocus() is a good example here).  If it were not for that, we could
114
0
   // ditch the aggregation and just deal with not being able to use NS_DECL_*
115
0
   // macros for this stuff....
116
0
   NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIEmbeddingSiteWindow, mSiteWindow)
117
0
NS_INTERFACE_MAP_END
118
119
//*****************************************************************************
120
// nsContentTreeOwner::nsIInterfaceRequestor
121
//*****************************************************************************
122
123
NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
124
0
{
125
0
  NS_ENSURE_ARG_POINTER(aSink);
126
0
  *aSink = 0;
127
0
128
0
  if(aIID.Equals(NS_GET_IID(nsIPrompt))) {
129
0
    NS_ENSURE_STATE(mXULWindow);
130
0
    return mXULWindow->GetInterface(aIID, aSink);
131
0
  }
132
0
  if(aIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
133
0
    NS_ENSURE_STATE(mXULWindow);
134
0
    return mXULWindow->GetInterface(aIID, aSink);
135
0
  }
136
0
  if (aIID.Equals(NS_GET_IID(nsIDocShellTreeItem))) {
137
0
    NS_ENSURE_STATE(mXULWindow);
138
0
    nsCOMPtr<nsIDocShell> shell;
139
0
    mXULWindow->GetDocShell(getter_AddRefs(shell));
140
0
    if (shell)
141
0
      return shell->QueryInterface(aIID, aSink);
142
0
    return NS_ERROR_FAILURE;
143
0
  }
144
0
145
0
  if (aIID.Equals(NS_GET_IID(nsIDOMWindow)) ||
146
0
      aIID.Equals(NS_GET_IID(nsPIDOMWindowOuter))) {
147
0
    NS_ENSURE_STATE(mXULWindow);
148
0
    nsCOMPtr<nsIDocShellTreeItem> shell;
149
0
    mXULWindow->GetPrimaryContentShell(getter_AddRefs(shell));
150
0
    if (shell) {
151
0
      nsCOMPtr<nsIInterfaceRequestor> thing(do_QueryInterface(shell));
152
0
      if (thing)
153
0
        return thing->GetInterface(aIID, aSink);
154
0
    }
155
0
    return NS_ERROR_FAILURE;
156
0
  }
157
0
158
0
  if (aIID.Equals(NS_GET_IID(nsIXULWindow))) {
159
0
    NS_ENSURE_STATE(mXULWindow);
160
0
    return mXULWindow->QueryInterface(aIID, aSink);
161
0
  }
162
0
163
0
  return QueryInterface(aIID, aSink);
164
0
}
165
166
//*****************************************************************************
167
// nsContentTreeOwner::nsIDocShellTreeOwner
168
//*****************************************************************************
169
170
NS_IMETHODIMP
171
nsContentTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
172
                                      bool aPrimary)
173
0
{
174
0
  NS_ENSURE_STATE(mXULWindow);
175
0
  return mXULWindow->ContentShellAdded(aContentShell, aPrimary);
176
0
}
177
178
NS_IMETHODIMP
179
nsContentTreeOwner::ContentShellRemoved(nsIDocShellTreeItem* aContentShell)
180
0
{
181
0
  NS_ENSURE_STATE(mXULWindow);
182
0
  return mXULWindow->ContentShellRemoved(aContentShell);
183
0
}
184
185
NS_IMETHODIMP
186
nsContentTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
187
0
{
188
0
   NS_ENSURE_STATE(mXULWindow);
189
0
   return mXULWindow->GetPrimaryContentShell(aShell);
190
0
}
191
192
NS_IMETHODIMP
193
nsContentTreeOwner::TabParentAdded(nsITabParent* aTab, bool aPrimary)
194
0
{
195
0
  NS_ENSURE_STATE(mXULWindow);
196
0
  return mXULWindow->TabParentAdded(aTab, aPrimary);
197
0
}
198
199
NS_IMETHODIMP
200
nsContentTreeOwner::TabParentRemoved(nsITabParent* aTab)
201
0
{
202
0
  NS_ENSURE_STATE(mXULWindow);
203
0
  return mXULWindow->TabParentRemoved(aTab);
204
0
}
205
206
NS_IMETHODIMP
207
nsContentTreeOwner::GetPrimaryTabParent(nsITabParent** aTab)
208
0
{
209
0
  NS_ENSURE_STATE(mXULWindow);
210
0
  return mXULWindow->GetPrimaryTabParent(aTab);
211
0
}
212
213
NS_IMETHODIMP
214
nsContentTreeOwner::GetPrimaryContentSize(int32_t* aWidth,
215
                                          int32_t* aHeight)
216
0
{
217
0
  NS_ENSURE_STATE(mXULWindow);
218
0
  return mXULWindow->GetPrimaryContentSize(aWidth, aHeight);
219
0
}
220
221
NS_IMETHODIMP
222
nsContentTreeOwner::SetPrimaryContentSize(int32_t aWidth,
223
                                          int32_t aHeight)
224
0
{
225
0
  NS_ENSURE_STATE(mXULWindow);
226
0
  return mXULWindow->SetPrimaryContentSize(aWidth, aHeight);
227
0
}
228
229
NS_IMETHODIMP
230
nsContentTreeOwner::GetRootShellSize(int32_t* aWidth,
231
                                     int32_t* aHeight)
232
0
{
233
0
  NS_ENSURE_STATE(mXULWindow);
234
0
  return mXULWindow->GetRootShellSize(aWidth, aHeight);
235
0
}
236
237
NS_IMETHODIMP
238
nsContentTreeOwner::SetRootShellSize(int32_t aWidth,
239
                                     int32_t aHeight)
240
0
{
241
0
  NS_ENSURE_STATE(mXULWindow);
242
0
  return mXULWindow->SetRootShellSize(aWidth, aHeight);
243
0
}
244
245
NS_IMETHODIMP nsContentTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
246
   int32_t aCX, int32_t aCY)
247
0
{
248
0
   NS_ENSURE_STATE(mXULWindow);
249
0
   return mXULWindow->SizeShellTo(aShellItem, aCX, aCY);
250
0
}
251
252
NS_IMETHODIMP
253
nsContentTreeOwner::SetPersistence(bool aPersistPosition,
254
                                   bool aPersistSize,
255
                                   bool aPersistSizeMode)
256
0
{
257
0
  NS_ENSURE_STATE(mXULWindow);
258
0
  nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
259
0
  if (!docShellElement)
260
0
    return NS_ERROR_FAILURE;
261
0
262
0
  nsAutoString persistString;
263
0
  docShellElement->GetAttribute(NS_LITERAL_STRING("persist"), persistString);
264
0
265
0
  bool saveString = false;
266
0
  int32_t index;
267
0
268
0
  // Set X
269
0
  index = persistString.Find("screenX");
270
0
  if (!aPersistPosition && index >= 0) {
271
0
    persistString.Cut(index, 7);
272
0
    saveString = true;
273
0
  } else if (aPersistPosition && index < 0) {
274
0
    persistString.AppendLiteral(" screenX");
275
0
    saveString = true;
276
0
  }
277
0
  // Set Y
278
0
  index = persistString.Find("screenY");
279
0
  if (!aPersistPosition && index >= 0) {
280
0
    persistString.Cut(index, 7);
281
0
    saveString = true;
282
0
  } else if (aPersistPosition && index < 0) {
283
0
    persistString.AppendLiteral(" screenY");
284
0
    saveString = true;
285
0
  }
286
0
  // Set CX
287
0
  index = persistString.Find("width");
288
0
  if (!aPersistSize && index >= 0) {
289
0
    persistString.Cut(index, 5);
290
0
    saveString = true;
291
0
  } else if (aPersistSize && index < 0) {
292
0
    persistString.AppendLiteral(" width");
293
0
    saveString = true;
294
0
  }
295
0
  // Set CY
296
0
  index = persistString.Find("height");
297
0
  if (!aPersistSize && index >= 0) {
298
0
    persistString.Cut(index, 6);
299
0
    saveString = true;
300
0
  } else if (aPersistSize && index < 0) {
301
0
    persistString.AppendLiteral(" height");
302
0
    saveString = true;
303
0
  }
304
0
  // Set SizeMode
305
0
  index = persistString.Find("sizemode");
306
0
  if (!aPersistSizeMode && (index >= 0)) {
307
0
    persistString.Cut(index, 8);
308
0
    saveString = true;
309
0
  } else if (aPersistSizeMode && (index < 0)) {
310
0
    persistString.AppendLiteral(" sizemode");
311
0
    saveString = true;
312
0
  }
313
0
314
0
  ErrorResult rv;
315
0
  if(saveString) {
316
0
    docShellElement->SetAttribute(NS_LITERAL_STRING("persist"), persistString, rv);
317
0
  }
318
0
319
0
  return NS_OK;
320
0
}
321
322
NS_IMETHODIMP
323
nsContentTreeOwner::GetPersistence(bool* aPersistPosition,
324
                                   bool* aPersistSize,
325
                                   bool* aPersistSizeMode)
326
0
{
327
0
  NS_ENSURE_STATE(mXULWindow);
328
0
  nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
329
0
  if (!docShellElement)
330
0
    return NS_ERROR_FAILURE;
331
0
332
0
  nsAutoString persistString;
333
0
  docShellElement->GetAttribute(NS_LITERAL_STRING("persist"), persistString);
334
0
335
0
  // data structure doesn't quite match the question, but it's close enough
336
0
  // for what we want (since this method is never actually called...)
337
0
  if (aPersistPosition)
338
0
    *aPersistPosition = persistString.Find("screenX") >= 0 || persistString.Find("screenY") >= 0 ? true : false;
339
0
  if (aPersistSize)
340
0
    *aPersistSize = persistString.Find("width") >= 0 || persistString.Find("height") >= 0 ? true : false;
341
0
  if (aPersistSizeMode)
342
0
    *aPersistSizeMode = persistString.Find("sizemode") >= 0 ? true : false;
343
0
344
0
  return NS_OK;
345
0
}
346
347
NS_IMETHODIMP
348
nsContentTreeOwner::GetTabCount(uint32_t* aResult)
349
0
{
350
0
  if (mXULWindow) {
351
0
    return mXULWindow->GetTabCount(aResult);
352
0
  }
353
0
354
0
  *aResult = 0;
355
0
  return NS_OK;
356
0
}
357
358
NS_IMETHODIMP
359
nsContentTreeOwner::GetHasPrimaryContent(bool* aResult)
360
0
{
361
0
  NS_ENSURE_STATE(mXULWindow);
362
0
  return mXULWindow->GetHasPrimaryContent(aResult);
363
0
}
364
365
//*****************************************************************************
366
// nsContentTreeOwner::nsIWebBrowserChrome3
367
//*****************************************************************************
368
369
NS_IMETHODIMP nsContentTreeOwner::OnBeforeLinkTraversal(const nsAString &originalTarget,
370
                                                        nsIURI *linkURI,
371
                                                        nsINode *linkNode,
372
                                                        bool isAppTab,
373
                                                        nsAString &_retval)
374
0
{
375
0
  NS_ENSURE_STATE(mXULWindow);
376
0
377
0
  nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
378
0
  mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
379
0
380
0
  if (xulBrowserWindow)
381
0
    return xulBrowserWindow->OnBeforeLinkTraversal(originalTarget, linkURI,
382
0
                                                   linkNode, isAppTab, _retval);
383
0
384
0
  _retval = originalTarget;
385
0
  return NS_OK;
386
0
}
387
388
NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI(nsIDocShell *aDocShell,
389
                                                nsIURI *aURI,
390
                                                nsIURI *aReferrer,
391
                                                bool aHasPostData,
392
                                                nsIPrincipal* aTriggeringPrincipal,
393
                                                bool *_retval)
394
0
{
395
0
  NS_ENSURE_STATE(mXULWindow);
396
0
397
0
  nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
398
0
  mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
399
0
400
0
  if (xulBrowserWindow)
401
0
    return xulBrowserWindow->ShouldLoadURI(aDocShell, aURI, aReferrer, aHasPostData,
402
0
                                           aTriggeringPrincipal, _retval);
403
0
404
0
  *_retval = true;
405
0
  return NS_OK;
406
0
}
407
408
NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURIInThisProcess(nsIURI* aURI,
409
                                                             bool* aRetVal)
410
0
{
411
0
  MOZ_ASSERT_UNREACHABLE("Should only be called in child process.");
412
0
  *aRetVal = true;
413
0
  return NS_OK;
414
0
}
415
416
NS_IMETHODIMP nsContentTreeOwner::ReloadInFreshProcess(nsIDocShell* aDocShell,
417
                                                       nsIURI* aURI,
418
                                                       nsIURI* aReferrer,
419
                                                       nsIPrincipal* aTriggeringPrincipal,
420
                                                       uint32_t aLoadFlags,
421
                                                       bool* aRetVal)
422
0
{
423
0
  NS_WARNING("Cannot reload in fresh process from a nsContentTreeOwner!");
424
0
  *aRetVal = false;
425
0
  return NS_OK;
426
0
}
427
428
//*****************************************************************************
429
// nsContentTreeOwner::nsIWebBrowserChrome2
430
//*****************************************************************************
431
432
NS_IMETHODIMP nsContentTreeOwner::SetStatusWithContext(uint32_t aStatusType,
433
                                                       const nsAString &aStatusText,
434
                                                       nsISupports *aStatusContext)
435
0
{
436
0
  // We only allow the status to be set from the primary content shell
437
0
  if (!mPrimary && aStatusType != STATUS_LINK)
438
0
    return NS_OK;
439
0
440
0
  NS_ENSURE_STATE(mXULWindow);
441
0
442
0
  nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
443
0
  mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
444
0
445
0
  if (xulBrowserWindow)
446
0
  {
447
0
    switch(aStatusType)
448
0
    {
449
0
    case STATUS_LINK:
450
0
      {
451
0
        nsCOMPtr<dom::Element> element = do_QueryInterface(aStatusContext);
452
0
        xulBrowserWindow->SetOverLink(aStatusText, element);
453
0
        break;
454
0
      }
455
0
    }
456
0
  }
457
0
458
0
  return NS_OK;
459
0
}
460
461
//*****************************************************************************
462
// nsContentTreeOwner::nsIWebBrowserChrome
463
//*****************************************************************************
464
465
NS_IMETHODIMP nsContentTreeOwner::SetStatus(uint32_t aStatusType,
466
                                            const char16_t* aStatus)
467
0
{
468
0
  return SetStatusWithContext(aStatusType,
469
0
      aStatus ? static_cast<const nsString &>(nsDependentString(aStatus))
470
0
              : EmptyString(),
471
0
      nullptr);
472
0
}
473
474
NS_IMETHODIMP nsContentTreeOwner::SetWebBrowser(nsIWebBrowser* aWebBrowser)
475
0
{
476
0
   NS_ERROR("Haven't Implemented this yet");
477
0
   return NS_ERROR_FAILURE;
478
0
}
479
480
NS_IMETHODIMP nsContentTreeOwner::GetWebBrowser(nsIWebBrowser** aWebBrowser)
481
0
{
482
0
  // Unimplemented, and probably will remain so; xpfe windows have docshells,
483
0
  // not webbrowsers.
484
0
  NS_ENSURE_ARG_POINTER(aWebBrowser);
485
0
  *aWebBrowser = 0;
486
0
  return NS_ERROR_FAILURE;
487
0
}
488
489
NS_IMETHODIMP nsContentTreeOwner::SetChromeFlags(uint32_t aChromeFlags)
490
0
{
491
0
   NS_ENSURE_STATE(mXULWindow);
492
0
   return mXULWindow->SetChromeFlags(aChromeFlags);
493
0
}
494
495
NS_IMETHODIMP nsContentTreeOwner::GetChromeFlags(uint32_t* aChromeFlags)
496
0
{
497
0
  NS_ENSURE_STATE(mXULWindow);
498
0
  return mXULWindow->GetChromeFlags(aChromeFlags);
499
0
}
500
501
NS_IMETHODIMP nsContentTreeOwner::DestroyBrowserWindow()
502
0
{
503
0
   NS_ERROR("Haven't Implemented this yet");
504
0
   return NS_ERROR_FAILURE;
505
0
}
506
507
NS_IMETHODIMP nsContentTreeOwner::SizeBrowserTo(int32_t aCX, int32_t aCY)
508
0
{
509
0
   NS_ERROR("Haven't Implemented this yet");
510
0
   return NS_ERROR_FAILURE;
511
0
}
512
513
NS_IMETHODIMP nsContentTreeOwner::ShowAsModal()
514
0
{
515
0
   NS_ENSURE_STATE(mXULWindow);
516
0
   return mXULWindow->ShowModal();
517
0
}
518
519
NS_IMETHODIMP nsContentTreeOwner::IsWindowModal(bool *_retval)
520
0
{
521
0
  NS_ENSURE_STATE(mXULWindow);
522
0
  *_retval = mXULWindow->mContinueModalLoop;
523
0
  return NS_OK;
524
0
}
525
526
NS_IMETHODIMP nsContentTreeOwner::ExitModalEventLoop(nsresult aStatus)
527
0
{
528
0
   NS_ENSURE_STATE(mXULWindow);
529
0
   return mXULWindow->ExitModalLoop(aStatus);
530
0
}
531
532
//*****************************************************************************
533
// nsContentTreeOwner::nsIBaseWindow
534
//*****************************************************************************
535
536
NS_IMETHODIMP nsContentTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
537
   nsIWidget* parentWidget, int32_t x, int32_t y, int32_t cx, int32_t cy)
538
0
{
539
0
   // Ignore wigdet parents for now.  Don't think those are a vaild thing to call.
540
0
   NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, 0), NS_ERROR_FAILURE);
541
0
542
0
   return NS_OK;
543
0
}
544
545
NS_IMETHODIMP nsContentTreeOwner::Create()
546
0
{
547
0
   NS_ASSERTION(false, "You can't call this");
548
0
   return NS_ERROR_UNEXPECTED;
549
0
}
550
551
NS_IMETHODIMP nsContentTreeOwner::Destroy()
552
0
{
553
0
   NS_ENSURE_STATE(mXULWindow);
554
0
   return mXULWindow->Destroy();
555
0
}
556
557
NS_IMETHODIMP nsContentTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double* aScale)
558
0
{
559
0
   NS_ENSURE_STATE(mXULWindow);
560
0
   return mXULWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale);
561
0
}
562
563
NS_IMETHODIMP nsContentTreeOwner::GetDevicePixelsPerDesktopPixel(double* aScale)
564
0
{
565
0
   NS_ENSURE_STATE(mXULWindow);
566
0
   return mXULWindow->GetDevicePixelsPerDesktopPixel(aScale);
567
0
}
568
569
NS_IMETHODIMP nsContentTreeOwner::SetPositionDesktopPix(int32_t aX, int32_t aY)
570
0
{
571
0
   NS_ENSURE_STATE(mXULWindow);
572
0
   return mXULWindow->SetPositionDesktopPix(aX, aY);
573
0
}
574
575
NS_IMETHODIMP nsContentTreeOwner::SetPosition(int32_t aX, int32_t aY)
576
0
{
577
0
   NS_ENSURE_STATE(mXULWindow);
578
0
   return mXULWindow->SetPosition(aX, aY);
579
0
}
580
581
NS_IMETHODIMP nsContentTreeOwner::GetPosition(int32_t* aX, int32_t* aY)
582
0
{
583
0
   NS_ENSURE_STATE(mXULWindow);
584
0
   return mXULWindow->GetPosition(aX, aY);
585
0
}
586
587
NS_IMETHODIMP nsContentTreeOwner::SetSize(int32_t aCX, int32_t aCY, bool aRepaint)
588
0
{
589
0
   NS_ENSURE_STATE(mXULWindow);
590
0
   return mXULWindow->SetSize(aCX, aCY, aRepaint);
591
0
}
592
593
NS_IMETHODIMP nsContentTreeOwner::GetSize(int32_t* aCX, int32_t* aCY)
594
0
{
595
0
   NS_ENSURE_STATE(mXULWindow);
596
0
   return mXULWindow->GetSize(aCX, aCY);
597
0
}
598
599
NS_IMETHODIMP nsContentTreeOwner::SetPositionAndSize(int32_t aX, int32_t aY,
600
   int32_t aCX, int32_t aCY, uint32_t aFlags)
601
0
{
602
0
   NS_ENSURE_STATE(mXULWindow);
603
0
   return mXULWindow->SetPositionAndSize(aX, aY, aCX, aCY, aFlags);
604
0
}
605
606
NS_IMETHODIMP nsContentTreeOwner::GetPositionAndSize(int32_t* aX, int32_t* aY,
607
   int32_t* aCX, int32_t* aCY)
608
0
{
609
0
   NS_ENSURE_STATE(mXULWindow);
610
0
   return mXULWindow->GetPositionAndSize(aX, aY, aCX, aCY);
611
0
}
612
613
NS_IMETHODIMP nsContentTreeOwner::Repaint(bool aForce)
614
0
{
615
0
   NS_ENSURE_STATE(mXULWindow);
616
0
   return mXULWindow->Repaint(aForce);
617
0
}
618
619
NS_IMETHODIMP nsContentTreeOwner::GetParentWidget(nsIWidget** aParentWidget)
620
0
{
621
0
   NS_ENSURE_STATE(mXULWindow);
622
0
   return mXULWindow->GetParentWidget(aParentWidget);
623
0
}
624
625
NS_IMETHODIMP nsContentTreeOwner::SetParentWidget(nsIWidget* aParentWidget)
626
0
{
627
0
   NS_ASSERTION(false, "You can't call this");
628
0
   return NS_ERROR_NOT_IMPLEMENTED;
629
0
}
630
631
NS_IMETHODIMP nsContentTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
632
0
{
633
0
   NS_ENSURE_STATE(mXULWindow);
634
0
   return mXULWindow->GetParentNativeWindow(aParentNativeWindow);
635
0
}
636
637
NS_IMETHODIMP nsContentTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow)
638
0
{
639
0
   NS_ASSERTION(false, "You can't call this");
640
0
   return NS_ERROR_NOT_IMPLEMENTED;
641
0
}
642
643
NS_IMETHODIMP nsContentTreeOwner::GetNativeHandle(nsAString& aNativeHandle)
644
0
{
645
0
   NS_ENSURE_STATE(mXULWindow);
646
0
   return mXULWindow->GetNativeHandle(aNativeHandle);
647
0
}
648
649
NS_IMETHODIMP nsContentTreeOwner::GetVisibility(bool* aVisibility)
650
0
{
651
0
   NS_ENSURE_STATE(mXULWindow);
652
0
   return mXULWindow->GetVisibility(aVisibility);
653
0
}
654
655
NS_IMETHODIMP nsContentTreeOwner::SetVisibility(bool aVisibility)
656
0
{
657
0
   NS_ENSURE_STATE(mXULWindow);
658
0
   return mXULWindow->SetVisibility(aVisibility);
659
0
}
660
661
NS_IMETHODIMP nsContentTreeOwner::GetEnabled(bool *aEnabled)
662
0
{
663
0
   NS_ENSURE_STATE(mXULWindow);
664
0
   return mXULWindow->GetEnabled(aEnabled);
665
0
}
666
667
NS_IMETHODIMP nsContentTreeOwner::SetEnabled(bool aEnable)
668
0
{
669
0
   NS_ENSURE_STATE(mXULWindow);
670
0
   return mXULWindow->SetEnabled(aEnable);
671
0
}
672
673
NS_IMETHODIMP nsContentTreeOwner::GetMainWidget(nsIWidget** aMainWidget)
674
0
{
675
0
   NS_ENSURE_ARG_POINTER(aMainWidget);
676
0
   NS_ENSURE_STATE(mXULWindow);
677
0
678
0
   *aMainWidget = mXULWindow->mWindow;
679
0
   NS_IF_ADDREF(*aMainWidget);
680
0
681
0
   return NS_OK;
682
0
}
683
684
NS_IMETHODIMP nsContentTreeOwner::SetFocus()
685
0
{
686
0
   NS_ENSURE_STATE(mXULWindow);
687
0
   return mXULWindow->SetFocus();
688
0
}
689
690
NS_IMETHODIMP nsContentTreeOwner::GetTitle(nsAString& aTitle)
691
0
{
692
0
   NS_ENSURE_STATE(mXULWindow);
693
0
694
0
   return mXULWindow->GetTitle(aTitle);
695
0
}
696
697
NS_IMETHODIMP nsContentTreeOwner::SetTitle(const nsAString& aTitle)
698
0
{
699
0
   // We only allow the title to be set from the primary content shell
700
0
  if(!mPrimary || !mContentTitleSetting)
701
0
    return NS_OK;
702
0
703
0
  NS_ENSURE_STATE(mXULWindow);
704
0
705
0
  nsAutoString   title;
706
0
  nsAutoString   docTitle(aTitle);
707
0
708
0
  if (docTitle.IsEmpty())
709
0
    docTitle.Assign(mTitleDefault);
710
0
711
0
  if (!docTitle.IsEmpty()) {
712
0
    if (!mTitlePreface.IsEmpty()) {
713
0
      // Title will be: "Preface: Doc Title - Mozilla"
714
0
      title.Assign(mTitlePreface);
715
0
      title.Append(docTitle);
716
0
    }
717
0
    else {
718
0
      // Title will be: "Doc Title - Mozilla"
719
0
      title = docTitle;
720
0
    }
721
0
722
0
    if (!mWindowTitleModifier.IsEmpty())
723
0
      title += mTitleSeparator + mWindowTitleModifier;
724
0
  }
725
0
  else
726
0
    title.Assign(mWindowTitleModifier); // Title will just be plain "Mozilla"
727
0
728
0
  //
729
0
  // if there is no location bar we modify the title to display at least
730
0
  // the scheme and host (if any) as an anti-spoofing measure.
731
0
  //
732
0
  nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
733
0
734
0
  if (docShellElement) {
735
0
    nsAutoString chromeString;
736
0
    docShellElement->GetAttribute(NS_LITERAL_STRING("chromehidden"), chromeString);
737
0
    if (chromeString.Find(NS_LITERAL_STRING("location")) != kNotFound) {
738
0
      //
739
0
      // location bar is turned off, find the browser location
740
0
      //
741
0
      // use the document's ContentPrincipal to find the true owner
742
0
      // in case of javascript: or data: documents
743
0
      //
744
0
      nsCOMPtr<nsIDocShellTreeItem> dsitem;
745
0
      GetPrimaryContentShell(getter_AddRefs(dsitem));
746
0
      nsCOMPtr<nsIScriptObjectPrincipal> doc =
747
0
        do_QueryInterface(dsitem ? dsitem->GetDocument() : nullptr);
748
0
      if (doc) {
749
0
        nsCOMPtr<nsIURI> uri;
750
0
        nsIPrincipal* principal = doc->GetPrincipal();
751
0
        if (principal) {
752
0
          principal->GetURI(getter_AddRefs(uri));
753
0
          if (uri) {
754
0
            //
755
0
            // remove any user:pass information
756
0
            //
757
0
            nsCOMPtr<nsIURIFixup> fixup(do_GetService(NS_URIFIXUP_CONTRACTID));
758
0
            if (fixup) {
759
0
              nsCOMPtr<nsIURI> tmpuri;
760
0
              nsresult rv = fixup->CreateExposableURI(uri,getter_AddRefs(tmpuri));
761
0
              if (NS_SUCCEEDED(rv) && tmpuri) {
762
0
                // (don't bother if there's no host)
763
0
                nsAutoCString host;
764
0
                nsAutoCString prepath;
765
0
                tmpuri->GetHost(host);
766
0
                tmpuri->GetPrePath(prepath);
767
0
                if (!host.IsEmpty()) {
768
0
                  //
769
0
                  // We have a scheme/host, update the title
770
0
                  //
771
0
                  title.Insert(NS_ConvertUTF8toUTF16(prepath) +
772
0
                               mTitleSeparator, 0);
773
0
                }
774
0
              }
775
0
            }
776
0
          }
777
0
        }
778
0
      }
779
0
    }
780
0
    nsIDocument* document = docShellElement->OwnerDoc();
781
0
    ErrorResult rv;
782
0
    document->SetTitle(title, rv);
783
0
    return rv.StealNSResult();
784
0
  }
785
0
786
0
  return mXULWindow->SetTitle(title);
787
0
}
788
789
//*****************************************************************************
790
// nsContentTreeOwner: nsIWindowProvider
791
//*****************************************************************************
792
NS_IMETHODIMP
793
nsContentTreeOwner::ProvideWindow(mozIDOMWindowProxy* aParent,
794
                                  uint32_t aChromeFlags,
795
                                  bool aCalledFromJS,
796
                                  bool aPositionSpecified,
797
                                  bool aSizeSpecified,
798
                                  nsIURI* aURI,
799
                                  const nsAString& aName,
800
                                  const nsACString& aFeatures,
801
                                  bool aForceNoOpener,
802
                                  nsDocShellLoadInfo* aLoadInfo,
803
                                  bool* aWindowIsNew,
804
                                  mozIDOMWindowProxy** aReturn)
805
0
{
806
0
  NS_ENSURE_ARG_POINTER(aParent);
807
0
808
0
  auto* parent = nsPIDOMWindowOuter::From(aParent);
809
0
810
0
  *aReturn = nullptr;
811
0
812
0
  if (!mXULWindow) {
813
0
    // Nothing to do here
814
0
    return NS_OK;
815
0
  }
816
0
817
#ifdef DEBUG
818
  nsCOMPtr<nsIWebNavigation> parentNav = do_GetInterface(aParent);
819
  nsCOMPtr<nsIDocShellTreeOwner> parentOwner = do_GetInterface(parentNav);
820
  NS_ASSERTION(SameCOMIdentity(parentOwner,
821
                               static_cast<nsIDocShellTreeOwner*>(this)),
822
               "Parent from wrong docshell tree?");
823
#endif
824
825
0
  // If aParent is inside an <iframe mozbrowser> and this isn't a request to
826
0
  // open a modal-type window, we're going to create a new <iframe mozbrowser>
827
0
  // and return its window here.
828
0
  nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
829
0
  if (docshell && docshell->GetIsInMozBrowser() &&
830
0
      !(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
831
0
                        nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
832
0
                        nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {
833
0
834
0
    BrowserElementParent::OpenWindowResult opened =
835
0
      BrowserElementParent::OpenWindowInProcess(parent, aURI, aName,
836
0
                                                aFeatures, aForceNoOpener, aReturn);
837
0
838
0
    // If OpenWindowInProcess handled the open (by opening it or blocking the
839
0
    // popup), tell our caller not to proceed trying to create a new window
840
0
    // through other means.
841
0
    if (opened != BrowserElementParent::OPEN_WINDOW_IGNORED) {
842
0
      *aWindowIsNew = opened == BrowserElementParent::OPEN_WINDOW_ADDED;
843
0
      return *aWindowIsNew ? NS_OK : NS_ERROR_ABORT;
844
0
    }
845
0
846
0
    // If we're in an app and the target is _blank, send the url to the OS
847
0
    if (aName.LowerCaseEqualsLiteral("_blank")) {
848
0
      nsCOMPtr<nsIExternalURLHandlerService> exUrlServ(
849
0
                        do_GetService(NS_EXTERNALURLHANDLERSERVICE_CONTRACTID));
850
0
      if (exUrlServ) {
851
0
852
0
        nsCOMPtr<nsIHandlerInfo> info;
853
0
        bool found;
854
0
        exUrlServ->GetURLHandlerInfoFromOS(aURI, &found, getter_AddRefs(info));
855
0
856
0
        if (info && found) {
857
0
          info->LaunchWithURI(aURI, nullptr);
858
0
          return NS_ERROR_ABORT;
859
0
        }
860
0
861
0
      }
862
0
    }
863
0
  }
864
0
865
0
  int32_t openLocation =
866
0
    nsWindowWatcher::GetWindowOpenLocation(parent, aChromeFlags, aCalledFromJS,
867
0
                                           aPositionSpecified, aSizeSpecified);
868
0
869
0
  if (openLocation != nsIBrowserDOMWindow::OPEN_NEWTAB &&
870
0
      openLocation != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW) {
871
0
    // Just open a window normally
872
0
    return NS_OK;
873
0
  }
874
0
875
0
  nsCOMPtr<mozIDOMWindowProxy> domWin;
876
0
  mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWin));
877
0
  nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(domWin);
878
0
  if (!chromeWin) {
879
0
    // Really odd... but whatever
880
0
    NS_WARNING("nsXULWindow's DOMWindow is not a chrome window");
881
0
    return NS_OK;
882
0
  }
883
0
884
0
  nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
885
0
  chromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
886
0
  if (!browserDOMWin) {
887
0
    return NS_OK;
888
0
  }
889
0
890
0
  *aWindowIsNew = (openLocation != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW);
891
0
892
0
  {
893
0
    dom::AutoNoJSAPI nojsapi;
894
0
895
0
    uint32_t flags = nsIBrowserDOMWindow::OPEN_NEW;
896
0
    if (aForceNoOpener) {
897
0
      flags |= nsIBrowserDOMWindow::OPEN_NO_OPENER;
898
0
    }
899
0
900
0
    // Get a new rendering area from the browserDOMWin.
901
0
    // Since we are not loading any URI, we follow the principle of least
902
0
    // privilege and use a nullPrincipal as the triggeringPrincipal.
903
0
    //
904
0
    // This method handles setting the opener for us, so we don't need to set it
905
0
    // ourselves.
906
0
    RefPtr<NullPrincipal> nullPrincipal = NullPrincipal::CreateWithoutOriginAttributes();
907
0
    return browserDOMWin->CreateContentWindow(aURI, aParent, openLocation,
908
0
                                              flags, nullPrincipal, aReturn);
909
0
  }
910
0
}
911
912
//*****************************************************************************
913
// nsContentTreeOwner: Accessors
914
//*****************************************************************************
915
916
#if defined(XP_MACOSX)
917
class nsContentTitleSettingEvent : public Runnable
918
{
919
public:
920
  nsContentTitleSettingEvent(dom::Element* dse, const nsAString& wtm)
921
    : Runnable("nsContentTitleSettingEvent"),
922
      mElement(dse),
923
      mTitleDefault(wtm) {}
924
925
  NS_IMETHOD Run() override
926
  {
927
    ErrorResult rv;
928
    mElement->SetAttribute(NS_LITERAL_STRING("titledefault"), mTitleDefault, rv);
929
    mElement->RemoveAttribute(NS_LITERAL_STRING("titlemodifier"), rv);
930
    return NS_OK;
931
  }
932
933
private:
934
  nsCOMPtr<dom::Element> mElement;
935
  nsString mTitleDefault;
936
};
937
#endif
938
939
void nsContentTreeOwner::XULWindow(nsXULWindow* aXULWindow)
940
0
{
941
0
   mXULWindow = aXULWindow;
942
0
   if (mXULWindow && mPrimary) {
943
0
      // Get the window title modifiers
944
0
      nsCOMPtr<dom::Element> docShellElement = mXULWindow->GetWindowDOMElement();
945
0
946
0
      nsAutoString   contentTitleSetting;
947
0
948
0
      if(docShellElement)
949
0
         {
950
0
         docShellElement->GetAttribute(NS_LITERAL_STRING("contenttitlesetting"), contentTitleSetting);
951
0
         if(contentTitleSetting.EqualsLiteral("true"))
952
0
            {
953
0
            mContentTitleSetting = true;
954
0
            docShellElement->GetAttribute(NS_LITERAL_STRING("titledefault"), mTitleDefault);
955
0
            docShellElement->GetAttribute(NS_LITERAL_STRING("titlemodifier"), mWindowTitleModifier);
956
0
            docShellElement->GetAttribute(NS_LITERAL_STRING("titlepreface"), mTitlePreface);
957
0
958
#if defined(XP_MACOSX)
959
            // On OS X, treat the titlemodifier like it's the titledefault, and don't ever append
960
            // the separator + appname.
961
            if (mTitleDefault.IsEmpty()) {
962
                NS_DispatchToCurrentThread(
963
                    new nsContentTitleSettingEvent(docShellElement,
964
                                                   mWindowTitleModifier));
965
                mTitleDefault = mWindowTitleModifier;
966
                mWindowTitleModifier.Truncate();
967
            }
968
#endif
969
0
            docShellElement->GetAttribute(NS_LITERAL_STRING("titlemenuseparator"), mTitleSeparator);
970
0
            }
971
0
         }
972
0
      else
973
0
         {
974
0
         NS_ERROR("This condition should never happen.  If it does, "
975
0
            "we just won't get a modifier, but it still shouldn't happen.");
976
0
         }
977
0
      }
978
0
}
979
980
nsXULWindow* nsContentTreeOwner::XULWindow()
981
0
{
982
0
   return mXULWindow;
983
0
}
984
985
//*****************************************************************************
986
//*** nsSiteWindow implementation
987
//*****************************************************************************
988
989
nsSiteWindow::nsSiteWindow(nsContentTreeOwner *aAggregator)
990
0
{
991
0
  mAggregator = aAggregator;
992
0
}
993
994
nsSiteWindow::~nsSiteWindow()
995
0
{
996
0
}
997
998
NS_IMPL_ADDREF_USING_AGGREGATOR(nsSiteWindow, mAggregator)
999
NS_IMPL_RELEASE_USING_AGGREGATOR(nsSiteWindow, mAggregator)
1000
1001
0
NS_INTERFACE_MAP_BEGIN(nsSiteWindow)
1002
0
  NS_INTERFACE_MAP_ENTRY(nsISupports)
1003
0
  NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
1004
0
NS_INTERFACE_MAP_END_AGGREGATED(mAggregator)
1005
1006
NS_IMETHODIMP
1007
nsSiteWindow::SetDimensions(uint32_t aFlags,
1008
                    int32_t aX, int32_t aY, int32_t aCX, int32_t aCY)
1009
0
{
1010
0
  // XXX we're ignoring aFlags
1011
0
  return mAggregator->SetPositionAndSize(aX, aY, aCX, aCY,
1012
0
                                         nsIBaseWindow::eRepaint);
1013
0
}
1014
1015
NS_IMETHODIMP
1016
nsSiteWindow::GetDimensions(uint32_t aFlags,
1017
                    int32_t *aX, int32_t *aY, int32_t *aCX, int32_t *aCY)
1018
0
{
1019
0
  // XXX we're ignoring aFlags
1020
0
  return mAggregator->GetPositionAndSize(aX, aY, aCX, aCY);
1021
0
}
1022
1023
NS_IMETHODIMP
1024
nsSiteWindow::SetFocus(void)
1025
0
{
1026
#if 0
1027
  /* This implementation focuses the main document and could make sense.
1028
     However this method is actually being used from within
1029
     nsGlobalWindow::Focus (providing a hook for MDI embedding apps)
1030
     and it's better for our purposes to not pick a document and
1031
     focus it, but allow nsGlobalWindow to carry on unhindered.
1032
  */
1033
  nsXULWindow *window = mAggregator->XULWindow();
1034
  if (window) {
1035
    nsCOMPtr<nsIDocShell> docshell;
1036
    window->GetDocShell(getter_AddRefs(docshell));
1037
    if (docShell) {
1038
      nsCOMPtr<nsPIDOMWindowOuter> domWindow(docShell->GetWindow());
1039
      if (domWindow)
1040
        domWindow->Focus();
1041
    }
1042
  }
1043
#endif
1044
  return NS_OK;
1045
0
}
1046
1047
/* this implementation focuses another window. if there isn't another
1048
   window to focus, we do nothing. */
1049
NS_IMETHODIMP
1050
nsSiteWindow::Blur(void)
1051
0
{
1052
0
  NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
1053
0
1054
0
  nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
1055
0
  nsCOMPtr<nsIXULWindow>        xulWindow;
1056
0
  bool                          more, foundUs;
1057
0
  nsXULWindow                  *ourWindow = mAggregator->XULWindow();
1058
0
1059
0
  {
1060
0
    nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
1061
0
    if (windowMediator)
1062
0
      windowMediator->GetZOrderXULWindowEnumerator(0, true,
1063
0
                        getter_AddRefs(windowEnumerator));
1064
0
  }
1065
0
1066
0
  if (!windowEnumerator)
1067
0
    return NS_ERROR_FAILURE;
1068
0
1069
0
  // step through the top-level windows
1070
0
  foundUs = false;
1071
0
  windowEnumerator->HasMoreElements(&more);
1072
0
  while (more) {
1073
0
1074
0
    nsCOMPtr<nsISupports>  nextWindow;
1075
0
    nsCOMPtr<nsIXULWindow> nextXULWindow;
1076
0
1077
0
    windowEnumerator->GetNext(getter_AddRefs(nextWindow));
1078
0
    nextXULWindow = do_QueryInterface(nextWindow);
1079
0
1080
0
    // got it!(?)
1081
0
    if (foundUs) {
1082
0
      xulWindow = nextXULWindow;
1083
0
      break;
1084
0
    }
1085
0
1086
0
    // remember the very first one, in case we have to wrap
1087
0
    if (!xulWindow)
1088
0
      xulWindow = nextXULWindow;
1089
0
1090
0
    // look for us
1091
0
    if (nextXULWindow == ourWindow)
1092
0
      foundUs = true;
1093
0
1094
0
    windowEnumerator->HasMoreElements(&more);
1095
0
  }
1096
0
1097
0
  // change focus to the window we just found
1098
0
  if (xulWindow) {
1099
0
    nsCOMPtr<nsIDocShell> docshell;
1100
0
    xulWindow->GetDocShell(getter_AddRefs(docshell));
1101
0
    if (!docshell) {
1102
0
      return NS_OK;
1103
0
    }
1104
0
1105
0
    nsCOMPtr<nsPIDOMWindowOuter> domWindow = docshell->GetWindow();
1106
0
    if (domWindow)
1107
0
      domWindow->Focus();
1108
0
  }
1109
0
  return NS_OK;
1110
0
}
1111
1112
NS_IMETHODIMP
1113
nsSiteWindow::GetVisibility(bool *aVisibility)
1114
0
{
1115
0
  return mAggregator->GetVisibility(aVisibility);
1116
0
}
1117
1118
NS_IMETHODIMP
1119
nsSiteWindow::SetVisibility(bool aVisibility)
1120
0
{
1121
0
  return mAggregator->SetVisibility(aVisibility);
1122
0
}
1123
1124
NS_IMETHODIMP
1125
nsSiteWindow::GetTitle(nsAString& aTitle)
1126
0
{
1127
0
  return mAggregator->GetTitle(aTitle);
1128
0
}
1129
1130
NS_IMETHODIMP
1131
nsSiteWindow::SetTitle(const nsAString& aTitle)
1132
0
{
1133
0
  return mAggregator->SetTitle(aTitle);
1134
0
}
1135
1136
NS_IMETHODIMP
1137
nsSiteWindow::GetSiteWindow(void **aSiteWindow)
1138
0
{
1139
0
  return mAggregator->GetParentNativeWindow(aSiteWindow);
1140
0
}
1141