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

Side by Side Diff: ios/chrome/browser/experimental_flags.mm

Issue 1144803002: [iOS] Upstream switches and flags controlling which WebView is used (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « ios/chrome/browser/experimental_flags.h ('k') | ios/chrome/browser/web/web_view_type_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This file can be empty. Its purpose is to contain the relatively short lived 5 // This file can be empty. Its purpose is to contain the relatively short lived
6 // definitions required for experimental flags. 6 // definitions required for experimental flags.
7 7
8 #include "ios/chrome/browser/experimental_flags.h" 8 #include "ios/chrome/browser/experimental_flags.h"
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h"
15 #include "components/variations/variations_associated_data.h" 16 #include "components/variations/variations_associated_data.h"
16 #include "ios/chrome/browser/chrome_switches.h" 17 #include "ios/chrome/browser/chrome_switches.h"
18 #include "ios/web/public/web_view_util.h"
17 19
18 namespace { 20 namespace {
19 NSString* const kEnableAlertOnBackgroundUpload = 21 NSString* const kEnableAlertOnBackgroundUpload =
20 @"EnableAlertsOnBackgroundUpload"; 22 @"EnableAlertsOnBackgroundUpload";
21 } // namespace 23 } // namespace
22 24
23 namespace experimental_flags { 25 namespace experimental_flags {
24 26
25 bool IsAlertOnBackgroundUploadEnabled() { 27 bool IsAlertOnBackgroundUploadEnabled() {
26 return [[NSUserDefaults standardUserDefaults] 28 return [[NSUserDefaults standardUserDefaults]
27 boolForKey:kEnableAlertOnBackgroundUpload]; 29 boolForKey:kEnableAlertOnBackgroundUpload];
28 } 30 }
29 31
30 bool IsOpenFromClipboardEnabled() { 32 bool IsOpenFromClipboardEnabled() {
31 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 33 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
32 return command_line->HasSwitch(switches::kEnableIOSOpenFromClipboard); 34 return command_line->HasSwitch(switches::kEnableIOSOpenFromClipboard);
33 } 35 }
34 36
37 bool IsWKWebViewEnabled() {
38 // If WKWebView isn't supported, don't activate the experiment at all. This
39 // avoids someone being slotted into the WKWebView bucket (and thus reporting
40 // as WKWebView), but actually running UIWebView.
41 if (!web::IsWKWebViewSupported())
42 return false;
43
44 std::string group_name =
45 base::FieldTrialList::FindFullName("IOSUseWKWebView");
46
47 // First check if the experimental flag is turned on.
48 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
49 if (command_line->HasSwitch(switches::kEnableIOSWKWebView)) {
50 return true;
51 } else if (command_line->HasSwitch(switches::kDisableIOSWKWebView)) {
52 return false;
53 }
54
55 // Check if the finch experiment is turned on.
56 return StartsWithASCII(group_name, "Enabled", false);
57 }
58
35 size_t MemoryWedgeSizeInMB() { 59 size_t MemoryWedgeSizeInMB() {
36 std::string wedge_size_string; 60 std::string wedge_size_string;
37 61
38 // Get the size from the Experimental setting. 62 // Get the size from the Experimental setting.
39 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 63 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
40 wedge_size_string = 64 wedge_size_string =
41 command_line->GetSwitchValueASCII(switches::kIOSMemoryWedgeSize); 65 command_line->GetSwitchValueASCII(switches::kIOSMemoryWedgeSize);
42 66
43 // Otherwise, get from a variation param. 67 // Otherwise, get from a variation param.
44 if (wedge_size_string.empty()) { 68 if (wedge_size_string.empty()) {
45 wedge_size_string = 69 wedge_size_string =
46 variations::GetVariationParamValue("MemoryWedge", "wedge_size"); 70 variations::GetVariationParamValue("MemoryWedge", "wedge_size");
47 } 71 }
48 72
49 // Parse the value. 73 // Parse the value.
50 size_t wedge_size_in_mb = 0; 74 size_t wedge_size_in_mb = 0;
51 if (base::StringToSizeT(wedge_size_string, &wedge_size_in_mb)) 75 if (base::StringToSizeT(wedge_size_string, &wedge_size_in_mb))
52 return wedge_size_in_mb; 76 return wedge_size_in_mb;
53 return 0; 77 return 0;
54 } 78 }
55 79
56 } // namespace experimental_flags 80 } // namespace experimental_flags
OLDNEW
« no previous file with comments | « ios/chrome/browser/experimental_flags.h ('k') | ios/chrome/browser/web/web_view_type_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698