Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: ios/web/web_state/web_view_internal_creation_util.mm

Issue 1799843002: Removing StaticFileWebView vending methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #import <WebKit/WebKit.h> 8 #import <WebKit/WebKit.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/mac/scoped_nsobject.h" 11 #include "base/mac/scoped_nsobject.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #import "ios/web/alloc_with_zone_interceptor.h" 13 #import "ios/web/alloc_with_zone_interceptor.h"
14 #include "ios/web/public/active_state_manager.h" 14 #include "ios/web/public/active_state_manager.h"
15 #include "ios/web/public/browser_state.h" 15 #include "ios/web/public/browser_state.h"
16 #import "ios/web/public/browsing_data_partition.h" 16 #import "ios/web/public/browsing_data_partition.h"
17 #include "ios/web/public/web_client.h" 17 #include "ios/web/public/web_client.h"
18 #import "ios/web/public/web_view_counter.h" 18 #import "ios/web/public/web_view_counter.h"
19 #import "ios/web/public/web_view_creation_util.h" 19 #import "ios/web/public/web_view_creation_util.h"
20 #include "ios/web/ui_web_view_util.h" 20 #include "ios/web/ui_web_view_util.h"
21 #import "ios/web/weak_nsobject_counter.h" 21 #import "ios/web/weak_nsobject_counter.h"
22 #import "ios/web/web_state/ui/crw_static_file_web_view.h" 22 #import "ios/web/web_state/ui/crw_static_file_web_view.h"
Eugene But (OOO till 7-30) 2016/03/14 20:25:46 Is this include still necessary?
shreyasv1 2016/03/14 22:28:32 Done.
23 #import "ios/web/web_state/ui/crw_ui_simple_web_view_controller.h" 23 #import "ios/web/web_state/ui/crw_ui_simple_web_view_controller.h"
24 #import "ios/web/web_state/ui/crw_wk_simple_web_view_controller.h" 24 #import "ios/web/web_state/ui/crw_wk_simple_web_view_controller.h"
25 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" 25 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h"
26 #import "ios/web/web_view_counter_impl.h" 26 #import "ios/web/web_view_counter_impl.h"
27 27
28 #if !defined(NDEBUG) 28 #if !defined(NDEBUG)
29 29
30 namespace { 30 namespace {
31 // Returns the counter of all the active WKWebViews. 31 // Returns the counter of all the active WKWebViews.
32 // DEPRECATED. Please use web::WebViewCounter instead. 32 // DEPRECATED. Please use web::WebViewCounter instead.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // Transparently return the correct subclass. 202 // Transparently return the correct subclass.
203 if (web_view_type == WK_WEB_VIEW_TYPE) { 203 if (web_view_type == WK_WEB_VIEW_TYPE) {
204 base::scoped_nsobject<WKWebView> web_view( 204 base::scoped_nsobject<WKWebView> web_view(
205 web::CreateWKWebView(frame, browser_state)); 205 web::CreateWKWebView(frame, browser_state));
206 return [[CRWWKSimpleWebViewController alloc] initWithWKWebView:web_view]; 206 return [[CRWWKSimpleWebViewController alloc] initWithWKWebView:web_view];
207 } 207 }
208 base::scoped_nsobject<UIWebView> web_view(web::CreateWebView(frame)); 208 base::scoped_nsobject<UIWebView> web_view(web::CreateWebView(frame));
209 return [[CRWUISimpleWebViewController alloc] initWithUIWebView:web_view]; 209 return [[CRWUISimpleWebViewController alloc] initWithUIWebView:web_view];
210 } 210 }
211 211
212 id<CRWSimpleWebViewController> CreateStaticFileSimpleWebViewController(
213 CGRect frame,
214 BrowserState* browser_state,
215 WebViewType web_view_type) {
216 DCHECK(web::BrowsingDataPartition::IsSynchronized());
217
218 // Transparently return the correct subclass.
219 if (web_view_type == WK_WEB_VIEW_TYPE) {
220 // TOOD(shreyasv): Create a new util function vending a WKWebView, wrap that
221 // now return the UIWebView version. crbug.com/403634.
222 }
223 base::scoped_nsobject<UIWebView> staticFileWebView(
224 CreateStaticFileWebView(frame, browser_state));
225 return [[CRWUISimpleWebViewController alloc]
226 initWithUIWebView:staticFileWebView];
227 }
228
229 UIWebView* CreateStaticFileWebView(CGRect frame, BrowserState* browser_state) {
230 DCHECK(web::GetWebClient());
231 web::GetWebClient()->PreWebViewCreation();
232
233 UIWebView* result =
234 [[CRWStaticFileWebView alloc] initWithFrame:frame
235 browserState:browser_state];
236
237 web::GetWebClient()->PostWebViewCreation(result);
238 return result;
239 }
240
241 UIWebView* CreateStaticFileWebView() {
242 return CreateStaticFileWebView(CGRectZero, nullptr);
243 }
244
245 #if !defined(NDEBUG) 212 #if !defined(NDEBUG)
246 bool IsWebViewAllocInitAllowed() { 213 bool IsWebViewAllocInitAllowed() {
247 static dispatch_once_t once_token = 0; 214 static dispatch_once_t once_token = 0;
248 dispatch_once(&once_token, ^{ 215 dispatch_once(&once_token, ^{
249 DCHECK(GetWebClient()); 216 DCHECK(GetWebClient());
250 gAllowWebViewCreation = GetWebClient()->AllowWebViewAllocInit(); 217 gAllowWebViewCreation = GetWebClient()->AllowWebViewAllocInit();
251 if (!gAllowWebViewCreation) { 218 if (!gAllowWebViewCreation) {
252 gWebViewsNeedActiveStateManager = 219 gWebViewsNeedActiveStateManager =
253 GetWebClient()->WebViewsNeedActiveStateManager(); 220 GetWebClient()->WebViewsNeedActiveStateManager();
254 } 221 }
255 }); 222 });
256 return gAllowWebViewCreation; 223 return gAllowWebViewCreation;
257 } 224 }
258 #endif 225 #endif
259 226
260 } // namespace web 227 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698