|
|
234 |
#include "nsXULAppAPI.h" |
234 |
#include "nsXULAppAPI.h" |
235 |
#endif |
235 |
#endif |
236 |
|
236 |
|
|
|
237 |
#include "nsDOMNavigationTiming.h" |
238 |
|
237 |
using namespace mozilla; |
239 |
using namespace mozilla; |
238 |
|
240 |
|
239 |
// Number of documents currently loading |
241 |
// Number of documents currently loading |
|
675 |
ForEachPing(content, SendPing, &info); |
677 |
ForEachPing(content, SendPing, &info); |
676 |
} |
678 |
} |
677 |
|
679 |
|
|
|
680 |
static nsDOMNavigationTimingType |
681 |
ConvertLoadTypeToNavigationType(PRUint32 aLoadType) |
682 |
{ |
683 |
nsDOMNavigationTimingType result = nsIDOMNavigationTiming::NAVIGATION_OTHER; |
684 |
switch (aLoadType) { |
685 |
case LOAD_NORMAL: |
686 |
case LOAD_NORMAL_EXTERNAL: |
687 |
case LOAD_NORMAL_BYPASS_CACHE: |
688 |
case LOAD_NORMAL_BYPASS_PROXY: |
689 |
case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE: |
690 |
result = nsIDOMNavigationTiming::NAVIGATION_BROWSER; |
691 |
break; |
692 |
case LOAD_HISTORY: |
693 |
result = nsIDOMNavigationTiming::NAVIGATION_FORWARD_BACK; |
694 |
break; |
695 |
case LOAD_RELOAD_NORMAL: |
696 |
case LOAD_RELOAD_CHARSET_CHANGE: |
697 |
case LOAD_RELOAD_BYPASS_CACHE: |
698 |
case LOAD_RELOAD_BYPASS_PROXY: |
699 |
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE: |
700 |
result = nsIDOMNavigationTiming::NAVIGATION_RELOAD; |
701 |
break; |
702 |
case LOAD_LINK: |
703 |
result = nsIDOMNavigationTiming::NAVIGATION_LINK; |
704 |
break; |
705 |
case LOAD_NORMAL_REPLACE: |
706 |
case LOAD_STOP_CONTENT: |
707 |
case LOAD_STOP_CONTENT_AND_REPLACE: |
708 |
case LOAD_REFRESH: |
709 |
case LOAD_BYPASS_HISTORY: |
710 |
case LOAD_ERROR_PAGE: |
711 |
case LOAD_PUSHSTATE: |
712 |
result = nsIDOMNavigationTiming::NAVIGATION_OTHER; |
713 |
break; |
714 |
default: |
715 |
NS_NOTREACHED("Unexpected load type value"); |
716 |
} |
717 |
|
718 |
return result; |
719 |
} |
720 |
|
678 |
static nsISHEntry* GetRootSHEntry(nsISHEntry *entry); |
721 |
static nsISHEntry* GetRootSHEntry(nsISHEntry *entry); |
679 |
|
722 |
|
680 |
//***************************************************************************** |
723 |
//***************************************************************************** |
|
1534 |
// Now make sure our editor, if any, is detached before we go |
1577 |
// Now make sure our editor, if any, is detached before we go |
1535 |
// any farther. |
1578 |
// any farther. |
1536 |
DetachEditorFromWindow(); |
1579 |
DetachEditorFromWindow(); |
1537 |
} |
1580 |
// Make sure timing is created. mCurrentURI is out of date. |
1538 |
|
1581 |
nsresult rv = initTiming(mLoadingURI); |
1539 |
return NS_OK; |
1582 |
NS_ENSURE_SUCCESS(rv, rv); |
1540 |
} |
1583 |
mTiming->NotifyLastUnload(mCurrentURI); |
|
|
1584 |
} |
1585 |
|
1586 |
return NS_OK; |
1587 |
} |
1588 |
|
1589 |
nsresult |
1590 |
nsDocShell::initTiming(nsIURI* aCurrentURI) |
1591 |
{ |
1592 |
if (mTiming) { |
1593 |
return NS_OK; |
1594 |
} |
1595 |
mTiming = new nsDOMNavigationTiming(); |
1596 |
NS_ENSURE_TRUE(mTiming, NS_ERROR_OUT_OF_MEMORY); |
1597 |
|
1598 |
// Is this a new window or a frame? |
1599 |
nsDOMNavigationTimingType navType = |
1600 |
nsIDOMNavigationTiming::NAVIGATION_NEW_WINDOW; |
1601 |
nsCOMPtr<nsIDocShellTreeItem> root; |
1602 |
GetSameTypeParent(getter_AddRefs(root)); |
1603 |
if (root && root != this) { |
1604 |
navType = nsIDOMNavigationTiming::NAVIGATION_FRAME; |
1605 |
} |
1606 |
|
1607 |
mTiming->NotifyNavigationStart(aCurrentURI, navType); |
1608 |
return NS_OK; |
1609 |
} |
1610 |
|
1541 |
|
1611 |
|
1542 |
// |
1612 |
// |
1543 |
// Bug 13871: Prevent frameset spoofing |
1613 |
// Bug 13871: Prevent frameset spoofing |
|
5789 |
nsresult rv; |
5859 |
nsresult rv; |
5790 |
|
5860 |
|
5791 |
if ((~aStateFlags & (STATE_START | STATE_IS_NETWORK)) == 0) { |
5861 |
if ((~aStateFlags & (STATE_START | STATE_IS_NETWORK)) == 0) { |
|
|
5862 |
// Save timing statistics. |
5863 |
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest)); |
5864 |
nsCOMPtr<nsIURI> uri; |
5865 |
channel->GetURI(getter_AddRefs(uri)); |
5866 |
if (mTiming) { |
5867 |
mTiming->NotifyNavigationStart(uri, |
5868 |
ConvertLoadTypeToNavigationType(mLoadType)); |
5869 |
} |
5870 |
else { |
5871 |
// Create and notify about the navigation start |
5872 |
rv = initTiming(uri); |
5873 |
NS_ENSURE_SUCCESS(rv, rv); |
5874 |
} |
5875 |
|
5792 |
nsCOMPtr<nsIWyciwygChannel> wcwgChannel(do_QueryInterface(aRequest)); |
5876 |
nsCOMPtr<nsIWyciwygChannel> wcwgChannel(do_QueryInterface(aRequest)); |
5793 |
nsCOMPtr<nsIWebProgress> webProgress = |
5877 |
nsCOMPtr<nsIWebProgress> webProgress = |
5794 |
do_QueryInterface(GetAsSupports(this)); |
5878 |
do_QueryInterface(GetAsSupports(this)); |
5795 |
|
5879 |
|
5796 |
// Was the wyciwyg document loaded on this docshell? |
5880 |
// Was the wyciwyg document loaded on this docshell? |
5797 |
if (wcwgChannel && !mLSHE && (mItemType == typeContent) && aProgress == webProgress.get()) { |
5881 |
if (wcwgChannel && !mLSHE && (mItemType == typeContent) && aProgress == webProgress.get()) { |
5798 |
nsCOMPtr<nsIURI> uri; |
|
|
5799 |
wcwgChannel->GetURI(getter_AddRefs(uri)); |
5800 |
|
5801 |
PRBool equalUri = PR_TRUE; |
5882 |
PRBool equalUri = PR_TRUE; |
5802 |
// Store the wyciwyg url in session history, only if it is |
5883 |
// Store the wyciwyg url in session history, only if it is |
5803 |
// being loaded fresh for the first time. We don't want |
5884 |
// being loaded fresh for the first time. We don't want |
|
5915 |
nsCOMPtr<nsIURI> oldURI, newURI; |
5996 |
nsCOMPtr<nsIURI> oldURI, newURI; |
5916 |
aOldChannel->GetURI(getter_AddRefs(oldURI)); |
5997 |
aOldChannel->GetURI(getter_AddRefs(oldURI)); |
5917 |
aNewChannel->GetURI(getter_AddRefs(newURI)); |
5998 |
aNewChannel->GetURI(getter_AddRefs(newURI)); |
|
|
5999 |
mTiming->NotifyRedirectStart(newURI); |
5918 |
if (!oldURI || !newURI) { |
6000 |
if (!oldURI || !newURI) { |
5919 |
return; |
6001 |
return; |
5920 |
} |
6002 |
} |
|
6003 |
nsCOMPtr<nsIURI> url; |
6085 |
nsCOMPtr<nsIURI> url; |
6004 |
nsresult rv = aChannel->GetURI(getter_AddRefs(url)); |
6086 |
nsresult rv = aChannel->GetURI(getter_AddRefs(url)); |
6005 |
if (NS_FAILED(rv)) return rv; |
6087 |
if (NS_FAILED(rv)) return rv; |
6006 |
|
6088 |
|
|
|
6089 |
mTiming->NotifyNavigationEnd(url); |
6090 |
|
6007 |
// clean up reload state for meta charset |
6091 |
// clean up reload state for meta charset |
6008 |
if (eCharsetReloadRequested == mCharsetReloadState) |
6092 |
if (eCharsetReloadRequested == mCharsetReloadState) |
6009 |
mCharsetReloadState = eCharsetReloadStopOrigional; |
6093 |
mCharsetReloadState = eCharsetReloadStopOrigional; |
|
11583 |
#endif |
11667 |
#endif |
11584 |
} |
11668 |
} |
11585 |
|
11669 |
|
|
|
11670 |
NS_IMETHODIMP |
11671 |
nsDocShell::GetNavigationTiming(nsIDOMNavigationTiming** aNavigationTiming) |
11672 |
{ |
11673 |
NS_IF_ADDREF(*aNavigationTiming = mTiming); |
11674 |
return NS_OK; |
11675 |
} |
11676 |
|
11586 |
|
11677 |
|
11587 |
#ifdef DEBUG |
11678 |
#ifdef DEBUG |
11588 |
unsigned long nsDocShell::gNumberOfDocShells = 0; |
11679 |
unsigned long nsDocShell::gNumberOfDocShells = 0; |