Introduce content::PageState (again).

This is a concrete class wrapping a string that contains the
data of a serialized WebKit::WebHistoryItem class. Previously,
we've just passed around these as strings, giving them names
like "state", "content_state" or "history_state". It has been
hard to identify all of the places in the code where these
strings get passed around. A concrete class should make usage
more apparent. Plus, instead of manipulating the strings using
methods from webkit/glue/glue_serialize.h, we can just declare
methods on the PageState class. This makes the code much cleaner.

This first pass just implements PageState in terms of glue_serialize.
It also adds content/public/renderer/history_item_serialization.h
as the home for PageState to WebKit::WebHistoryItem conversion,
which should ideally only be usable from the renderer process.
(This bit is a step toward resolving bug 237243.)

page_state.h declares operator==() to support DCHECK_EQ, which
seems consistent with the idea of PageState being a replacement
for std::string. I didn't want to litter tests with calls to
PageState::ToEncodedData(). That would get cumbersome.

Originally reviewed at:
https://codereview.chromium.org/14985014

The only difference is that page_state.cc is now split into two
pieces: page_state.cc and page_state_webkit.cc.  The second holds
the definition of all methods that depend on webkit/glue.  That way
code like Chrome Frame and the iOS port of Chromium can use PageState
without pulling in a dependency on webkit/glue at link time.

BUG=240426
[email protected], [email protected], [email protected], [email protected]

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202678 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/web_contents/navigation_controller_impl.cc b/content/browser/web_contents/navigation_controller_impl.cc
index 5488c6c..8bd29ee 100644
--- a/content/browser/web_contents/navigation_controller_impl.cc
+++ b/content/browser/web_contents/navigation_controller_impl.cc
@@ -40,7 +40,6 @@
 #include "net/base/mime_util.h"
 #include "net/base/net_util.h"
 #include "skia/ext/platform_canvas.h"
-#include "webkit/glue/glue_serialize.h"
 
 namespace content {
 namespace {
@@ -69,11 +68,9 @@
 // losing the navigation entries and generating a new navigation entry after
 // this one. We don't want that. To avoid this we create a valid state which
 // WebKit will not treat as a new navigation.
-void SetContentStateIfEmpty(NavigationEntryImpl* entry) {
-  if (entry->GetContentState().empty()) {
-    entry->SetContentState(
-        webkit_glue::CreateHistoryStateForURL(entry->GetURL()));
-  }
+void SetPageStateIfEmpty(NavigationEntryImpl* entry) {
+  if (!entry->GetPageState().IsValid())
+    entry->SetPageState(PageState::CreateFromURL(entry->GetURL()));
 }
 
 NavigationEntryImpl::RestoreType ControllerRestoreTypeToEntryType(
@@ -101,7 +98,7 @@
     (*entries)[i]->SetTransitionType(PAGE_TRANSITION_RELOAD);
     (*entries)[i]->set_restore_type(ControllerRestoreTypeToEntryType(type));
     // NOTE(darin): This code is only needed for backwards compat.
-    SetContentStateIfEmpty((*entries)[i].get());
+    SetPageStateIfEmpty((*entries)[i].get());
   }
 }
 
@@ -769,11 +766,11 @@
 
   // All committed entries should have nonempty content state so WebKit doesn't
   // get confused when we go back to them (see the function for details).
-  DCHECK(!params.content_state.empty());
+  DCHECK(params.page_state.IsValid());
   NavigationEntryImpl* active_entry =
       NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry());
   active_entry->SetTimestamp(timestamp);
-  active_entry->SetContentState(params.content_state);
+  active_entry->SetPageState(params.page_state);
   // No longer needed since content state will hold the post data if any.
   active_entry->SetBrowserInitiatedPostData(NULL);