Useragent switcher tweaks
Children inherit parent tab's setting
Setting is now save/restored across kills
Change-Id: I664d2d887281df7b99e8239e3ba41ba540f4bbec
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index e1dd1ca..8962475 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -191,6 +191,7 @@
static final String APPID = "appid";
static final String INCOGNITO = "privateBrowsingEnabled";
static final String SCREENSHOT = "screenshot";
+ static final String USERAGENT = "useragent";
// -------------------------------------------------------------------------
@@ -1449,6 +1450,12 @@
mSavedState.putLong(PARENTTAB, parent.getId());
}
}
+
+ // Sync the WebView useragent with the parent
+ if (parent != null && mSettings.hasDesktopUseragent(parent.getWebView())
+ != mSettings.hasDesktopUseragent(getWebView())) {
+ mSettings.toggleDesktopUseragent(getWebView());
+ }
}
/**
@@ -1739,6 +1746,8 @@
if (mScreenshot != null) {
mSavedState.putParcelable(SCREENSHOT, mScreenshot);
}
+ mSavedState.putBoolean(USERAGENT,
+ mSettings.hasDesktopUseragent(getWebView()));
return true;
}
@@ -1755,6 +1764,10 @@
mId = b.getLong(ID);
mAppId = b.getString(APPID);
mScreenshot = b.getParcelable(SCREENSHOT);
+ if (b.getBoolean(USERAGENT)
+ != mSettings.hasDesktopUseragent(getWebView())) {
+ mSettings.toggleDesktopUseragent(getWebView());
+ }
final WebBackForwardList list = mMainView.restoreState(b);
if (list == null) {