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

Unified Diff: ios/web_view/internal/cwv_web_view.mm

Issue 2757603003: Add window open and close delegate methods to CWVUIDelegate. (Closed)
Patch Set: Respond to comments. Created 3 years, 9 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_view/internal/cwv_navigation_action_internal.h ('k') | ios/web_view/public/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web_view/internal/cwv_web_view.mm
diff --git a/ios/web_view/internal/cwv_web_view.mm b/ios/web_view/internal/cwv_web_view.mm
index 6df0d2ac3845f06ea52ed5ef58bf542b43f1dcb7..383dc77f8393615b4037bc136e64198f19423f04 100644
--- a/ios/web_view/internal/cwv_web_view.mm
+++ b/ios/web_view/internal/cwv_web_view.mm
@@ -20,6 +20,7 @@
#import "ios/web/public/web_state/web_state_delegate_bridge.h"
#import "ios/web/public/web_state/web_state_observer_bridge.h"
#import "ios/web_view/internal/cwv_html_element_internal.h"
+#import "ios/web_view/internal/cwv_navigation_action_internal.h"
#import "ios/web_view/internal/cwv_web_view_configuration_internal.h"
#import "ios/web_view/internal/translate/web_view_translate_client.h"
#include "ios/web_view/internal/web_view_browser_state.h"
@@ -227,6 +228,38 @@
return YES;
}
+- (web::WebState*)webState:(web::WebState*)webState
+ createNewWebStateForURL:(const GURL&)URL
+ openerURL:(const GURL&)openerURL
+ initiatedByUser:(BOOL)initiatedByUser {
+ SEL selector =
+ @selector(webView:createWebViewWithConfiguration:forNavigationAction:);
+ if (![_UIDelegate respondsToSelector:selector]) {
+ return nullptr;
+ }
+
+ NSURLRequest* request =
+ [[NSURLRequest alloc] initWithURL:net::NSURLWithGURL(URL)];
+ CWVNavigationAction* navigationAction =
+ [[CWVNavigationAction alloc] initWithRequest:request
+ userInitiated:initiatedByUser];
+ // TODO(crbug.com/702298): Window created by CWVUIDelegate should be closable.
+ CWVWebView* webView = [_UIDelegate webView:self
+ createWebViewWithConfiguration:_configuration
+ forNavigationAction:navigationAction];
+ if (!webView) {
+ return nullptr;
+ }
+ return webView->_webState.get();
+}
+
+- (void)closeWebState:(web::WebState*)webState {
+ SEL selector = @selector(webViewDidClose:);
+ if ([_UIDelegate respondsToSelector:selector]) {
+ [_UIDelegate webViewDidClose:self];
+ }
+}
+
- (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState:
(web::WebState*)webState {
return _javaScriptDialogPresenter.get();
« no previous file with comments | « ios/web_view/internal/cwv_navigation_action_internal.h ('k') | ios/web_view/public/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698