Commit f482af24 authored by stkhapugin@chromium.org's avatar stkhapugin@chromium.org Committed by Commit Bot

Removes more usage of scoped_nsobject.

Removes usage of scoped_nsobject in ios/web/public.

Bug: 717540
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Icec9644b72efd0d57db00c4ed106575d5de59c9f
Reviewed-on: https://chromium-review.googlesource.com/846804Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526714}
parent b6206943
......@@ -42,7 +42,7 @@ class ContextMenuCoordinatorTest : public PlatformTest {
TEST_F(ContextMenuCoordinatorTest, ValidateIsVisible) {
web::ContextMenuParams params;
params.location = CGPointZero;
params.view.reset([view_controller_ view]);
params.view = [view_controller_ view];
menu_coordinator_ = [[ContextMenuCoordinator alloc]
initWithBaseViewController:view_controller_
params:params];
......@@ -55,7 +55,7 @@ TEST_F(ContextMenuCoordinatorTest, ValidateIsVisible) {
TEST_F(ContextMenuCoordinatorTest, ValidateDismissalOnStop) {
web::ContextMenuParams params;
params.location = CGPointZero;
params.view.reset([view_controller_ view]);
params.view = [view_controller_ view];
menu_coordinator_ = [[ContextMenuCoordinator alloc]
initWithBaseViewController:view_controller_
params:params];
......@@ -70,7 +70,7 @@ TEST_F(ContextMenuCoordinatorTest, ValidateDismissalOnStop) {
TEST_F(ContextMenuCoordinatorTest, ValidateActions) {
web::ContextMenuParams params;
params.location = CGPointZero;
params.view.reset([view_controller_ view]);
params.view = [view_controller_ view];
menu_coordinator_ = [[ContextMenuCoordinator alloc]
initWithBaseViewController:view_controller_
params:params];
......@@ -105,7 +105,7 @@ TEST_F(ContextMenuCoordinatorTest, ValidateActions) {
TEST_F(ContextMenuCoordinatorTest, CancelButtonExists) {
web::ContextMenuParams params;
params.location = CGPointZero;
params.view.reset([view_controller_ view]);
params.view = [view_controller_ view];
menu_coordinator_ = [[ContextMenuCoordinator alloc]
initWithBaseViewController:view_controller_
params:params];
......@@ -130,8 +130,8 @@ TEST_F(ContextMenuCoordinatorTest, ValidateContextMenuParams) {
web::ContextMenuParams params;
params.location = location;
params.menu_title.reset(title);
params.view.reset([view_controller_ view]);
params.menu_title = title;
params.view = [view_controller_ view];
menu_coordinator_ = [[ContextMenuCoordinator alloc]
initWithBaseViewController:view_controller_
params:params];
......
......@@ -821,10 +821,10 @@ const CGFloat kSeparatorInset = 10;
__weak HistoryCollectionViewController* weakSelf = self;
web::ContextMenuParams params;
params.location = touchLocation;
params.view.reset(self.collectionView);
params.view = self.collectionView;
NSString* menuTitle =
base::SysUTF16ToNSString(url_formatter::FormatUrl(entry.URL));
params.menu_title.reset([menuTitle copy]);
params.menu_title = [menuTitle copy];
// Present sheet/popover using controller that is added to view hierarchy.
// TODO(crbug.com/754642): Remove TopPresentedViewController().
......
......@@ -632,7 +632,7 @@ enum CellType {
// Get view coordinates in local space.
CGPoint viewCoordinate = [longPressGesture locationInView:self.tableView];
params.location = viewCoordinate;
params.view.reset(self.tableView);
params.view = self.tableView;
// Present sheet/popover using controller that is added to view hierarchy.
// TODO(crbug.com/754642): Remove TopPresentedViewController().
......
......@@ -8,7 +8,6 @@
#import <Foundation/Foundation.h>
#import "base/mac/bundle_locations.h"
#import "base/mac/scoped_nsobject.h"
#import "testing/gtest_mac.h"
namespace web {
......@@ -53,7 +52,7 @@ class WebJsTest : public WebTestT {
// Injects JavaScript at |java_script_paths_|.
void Inject();
base::scoped_nsobject<NSArray> java_script_paths_;
NSArray* java_script_paths_;
};
template <class WebTestT>
......@@ -61,7 +60,7 @@ void WebJsTest<WebTestT>::Inject() {
// Main web injection should have occurred.
ASSERT_NSEQ(@"object", WebTestT::ExecuteJavaScript(@"typeof __gCrWeb"));
for (NSString* java_script_path in java_script_paths_.get()) {
for (NSString* java_script_path in java_script_paths_) {
NSString* path =
[base::mac::FrameworkBundle() pathForResource:java_script_path
ofType:@"js"];
......@@ -76,8 +75,8 @@ template <class WebTestT>
id WebJsTest<WebTestT>::ExecuteJavaScriptWithFormat(NSString* format, ...) {
va_list args;
va_start(args, format);
base::scoped_nsobject<NSString> java_script(
[[NSString alloc] initWithFormat:format arguments:args]);
NSString* java_script =
[[NSString alloc] initWithFormat:format arguments:args];
va_end(args);
return WebTestT::ExecuteJavaScript(java_script);
......
......@@ -6,7 +6,6 @@
#import <UIKit/UIKit.h>
#import "base/mac/scoped_nsobject.h"
#include "base/strings/string16.h"
#include "ios/web/public/referrer.h"
#include "url/gurl.h"
......@@ -21,7 +20,7 @@ struct ContextMenuParams {
~ContextMenuParams();
// The title of the menu.
base::scoped_nsobject<NSString> menu_title;
NSString* menu_title;
// The URL of the link that encloses the node the context menu was invoked on.
GURL link_url;
......@@ -34,14 +33,14 @@ struct ContextMenuParams {
web::ReferrerPolicy referrer_policy;
// The view in which to present the menu.
base::scoped_nsobject<UIView> view;
UIView* view;
// The location in |view| to present the menu.
CGPoint location;
// The text associated with the link. It is either nil or nonempty (it can not
// be empty).
base::scoped_nsobject<NSString> link_text;
NSString* link_text;
};
} // namespace web
......
......@@ -41,7 +41,7 @@ ContextMenuParams ContextMenuParamsFromElementDictionary(
if (titleAttribute)
title = titleAttribute;
if (title) {
params.menu_title.reset([title copy]);
params.menu_title = [title copy];
}
NSString* referrerPolicy = element[kContextMenuElementReferrerPolicy];
if (referrerPolicy) {
......@@ -50,7 +50,7 @@ ContextMenuParams ContextMenuParamsFromElementDictionary(
}
NSString* innerText = element[kContextMenuElementInnerText];
if ([innerText length] > 0) {
params.link_text.reset([innerText copy]);
params.link_text = [innerText copy];
}
return params;
}
......
......@@ -37,13 +37,13 @@ typedef PlatformTest ContextMenuParamsUtilsTest;
// Tests the empty contructor.
TEST_F(ContextMenuParamsUtilsTest, EmptyParams) {
web::ContextMenuParams params;
EXPECT_EQ(params.menu_title.get(), nil);
EXPECT_EQ(params.menu_title, nil);
EXPECT_FALSE(params.link_url.is_valid());
EXPECT_FALSE(params.src_url.is_valid());
EXPECT_EQ(params.referrer_policy, web::ReferrerPolicyDefault);
EXPECT_EQ(params.view.get(), nil);
EXPECT_EQ(params.view, nil);
EXPECT_TRUE(CGPointEqualToPoint(params.location, CGPointZero));
EXPECT_EQ(params.link_text.get(), nil);
EXPECT_EQ(params.link_text, nil);
}
// Tests the the parsing of the element NSDictionary.
......@@ -56,14 +56,14 @@ TEST_F(ContextMenuParamsUtilsTest, DictionaryConstructorTest) {
kContextMenuElementInnerText : @(kLinkText),
});
EXPECT_NSEQ(params.menu_title.get(), @(kTitle));
EXPECT_NSEQ(params.menu_title, @(kTitle));
EXPECT_EQ(params.link_url, GURL(kLinkUrl));
EXPECT_EQ(params.src_url, GURL(kSrcUrl));
EXPECT_NSEQ(params.link_text.get(), @(kLinkText));
EXPECT_NSEQ(params.link_text, @(kLinkText));
EXPECT_EQ(params.referrer_policy,
web::ReferrerPolicyFromString(kReferrerPolicy));
EXPECT_EQ(params.view.get(), nil);
EXPECT_EQ(params.view, nil);
EXPECT_TRUE(CGPointEqualToPoint(params.location, CGPointZero));
}
......@@ -75,7 +75,7 @@ TEST_F(ContextMenuParamsUtilsTest, DictionaryConstructorTestNoTitle) {
base::string16 urlText = url_formatter::FormatUrl(GURL(kLinkUrl));
NSString* title = base::SysUTF16ToNSString(urlText);
EXPECT_NSEQ(params.menu_title.get(), title);
EXPECT_NSEQ(params.menu_title, title);
}
// Tests title is set to "JavaScript" if there is no title and "href" links to
......@@ -84,7 +84,7 @@ TEST_F(ContextMenuParamsUtilsTest, DictionaryConstructorTestJavascriptTitle) {
web::ContextMenuParams params = web::ContextMenuParamsFromElementDictionary(@{
kContextMenuElementHyperlink : @(kJavaScriptLinkUrl),
});
EXPECT_NSEQ(params.menu_title.get(), @"JavaScript");
EXPECT_NSEQ(params.menu_title, @"JavaScript");
}
// Tests title is set to |src_url| if there is no title.
......@@ -93,7 +93,7 @@ TEST_F(ContextMenuParamsUtilsTest, DictionaryConstructorTestSrcTitle) {
kContextMenuElementSource : @(kSrcUrl),
});
EXPECT_EQ(params.src_url, GURL(kSrcUrl));
EXPECT_NSEQ(params.menu_title.get(), @(kSrcUrl));
EXPECT_NSEQ(params.menu_title, @(kSrcUrl));
}
// Tests title is set to nil if there is no title and src is a data URL.
......@@ -102,7 +102,7 @@ TEST_F(ContextMenuParamsUtilsTest, DictionaryConstructorTestDataTitle) {
kContextMenuElementSource : @(kDataUrl),
});
EXPECT_EQ(params.src_url, GURL(kDataUrl));
EXPECT_NSEQ(params.menu_title.get(), nil);
EXPECT_NSEQ(params.menu_title, nil);
}
} // namespace web
......@@ -255,7 +255,7 @@ void CancelTouches(UIGestureRecognizer* gesture_recognizer) {
- (void)showContextMenu {
web::ContextMenuParams params =
web::ContextMenuParamsFromElementDictionary(_DOMElementForLastTouch);
params.view.reset(_webView);
params.view = _webView;
params.location = _locationForLastTouch;
[_delegate webView:_webView handleContextMenu:params];
}
......
......@@ -110,11 +110,11 @@ TEST_F(WebStateDelegateBridgeTest, OpenURLFromWebState) {
TEST_F(WebStateDelegateBridgeTest, HandleContextMenu) {
EXPECT_EQ(nil, [delegate_ contextMenuParams]);
web::ContextMenuParams context_menu_params;
context_menu_params.menu_title.reset([@"Menu title" copy]);
context_menu_params.menu_title = [@"Menu title" copy];
context_menu_params.link_url = GURL("http://www.url.com");
context_menu_params.src_url = GURL("http://www.url.com/image.jpeg");
context_menu_params.referrer_policy = web::ReferrerPolicyOrigin;
context_menu_params.view.reset([[UIView alloc] init]);
context_menu_params.view = [[UIView alloc] init];
context_menu_params.location = CGPointMake(5.0, 5.0);
bridge_->HandleContextMenu(nullptr, context_menu_params);
web::ContextMenuParams* result_params = [delegate_ contextMenuParams];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment