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

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..1a1a1f1e024b5be4a176bfde3aa7fa3c3c44ffa1 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 nil;
Eugene But (OOO till 7-30) 2017/03/16 18:48:56 s/nil/nullptr
michaeldo 2017/03/16 20:25:39 Done.
+ }
+
+ 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) {
Eugene But (OOO till 7-30) 2017/03/16 18:48:55 Optional nit: Do you want to swap conditions for
michaeldo 2017/03/16 20:25:39 Done.
+ return webView->_webState.get();
+ }
+ return nullptr;
+}
+
+- (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