Index: chrome/browser/ui/browser_commands.cc |
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc |
index a4c589dea2f6014a849bc9ff5cf9cd7d94714f00..93c476b135d6e7a401da05eada120d6a2d222f9f 100644 |
--- a/chrome/browser/ui/browser_commands.cc |
+++ b/chrome/browser/ui/browser_commands.cc |
@@ -876,13 +876,14 @@ bool IsDebuggerAttachedToCurrentTab(Browser* browser) { |
void ViewSource(Browser* browser, TabContents* contents) { |
DCHECK(contents); |
- NavigationEntry* active_entry = |
- contents->web_contents()->GetController().GetActiveEntry(); |
- if (!active_entry) |
+ // Use the last committed entry, since the pending entry hasn't loaded yet and |
+ // won't be copied into the cloned tab. |
+ NavigationEntry* entry = |
+ contents->web_contents()->GetController().GetLastCommittedEntry(); |
+ if (!entry) |
return; |
- ViewSource(browser, contents, active_entry->GetURL(), |
- active_entry->GetContentState()); |
+ ViewSource(browser, contents, entry->GetURL(), entry->GetContentState()); |
} |
void ViewSource(Browser* browser, |
@@ -892,6 +893,8 @@ void ViewSource(Browser* browser, |
content::RecordAction(UserMetricsAction("ViewSource")); |
DCHECK(contents); |
+ // Note that Clone does not copy the pending or transient entries, so the |
+ // active entry in view_source_contents will be the last committed entry. |
TabContents* view_source_contents = contents->Clone(); |
view_source_contents->web_contents()->GetController().PruneAllButActive(); |
NavigationEntry* active_entry = |