| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/web_view/public/cwv_web_view.h" | 5 #import "ios/web_view/public/cwv_web_view.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #import "base/ios/weak_nsobject.h" | 10 #import "base/ios/weak_nsobject.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 13 #import "ios/web/public/navigation_manager.h" | 13 #import "ios/web/public/navigation_manager.h" |
| 14 #include "ios/web/public/referrer.h" | 14 #include "ios/web/public/referrer.h" |
| 15 #include "ios/web/public/reload_type.h" | 15 #include "ios/web/public/reload_type.h" |
| 16 #import "ios/web/public/web_state/context_menu_params.h" | 16 #import "ios/web/public/web_state/context_menu_params.h" |
| 17 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h" | 17 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h" |
| 18 #import "ios/web/public/web_state/ui/crw_web_delegate.h" | 18 #import "ios/web/public/web_state/ui/crw_web_delegate.h" |
| 19 #import "ios/web/public/web_state/web_state.h" | 19 #import "ios/web/public/web_state/web_state.h" |
| 20 #import "ios/web/public/web_state/web_state_delegate_bridge.h" | 20 #import "ios/web/public/web_state/web_state_delegate_bridge.h" |
| 21 #import "ios/web/public/web_state/web_state_observer_bridge.h" | 21 #import "ios/web/public/web_state/web_state_observer_bridge.h" |
| 22 #import "ios/web_view/internal/cwv_html_element_internal.h" | 22 #import "ios/web_view/internal/cwv_html_element_internal.h" |
| 23 #import "ios/web_view/internal/cwv_navigation_action_internal.h" |
| 23 #import "ios/web_view/internal/cwv_web_view_configuration_internal.h" | 24 #import "ios/web_view/internal/cwv_web_view_configuration_internal.h" |
| 24 #import "ios/web_view/internal/translate/web_view_translate_client.h" | 25 #import "ios/web_view/internal/translate/web_view_translate_client.h" |
| 25 #include "ios/web_view/internal/web_view_browser_state.h" | 26 #include "ios/web_view/internal/web_view_browser_state.h" |
| 26 #import "ios/web_view/internal/web_view_java_script_dialog_presenter.h" | 27 #import "ios/web_view/internal/web_view_java_script_dialog_presenter.h" |
| 27 #import "ios/web_view/internal/web_view_web_state_policy_decider.h" | 28 #import "ios/web_view/internal/web_view_web_state_policy_decider.h" |
| 28 #import "ios/web_view/public/cwv_navigation_delegate.h" | 29 #import "ios/web_view/public/cwv_navigation_delegate.h" |
| 29 #import "ios/web_view/public/cwv_ui_delegate.h" | 30 #import "ios/web_view/public/cwv_ui_delegate.h" |
| 30 #import "ios/web_view/public/cwv_web_view_configuration.h" | 31 #import "ios/web_view/public/cwv_web_view_configuration.h" |
| 31 #import "net/base/mac/url_conversions.h" | 32 #import "net/base/mac/url_conversions.h" |
| 32 #include "ui/base/page_transition_types.h" | 33 #include "ui/base/page_transition_types.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 mediaSource:mediaSource | 221 mediaSource:mediaSource |
| 221 text:params.link_text]; | 222 text:params.link_text]; |
| 222 [_UIDelegate webView:self | 223 [_UIDelegate webView:self |
| 223 runContextMenuWithTitle:params.menu_title | 224 runContextMenuWithTitle:params.menu_title |
| 224 forHTMLElement:HTMLElement | 225 forHTMLElement:HTMLElement |
| 225 inView:params.view | 226 inView:params.view |
| 226 userGestureLocation:params.location]; | 227 userGestureLocation:params.location]; |
| 227 return YES; | 228 return YES; |
| 228 } | 229 } |
| 229 | 230 |
| 231 - (web::WebState*)webState:(web::WebState*)webState |
| 232 createNewWebStateForURL:(const GURL&)URL |
| 233 openerURL:(const GURL&)openerURL |
| 234 initiatedByUser:(BOOL)initiatedByUser { |
| 235 SEL selector = |
| 236 @selector(webView:createWebViewWithConfiguration:forNavigationAction:); |
| 237 if (![_UIDelegate respondsToSelector:selector]) { |
| 238 return nullptr; |
| 239 } |
| 240 |
| 241 NSURLRequest* request = |
| 242 [[NSURLRequest alloc] initWithURL:net::NSURLWithGURL(URL)]; |
| 243 CWVNavigationAction* navigationAction = |
| 244 [[CWVNavigationAction alloc] initWithRequest:request |
| 245 userInitiated:initiatedByUser]; |
| 246 // TODO(crbug.com/702298): Window created by CWVUIDelegate should be closable. |
| 247 CWVWebView* webView = [_UIDelegate webView:self |
| 248 createWebViewWithConfiguration:_configuration |
| 249 forNavigationAction:navigationAction]; |
| 250 if (!webView) { |
| 251 return nullptr; |
| 252 } |
| 253 return webView->_webState.get(); |
| 254 } |
| 255 |
| 256 - (void)closeWebState:(web::WebState*)webState { |
| 257 SEL selector = @selector(webViewDidClose:); |
| 258 if ([_UIDelegate respondsToSelector:selector]) { |
| 259 [_UIDelegate webViewDidClose:self]; |
| 260 } |
| 261 } |
| 262 |
| 230 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState: | 263 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState: |
| 231 (web::WebState*)webState { | 264 (web::WebState*)webState { |
| 232 return _javaScriptDialogPresenter.get(); | 265 return _javaScriptDialogPresenter.get(); |
| 233 } | 266 } |
| 234 | 267 |
| 235 @end | 268 @end |
| OLD | NEW |