| 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 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 BrowserState* browser_state, | 38 BrowserState* browser_state, |
| 39 BOOL use_desktop_user_agent, | 39 BOOL use_desktop_user_agent, |
| 40 id<CRWContextMenuDelegate> context_menu_delegate) { | 40 id<CRWContextMenuDelegate> context_menu_delegate) { |
| 41 VerifyWKWebViewCreationPreConditions(browser_state, configuration); | 41 VerifyWKWebViewCreationPreConditions(browser_state, configuration); |
| 42 | 42 |
| 43 GetWebClient()->PreWebViewCreation(); | 43 GetWebClient()->PreWebViewCreation(); |
| 44 WKWebView* web_view = | 44 WKWebView* web_view = |
| 45 [[WKWebView alloc] initWithFrame:frame configuration:configuration]; | 45 [[WKWebView alloc] initWithFrame:frame configuration:configuration]; |
| 46 | 46 |
| 47 // Set the user agent. | 47 // Set the user agent. |
| 48 UserAgentType user_agent_type = |
| 49 use_desktop_user_agent ? UserAgentType::DESKTOP : UserAgentType::MOBILE; |
| 48 web_view.customUserAgent = base::SysUTF8ToNSString( | 50 web_view.customUserAgent = base::SysUTF8ToNSString( |
| 49 web::GetWebClient()->GetUserAgent(use_desktop_user_agent)); | 51 web::GetWebClient()->GetUserAgent(user_agent_type)); |
| 50 | 52 |
| 51 // By default the web view uses a very sluggish scroll speed. Set it to a more | 53 // By default the web view uses a very sluggish scroll speed. Set it to a more |
| 52 // reasonable value. | 54 // reasonable value. |
| 53 web_view.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal; | 55 web_view.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal; |
| 54 | 56 |
| 55 // Starting in iOS10, |allowsLinkPreview| defaults to YES. This should be | 57 // Starting in iOS10, |allowsLinkPreview| defaults to YES. This should be |
| 56 // disabled since the default implementation will open the link in Safari. | 58 // disabled since the default implementation will open the link in Safari. |
| 57 // TODO(crbug.com/622746): Remove once web// link preview implementation is | 59 // TODO(crbug.com/622746): Remove once web// link preview implementation is |
| 58 // created. | 60 // created. |
| 59 web_view.allowsLinkPreview = NO; | 61 web_view.allowsLinkPreview = NO; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 82 | 84 |
| 83 WKWebView* BuildWKWebView(CGRect frame, | 85 WKWebView* BuildWKWebView(CGRect frame, |
| 84 WKWebViewConfiguration* configuration, | 86 WKWebViewConfiguration* configuration, |
| 85 BrowserState* browser_state) { | 87 BrowserState* browser_state) { |
| 86 BOOL use_desktop_user_agent = NO; | 88 BOOL use_desktop_user_agent = NO; |
| 87 return BuildWKWebView(frame, configuration, browser_state, | 89 return BuildWKWebView(frame, configuration, browser_state, |
| 88 use_desktop_user_agent); | 90 use_desktop_user_agent); |
| 89 } | 91 } |
| 90 | 92 |
| 91 } // namespace web | 93 } // namespace web |
| OLD | NEW |