| Index: ios/chrome/browser/xcallback_parameters.mm
|
| diff --git a/ios/chrome/browser/xcallback_parameters.mm b/ios/chrome/browser/xcallback_parameters.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0d55d38b85334d24c891bbd5daff072a78f7c8fa
|
| --- /dev/null
|
| +++ b/ios/chrome/browser/xcallback_parameters.mm
|
| @@ -0,0 +1,94 @@
|
| +// Copyright 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#import "ios/chrome/browser/xcallback_parameters.h"
|
| +
|
| +#include "base/mac/scoped_nsobject.h"
|
| +#include "base/strings/sys_string_conversions.h"
|
| +
|
| +namespace {
|
| +NSString* const kSourceAppIdKey = @"sourceAppId";
|
| +NSString* const kSourceAppNameKey = @"sourceAppName";
|
| +NSString* const kSuccessURLKey = @"successURL";
|
| +NSString* const kCreateNewTabKey = @"createNewTab";
|
| +}
|
| +
|
| +@interface XCallbackParameters () {
|
| + base::scoped_nsobject<NSString> _sourceAppId;
|
| + base::scoped_nsobject<NSString> _sourceAppName;
|
| + GURL _successURL;
|
| + BOOL _createNewTab;
|
| +}
|
| +@end
|
| +
|
| +@implementation XCallbackParameters
|
| +
|
| +@synthesize successURL = _successURL;
|
| +@synthesize createNewTab = _createNewTab;
|
| +
|
| +- (instancetype)initWithSourceAppId:(NSString*)sourceAppId
|
| + sourceAppName:(NSString*)sourceAppName
|
| + successURL:(const GURL&)successURL
|
| + createNewTab:(BOOL)createNewTab {
|
| + self = [super init];
|
| + if (self) {
|
| + _sourceAppId.reset([sourceAppId copy]);
|
| + _sourceAppName.reset([sourceAppName copy]);
|
| + _successURL = successURL;
|
| + _createNewTab = createNewTab;
|
| + }
|
| + return self;
|
| +}
|
| +
|
| +- (NSString*)description {
|
| + return [NSString stringWithFormat:@"SourceApp: %@ (%@)\nSuccessURL: %s\n",
|
| + _sourceAppName.get(), _sourceAppId.get(),
|
| + _successURL.spec().c_str()];
|
| +}
|
| +
|
| +- (NSString*)sourceAppId {
|
| + return _sourceAppId.get();
|
| +}
|
| +
|
| +- (NSString*)sourceAppName {
|
| + return _sourceAppName.get();
|
| +}
|
| +
|
| +#pragma mark - NSCoding Methods
|
| +
|
| +- (instancetype)initWithCoder:(NSCoder*)aDecoder {
|
| + GURL successURL;
|
| + NSString* successURLStr = [aDecoder decodeObjectForKey:kSuccessURLKey];
|
| + if (successURLStr)
|
| + _successURL = GURL(base::SysNSStringToUTF8(successURLStr));
|
| +
|
| + return
|
| + [self initWithSourceAppId:[aDecoder decodeObjectForKey:kSourceAppIdKey]
|
| + sourceAppName:[aDecoder decodeObjectForKey:kSourceAppNameKey]
|
| + successURL:successURL
|
| + createNewTab:[aDecoder decodeBoolForKey:kCreateNewTabKey]];
|
| +}
|
| +
|
| +- (void)encodeWithCoder:(NSCoder*)aCoder {
|
| + [aCoder encodeObject:_sourceAppId forKey:kSourceAppIdKey];
|
| + [aCoder encodeObject:_sourceAppName forKey:kSourceAppNameKey];
|
| + if (_successURL.is_valid()) {
|
| + NSString* successStr = base::SysUTF8ToNSString(_successURL.spec());
|
| + [aCoder encodeObject:successStr forKey:kSuccessURLKey];
|
| + }
|
| + [aCoder encodeBool:_createNewTab forKey:kCreateNewTabKey];
|
| +}
|
| +
|
| +#pragma mark - NSCopying Methods
|
| +
|
| +- (instancetype)copyWithZone:(NSZone*)zone {
|
| + XCallbackParameters* copy = [[[self class] allocWithZone:zone] init];
|
| + copy->_sourceAppId.reset([_sourceAppId copy]);
|
| + copy->_sourceAppName.reset([_sourceAppName copy]);
|
| + copy->_successURL = _successURL;
|
| + copy->_createNewTab = _createNewTab;
|
| + return copy;
|
| +}
|
| +
|
| +@end
|
|
|