OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context_impl.h" |
| 6 |
| 7 #include "base/strings/utf_string_conversions.h" |
| 8 #import "ios/web/public/web_state/context_menu_params.h" |
| 9 #include "url/gurl.h" |
| 10 #include "url/url_constants.h" |
| 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." |
| 14 #endif |
| 15 |
| 16 @interface ContextMenuContextImpl () { |
| 17 // The parameters passed on initialization. |
| 18 web::ContextMenuParams _params; |
| 19 // The context menu link's script, if of the javascript: scheme. |
| 20 base::string16 _script; |
| 21 } |
| 22 |
| 23 @end |
| 24 |
| 25 @implementation ContextMenuContextImpl |
| 26 |
| 27 - (instancetype)initWithParams:(const web::ContextMenuParams&)params { |
| 28 if ((self = [super init])) { |
| 29 _params = params; |
| 30 const GURL& linkURL = _params.link_url; |
| 31 if (linkURL.is_valid() && linkURL.SchemeIs(url::kJavaScriptScheme)) |
| 32 _script = base::UTF8ToUTF16(linkURL.GetContent()); |
| 33 } |
| 34 return self; |
| 35 } |
| 36 |
| 37 #pragma mark - Accessors |
| 38 |
| 39 - (NSString*)menuTitle { |
| 40 return _params.menu_title.get(); |
| 41 } |
| 42 |
| 43 - (const GURL&)linkURL { |
| 44 return _params.link_url; |
| 45 } |
| 46 |
| 47 - (const GURL&)imageURL { |
| 48 return _params.src_url; |
| 49 } |
| 50 |
| 51 - (const base::string16&)script { |
| 52 return _script; |
| 53 } |
| 54 |
| 55 @end |
OLD | NEW |