Ensure transient NavigationEntryImpl values are cleared after commit.

We handled some but not all of the cases that claimed to need a reset in
their declaration.  Also resetting transferred_global_request_id_ and
should_replace_entry_, and adding a test.

BUG=311721
TEST=should_replace_entry cleared after commit
[email protected]

Review URL: https://codereview.chromium.org/50203005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231580 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 0b22940..00d07ef 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1979,10 +1979,10 @@
     // SiteInstance, and ensure the address bar updates accordingly.  We don't
     // know the referrer or extra headers at this point, but the referrer will
     // be set properly upon commit.
-    NavigationEntry* pending_entry = controller_.GetPendingEntry();
+    NavigationEntryImpl* pending_entry =
+        NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry());
     bool has_browser_initiated_pending_entry = pending_entry &&
-        !NavigationEntryImpl::FromNavigationEntry(pending_entry)->
-            is_renderer_initiated();
+        !pending_entry->is_renderer_initiated();
     if (!has_browser_initiated_pending_entry && !is_error_page) {
       NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(
           controller_.CreateNavigationEntry(validated_url,
@@ -1995,10 +1995,10 @@
           static_cast<SiteInstanceImpl*>(GetSiteInstance()));
       // TODO(creis): If there's a pending entry already, find a safe way to
       // update it instead of replacing it and copying over things like this.
-      if (pending_entry &&
-          NavigationEntryImpl::FromNavigationEntry(pending_entry)->
-              should_replace_entry()) {
-        entry->set_should_replace_entry(true);
+      if (pending_entry) {
+        entry->set_transferred_global_request_id(
+            pending_entry->transferred_global_request_id());
+        entry->set_should_replace_entry(pending_entry->should_replace_entry());
       }
       controller_.SetPendingEntry(entry);
       NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL);