Index: ios/chrome/browser/ui/static_content/static_html_view_controller.mm |
diff --git a/ios/chrome/browser/ui/static_content/static_html_view_controller.mm b/ios/chrome/browser/ui/static_content/static_html_view_controller.mm |
index cd2e6331a2038863d3fd100e8e5f02b682194249..d5948eac23546b3a854abce0d5d3807ff4fa4444 100644 |
--- a/ios/chrome/browser/ui/static_content/static_html_view_controller.mm |
+++ b/ios/chrome/browser/ui/static_content/static_html_view_controller.mm |
@@ -15,6 +15,7 @@ |
#include "ios/web/public/referrer.h" |
#import "ios/web/public/web_state/ui/crw_native_content.h" |
#import "ios/web/public/web_view_creation_util.h" |
+#import "ios/web/public/web_state/ui/crw_context_menu_controller.h" |
#import "net/base/mac/url_conversions.h" |
#include "ui/base/page_transition_types.h" |
#include "ui/base/resource/resource_bundle.h" |
@@ -43,7 +44,9 @@ |
} |
@end |
-@interface StaticHtmlViewController ()<WKNavigationDelegate> { |
+@interface StaticHtmlViewController ()<CRWContextMenuControllerWebView, |
+ WKNavigationDelegate, |
+ UIGestureRecognizerDelegate> { |
jif
2017/01/12 17:13:12
remove UIGestureRecognizerDelegate?
Olivier
2017/01/13 10:20:25
Done.
|
@private |
// The referrer that will be passed when navigating from this page. |
web::Referrer referrer_; |
@@ -76,6 +79,10 @@ |
// The delegate of the native content. |
id<CRWNativeContentDelegate> delegate_; // weak |
+ // The controller that will recognize the long press and trigger the context |
+ // menu. |
+ base::scoped_nsobject<CRWContextMenuController> contextMenuController_; |
+ |
// The loader to navigate from the page. |
id<UrlLoader> loader_; // weak |
} |
@@ -116,7 +123,9 @@ |
- (instancetype)initWithFileURL:(const GURL&)URL |
allowingReadAccessToURL:(const GURL&)resourcesRoot |
- browserState:(web::BrowserState*)browserState { |
+ browserState:(web::BrowserState*)browserState |
+ contextMenuDelegate: |
+ (id<CRWContextMenuControllerDelegate>)contextMenuDelegate { |
DCHECK(URL.is_valid()); |
DCHECK(URL.SchemeIsFile()); |
DCHECK(browserState); |
@@ -124,6 +133,11 @@ |
resourceUrl_.reset([net::NSURLWithGURL(URL) retain]); |
resourcesRootDirectory_.reset([net::NSURLWithGURL(resourcesRoot) retain]); |
browserState_ = browserState; |
+ if (contextMenuDelegate) { |
+ contextMenuController_.reset([[CRWContextMenuController alloc] |
+ initWithWebView:self |
+ delegate:contextMenuDelegate]); |
+ } |
} |
return self; |
} |
@@ -210,6 +224,12 @@ |
} |
#pragma mark - |
+#pragma mark CRWWKContextMenuWebView implementation |
+- (UIView*)webScrollView { |
+ return self.scrollView; |
+} |
+ |
+#pragma mark - |
#pragma mark KVO callback |
- (void)observeValueForKeyPath:(NSString*)keyPath |