Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(690)

Unified Diff: chrome/browser/ui/browser_commands.cc

Issue 10829308: Use the last committed entry for View Source. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browser_commands_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 =
« no previous file with comments | « chrome/browser/browser_commands_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698