Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef nsDocShell_h__
8 : #define nsDocShell_h__
9 :
10 : #include "nsITimer.h"
11 : #include "nsContentPolicyUtils.h"
12 : #include "nsIDocShell.h"
13 : #include "nsIDocShellTreeItem.h"
14 : #include "nsIBaseWindow.h"
15 : #include "nsINetworkInterceptController.h"
16 : #include "nsIScrollable.h"
17 : #include "nsITextScroll.h"
18 : #include "nsIContentViewerContainer.h"
19 : #include "nsIDOMStorageManager.h"
20 : #include "nsDocLoader.h"
21 : #include "mozilla/BasePrincipal.h"
22 : #include "mozilla/UniquePtr.h"
23 : #include "mozilla/WeakPtr.h"
24 : #include "mozilla/TimeStamp.h"
25 : #include "GeckoProfiler.h"
26 : #include "mozilla/dom/ProfileTimelineMarkerBinding.h"
27 : #include "mozilla/LinkedList.h"
28 : #include "jsapi.h"
29 :
30 : // Helper Classes
31 : #include "nsCOMPtr.h"
32 : #include "nsPoint.h" // mCurrent/mDefaultScrollbarPreferences
33 : #include "nsString.h"
34 : #include "nsAutoPtr.h"
35 : #include "nsThreadUtils.h"
36 : #include "nsContentUtils.h"
37 : #include "timeline/ObservedDocShell.h"
38 : #include "timeline/TimelineConsumers.h"
39 : #include "timeline/TimelineMarker.h"
40 :
41 : // Threshold value in ms for META refresh based redirects
42 : #define REFRESH_REDIRECT_TIMER 15000
43 :
44 : // Interfaces Needed
45 : #include "nsIDocCharset.h"
46 : #include "nsIInterfaceRequestor.h"
47 : #include "nsIRefreshURI.h"
48 : #include "nsIWebNavigation.h"
49 : #include "nsIWebPageDescriptor.h"
50 : #include "nsIWebProgressListener.h"
51 : #include "nsIDocShellLoadInfo.h"
52 : #include "nsIAuthPromptProvider.h"
53 : #include "nsILoadContext.h"
54 : #include "nsIWebShellServices.h"
55 : #include "nsILinkHandler.h"
56 : #include "nsIClipboardCommands.h"
57 : #include "nsITabParent.h"
58 : #include "nsCRT.h"
59 : #include "prtime.h"
60 : #include "nsRect.h"
61 : #include "Units.h"
62 : #include "nsIDeprecationWarner.h"
63 :
64 : namespace mozilla {
65 : class Encoding;
66 : enum class TaskCategory;
67 : namespace dom {
68 : class EventTarget;
69 : class PendingGlobalHistoryEntry;
70 : typedef uint32_t ScreenOrientationInternal;
71 : } // namespace dom
72 : } // namespace mozilla
73 :
74 : class nsDocShell;
75 : class nsDOMNavigationTiming;
76 : class nsGlobalWindow;
77 : class nsIController;
78 : class nsIScrollableFrame;
79 : class OnLinkClickEvent;
80 : class nsDSURIContentListener;
81 : class nsDocShellEditorData;
82 : class nsIClipboardDragDropHookList;
83 : class nsICommandManager;
84 : class nsIContentViewer;
85 : class nsIDocument;
86 : class nsIDOMNode;
87 : class nsIDocShellTreeOwner;
88 : class nsIGlobalHistory2;
89 : class nsIHttpChannel;
90 : class nsIMutableArray;
91 : class nsIPrompt;
92 : class nsISHistory;
93 : class nsISecureBrowserUI;
94 : class nsIStringBundle;
95 : class nsIURIFixup;
96 : class nsIURILoader;
97 : class nsIWebBrowserFind;
98 : class nsIWidget;
99 : class FramingChecker;
100 :
101 : /* internally used ViewMode types */
102 : enum ViewMode
103 : {
104 : viewNormal = 0x0,
105 : viewSource = 0x1
106 : };
107 :
108 : class nsRefreshTimer : public nsITimerCallback
109 : {
110 : public:
111 : nsRefreshTimer();
112 :
113 : NS_DECL_THREADSAFE_ISUPPORTS
114 : NS_DECL_NSITIMERCALLBACK
115 :
116 0 : int32_t GetDelay() { return mDelay ;}
117 :
118 : RefPtr<nsDocShell> mDocShell;
119 : nsCOMPtr<nsIURI> mURI;
120 : int32_t mDelay;
121 : bool mRepeat;
122 : bool mMetaRefresh;
123 :
124 : protected:
125 : virtual ~nsRefreshTimer();
126 : };
127 :
128 : enum eCharsetReloadState
129 : {
130 : eCharsetReloadInit,
131 : eCharsetReloadRequested,
132 : eCharsetReloadStopOrigional
133 : };
134 :
135 : class nsDocShell final
136 : : public nsDocLoader
137 : , public nsIDocShell
138 : , public nsIWebNavigation
139 : , public nsIBaseWindow
140 : , public nsIScrollable
141 : , public nsITextScroll
142 : , public nsIDocCharset
143 : , public nsIContentViewerContainer
144 : , public nsIRefreshURI
145 : , public nsIWebProgressListener
146 : , public nsIWebPageDescriptor
147 : , public nsIAuthPromptProvider
148 : , public nsILoadContext
149 : , public nsIWebShellServices
150 : , public nsILinkHandler
151 : , public nsIClipboardCommands
152 : , public nsIDOMStorageManager
153 : , public nsINetworkInterceptController
154 : , public nsIDeprecationWarner
155 : , public mozilla::SupportsWeakPtr<nsDocShell>
156 : {
157 : friend class nsDSURIContentListener;
158 : friend class FramingChecker;
159 : using Encoding = mozilla::Encoding;
160 :
161 : public:
162 531 : MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsDocShell)
163 :
164 : nsDocShell();
165 :
166 : virtual nsresult Init() override;
167 :
168 : NS_DECL_ISUPPORTS_INHERITED
169 :
170 : NS_DECL_NSIDOCSHELL
171 : NS_DECL_NSIDOCSHELLTREEITEM
172 : NS_DECL_NSIWEBNAVIGATION
173 : NS_DECL_NSIBASEWINDOW
174 : NS_DECL_NSISCROLLABLE
175 : NS_DECL_NSITEXTSCROLL
176 : NS_DECL_NSIDOCCHARSET
177 : NS_DECL_NSIINTERFACEREQUESTOR
178 : NS_DECL_NSIWEBPROGRESSLISTENER
179 : NS_DECL_NSIREFRESHURI
180 : NS_DECL_NSICONTENTVIEWERCONTAINER
181 : NS_DECL_NSIWEBPAGEDESCRIPTOR
182 : NS_DECL_NSIAUTHPROMPTPROVIDER
183 : NS_DECL_NSICLIPBOARDCOMMANDS
184 : NS_DECL_NSIWEBSHELLSERVICES
185 : NS_DECL_NSINETWORKINTERCEPTCONTROLLER
186 : NS_DECL_NSIDEPRECATIONWARNER
187 1 : NS_FORWARD_SAFE_NSIDOMSTORAGEMANAGER(TopSessionStorageManager())
188 :
189 8 : NS_IMETHOD Stop() override
190 : {
191 : // Need this here because otherwise nsIWebNavigation::Stop
192 : // overrides the docloader's Stop()
193 8 : return nsDocLoader::Stop();
194 : }
195 :
196 : // Need to implement (and forward) nsISecurityEventSink, because
197 : // nsIWebProgressListener has methods with identical names...
198 1 : NS_FORWARD_NSISECURITYEVENTSINK(nsDocLoader::)
199 :
200 : // nsILinkHandler
201 : NS_IMETHOD OnLinkClick(nsIContent* aContent,
202 : nsIURI* aURI,
203 : const char16_t* aTargetSpec,
204 : const nsAString& aFileName,
205 : nsIInputStream* aPostDataStream,
206 : nsIInputStream* aHeadersDataStream,
207 : bool aIsTrusted,
208 : nsIPrincipal* aTriggeringPrincipal) override;
209 : NS_IMETHOD OnLinkClickSync(nsIContent* aContent,
210 : nsIURI* aURI,
211 : const char16_t* aTargetSpec,
212 : const nsAString& aFileName,
213 : nsIInputStream* aPostDataStream = 0,
214 : nsIInputStream* aHeadersDataStream = 0,
215 : bool aNoOpenerImplied = false,
216 : nsIDocShell** aDocShell = 0,
217 : nsIRequest** aRequest = 0,
218 : nsIPrincipal* aTriggeringPrincipal = nullptr) override;
219 : NS_IMETHOD OnOverLink(nsIContent* aContent,
220 : nsIURI* aURI,
221 : const char16_t* aTargetSpec) override;
222 : NS_IMETHOD OnLeaveLink() override;
223 :
224 : nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType);
225 : uint32_t ConvertDocShellLoadInfoToLoadType(
226 : nsDocShellInfoLoadType aDocShellLoadType);
227 :
228 : // Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods
229 : // are shared with nsIDocShell (appID, etc.) and can't be declared twice.
230 : NS_IMETHOD GetAssociatedWindow(mozIDOMWindowProxy**) override;
231 : NS_IMETHOD GetTopWindow(mozIDOMWindowProxy**) override;
232 : NS_IMETHOD GetTopFrameElement(nsIDOMElement**) override;
233 : NS_IMETHOD GetNestedFrameId(uint64_t*) override;
234 : NS_IMETHOD GetIsContent(bool*) override;
235 : NS_IMETHOD GetUsePrivateBrowsing(bool*) override;
236 : NS_IMETHOD SetUsePrivateBrowsing(bool) override;
237 : NS_IMETHOD SetPrivateBrowsing(bool) override;
238 : NS_IMETHOD GetUseRemoteTabs(bool*) override;
239 : NS_IMETHOD SetRemoteTabs(bool) override;
240 : NS_IMETHOD GetScriptableOriginAttributes(JS::MutableHandle<JS::Value>) override;
241 :
242 : // Restores a cached presentation from history (mLSHE).
243 : // This method swaps out the content viewer and simulates loads for
244 : // subframes. It then simulates the completion of the toplevel load.
245 : nsresult RestoreFromHistory();
246 :
247 : // Perform a URI load from a refresh timer. This is just like the
248 : // ForceRefreshURI method on nsIRefreshURI, but makes sure to take
249 : // the timer involved out of mRefreshURIList if it's there.
250 : // aTimer must not be null.
251 : nsresult ForceRefreshURIFromTimer(nsIURI* aURI, int32_t aDelay,
252 : bool aMetaRefresh, nsITimer* aTimer);
253 :
254 : friend class OnLinkClickEvent;
255 :
256 : // We need dummy OnLocationChange in some cases to update the UI without
257 : // updating security info.
258 0 : void FireDummyOnLocationChange()
259 : {
260 0 : FireOnLocationChange(this, nullptr, mCurrentURI,
261 0 : LOCATION_CHANGE_SAME_DOCUMENT);
262 0 : }
263 :
264 : nsresult HistoryTransactionRemoved(int32_t aIndex);
265 :
266 : // Notify Scroll observers when an async panning/zooming transform
267 : // has started being applied
268 : void NotifyAsyncPanZoomStarted();
269 : // Notify Scroll observers when an async panning/zooming transform
270 : // is no longer applied
271 : void NotifyAsyncPanZoomStopped();
272 :
273 0 : void SetInFrameSwap(bool aInSwap)
274 : {
275 0 : mInFrameSwap = aInSwap;
276 0 : }
277 : bool InFrameSwap();
278 :
279 1 : const Encoding* GetForcedCharset() { return mForcedCharset; }
280 :
281 : private:
282 : bool CanSetOriginAttributes();
283 :
284 : public:
285 : const mozilla::OriginAttributes&
286 21 : GetOriginAttributes()
287 : {
288 21 : return mOriginAttributes;
289 : }
290 :
291 : nsresult SetOriginAttributes(const mozilla::OriginAttributes& aAttrs);
292 :
293 4 : void GetInterceptedDocumentId(nsAString& aId)
294 : {
295 4 : aId = mInterceptedDocumentId;
296 4 : }
297 :
298 : private:
299 : // An observed docshell wrapper is created when recording markers is enabled.
300 : mozilla::UniquePtr<mozilla::ObservedDocShell> mObserved;
301 :
302 : // It is necessary to allow adding a timeline marker wherever a docshell
303 : // instance is available. This operation happens frequently and needs to
304 : // be very fast, so instead of using a Map or having to search for some
305 : // docshell-specific markers storage, a pointer to an `ObservedDocShell` is
306 : // is stored on docshells directly.
307 : friend void mozilla::TimelineConsumers::AddConsumer(nsDocShell*);
308 : friend void mozilla::TimelineConsumers::RemoveConsumer(nsDocShell*);
309 : friend void mozilla::TimelineConsumers::AddMarkerForDocShell(
310 : nsDocShell*, const char*, MarkerTracingType, MarkerStackRequest);
311 : friend void mozilla::TimelineConsumers::AddMarkerForDocShell(
312 : nsDocShell*, const char*, const TimeStamp&, MarkerTracingType,
313 : MarkerStackRequest);
314 : friend void mozilla::TimelineConsumers::AddMarkerForDocShell(
315 : nsDocShell*, UniquePtr<AbstractTimelineMarker>&&);
316 : friend void mozilla::TimelineConsumers::PopMarkers(nsDocShell*,
317 : JSContext*, nsTArray<dom::ProfileTimelineMarker>&);
318 :
319 : public:
320 : // Tell the favicon service that aNewURI has the same favicon as aOldURI.
321 : static void CopyFavicon(nsIURI* aOldURI,
322 : nsIURI* aNewURI,
323 : nsIPrincipal* aLoadingPrincipal,
324 : bool aInPrivateBrowsing);
325 :
326 14 : static nsDocShell* Cast(nsIDocShell* aDocShell)
327 : {
328 14 : return static_cast<nsDocShell*>(aDocShell);
329 : }
330 :
331 : protected:
332 : virtual ~nsDocShell();
333 : virtual void DestroyChildren() override;
334 :
335 : // Content Viewer Management
336 : nsresult EnsureContentViewer();
337 : // aPrincipal can be passed in if the caller wants. If null is
338 : // passed in, the about:blank principal will end up being used.
339 : nsresult CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
340 : nsIURI* aBaseURI,
341 : bool aTryToSaveOldPresentation = true,
342 : bool aCheckPermitUnload = true);
343 : nsresult CreateContentViewer(const nsACString& aContentType,
344 : nsIRequest* aRequest,
345 : nsIStreamListener** aContentHandler);
346 : nsresult NewContentViewerObj(const nsACString& aContentType,
347 : nsIRequest* aRequest, nsILoadGroup* aLoadGroup,
348 : nsIStreamListener** aContentHandler,
349 : nsIContentViewer** aViewer);
350 : nsresult SetupNewViewer(nsIContentViewer* aNewViewer);
351 :
352 : void SetupReferrerFromChannel(nsIChannel* aChannel);
353 :
354 : nsresult GetEldestPresContext(nsPresContext** aPresContext);
355 :
356 : // Get the principal that we'll set on the channel if we're inheriting. If
357 : // aConsiderCurrentDocument is true, we try to use the current document if
358 : // at all possible. If that fails, we fall back on the parent document.
359 : // If that fails too, we force creation of a content viewer and use the
360 : // resulting principal. If aConsiderCurrentDocument is false, we just look
361 : // at the parent.
362 : nsIPrincipal* GetInheritedPrincipal(bool aConsiderCurrentDocument);
363 :
364 : // Actually open a channel and perform a URI load. Callers need to pass a
365 : // non-null aTriggeringPrincipal which initiated the URI load. Please note
366 : // that aTriggeringPrincipal will be used for performing security checks.
367 : // If the argument aURI is provided by the web, then please do not pass a
368 : // SystemPrincipal as the triggeringPrincipal. If principalToInherit is
369 : // null, then no inheritance of any sort will happen and the load will
370 : // get a principal based on the URI being loaded.
371 : // If aSrcdoc is not void, the load will be considered as a srcdoc load,
372 : // and the contents of aSrcdoc will be loaded instead of aURI.
373 : // aOriginalURI will be set as the originalURI on the channel that does the
374 : // load. If aOriginalURI is null, aURI will be set as the originalURI.
375 : // If aLoadReplace is true, LOAD_REPLACE flag will be set to the nsIChannel.
376 : nsresult DoURILoad(nsIURI* aURI,
377 : nsIURI* aOriginalURI,
378 : mozilla::Maybe<nsCOMPtr<nsIURI>> const& aResultPrincipalURI,
379 : bool aLoadReplace,
380 : nsIURI* aReferrer,
381 : bool aSendReferrer,
382 : uint32_t aReferrerPolicy,
383 : nsIPrincipal* aTriggeringPrincipal,
384 : nsIPrincipal* aPrincipalToInherit,
385 : const char* aTypeHint,
386 : const nsAString& aFileName,
387 : nsIInputStream* aPostData,
388 : nsIInputStream* aHeadersData,
389 : bool aFirstParty,
390 : nsIDocShell** aDocShell,
391 : nsIRequest** aRequest,
392 : bool aIsNewWindowTarget,
393 : bool aBypassClassifier,
394 : bool aForceAllowCookies,
395 : const nsAString& aSrcdoc,
396 : nsIURI* aBaseURI,
397 : nsContentPolicyType aContentPolicyType);
398 : nsresult AddHeadersToChannel(nsIInputStream* aHeadersData,
399 : nsIChannel* aChannel);
400 : nsresult DoChannelLoad(nsIChannel* aChannel,
401 : nsIURILoader* aURILoader,
402 : bool aBypassClassifier);
403 :
404 : nsresult ScrollToAnchor(bool aCurHasRef,
405 : bool aNewHasRef,
406 : nsACString& aNewHash,
407 : uint32_t aLoadType);
408 :
409 : // Returns true if would have called FireOnLocationChange,
410 : // but did not because aFireOnLocationChange was false on entry.
411 : // In this case it is the caller's responsibility to ensure
412 : // FireOnLocationChange is called.
413 : // In all other cases false is returned.
414 : bool OnLoadingSite(nsIChannel* aChannel,
415 : bool aFireOnLocationChange,
416 : bool aAddToGlobalHistory = true);
417 :
418 : // Returns true if would have called FireOnLocationChange,
419 : // but did not because aFireOnLocationChange was false on entry.
420 : // In this case it is the caller's responsibility to ensure
421 : // FireOnLocationChange is called.
422 : // In all other cases false is returned.
423 : // Either aChannel or aTriggeringPrincipal must be null. If aChannel is
424 : // present, the owner should be gotten from it.
425 : // If OnNewURI calls AddToSessionHistory, it will pass its
426 : // aCloneSHChildren argument as aCloneChildren.
427 : bool OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
428 : nsIPrincipal* aTriggeringPrincipal,
429 : nsIPrincipal* aPrincipalToInherit,
430 : uint32_t aLoadType,
431 : bool aFireOnLocationChange,
432 : bool aAddToGlobalHistory,
433 : bool aCloneSHChildren);
434 :
435 : void SetReferrerURI(nsIURI* aURI);
436 : void SetReferrerPolicy(uint32_t aReferrerPolicy);
437 :
438 : // Session History
439 : bool ShouldAddToSessionHistory(nsIURI* aURI);
440 : // Either aChannel or aOwner must be null. If aChannel is
441 : // present, the owner should be gotten from it.
442 : // If aCloneChildren is true, then our current session history's
443 : // children will be cloned onto the new entry. This should be
444 : // used when we aren't actually changing the document while adding
445 : // the new session history entry.
446 : nsresult AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
447 : nsIPrincipal* aTriggeringPrincipal,
448 : nsIPrincipal* aPrincipalToInherit,
449 : bool aCloneChildren,
450 : nsISHEntry** aNewEntry);
451 : nsresult AddChildSHEntryToParent(nsISHEntry* aNewEntry, int32_t aChildOffset,
452 : bool aCloneChildren);
453 :
454 : nsresult AddChildSHEntryInternal(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
455 : int32_t aChildOffset, uint32_t aLoadType,
456 : bool aCloneChildren);
457 :
458 : nsresult LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType);
459 : nsresult PersistLayoutHistoryState();
460 :
461 : // Clone a session history tree for subframe navigation.
462 : // The tree rooted at |aSrcEntry| will be cloned into |aDestEntry|, except
463 : // for the entry with id |aCloneID|, which will be replaced with
464 : // |aReplaceEntry|. |aSrcShell| is a (possibly null) docshell which
465 : // corresponds to |aSrcEntry| via its mLSHE or mOHE pointers, and will
466 : // have that pointer updated to point to the cloned history entry.
467 : // If aCloneChildren is true then the children of the entry with id
468 : // |aCloneID| will be cloned into |aReplaceEntry|.
469 : static nsresult CloneAndReplace(nsISHEntry* aSrcEntry,
470 : nsDocShell* aSrcShell,
471 : uint32_t aCloneID,
472 : nsISHEntry* aReplaceEntry,
473 : bool aCloneChildren,
474 : nsISHEntry** aDestEntry);
475 :
476 : // Child-walking callback for CloneAndReplace
477 : static nsresult CloneAndReplaceChild(nsISHEntry* aEntry, nsDocShell* aShell,
478 : int32_t aChildIndex, void* aData);
479 :
480 : nsresult GetRootSessionHistory(nsISHistory** aReturn);
481 : nsresult GetHttpChannel(nsIChannel* aChannel, nsIHttpChannel** aReturn);
482 : bool ShouldDiscardLayoutState(nsIHttpChannel* aChannel);
483 :
484 : // Determine whether this docshell corresponds to the given history entry,
485 : // via having a pointer to it in mOSHE or mLSHE.
486 0 : bool HasHistoryEntry(nsISHEntry* aEntry) const
487 : {
488 0 : return aEntry && (aEntry == mOSHE || aEntry == mLSHE);
489 : }
490 :
491 : // Update any pointers (mOSHE or mLSHE) to aOldEntry to point to aNewEntry
492 : void SwapHistoryEntries(nsISHEntry* aOldEntry, nsISHEntry* aNewEntry);
493 :
494 : // Call this method to swap in a new history entry to m[OL]SHE, rather than
495 : // setting it directly. This completes the navigation in all docshells
496 : // in the case of a subframe navigation.
497 : void SetHistoryEntry(nsCOMPtr<nsISHEntry>* aPtr, nsISHEntry* aEntry);
498 :
499 : // Child-walking callback for SetHistoryEntry
500 : static nsresult SetChildHistoryEntry(nsISHEntry* aEntry, nsDocShell* aShell,
501 : int32_t aEntryIndex, void* aData);
502 :
503 : // Callback prototype for WalkHistoryEntries.
504 : // aEntry is the child history entry, aShell is its corresponding docshell,
505 : // aChildIndex is the child's index in its parent entry, and aData is
506 : // the opaque pointer passed to WalkHistoryEntries.
507 : typedef nsresult(*WalkHistoryEntriesFunc)(nsISHEntry* aEntry,
508 : nsDocShell* aShell,
509 : int32_t aChildIndex,
510 : void* aData);
511 :
512 : // For each child of aRootEntry, find the corresponding docshell which is
513 : // a child of aRootShell, and call aCallback. The opaque pointer aData
514 : // is passed to the callback.
515 : static nsresult WalkHistoryEntries(nsISHEntry* aRootEntry,
516 : nsDocShell* aRootShell,
517 : WalkHistoryEntriesFunc aCallback,
518 : void* aData);
519 :
520 : // overridden from nsDocLoader, this provides more information than the
521 : // normal OnStateChange with flags STATE_REDIRECTING
522 : virtual void OnRedirectStateChange(nsIChannel* aOldChannel,
523 : nsIChannel* aNewChannel,
524 : uint32_t aRedirectFlags,
525 : uint32_t aStateFlags) override;
526 :
527 : /**
528 : * Helper function that determines if channel is an HTTP POST.
529 : *
530 : * @param aChannel
531 : * The channel to test
532 : *
533 : * @return True iff channel is an HTTP post.
534 : */
535 : bool ChannelIsPost(nsIChannel* aChannel);
536 :
537 : /**
538 : * Helper function that finds the last URI and its transition flags for a
539 : * channel.
540 : *
541 : * This method first checks the channel's property bag to see if previous
542 : * info has been saved. If not, it gives back the referrer of the channel.
543 : *
544 : * @param aChannel
545 : * The channel we are transitioning to
546 : * @param aURI
547 : * Output parameter with the previous URI, not addref'd
548 : * @param aChannelRedirectFlags
549 : * If a redirect, output parameter with the previous redirect flags
550 : * from nsIChannelEventSink
551 : */
552 : void ExtractLastVisit(nsIChannel* aChannel,
553 : nsIURI** aURI,
554 : uint32_t* aChannelRedirectFlags);
555 :
556 : /**
557 : * Helper function that caches a URI and a transition for saving later.
558 : *
559 : * @param aChannel
560 : * Channel that will have these properties saved
561 : * @param aURI
562 : * The URI to save for later
563 : * @param aChannelRedirectFlags
564 : * The nsIChannelEventSink redirect flags to save for later
565 : */
566 : void SaveLastVisit(nsIChannel* aChannel,
567 : nsIURI* aURI,
568 : uint32_t aChannelRedirectFlags);
569 :
570 : /**
571 : * Helper function for adding a URI visit using IHistory. If IHistory is
572 : * not available, the method tries nsIGlobalHistory2.
573 : *
574 : * The IHistory API maintains chains of visits, tracking both HTTP referrers
575 : * and redirects for a user session. VisitURI requires the current URI and
576 : * the previous URI in the chain.
577 : *
578 : * Visits can be saved either during a redirect or when the request has
579 : * reached its final destination. The previous URI in the visit may be
580 : * from another redirect or it may be the referrer.
581 : *
582 : * @pre aURI is not null.
583 : *
584 : * @param aURI
585 : * The URI that was just visited
586 : * @param aReferrerURI
587 : * The referrer URI of this request
588 : * @param aPreviousURI
589 : * The previous URI of this visit (may be the same as aReferrerURI)
590 : * @param aChannelRedirectFlags
591 : * For redirects, the redirect flags from nsIChannelEventSink
592 : * (0 otherwise)
593 : * @param aResponseStatus
594 : * For HTTP channels, the response code (0 otherwise).
595 : */
596 : void AddURIVisit(nsIURI* aURI,
597 : nsIURI* aReferrerURI,
598 : nsIURI* aPreviousURI,
599 : uint32_t aChannelRedirectFlags,
600 : uint32_t aResponseStatus = 0);
601 :
602 : // Helper Routines
603 : nsresult ConfirmRepost(bool* aRepost);
604 : NS_IMETHOD GetPromptAndStringBundle(nsIPrompt** aPrompt,
605 : nsIStringBundle** aStringBundle);
606 : NS_IMETHOD GetChildOffset(nsIDOMNode* aChild, nsIDOMNode* aParent,
607 : int32_t* aOffset);
608 : nsIScrollableFrame* GetRootScrollFrame();
609 : NS_IMETHOD EnsureScriptEnvironment();
610 : NS_IMETHOD EnsureEditorData();
611 : nsresult EnsureTransferableHookData();
612 : NS_IMETHOD EnsureFind();
613 : nsresult RefreshURIFromQueue();
614 : NS_IMETHOD LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
615 : const char* aErrorPage,
616 : const char16_t* aErrorType,
617 : const char16_t* aDescription,
618 : const char* aCSSClass,
619 : nsIChannel* aFailedChannel);
620 : bool IsPrintingOrPP(bool aDisplayErrorDialog = true);
621 : bool IsNavigationAllowed(bool aDisplayPrintErrorDialog = true,
622 : bool aCheckIfUnloadFired = true);
623 :
624 : nsresult SetBaseUrlForWyciwyg(nsIContentViewer* aContentViewer);
625 :
626 1 : static inline uint32_t PRTimeToSeconds(PRTime aTimeUsec)
627 : {
628 1 : PRTime usecPerSec = PR_USEC_PER_SEC;
629 1 : return uint32_t(aTimeUsec /= usecPerSec);
630 : }
631 :
632 0 : inline bool UseErrorPages()
633 : {
634 0 : return (mObserveErrorPages ? sUseErrorPages : mUseErrorPages);
635 : }
636 :
637 : bool IsFrame();
638 :
639 : //
640 : // Helper method that is called when a new document (including any
641 : // sub-documents - ie. frames) has been completely loaded.
642 : //
643 : virtual nsresult EndPageLoad(nsIWebProgress* aProgress,
644 : nsIChannel* aChannel,
645 : nsresult aResult);
646 :
647 : // Sets the current document's current state object to the given SHEntry's
648 : // state object. The current state object is eventually given to the page
649 : // in the PopState event.
650 : nsresult SetDocCurrentStateObj(nsISHEntry* aShEntry);
651 :
652 : nsresult CheckLoadingPermissions();
653 :
654 : // Security checks to prevent frameset spoofing. See comments at
655 : // implementation sites.
656 : static bool CanAccessItem(nsIDocShellTreeItem* aTargetItem,
657 : nsIDocShellTreeItem* aAccessingItem,
658 : bool aConsiderOpener = true);
659 : static bool ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem,
660 : nsIDocShellTreeItem* aTargetTreeItem);
661 :
662 : // Returns true if would have called FireOnLocationChange,
663 : // but did not because aFireOnLocationChange was false on entry.
664 : // In this case it is the caller's responsibility to ensure
665 : // FireOnLocationChange is called.
666 : // In all other cases false is returned.
667 : bool SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
668 : bool aFireOnLocationChange,
669 : uint32_t aLocationFlags);
670 :
671 : // The following methods deal with saving and restoring content viewers
672 : // in session history.
673 :
674 : // mContentViewer points to the current content viewer associated with
675 : // this docshell. When loading a new document, the content viewer is
676 : // either destroyed or stored into a session history entry. To make sure
677 : // that destruction happens in a controlled fashion, a given content viewer
678 : // is always owned in exactly one of these ways:
679 : // 1) The content viewer is active and owned by a docshell's
680 : // mContentViewer.
681 : // 2) The content viewer is still being displayed while we begin loading
682 : // a new document. The content viewer is owned by the _new_
683 : // content viewer's mPreviousViewer, and has a pointer to the
684 : // nsISHEntry where it will eventually be stored. The content viewer
685 : // has been close()d by the docshell, which detaches the document from
686 : // the window object.
687 : // 3) The content viewer is cached in session history. The nsISHEntry
688 : // has the only owning reference to the content viewer. The viewer
689 : // has released its nsISHEntry pointer to prevent circular ownership.
690 : //
691 : // When restoring a content viewer from session history, open() is called
692 : // to reattach the document to the window object. The content viewer is
693 : // then placed into mContentViewer and removed from the history entry.
694 : // (mContentViewer is put into session history as described above, if
695 : // applicable).
696 :
697 : // Determines whether we can safely cache the current mContentViewer in
698 : // session history. This checks a number of factors such as cache policy,
699 : // pending requests, and unload handlers.
700 : // |aLoadType| should be the load type that will replace the current
701 : // presentation. |aNewRequest| should be the request for the document to
702 : // be loaded in place of the current document, or null if such a request
703 : // has not been created yet. |aNewDocument| should be the document that will
704 : // replace the current document.
705 : bool CanSavePresentation(uint32_t aLoadType,
706 : nsIRequest* aNewRequest,
707 : nsIDocument* aNewDocument);
708 :
709 : // Captures the state of the supporting elements of the presentation
710 : // (the "window" object, docshell tree, meta-refresh loads, and security
711 : // state) and stores them on |mOSHE|.
712 : nsresult CaptureState();
713 :
714 : // Begin the toplevel restore process for |aSHEntry|.
715 : // This simulates a channel open, and defers the real work until
716 : // RestoreFromHistory is called from a PLEvent.
717 : nsresult RestorePresentation(nsISHEntry* aSHEntry, bool* aRestoring);
718 :
719 : // Call BeginRestore(nullptr, false) for each child of this shell.
720 : nsresult BeginRestoreChildren();
721 :
722 : // Method to get our current position and size without flushing
723 : void DoGetPositionAndSize(int32_t* aX, int32_t* aY, int32_t* aWidth,
724 : int32_t* aHeight);
725 :
726 : // Call this when a URI load is handed to us (via OnLinkClick or
727 : // InternalLoad). This makes sure that we're not inside unload, or that if
728 : // we are it's still OK to load this URI.
729 : bool IsOKToLoadURI(nsIURI* aURI);
730 :
731 : void ReattachEditorToWindow(nsISHEntry* aSHEntry);
732 :
733 : nsCOMPtr<nsIDOMStorageManager> mSessionStorageManager;
734 : nsIDOMStorageManager* TopSessionStorageManager();
735 :
736 : // helpers for executing commands
737 : nsresult GetControllerForCommand(const char* aCommand,
738 : nsIController** aResult);
739 : nsresult EnsureCommandHandler();
740 :
741 : nsIChannel* GetCurrentDocChannel();
742 :
743 : bool ShouldBlockLoadingForBackButton();
744 :
745 : // Convenience method for getting our parent docshell. Can return null
746 : already_AddRefed<nsDocShell> GetParentDocshell();
747 :
748 : protected:
749 : nsresult GetCurScrollPos(int32_t aScrollOrientation, int32_t* aCurPos);
750 : nsresult SetCurScrollPosEx(int32_t aCurHorizontalPos,
751 : int32_t aCurVerticalPos);
752 :
753 : // Override the parent setter from nsDocLoader
754 : virtual nsresult SetDocLoaderParent(nsDocLoader* aLoader) override;
755 :
756 : void ClearFrameHistory(nsISHEntry* aEntry);
757 :
758 : /**
759 : * Initializes mTiming if it isn't yet.
760 : * After calling this, mTiming is non-null. This method returns true if the
761 : * initialization of the Timing can be reset (basically this is true if a new
762 : * Timing object is created).
763 : * In case the loading is aborted, MaybeResetInitTiming() can be called
764 : * passing the return value of MaybeInitTiming(): if it's possible to reset
765 : * the Timing, this method will do it.
766 : */
767 : MOZ_MUST_USE bool MaybeInitTiming();
768 : void MaybeResetInitTiming(bool aReset);
769 :
770 0 : bool DisplayLoadError(nsresult aError, nsIURI* aURI, const char16_t* aURL,
771 : nsIChannel* aFailedChannel)
772 : {
773 0 : bool didDisplayLoadError = false;
774 0 : DisplayLoadError(aError, aURI, aURL, aFailedChannel, &didDisplayLoadError);
775 0 : return didDisplayLoadError;
776 : }
777 :
778 : public:
779 : // Event type dispatched by RestorePresentation
780 0 : class RestorePresentationEvent : public mozilla::Runnable
781 : {
782 : public:
783 : NS_DECL_NSIRUNNABLE
784 0 : explicit RestorePresentationEvent(nsDocShell* aDs)
785 0 : : mozilla::Runnable("nsDocShell::RestorePresentationEvent")
786 0 : , mDocShell(aDs)
787 : {
788 0 : }
789 0 : void Revoke() { mDocShell = nullptr; }
790 : private:
791 : RefPtr<nsDocShell> mDocShell;
792 : };
793 :
794 : protected:
795 : bool JustStartedNetworkLoad();
796 :
797 : nsresult CreatePrincipalFromReferrer(nsIURI* aReferrer,
798 : nsIPrincipal** aResult);
799 :
800 0 : static const nsCString FrameTypeToString(uint32_t aFrameType)
801 : {
802 0 : switch (aFrameType) {
803 : case FRAME_TYPE_BROWSER:
804 0 : return NS_LITERAL_CSTRING("browser");
805 : case FRAME_TYPE_REGULAR:
806 0 : return NS_LITERAL_CSTRING("regular");
807 : default:
808 0 : NS_ERROR("Unknown frame type");
809 0 : return EmptyCString();
810 : }
811 : }
812 :
813 : uint32_t GetInheritedFrameType();
814 :
815 : bool HasUnloadedParent();
816 :
817 : void UpdateGlobalHistoryTitle(nsIURI* aURI);
818 :
819 : NS_IMETHOD_(void) GetOriginAttributes(mozilla::OriginAttributes& aAttrs) override;
820 :
821 : // Dimensions of the docshell
822 : nsIntRect mBounds;
823 : nsString mName;
824 : nsString mTitle;
825 : nsString mCustomUserAgent;
826 :
827 : /**
828 : * Content-Type Hint of the most-recently initiated load. Used for
829 : * session history entries.
830 : */
831 : nsCString mContentTypeHint;
832 : nsIntPoint mDefaultScrollbarPref; // persistent across doc loads
833 :
834 : nsCOMPtr<nsIMutableArray> mRefreshURIList;
835 : nsCOMPtr<nsIMutableArray> mSavedRefreshURIList;
836 : RefPtr<nsDSURIContentListener> mContentListener;
837 : nsCOMPtr<nsIContentViewer> mContentViewer;
838 : nsCOMPtr<nsIWidget> mParentWidget;
839 :
840 : // mCurrentURI should be marked immutable on set if possible.
841 : nsCOMPtr<nsIURI> mCurrentURI;
842 : nsCOMPtr<nsIURI> mReferrerURI;
843 : uint32_t mReferrerPolicy;
844 : RefPtr<nsGlobalWindow> mScriptGlobal;
845 : nsCOMPtr<nsISHistory> mSessionHistory;
846 : nsCOMPtr<nsIGlobalHistory2> mGlobalHistory;
847 : nsCOMPtr<nsIWebBrowserFind> mFind;
848 : nsCOMPtr<nsICommandManager> mCommandManager;
849 : // Reference to the SHEntry for this docshell until the page is destroyed.
850 : // Somebody give me better name
851 : nsCOMPtr<nsISHEntry> mOSHE;
852 : // Reference to the SHEntry for this docshell until the page is loaded
853 : // Somebody give me better name.
854 : // If mLSHE is non-null, non-pushState subframe loads don't create separate
855 : // root history entries. That is, frames loaded during the parent page
856 : // load don't generate history entries the way frame navigation after the
857 : // parent has loaded does. (This isn't the only purpose of mLSHE.)
858 : nsCOMPtr<nsISHEntry> mLSHE;
859 :
860 : // Holds a weak pointer to a RestorePresentationEvent object if any that
861 : // holds a weak pointer back to us. We use this pointer to possibly revoke
862 : // the event whenever necessary.
863 : nsRevocableEventPtr<RestorePresentationEvent> mRestorePresentationEvent;
864 :
865 : // Editor data, if this document is designMode or contentEditable.
866 : nsAutoPtr<nsDocShellEditorData> mEditorData;
867 :
868 : // Transferable hooks/callbacks
869 : nsCOMPtr<nsIClipboardDragDropHookList> mTransferableHookData;
870 :
871 : // Secure browser UI object
872 : nsCOMPtr<nsISecureBrowserUI> mSecurityUI;
873 :
874 : // The URI we're currently loading. This is only relevant during the
875 : // firing of a pagehide/unload. The caller of FirePageHideNotification()
876 : // is responsible for setting it and unsetting it. It may be null if the
877 : // pagehide/unload is happening for some reason other than just loading a
878 : // new URI.
879 : nsCOMPtr<nsIURI> mLoadingURI;
880 :
881 : // Set in LoadErrorPage from the method argument and used later
882 : // in CreateContentViewer. We have to delay an shistory entry creation
883 : // for which these objects are needed.
884 : nsCOMPtr<nsIURI> mFailedURI;
885 : nsCOMPtr<nsIChannel> mFailedChannel;
886 : uint32_t mFailedLoadType;
887 :
888 : // Set in DoURILoad when either the LOAD_RELOAD_ALLOW_MIXED_CONTENT flag or
889 : // the LOAD_NORMAL_ALLOW_MIXED_CONTENT flag is set.
890 : // Checked in nsMixedContentBlocker, to see if the channels match.
891 : nsCOMPtr<nsIChannel> mMixedContentChannel;
892 :
893 : // WEAK REFERENCES BELOW HERE.
894 : // Note these are intentionally not addrefd. Doing so will create a cycle.
895 : // For that reasons don't use nsCOMPtr.
896 :
897 : nsIDocShellTreeOwner* mTreeOwner; // Weak Reference
898 : mozilla::dom::EventTarget* mChromeEventHandler; // Weak Reference
899 :
900 : eCharsetReloadState mCharsetReloadState;
901 :
902 : // Offset in the parent's child list.
903 : // -1 if the docshell is added dynamically to the parent shell.
904 : uint32_t mChildOffset;
905 : uint32_t mBusyFlags;
906 : uint32_t mAppType;
907 : uint32_t mLoadType;
908 :
909 : int32_t mMarginWidth;
910 : int32_t mMarginHeight;
911 :
912 : // This can either be a content docshell or a chrome docshell. After
913 : // Create() is called, the type is not expected to change.
914 : int32_t mItemType;
915 :
916 : // Index into the SHTransaction list, indicating the previous and current
917 : // transaction at the time that this DocShell begins to load
918 : int32_t mPreviousTransIndex;
919 : int32_t mLoadedTransIndex;
920 :
921 : uint32_t mSandboxFlags;
922 : nsWeakPtr mOnePermittedSandboxedNavigator;
923 :
924 : // The orientation lock as described by
925 : // https://w3c.github.io/screen-orientation/
926 : mozilla::dom::ScreenOrientationInternal mOrientationLock;
927 :
928 : // mFullscreenAllowed stores how we determine whether fullscreen is allowed
929 : // when GetFullscreenAllowed() is called. Fullscreen is allowed in a
930 : // docshell when all containing iframes have the allowfullscreen
931 : // attribute set to true. When mFullscreenAllowed is CHECK_ATTRIBUTES
932 : // we check this docshell's containing frame for the allowfullscreen
933 : // attribute, and recurse onto the parent docshell to ensure all containing
934 : // frames also have the allowfullscreen attribute. If we find an ancestor
935 : // docshell with mFullscreenAllowed not equal to CHECK_ATTRIBUTES, we've
936 : // reached a content boundary, and mFullscreenAllowed denotes whether the
937 : // parent across the content boundary has allowfullscreen=true in all its
938 : // containing iframes. mFullscreenAllowed defaults to CHECK_ATTRIBUTES and
939 : // is set otherwise when docshells which are content boundaries are created.
940 : enum FullscreenAllowedState : uint8_t
941 : {
942 : CHECK_ATTRIBUTES,
943 : PARENT_ALLOWS,
944 : PARENT_PROHIBITS
945 : };
946 : FullscreenAllowedState mFullscreenAllowed;
947 :
948 : // Cached value of the "browser.xul.error_pages.enabled" preference.
949 : static bool sUseErrorPages;
950 :
951 : bool mCreated : 1;
952 : bool mAllowSubframes : 1;
953 : bool mAllowPlugins : 1;
954 : bool mAllowJavascript : 1;
955 : bool mAllowMetaRedirects : 1;
956 : bool mAllowImages : 1;
957 : bool mAllowMedia : 1;
958 : bool mAllowDNSPrefetch : 1;
959 : bool mAllowWindowControl : 1;
960 : bool mAllowContentRetargeting : 1;
961 : bool mAllowContentRetargetingOnChildren : 1;
962 : bool mUseErrorPages : 1;
963 : bool mObserveErrorPages : 1;
964 : bool mAllowAuth : 1;
965 : bool mAllowKeywordFixup : 1;
966 : bool mIsOffScreenBrowser : 1;
967 : bool mIsActive : 1;
968 : bool mDisableMetaRefreshWhenInactive : 1;
969 : bool mIsPrerendered : 1;
970 : bool mIsAppTab : 1;
971 : bool mUseGlobalHistory : 1;
972 : bool mUseRemoteTabs : 1;
973 : bool mUseTrackingProtection : 1;
974 : bool mDeviceSizeIsPageSize : 1;
975 : bool mWindowDraggingAllowed : 1;
976 : bool mInFrameSwap : 1;
977 : bool mInheritPrivateBrowsingId : 1;
978 :
979 : // Because scriptability depends on the mAllowJavascript values of our
980 : // ancestors, we cache the effective scriptability and recompute it when
981 : // it might have changed;
982 : bool mCanExecuteScripts : 1;
983 : void RecomputeCanExecuteScripts();
984 :
985 : // This boolean is set to true right before we fire pagehide and generally
986 : // unset when we embed a new content viewer. While it's true no navigation
987 : // is allowed in this docshell.
988 : bool mFiredUnloadEvent : 1;
989 :
990 : // this flag is for bug #21358. a docshell may load many urls
991 : // which don't result in new documents being created (i.e. a new
992 : // content viewer) we want to make sure we don't call a on load
993 : // event more than once for a given content viewer.
994 : bool mEODForCurrentDocument : 1;
995 : bool mURIResultedInDocument : 1;
996 :
997 : bool mIsBeingDestroyed : 1;
998 :
999 : bool mIsExecutingOnLoadHandler : 1;
1000 :
1001 : // Indicates that a DocShell in this "docshell tree" is printing
1002 : bool mIsPrintingOrPP : 1;
1003 :
1004 : // Indicates to CreateContentViewer() that it is safe to cache the old
1005 : // presentation of the page, and to SetupNewViewer() that the old viewer
1006 : // should be passed a SHEntry to save itself into.
1007 : bool mSavingOldViewer : 1;
1008 :
1009 : // @see nsIDocShellHistory::createdDynamically
1010 : bool mDynamicallyCreated : 1;
1011 : bool mAffectPrivateSessionLifetime : 1;
1012 : bool mInvisible : 1;
1013 : bool mHasLoadedNonBlankURI : 1;
1014 :
1015 : // This flag means that mTiming has been initialized but nulled out.
1016 : // We will check the innerWin's timing before creating a new one
1017 : // in MaybeInitTiming()
1018 : bool mBlankTiming : 1;
1019 :
1020 : // The following two fields cannot be declared as bit fields
1021 : // because of uses with AutoRestore.
1022 : bool mCreatingDocument; // (should be) debugging only
1023 : #ifdef DEBUG
1024 : bool mInEnsureScriptEnv;
1025 : #endif
1026 :
1027 : nsID mHistoryID;
1028 : uint32_t mDefaultLoadFlags;
1029 :
1030 : static nsIURIFixup* sURIFixup;
1031 :
1032 : RefPtr<nsDOMNavigationTiming> mTiming;
1033 :
1034 : // Are we a regular frame, a browser frame, or an app frame?
1035 : uint32_t mFrameType;
1036 :
1037 : // This represents the state of private browsing in the docshell.
1038 : // Currently treated as a binary value: 1 - in private mode, 0 - not private mode
1039 : // On content docshells mPrivateBrowsingId == mOriginAttributes.mPrivateBrowsingId
1040 : // On chrome docshells this value will be set, but not have the corresponding
1041 : // origin attribute set.
1042 : uint32_t mPrivateBrowsingId;
1043 :
1044 : nsString mInterceptedDocumentId;
1045 :
1046 : private:
1047 : const Encoding* mForcedCharset;
1048 : const Encoding* mParentCharset;
1049 : int32_t mParentCharsetSource;
1050 : nsCOMPtr<nsIPrincipal> mParentCharsetPrincipal;
1051 : nsTObserverArray<nsWeakPtr> mPrivacyObservers;
1052 : nsTObserverArray<nsWeakPtr> mReflowObservers;
1053 : nsTObserverArray<nsWeakPtr> mScrollObservers;
1054 : nsCString mOriginalUriString;
1055 : nsWeakPtr mOpener;
1056 : mozilla::OriginAttributes mOriginAttributes;
1057 :
1058 : mozilla::UniquePtr<mozilla::dom::PendingGlobalHistoryEntry> mPrerenderGlobalHistory;
1059 :
1060 : // A depth count of how many times NotifyRunToCompletionStart
1061 : // has been called without a matching NotifyRunToCompletionStop.
1062 : uint32_t mJSRunToCompletionDepth;
1063 :
1064 : // Whether or not touch events are overridden. Possible values are defined
1065 : // as constants in the nsIDocShell.idl file.
1066 : uint32_t mTouchEventsOverride;
1067 :
1068 : // Separate function to do the actual name (i.e. not _top, _self etc.)
1069 : // searching for FindItemWithName.
1070 : nsresult DoFindItemWithName(const nsAString& aName,
1071 : nsIDocShellTreeItem* aRequestor,
1072 : nsIDocShellTreeItem* aOriginalRequestor,
1073 : bool aSkipTabGroup,
1074 : nsIDocShellTreeItem** aResult);
1075 :
1076 : // Helper assertion to enforce that mInPrivateBrowsing is in sync with
1077 : // OriginAttributes.mPrivateBrowsingId
1078 : void AssertOriginAttributesMatchPrivateBrowsing();
1079 :
1080 : // Notify consumers of a search being loaded through the observer service:
1081 : void MaybeNotifyKeywordSearchLoading(const nsString& aProvider,
1082 : const nsString& aKeyword);
1083 :
1084 : // Internal implementation of nsIDocShell::FirePageHideNotification.
1085 : // If aSkipCheckingDynEntries is true, it will not try to remove dynamic
1086 : // subframe entries. This is to avoid redundant RemoveDynEntries calls in all
1087 : // children docshells.
1088 : void FirePageHideNotificationInternal(bool aIsUnload,
1089 : bool aSkipCheckingDynEntries);
1090 :
1091 : // Dispatch a runnable to the TabGroup associated to this docshell.
1092 : nsresult DispatchToTabGroup(const char* aName,
1093 : mozilla::TaskCategory aCategory,
1094 : already_AddRefed<nsIRunnable>&& aRunnable);
1095 :
1096 : #ifdef DEBUG
1097 : // We're counting the number of |nsDocShells| to help find leaks
1098 : static unsigned long gNumberOfDocShells;
1099 : #endif /* DEBUG */
1100 :
1101 : public:
1102 : class InterfaceRequestorProxy : public nsIInterfaceRequestor
1103 : {
1104 : public:
1105 : explicit InterfaceRequestorProxy(nsIInterfaceRequestor* aRequestor);
1106 : NS_DECL_THREADSAFE_ISUPPORTS
1107 : NS_DECL_NSIINTERFACEREQUESTOR
1108 :
1109 : protected:
1110 : virtual ~InterfaceRequestorProxy();
1111 : InterfaceRequestorProxy() {}
1112 : nsWeakPtr mWeakPtr;
1113 : };
1114 : };
1115 :
1116 : #endif /* nsDocShell_h__ */
|