1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_ANDROID_TAB_STATE_H_
6 #define CHROME_BROWSER_ANDROID_TAB_STATE_H_
11 #include "base/android/scoped_java_ref.h"
14 class NavigationEntry
;
20 // Stores state for a WebContents, including its navigation history.
21 class WebContentsState
{
23 static base::android::ScopedJavaLocalRef
<jobject
>
24 GetContentsStateAsByteBuffer(JNIEnv
* env
, TabAndroid
* tab
);
26 // Common implementation for GetContentsStateAsByteBuffer() and
27 // CreateContentsStateAsByteBuffer(). Does not assume ownership of the
29 static base::android::ScopedJavaLocalRef
<jobject
>
30 WriteNavigationsAsByteBuffer(
32 bool is_off_the_record
,
33 const std::vector
<content::NavigationEntry
*>& navigations
,
36 // Extracts display title from serialized tab data on restore
37 static base::android::ScopedJavaLocalRef
<jstring
>
38 GetDisplayTitleFromByteBuffer(JNIEnv
* env
, void* data
,
39 int size
, int saved_state_version
);
41 // Extracts virtual url from serialized tab data on restore
42 static base::android::ScopedJavaLocalRef
<jstring
>
43 GetVirtualUrlFromByteBuffer(JNIEnv
* env
, void* data
,
44 int size
, int saved_state_version
);
46 // Restores a WebContents from the passed in state.
47 static content::WebContents
* RestoreContentsFromByteBuffer(
50 int saved_state_version
,
51 bool initially_hidden
);
53 // Restores a WebContents from the passed in state.
54 static content::WebContents
* RestoreContentsFromByteBuffer(
58 jint saved_state_version
,
59 jboolean initially_hidden
);
61 // Synthesizes a stub, single-navigation state for a tab that will be loaded
63 static base::android::ScopedJavaLocalRef
<jobject
>
64 CreateSingleNavigationStateAsByteBuffer(JNIEnv
* env
, jstring url
,
67 jboolean is_off_the_record
);
70 // Registers methods for JNI.
71 bool RegisterTabState(JNIEnv
* env
);
73 #endif // CHROME_BROWSER_ANDROID_TAB_STATE_H_