| Index: ios/web/web_state/context_menu_params.mm
|
| diff --git a/ios/web/web_state/context_menu_params.mm b/ios/web/web_state/context_menu_params.mm
|
| index d2c5f10964466f3498af3332176ff09b5a16d3c3..29ed453d9091de624a974abc55e95cb854194425 100644
|
| --- a/ios/web/web_state/context_menu_params.mm
|
| +++ b/ios/web/web_state/context_menu_params.mm
|
| @@ -4,6 +4,10 @@
|
|
|
| #import "ios/web/public/web_state/context_menu_params.h"
|
|
|
| +#include "base/strings/sys_string_conversions.h"
|
| +#include "components/url_formatter/url_formatter.h"
|
| +#include "ios/web/public/referrer_util.h"
|
| +
|
| #if !defined(__has_feature) || !__has_feature(objc_arc)
|
| #error "This file requires ARC support."
|
| #endif
|
| @@ -17,4 +21,42 @@ ContextMenuParams::ContextMenuParams(const ContextMenuParams& other) = default;
|
|
|
| ContextMenuParams::~ContextMenuParams() {}
|
|
|
| +ContextMenuParams::ContextMenuParams(NSDictionary* element)
|
| + : ContextMenuParams() {
|
| + NSString* title = nil;
|
| + NSString* href = element[@"href"];
|
| + if (href) {
|
| + link_url = GURL(base::SysNSStringToUTF8(href));
|
| + if (link_url.SchemeIs(url::kJavaScriptScheme)) {
|
| + title = @"JavaScript";
|
| + } else {
|
| + base::string16 URLText = url_formatter::FormatUrl(link_url);
|
| + title = base::SysUTF16ToNSString(URLText);
|
| + }
|
| + }
|
| + NSString* src = element[@"src"];
|
| + if (src) {
|
| + src_url = GURL(base::SysNSStringToUTF8(src));
|
| + if (!title)
|
| + title = [src copy];
|
| + if ([title hasPrefix:base::SysUTF8ToNSString(url::kDataScheme)])
|
| + title = nil;
|
| + }
|
| + NSString* titleAttribute = element[@"title"];
|
| + if (titleAttribute)
|
| + title = titleAttribute;
|
| + if (title) {
|
| + menu_title.reset([title copy]);
|
| + }
|
| + NSString* referrerPolicy = element[@"referrerPolicy"];
|
| + if (referrerPolicy) {
|
| + referrer_policy =
|
| + web::ReferrerPolicyFromString(base::SysNSStringToUTF8(referrerPolicy));
|
| + }
|
| + NSString* innerText = element[@"innerText"];
|
| + if ([innerText length] > 0) {
|
| + link_text.reset([innerText copy]);
|
| + }
|
| +}
|
| +
|
| } // namespace web
|
|
|