| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #import "net/base/mac/url_conversions.h" | 32 #import "net/base/mac/url_conversions.h" |
| 33 #include "ui/base/page_transition_types.h" | 33 #include "ui/base/page_transition_types.h" |
| 34 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 // A key used in NSCoder to store the session storage object. | 37 // A key used in NSCoder to store the session storage object. |
| 38 NSString* const kSessionStorageKey = @"sessionStorage"; | 38 NSString* const kSessionStorageKey = @"sessionStorage"; |
| 39 } | 39 } |
| 40 | 40 |
| 41 @interface CWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> { | 41 @interface CWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> { |
| 42 CWVWebViewConfiguration* _configuration; | |
| 43 std::unique_ptr<web::WebState> _webState; | 42 std::unique_ptr<web::WebState> _webState; |
| 44 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; | 43 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; |
| 45 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; | 44 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; |
| 46 std::unique_ptr<ios_web_view::WebViewWebStatePolicyDecider> | 45 std::unique_ptr<ios_web_view::WebViewWebStatePolicyDecider> |
| 47 _webStatePolicyDecider; | 46 _webStatePolicyDecider; |
| 48 double _estimatedProgress; | 47 double _estimatedProgress; |
| 49 // Handles presentation of JavaScript dialogs. | 48 // Handles presentation of JavaScript dialogs. |
| 50 std::unique_ptr<ios_web_view::WebViewJavaScriptDialogPresenter> | 49 std::unique_ptr<ios_web_view::WebViewJavaScriptDialogPresenter> |
| 51 _javaScriptDialogPresenter; | 50 _javaScriptDialogPresenter; |
| 52 } | 51 } |
| 53 | 52 |
| 53 // Redefine the property as readwrite. |
| 54 @property(nonatomic, copy) CWVWebViewConfiguration* configuration; |
| 54 // Redefine the property as readwrite to define -setEstimatedProgress:, which | 55 // Redefine the property as readwrite to define -setEstimatedProgress:, which |
| 55 // can be used to send KVO notification. | 56 // can be used to send KVO notification. |
| 56 @property(nonatomic, readwrite) double estimatedProgress; | 57 @property(nonatomic, readwrite) double estimatedProgress; |
| 57 | 58 |
| 58 @end | 59 @end |
| 59 | 60 |
| 61 static NSString* gUserAgentProduct = nil; |
| 62 |
| 60 @implementation CWVWebView | 63 @implementation CWVWebView |
| 61 | 64 |
| 62 @synthesize configuration = _configuration; | 65 @synthesize configuration = _configuration; |
| 63 @synthesize navigationDelegate = _navigationDelegate; | 66 @synthesize navigationDelegate = _navigationDelegate; |
| 64 @synthesize translationDelegate = _translationDelegate; | 67 @synthesize translationDelegate = _translationDelegate; |
| 65 @synthesize estimatedProgress = _estimatedProgress; | 68 @synthesize estimatedProgress = _estimatedProgress; |
| 66 @synthesize UIDelegate = _UIDelegate; | 69 @synthesize UIDelegate = _UIDelegate; |
| 67 | 70 |
| 71 + (NSString*)userAgentProduct { |
| 72 return gUserAgentProduct; |
| 73 } |
| 74 |
| 75 + (void)setUserAgentProduct:(NSString*)product { |
| 76 gUserAgentProduct = [product copy]; |
| 77 } |
| 78 |
| 68 - (instancetype)initWithFrame:(CGRect)frame | 79 - (instancetype)initWithFrame:(CGRect)frame |
| 69 configuration:(CWVWebViewConfiguration*)configuration { | 80 configuration:(CWVWebViewConfiguration*)configuration { |
| 70 self = [super initWithFrame:frame]; | 81 self = [super initWithFrame:frame]; |
| 71 if (self) { | 82 if (self) { |
| 72 _configuration = [configuration copy]; | 83 _configuration = [configuration copy]; |
| 73 [self resetWebStateWithSessionStorage:nil]; | 84 [self resetWebStateWithSessionStorage:nil]; |
| 74 } | 85 } |
| 75 return self; | 86 return self; |
| 76 } | 87 } |
| 77 | 88 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 if (subview.superview == self) { | 316 if (subview.superview == self) { |
| 306 return; | 317 return; |
| 307 } | 318 } |
| 308 subview.frame = self.bounds; | 319 subview.frame = self.bounds; |
| 309 subview.autoresizingMask = | 320 subview.autoresizingMask = |
| 310 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | 321 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
| 311 [self addSubview:subview]; | 322 [self addSubview:subview]; |
| 312 } | 323 } |
| 313 | 324 |
| 314 @end | 325 @end |
| OLD | NEW |