Chromium Code Reviews| Index: ios/web/web_state/web_view_internal_creation_util.mm |
| diff --git a/ios/web/web_state/web_view_internal_creation_util.mm b/ios/web/web_state/web_view_internal_creation_util.mm |
| index 2fb8789dea675bbb5615ae1df6615592682af41b..76131bea504cd1d97bd6a9af3bf0deb854990376 100644 |
| --- a/ios/web/web_state/web_view_internal_creation_util.mm |
| +++ b/ios/web/web_state/web_view_internal_creation_util.mm |
| @@ -2,11 +2,14 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#import <objc/runtime.h> |
|
Eugene But (OOO till 7-30)
2017/01/13 16:19:42
This import should go after /web_view_internal_cre
Olivier
2017/01/13 18:08:59
Done.
|
| #import "ios/web/web_state/web_view_internal_creation_util.h" |
| #include "base/logging.h" |
| +#import "base/mac/scoped_nsobject.h" |
| #include "base/strings/sys_string_conversions.h" |
| #import "ios/web/public/web_client.h" |
| +#import "ios/web/web_state/ui/crw_context_menu_controller.h" |
| #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" |
| namespace web { |
| @@ -32,7 +35,8 @@ void VerifyWKWebViewCreationPreConditions( |
| WKWebView* BuildWKWebView(CGRect frame, |
| WKWebViewConfiguration* configuration, |
| BrowserState* browser_state, |
| - BOOL use_desktop_user_agent) { |
| + BOOL use_desktop_user_agent, |
| + id<CRWContextMenuDelegate> context_menu_delegate) { |
| VerifyWKWebViewCreationPreConditions(browser_state, configuration); |
| GetWebClient()->PreWebViewCreation(); |
| @@ -53,11 +57,30 @@ WKWebView* BuildWKWebView(CGRect frame, |
| // created. |
| web_view.allowsLinkPreview = NO; |
| + if (context_menu_delegate) { |
| + base::scoped_nsobject<CRWContextMenuController> context_menu_controller( |
| + [[CRWContextMenuController alloc] |
| + initWithWebView:web_view |
| + javaScriptDelegate:nil |
| + delegate:context_menu_delegate]); |
| + objc_setAssociatedObject(web_view, context_menu_controller.get(), |
| + context_menu_controller.get(), |
| + OBJC_ASSOCIATION_RETAIN_NONATOMIC); |
| + } |
| + |
| return [web_view autorelease]; |
| } |
| WKWebView* BuildWKWebView(CGRect frame, |
| WKWebViewConfiguration* configuration, |
| + BrowserState* browser_state, |
| + BOOL use_desktop_user_agent) { |
| + return BuildWKWebView(frame, configuration, browser_state, |
| + use_desktop_user_agent, nil); |
| +} |
| + |
| +WKWebView* BuildWKWebView(CGRect frame, |
| + WKWebViewConfiguration* configuration, |
| BrowserState* browser_state) { |
| BOOL use_desktop_user_agent = NO; |
| return BuildWKWebView(frame, configuration, browser_state, |