| 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/web_state/web_view_internal_creation_util.h" | 5 #import "ios/web/web_state/web_view_internal_creation_util.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "ios/web/public/web_client.h" | 9 #include "ios/web/public/web_client.h" |
| 10 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" | 10 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 DCHECK_EQ([config_provider.GetWebViewConfiguration() processPool], | 26 DCHECK_EQ([config_provider.GetWebViewConfiguration() processPool], |
| 27 [configuration processPool]); | 27 [configuration processPool]); |
| 28 } | 28 } |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 WKWebView* CreateWKWebView(CGRect frame, | 32 WKWebView* CreateWKWebView(CGRect frame, |
| 33 WKWebViewConfiguration* configuration, | 33 WKWebViewConfiguration* configuration, |
| 34 BrowserState* browser_state, | 34 BrowserState* browser_state, |
| 35 BOOL use_desktop_user_agent) { | 35 BOOL use_desktop_user_agent) { |
| 36 WKWebView* web_view = CreateWKWebView(frame, configuration, browser_state); | 36 VerifyWKWebViewCreationPreConditions(browser_state, configuration); |
| 37 |
| 38 GetWebClient()->PreWebViewCreation(); |
| 39 WKWebView* web_view = |
| 40 [[WKWebView alloc] initWithFrame:frame configuration:configuration]; |
| 41 |
| 42 // Set the user agent. |
| 37 web_view.customUserAgent = base::SysUTF8ToNSString( | 43 web_view.customUserAgent = base::SysUTF8ToNSString( |
| 38 web::GetWebClient()->GetUserAgent(use_desktop_user_agent)); | 44 web::GetWebClient()->GetUserAgent(use_desktop_user_agent)); |
| 45 |
| 46 // By default the web view uses a very sluggish scroll speed. Set it to a more |
| 47 // reasonable value. |
| 48 web_view.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal; |
| 49 |
| 50 // Starting in iOS10, |allowsLinkPreview| defaults to YES. This should be |
| 51 // disabled since the default implementation will open the link in Safari. |
| 52 // TODO(crbug.com/622746): Remove once web// link preview implementation is |
| 53 // created. |
| 54 web_view.allowsLinkPreview = NO; |
| 55 |
| 39 return web_view; | 56 return web_view; |
| 40 } | 57 } |
| 41 | 58 |
| 42 WKWebView* CreateWKWebView(CGRect frame, | 59 WKWebView* CreateWKWebView(CGRect frame, |
| 43 WKWebViewConfiguration* configuration, | 60 WKWebViewConfiguration* configuration, |
| 44 BrowserState* browser_state) { | 61 BrowserState* browser_state) { |
| 45 VerifyWKWebViewCreationPreConditions(browser_state, configuration); | 62 BOOL use_desktop_user_agent = NO; |
| 46 | 63 return CreateWKWebView(frame, configuration, browser_state, |
| 47 GetWebClient()->PreWebViewCreation(); | 64 use_desktop_user_agent); |
| 48 WKWebView* result = | |
| 49 [[WKWebView alloc] initWithFrame:frame configuration:configuration]; | |
| 50 | |
| 51 // By default the web view uses a very sluggish scroll speed. Set it to a more | |
| 52 // reasonable value. | |
| 53 result.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal; | |
| 54 | |
| 55 // Starting in iOS10, |allowsLinkPreview| defaults to YES. This should be | |
| 56 // disabled since the default implementation will open the link in Safari. | |
| 57 // TODO(crbug.com/622746): Remove once web// link preview implementation is | |
| 58 // created. | |
| 59 result.allowsLinkPreview = NO; | |
| 60 | |
| 61 return result; | |
| 62 } | 65 } |
| 63 | 66 |
| 64 } // namespace web | 67 } // namespace web |
| OLD | NEW |