Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Unified Diff: ios/web/web_state/web_view_internal_creation_util.mm

Issue 2627093003: Reuse context menu in StaticHTMLViewController (Closed)
Patch Set: feedback Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/web_state/web_view_internal_creation_util.h ('k') | ios/web/web_view_creation_util.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..59ff848827db4e88498c12062a89ec4627d06a95 100644
--- a/ios/web/web_state/web_view_internal_creation_util.mm
+++ b/ios/web/web_state/web_view_internal_creation_util.mm
@@ -4,9 +4,13 @@
#import "ios/web/web_state/web_view_internal_creation_util.h"
+#import <objc/runtime.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 +36,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 +58,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
+ injectionEvaluator: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,
« no previous file with comments | « ios/web/web_state/web_view_internal_creation_util.h ('k') | ios/web/web_view_creation_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698