| Index: ios/web/public/crw_navigation_item_storage.mm
|
| diff --git a/ios/web/public/crw_navigation_item_storage.mm b/ios/web/public/crw_navigation_item_storage.mm
|
| index 62a6055fc1061bd476fc2e6a35a0f8bde6befbec..f43159a53ec4f7ddf94945b14c5cb7b16ede2914 100644
|
| --- a/ios/web/public/crw_navigation_item_storage.mm
|
| +++ b/ios/web/public/crw_navigation_item_storage.mm
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/strings/sys_string_conversions.h"
|
| #import "ios/web/navigation/nscoder_util.h"
|
| +#import "ios/web/public/web_client.h"
|
| #import "net/base/mac/url_conversions.h"
|
|
|
| #if !defined(__has_feature) || !__has_feature(objc_arc)
|
| @@ -27,7 +28,8 @@
|
| NSString* const kNavigationItemStorageHTTPRequestHeadersKey = @"httpHeaders";
|
| NSString* const kNavigationItemStorageSkipRepostFormConfirmationKey =
|
| @"skipResubmitDataConfirmation";
|
| -NSString* const kNavigationItemStorageUseDesktopUserAgentKey =
|
| +NSString* const kNavigationItemStorageUserAgentTypeKey = @"userAgentType";
|
| +NSString* const kNavigationItemStorageUseDesktopUserAgentDeprecatedKey =
|
| @"useDesktopUserAgent";
|
|
|
| } // namespace web
|
| @@ -41,7 +43,7 @@ @implementation CRWNavigationItemStorage
|
| @synthesize displayState = _displayState;
|
| @synthesize shouldSkipRepostFormConfirmation =
|
| _shouldSkipRepostFormConfirmation;
|
| -@synthesize overridingUserAgent = _overridingUserAgent;
|
| +@synthesize userAgentType = _userAgentType;
|
| @synthesize POSTData = _POSTData;
|
| @synthesize HTTPRequestHeaders = _HTTPRequestHeaders;
|
|
|
| @@ -59,7 +61,8 @@ - (NSString*)description {
|
| [description appendFormat:@"skipRepostConfirmation : %@, ",
|
| @(_shouldSkipRepostFormConfirmation)];
|
| [description
|
| - appendFormat:@"overridingUserAgent : %@, ", @(_overridingUserAgent)];
|
| + appendFormat:@"userAgentType : %s, ",
|
| + web::GetUserAgentTypeDescription(_userAgentType).c_str()];
|
| [description appendFormat:@"POSTData : %@, ", _POSTData];
|
| [description appendFormat:@"HTTPRequestHeaders : %@", _HTTPRequestHeaders];
|
| return description;
|
| @@ -105,6 +108,27 @@ - (instancetype)initWithCoder:(NSCoder*)aDecoder {
|
| _timestamp = base::Time::FromInternalValue(us);
|
| }
|
|
|
| + if ([aDecoder
|
| + containsValueForKey:web::kNavigationItemStorageUserAgentTypeKey]) {
|
| + std::string userAgentDescription = web::nscoder_util::DecodeString(
|
| + aDecoder, web::kNavigationItemStorageUserAgentTypeKey);
|
| + _userAgentType =
|
| + web::GetUserAgentTypeWithDescription(userAgentDescription);
|
| + } else if (web::GetWebClient()->IsAppSpecificURL(_virtualURL)) {
|
| + // Legacy CRWNavigationItemStorages didn't have the concept of a NONE
|
| + // user agent for app-specific URLs, so check decoded virtual URL before
|
| + // attempting to decode the deprecated key.
|
| + _userAgentType = web::UserAgentType::NONE;
|
| + } else {
|
| + // The user agent type was previously recorded as a BOOL, where YES meant
|
| + // desktop user agent, and NO meant mobile user agent.
|
| + BOOL useDesktopUA = [aDecoder
|
| + decodeBoolForKey:
|
| + web::kNavigationItemStorageUseDesktopUserAgentDeprecatedKey];
|
| + _userAgentType = useDesktopUA ? web::UserAgentType::DESKTOP
|
| + : web::UserAgentType::MOBILE;
|
| + }
|
| +
|
| NSString* title =
|
| [aDecoder decodeObjectForKey:web::kNavigationItemStorageTitleKey];
|
| // Use a transition type of reload so that we don't incorrectly increase
|
| @@ -116,8 +140,6 @@ - (instancetype)initWithCoder:(NSCoder*)aDecoder {
|
| _shouldSkipRepostFormConfirmation =
|
| [aDecoder decodeBoolForKey:
|
| web::kNavigationItemStorageSkipRepostFormConfirmationKey];
|
| - _overridingUserAgent = [aDecoder
|
| - decodeBoolForKey:web::kNavigationItemStorageUseDesktopUserAgentKey];
|
| _POSTData =
|
| [aDecoder decodeObjectForKey:web::kNavigationItemStoragePOSTDataKey];
|
| _HTTPRequestHeaders = [aDecoder
|
| @@ -144,8 +166,9 @@ - (void)encodeWithCoder:(NSCoder*)aCoder {
|
| forKey:web::kNavigationItemStoragePageDisplayStateKey];
|
| [aCoder encodeBool:_shouldSkipRepostFormConfirmation
|
| forKey:web::kNavigationItemStorageSkipRepostFormConfirmationKey];
|
| - [aCoder encodeBool:_overridingUserAgent
|
| - forKey:web::kNavigationItemStorageUseDesktopUserAgentKey];
|
| + web::nscoder_util::EncodeString(
|
| + aCoder, web::kNavigationItemStorageUserAgentTypeKey,
|
| + web::GetUserAgentTypeDescription(_userAgentType));
|
| [aCoder encodeObject:_POSTData forKey:web::kNavigationItemStoragePOSTDataKey];
|
| [aCoder encodeObject:_HTTPRequestHeaders
|
| forKey:web::kNavigationItemStorageHTTPRequestHeadersKey];
|
|
|