blob: 8f65c5e63ac0ae896a1d60ac58532601ef7af541 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file can be empty. Its purpose is to contain the relatively short lived
// definitions required for experimental flags.
#include "ios/chrome/browser/experimental_flags.h"
#include <dispatch/dispatch.h>
#import <Foundation/Foundation.h>
#include <string>
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "base/strings/string_util.h"
#include "components/autofill/core/common/autofill_switches.h"
#include "components/variations/variations_associated_data.h"
#include "ios/chrome/browser/chrome_switches.h"
#include "ios/web/public/web_view_creation_util.h"
namespace {
NSString* const kEnableAlertOnBackgroundUpload =
@"EnableAlertsOnBackgroundUpload";
NSString* const kEnableViewCopyPasswords = @"EnableViewCopyPasswords";
NSString* const kHeuristicsForPasswordGeneration =
@"HeuristicsForPasswordGeneration";
NSString* const kEnableReadingList = @"EnableReadingList";
NSString* const kEnableReadingListKeepItems = @"EnableReadingListKeepItems";
} // namespace
namespace experimental_flags {
bool IsAlertOnBackgroundUploadEnabled() {
return [[NSUserDefaults standardUserDefaults]
boolForKey:kEnableAlertOnBackgroundUpload];
}
bool IsBookmarkCollectionEnabled() {
return true;
}
bool IsLRUSnapshotCacheEnabled() {
// Check if the experimental flag is forced on or off.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnableLRUSnapshotCache)) {
return true;
} else if (command_line->HasSwitch(switches::kDisableLRUSnapshotCache)) {
return false;
}
// Check if the finch experiment is turned on.
std::string group_name =
base::FieldTrialList::FindFullName("IOSLRUSnapshotCache");
return base::StartsWith(group_name, "Enabled",
base::CompareCase::INSENSITIVE_ASCII);
}
bool IsViewCopyPasswordsEnabled() {
NSString* viewCopyPasswordFlag = [[NSUserDefaults standardUserDefaults]
objectForKey:kEnableViewCopyPasswords];
if ([viewCopyPasswordFlag isEqualToString:@"Enabled"])
return true;
return false;
}
bool IsPasswordGenerationEnabled() {
// This call activates the field trial, if needed, so it must come before any
// early returns.
std::string group_name =
base::FieldTrialList::FindFullName("PasswordGeneration");
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnableIOSPasswordGeneration))
return true;
if (command_line->HasSwitch(switches::kDisableIOSPasswordGeneration))
return false;
return group_name != "Disabled";
}
bool UseOnlyLocalHeuristicsForPasswordGeneration() {
if ([[NSUserDefaults standardUserDefaults]
boolForKey:kHeuristicsForPasswordGeneration]) {
return true;
}
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
return command_line->HasSwitch(
autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration);
}
bool IsTabSwitcherEnabled() {
// Check if the experimental flag is forced on or off.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnableTabSwitcher)) {
return true;
} else if (command_line->HasSwitch(switches::kDisableTabSwitcher)) {
return false;
}
// Check if the finch experiment is turned on.
std::string group_name = base::FieldTrialList::FindFullName("IOSTabSwitcher");
return base::StartsWith(group_name, "Enabled",
base::CompareCase::INSENSITIVE_ASCII);
}
bool IsReadingListEnabled() {
return [[NSUserDefaults standardUserDefaults] boolForKey:kEnableReadingList];
}
bool IsReadingListKeepItemsEnabled() {
return [[NSUserDefaults standardUserDefaults]
boolForKey:kEnableReadingListKeepItems];
}
} // namespace experimental_flags
|