Commit 42f3f2e6 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Remove boolean return from Omnibox OnCopy

The boolean looks like it was needed because there was a bug in iOS 4
that didn't allow for this custom copy behavior. Now, the underlying
OnCopy method never returns false, and iOS 4 is no longer supported,
so this doesn't need t return a boolean. The copy will always happen.

Bug: 866446
Change-Id: I11f3b90b191d10442ab513d377756cacbfb898e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1869005
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709060}
parent 78abc7fa
......@@ -25,7 +25,7 @@ class OmniboxTextChangeDelegate {
// Called when the Omnibox text field returns. (The "go" button is tapped.)
virtual void OnAccept() = 0;
// Called when the Omnibox text field should copy.
virtual bool OnCopy() = 0;
virtual void OnCopy() = 0;
// Clear the Omnibox text.
virtual void ClearText() = 0;
// Called when the Omnibox text field should paste.
......
......@@ -10,11 +10,8 @@
@protocol OmniboxTextFieldDelegate<UITextFieldDelegate>
@optional
// Called when the OmniboxTextFieldIOS performs a copy operation. Returns YES
// if the delegate handled the copy operation itself. If the delegate returns
// NO, the field must perform the copy. Some platforms (iOS 4) do not expose an
// API that allows the delegate to handle the copy.
- (BOOL)onCopy;
// Called when the OmniboxTextFieldIOS performs a copy operation.
- (void)onCopy;
// Called before the OmniboxTextFieldIOS performs a paste operation.
- (void)willPaste;
......
......@@ -668,16 +668,13 @@ NSString* const kOmniboxFadeAnimationKey = @"OmniboxFadeAnimation";
// preprending http:// to the copied URL if needed.
- (void)copy:(id)sender {
id<OmniboxTextFieldDelegate> delegate = [self delegate];
BOOL handled = NO;
// Must test for the onCopy method, since it's optional.
if ([delegate respondsToSelector:@selector(onCopy)])
handled = [delegate onCopy];
// iOS 4 doesn't expose an API that allows the delegate to handle the copy
// operation, so let the superclass perform the copy if the delegate couldn't.
if (!handled)
if ([delegate respondsToSelector:@selector(onCopy)]) {
[delegate onCopy];
} else {
[super copy:sender];
}
}
- (void)cut:(id)sender {
......
......@@ -179,7 +179,7 @@ TEST_F(OmniboxTextFieldTest, CopyInPreedit) {
[textfield_ becomeFirstResponder];
[textfield_ enterPreEditState];
EXPECT_TRUE([textfield_ canPerformAction:@selector(copy:) withSender:nil]);
OCMExpect([delegateMock onCopy]).andReturn(YES);
[delegateMock onCopy];
[textfield_ copy:nil];
EXPECT_TRUE([textfield_.text isEqualToString:testString]);
[delegateMock verify];
......@@ -193,7 +193,7 @@ TEST_F(OmniboxTextFieldTest, CutInPreedit) {
[textfield_ becomeFirstResponder];
[textfield_ enterPreEditState];
EXPECT_TRUE([textfield_ canPerformAction:@selector(cut:) withSender:nil]);
OCMExpect([delegateMock onCopy]).andReturn(YES);
[delegateMock onCopy];
[textfield_ cut:nil];
EXPECT_TRUE([textfield_.text isEqualToString:@""]);
[delegateMock verify];
......
......@@ -230,9 +230,9 @@ const CGFloat kClearButtonSize = 28.0f;
return YES;
}
- (BOOL)onCopy {
- (void)onCopy {
DCHECK(_textChangeDelegate);
return _textChangeDelegate->OnCopy();
_textChangeDelegate->OnCopy();
}
- (void)willPaste {
......
......@@ -99,7 +99,7 @@ class OmniboxViewIOS : public OmniboxView,
void OnDidChange(bool processing_user_input) override;
void OnWillEndEditing() override;
void OnAccept() override;
bool OnCopy() override;
void OnCopy() override;
void ClearText() override;
void WillPaste() override;
void OnDeleteBackward() override;
......
......@@ -482,7 +482,7 @@ void OmniboxViewIOS::OnClear() {
[field_ exitPreEditState];
}
bool OmniboxViewIOS::OnCopy() {
void OmniboxViewIOS::OnCopy() {
omnibox_interacted_while_focused_ = YES;
UIPasteboard* board = [UIPasteboard generalPasteboard];
NSString* selectedText = nil;
......@@ -521,7 +521,6 @@ bool OmniboxViewIOS::OnCopy() {
[item setObject:net::NSURLWithGURL(url) forKey:(NSString*)kUTTypeURL];
board.items = [NSArray arrayWithObject:item];
return true;
}
void OmniboxViewIOS::WillPaste() {
......
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