[iOS] Remove OpenFromClipboard finch experiment and switch
[chromium-blink-merge.git] / ios / chrome / browser / experimental_flags.mm
blobdbd79fdcfa9b720e4747ca3f1e95c9f9bdca35e2
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
3 // found in the LICENSE file.
5 // This file can be empty. Its purpose is to contain the relatively short lived
6 // definitions required for experimental flags.
8 #include "ios/chrome/browser/experimental_flags.h"
10 #include <string>
12 #include "base/command_line.h"
13 #include "base/metrics/field_trial.h"
14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h"
16 #include "components/variations/variations_associated_data.h"
17 #include "ios/chrome/browser/chrome_switches.h"
18 #include "ios/web/public/web_view_util.h"
20 namespace {
21 NSString* const kEnableAlertOnBackgroundUpload =
22     @"EnableAlertsOnBackgroundUpload";
23 }  // namespace
25 namespace experimental_flags {
27 bool IsAlertOnBackgroundUploadEnabled() {
28   return [[NSUserDefaults standardUserDefaults]
29       boolForKey:kEnableAlertOnBackgroundUpload];
32 bool IsWKWebViewEnabled() {
33   // If WKWebView isn't supported, don't activate the experiment at all. This
34   // avoids someone being slotted into the WKWebView bucket (and thus reporting
35   // as WKWebView), but actually running UIWebView.
36   if (!web::IsWKWebViewSupported())
37     return false;
39   std::string group_name =
40       base::FieldTrialList::FindFullName("IOSUseWKWebView");
42   // First check if the experimental flag is turned on.
43   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
44   if (command_line->HasSwitch(switches::kEnableIOSWKWebView)) {
45     return true;
46   } else if (command_line->HasSwitch(switches::kDisableIOSWKWebView)) {
47     return false;
48   }
50   // Check if the finch experiment is turned on.
51   return StartsWithASCII(group_name, "Enabled", false);
54 size_t MemoryWedgeSizeInMB() {
55   std::string wedge_size_string;
57   // Get the size from the Experimental setting.
58   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
59   wedge_size_string =
60       command_line->GetSwitchValueASCII(switches::kIOSMemoryWedgeSize);
62   // Otherwise, get from a variation param.
63   if (wedge_size_string.empty()) {
64     wedge_size_string =
65         variations::GetVariationParamValue("MemoryWedge", "wedge_size");
66   }
68   // Parse the value.
69   size_t wedge_size_in_mb = 0;
70   if (base::StringToSizeT(wedge_size_string, &wedge_size_in_mb))
71     return wedge_size_in_mb;
72   return 0;
75 }  // namespace experimental_flags