Commit 46cacfc9 authored by sczs's avatar sczs Committed by Commit Bot

[ios] Moves SaveCard MessageWithLinks to its own file.

This will then be used by the SaveCardInfobarCoordinator.

Bug: 1014652
Change-Id: I2b92f3e4b818bb3844e87c15371a364797d22aec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1915819
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715323}
parent 13544233
......@@ -115,6 +115,7 @@ source_set("autofill_ui") {
"save_card_infobar_view_delegate.h",
]
deps = [
":autofill_message",
"//base",
"//base:i18n",
"//components/autofill/core/browser",
......@@ -134,11 +135,21 @@ source_set("autofill_ui") {
"//ios/third_party/material_components_ios",
"//ios/third_party/material_roboto_font_loader_ios",
"//ui/base",
"//url:url",
]
libs = [ "UIKit.framework" ]
}
source_set("autofill_message") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"save_card_message_with_links.h",
"save_card_message_with_links.mm",
]
deps = [
"//url:url",
]
}
source_set("eg_tests") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ]
......
......@@ -13,6 +13,7 @@
#include "ios/chrome/browser/infobars/infobar_controller_delegate.h"
#import "ios/chrome/browser/ui/autofill/save_card_infobar_view.h"
#import "ios/chrome/browser/ui/autofill/save_card_infobar_view_delegate.h"
#import "ios/chrome/browser/ui/autofill/save_card_message_with_links.h"
#include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#include "ios/chrome/grit/ios_theme_resources.h"
......@@ -93,7 +94,7 @@ base::string16 GetTitleForButton(ConfirmInfoBarDelegate* delegate,
// Message, if any.
base::string16 messageText = self.infoBarDelegate->GetMessageText();
if (!messageText.empty()) {
MessageWithLinks* message = [[MessageWithLinks alloc] init];
SaveCardMessageWithLinks* message = [[SaveCardMessageWithLinks alloc] init];
const base::string16 linkText = self.infoBarDelegate->GetLinkText();
GURL linkURL = self.infoBarDelegate->GetLinkURL();
......@@ -132,7 +133,8 @@ base::string16 GetTitleForButton(ConfirmInfoBarDelegate* delegate,
if (!self.infoBarDelegate->legal_message_lines().empty()) {
NSMutableArray* legalMessages = [[NSMutableArray alloc] init];
for (const auto& line : self.infoBarDelegate->legal_message_lines()) {
MessageWithLinks* message = [[MessageWithLinks alloc] init];
SaveCardMessageWithLinks* message =
[[SaveCardMessageWithLinks alloc] init];
message.messageText = base::SysUTF16ToNSString(line.text());
NSMutableArray* linkRanges = [[NSMutableArray alloc] init];
std::vector<GURL> linkURLs;
......
......@@ -9,19 +9,8 @@
#include <vector>
class GURL;
@protocol SaveCardInfoBarViewDelegate;
// Represents a message with optional links.
@interface MessageWithLinks : NSObject
@property(nonatomic, copy) NSString* messageText;
@property(nonatomic, strong) NSArray* linkRanges;
@property(nonatomic, assign) std::vector<GURL> linkURLs;
@end
@class SaveCardMessageWithLinks;
// An infobar for saving credit cards. It features a header section including
// an optional leading icon, followed by an optional message, followed by an
......@@ -38,7 +27,7 @@ class GURL;
@property(nonatomic, strong) UIImage* googlePayIcon;
@property(nonatomic, strong) MessageWithLinks* message;
@property(nonatomic, strong) SaveCardMessageWithLinks* message;
@property(nonatomic, strong) UIImage* closeButtonImage;
......@@ -50,7 +39,7 @@ class GURL;
@property(nonatomic, copy) NSString* cardSublabel;
@property(nonatomic, strong) NSArray<MessageWithLinks*>* legalMessages;
@property(nonatomic, strong) NSArray<SaveCardMessageWithLinks*>* legalMessages;
@property(nonatomic, copy) NSString* cancelButtonTitle;
......
......@@ -8,6 +8,7 @@
#include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/procedural_block_types.h"
#import "ios/chrome/browser/ui/autofill/save_card_infobar_view_delegate.h"
#import "ios/chrome/browser/ui/autofill/save_card_message_with_links.h"
#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
#import "ios/chrome/browser/ui/infobars/infobar_constants.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h"
......@@ -89,9 +90,6 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
} // namespace
@implementation MessageWithLinks
@end
@interface SaveCardInfoBarView ()
// Allows styled and clickable links in the message label. May be nil.
......@@ -542,7 +540,8 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
[cardDetailsContainerView addArrangedSubview:dummyView];
// Legal messages.
auto block = ^(MessageWithLinks* legalMessage, NSUInteger idx, BOOL* stop) {
auto block = ^(SaveCardMessageWithLinks* legalMessage, NSUInteger idx,
BOOL* stop) {
DCHECK_GT(legalMessage.messageText.length, 0UL);
DCHECK_EQ(legalMessage.linkURLs.size(), legalMessage.linkRanges.count);
......
// Copyright 2019 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.
#ifndef IOS_CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_MESSAGE_WITH_LINKS_H_
#define IOS_CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_MESSAGE_WITH_LINKS_H_
#import <UIKit/UIKit.h>
#include <vector>
class GURL;
// Represents a message with optional links. Each linkRange in |linkRanges|
// represents the range (in |messageText|) for the corresponding (same index)
// linkURL in |linkURLS|.
@interface SaveCardMessageWithLinks : NSObject
@property(nonatomic, copy) NSString* messageText;
@property(nonatomic, strong) NSArray* linkRanges;
@property(nonatomic, assign) std::vector<GURL> linkURLs;
@end
#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_SAVE_CARD_MESSAGE_WITH_LINKS_H_
// Copyright 2019 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/ui/autofill/save_card_message_with_links.h"
#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation SaveCardMessageWithLinks
@end
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