Chromium Code Reviews| 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_website_data_store_internal.h" | 24 #import "ios/web_view/internal/cwv_website_data_store_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 "ios/web_view/public/cwv_website_data_store.h" | 32 #import "ios/web_view/public/cwv_website_data_store.h" |
| 32 #import "net/base/mac/url_conversions.h" | 33 #import "net/base/mac/url_conversions.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 43 double _estimatedProgress; | 44 double _estimatedProgress; |
| 44 // Handles presentation of JavaScript dialogs. | 45 // Handles presentation of JavaScript dialogs. |
| 45 std::unique_ptr<ios_web_view::WebViewJavaScriptDialogPresenter> | 46 std::unique_ptr<ios_web_view::WebViewJavaScriptDialogPresenter> |
| 46 _javaScriptDialogPresenter; | 47 _javaScriptDialogPresenter; |
| 47 } | 48 } |
| 48 | 49 |
| 49 // Redefine the property as readwrite to define -setEstimatedProgress:, which | 50 // Redefine the property as readwrite to define -setEstimatedProgress:, which |
| 50 // can be used to send KVO notification. | 51 // can be used to send KVO notification. |
| 51 @property(nonatomic, readwrite) double estimatedProgress; | 52 @property(nonatomic, readwrite) double estimatedProgress; |
| 52 | 53 |
| 54 //@property(nonatomic, readonly) web::WebState estimatedProgress; | |
|
Eugene But (OOO till 7-30)
2017/03/16 17:09:02
Please remove this
michaeldo
2017/03/16 18:24:28
Done.
| |
| 55 | |
| 53 @end | 56 @end |
| 54 | 57 |
| 55 @implementation CWVWebView | 58 @implementation CWVWebView |
| 56 | 59 |
| 57 @synthesize navigationDelegate = _navigationDelegate; | 60 @synthesize navigationDelegate = _navigationDelegate; |
| 58 @synthesize translationDelegate = _translationDelegate; | 61 @synthesize translationDelegate = _translationDelegate; |
| 59 @synthesize estimatedProgress = _estimatedProgress; | 62 @synthesize estimatedProgress = _estimatedProgress; |
| 60 @synthesize UIDelegate = _UIDelegate; | 63 @synthesize UIDelegate = _UIDelegate; |
| 61 | 64 |
| 62 - (instancetype)initWithFrame:(CGRect)frame | 65 - (instancetype)initWithFrame:(CGRect)frame |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 mediaSource:mediaSource | 224 mediaSource:mediaSource |
| 222 text:params.link_text]; | 225 text:params.link_text]; |
| 223 [_UIDelegate webView:self | 226 [_UIDelegate webView:self |
| 224 runContextMenuWithTitle:params.menu_title | 227 runContextMenuWithTitle:params.menu_title |
| 225 forHTMLElement:HTMLElement | 228 forHTMLElement:HTMLElement |
| 226 inView:params.view | 229 inView:params.view |
| 227 userGestureLocation:params.location]; | 230 userGestureLocation:params.location]; |
| 228 return YES; | 231 return YES; |
| 229 } | 232 } |
| 230 | 233 |
| 234 - (web::WebState*)webState:(web::WebState*)webState | |
| 235 createNewWebStateForURL:(const GURL&)URL | |
| 236 openerURL:(const GURL&)openerURL | |
| 237 initiatedByUser:(BOOL)initiatedByUser { | |
| 238 SEL selector = | |
| 239 @selector(webView:createWebViewWithConfiguration:forNavigationAction:); | |
| 240 if (![_UIDelegate respondsToSelector:selector]) { | |
| 241 return nil; | |
| 242 } | |
| 243 | |
| 244 NSURLRequest* request = | |
| 245 [[NSURLRequest alloc] initWithURL:net::NSURLWithGURL(URL)]; | |
| 246 CWVNavigationAction* navigationAction = | |
| 247 [[CWVNavigationAction alloc] initWithRequest:request | |
| 248 userInitiated:initiatedByUser]; | |
| 249 CWVWebView* webView = [_UIDelegate webView:self | |
| 250 createWebViewWithConfiguration:_configuration | |
| 251 forNavigationAction:navigationAction]; | |
|
Eugene But (OOO till 7-30)
2017/03/16 17:09:02
This will create a non-closable window. WebState c
michaeldo
2017/03/16 18:24:28
Thank you for the details, I have created a bug an
| |
| 252 return webView->_webState.get(); | |
|
Eugene But (OOO till 7-30)
2017/03/16 17:09:02
This will crash if |webView| is nil.
michaeldo
2017/03/16 18:24:28
I've added a check that a webview was in fact retu
| |
| 253 } | |
| 254 | |
| 255 - (void)closeWebState:(web::WebState*)webState { | |
| 256 SEL selector = @selector(webViewDidClose:); | |
| 257 if (![_UIDelegate respondsToSelector:selector]) { | |
|
Eugene But (OOO till 7-30)
2017/03/16 17:09:02
nit: How about this?:
if ([_UIDelegate respondsTo
michaeldo
2017/03/16 18:24:28
Done.
| |
| 258 return; | |
| 259 } | |
| 260 [_UIDelegate webViewDidClose:self]; | |
| 261 } | |
| 262 | |
| 231 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState: | 263 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState: |
| 232 (web::WebState*)webState { | 264 (web::WebState*)webState { |
| 233 return _javaScriptDialogPresenter.get(); | 265 return _javaScriptDialogPresenter.get(); |
| 234 } | 266 } |
| 235 | 267 |
| 236 @end | 268 @end |
| OLD | NEW |