blob: 6adfb739566cd02c8f21b3061d8d0347c97eb8c2 [file] [log] [blame]
drogerf83b91262015-03-05 19:45:191// 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.
4
5// This file can be empty. Its purpose is to contain the relatively short lived
6// definitions required for experimental flags.
7
8#include "ios/chrome/browser/experimental_flags.h"
9
lpromero68537272015-04-29 11:16:0110#include <string>
11
drogerf83b91262015-03-05 19:45:1912#include "base/command_line.h"
lpromero68537272015-04-29 11:16:0113#include "base/metrics/field_trial.h"
14#include "base/strings/string_number_conversions.h"
15#include "components/variations/variations_associated_data.h"
drogerf83b91262015-03-05 19:45:1916#include "ios/chrome/browser/chrome_switches.h"
17
sdefresne8b192a72015-05-13 13:25:1918namespace {
19NSString* const kEnableAlertOnBackgroundUpload =
20 @"EnableAlertsOnBackgroundUpload";
21} // namespace
22
drogerf83b91262015-03-05 19:45:1923namespace experimental_flags {
24
sdefresne8b192a72015-05-13 13:25:1925bool IsAlertOnBackgroundUploadEnabled() {
26 return [[NSUserDefaults standardUserDefaults]
27 boolForKey:kEnableAlertOnBackgroundUpload];
28}
29
drogerf83b91262015-03-05 19:45:1930bool IsOpenFromClipboardEnabled() {
31 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
32 return command_line->HasSwitch(switches::kEnableIOSOpenFromClipboard);
33}
34
lpromero68537272015-04-29 11:16:0135size_t MemoryWedgeSizeInMB() {
36 std::string wedge_size_string;
37
38 // Get the size from the Experimental setting.
39 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
40 wedge_size_string =
41 command_line->GetSwitchValueASCII(switches::kIOSMemoryWedgeSize);
42
43 // Otherwise, get from a variation param.
44 if (wedge_size_string.empty()) {
45 wedge_size_string =
46 variations::GetVariationParamValue("MemoryWedge", "wedge_size");
47 }
48
49 // Parse the value.
50 size_t wedge_size_in_mb = 0;
51 if (base::StringToSizeT(wedge_size_string, &wedge_size_in_mb))
52 return wedge_size_in_mb;
53 return 0;
54}
55
drogerf83b91262015-03-05 19:45:1956} // namespace experimental_flags