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

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

Issue 1682273002: Use consistent background color for WKWebViews. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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"
(...skipping 23 matching lines...) Expand all
34 namespace { 34 namespace {
35 // Returns the counter of all the active WKWebViews. 35 // Returns the counter of all the active WKWebViews.
36 // DEPRECATED. Please use web::WebViewCounter instead. 36 // DEPRECATED. Please use web::WebViewCounter instead.
37 // TODO(shreyasv): Remove this once all callers have stopped using it. 37 // TODO(shreyasv): Remove this once all callers have stopped using it.
38 // crbug.com/480507 38 // crbug.com/480507
39 web::WeakNSObjectCounter& GetActiveWKWebViewCounter() { 39 web::WeakNSObjectCounter& GetActiveWKWebViewCounter() {
40 static web::WeakNSObjectCounter active_wk_web_view_counter; 40 static web::WeakNSObjectCounter active_wk_web_view_counter;
41 return active_wk_web_view_counter; 41 return active_wk_web_view_counter;
42 } 42 }
43 43
44 // The brightness of the web views' background colors.
45 const CGFloat kWebViewBackgroundColorBrightness = 0.2;
46
44 // Decides if web views can be created. 47 // Decides if web views can be created.
45 bool gAllowWebViewCreation = NO; 48 bool gAllowWebViewCreation = NO;
46 49
47 // Decides if web views are associated with an ActiveStateManager which is 50 // Decides if web views are associated with an ActiveStateManager which is
48 // active. 51 // active.
49 bool gWebViewsNeedActiveStateManager = NO; 52 bool gWebViewsNeedActiveStateManager = NO;
50 53
51 } // namespace 54 } // namespace
52 55
53 @interface WKWebView (CRWAdditions) 56 @interface WKWebView (CRWAdditions)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 BrowserState* browser_state) { 180 BrowserState* browser_state) {
178 VerifyWKWebViewCreationPreConditions(browser_state, configuration); 181 VerifyWKWebViewCreationPreConditions(browser_state, configuration);
179 182
180 PreWKWebViewCreation(browser_state); 183 PreWKWebViewCreation(browser_state);
181 #if !defined(NDEBUG) 184 #if !defined(NDEBUG)
182 bool previous_allow_web_view_creation_value = gAllowWebViewCreation; 185 bool previous_allow_web_view_creation_value = gAllowWebViewCreation;
183 gAllowWebViewCreation = true; 186 gAllowWebViewCreation = true;
184 #endif 187 #endif
185 WKWebView* result = 188 WKWebView* result =
186 [[WKWebView alloc] initWithFrame:frame configuration:configuration]; 189 [[WKWebView alloc] initWithFrame:frame configuration:configuration];
190 result.backgroundColor =
191 [UIColor colorWithWhite:kWebViewBackgroundColorBrightness alpha:1.0];
187 #if !defined(NDEBUG) 192 #if !defined(NDEBUG)
188 gAllowWebViewCreation = previous_allow_web_view_creation_value; 193 gAllowWebViewCreation = previous_allow_web_view_creation_value;
189 #endif 194 #endif
190 PostWKWebViewCreation(result, browser_state); 195 PostWKWebViewCreation(result, browser_state);
191 196
192 // By default the web view uses a very sluggish scroll speed. Set it to a more 197 // By default the web view uses a very sluggish scroll speed. Set it to a more
193 // reasonable value. 198 // reasonable value.
194 result.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal; 199 result.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
195 200
196 return result; 201 return result;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 if (!gAllowWebViewCreation) { 269 if (!gAllowWebViewCreation) {
265 gWebViewsNeedActiveStateManager = 270 gWebViewsNeedActiveStateManager =
266 GetWebClient()->WebViewsNeedActiveStateManager(); 271 GetWebClient()->WebViewsNeedActiveStateManager();
267 } 272 }
268 }); 273 });
269 return gAllowWebViewCreation; 274 return gAllowWebViewCreation;
270 } 275 }
271 #endif 276 #endif
272 277
273 } // namespace web 278 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698