cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ios / chrome / browser / experimental_flags.mm
blobc974b5eab5c21c429a29bf27963a940cb67de245
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 #import <Foundation/Foundation.h>
12 #include <string>
14 #include "base/command_line.h"
15 #include "base/strings/string_util.h"
16 #include "components/enhanced_bookmarks/enhanced_bookmark_features.h"
17 #include "components/variations/variations_associated_data.h"
18 #include "ios/chrome/browser/chrome_switches.h"
19 #include "ios/web/public/web_view_creation_util.h"
21 namespace {
22 NSString* const kEnableAlertOnBackgroundUpload =
23     @"EnableAlertsOnBackgroundUpload";
24 NSString* const kEnableBookmarkRefreshImageOnEachVisit =
25     @"EnableBookmarkRefreshImageOnEachVisit";
26 NSString* const kEnableViewCopyPasswords = @"EnableViewCopyPasswords";
27 }  // namespace
29 namespace experimental_flags {
31 bool IsAlertOnBackgroundUploadEnabled() {
32   return [[NSUserDefaults standardUserDefaults]
33       boolForKey:kEnableAlertOnBackgroundUpload];
36 bool IsExternalURLBlockingEnabled() {
37   std::string group_name =
38       base::FieldTrialList::FindFullName("IOSBlockUnpromptedExternalURLs");
40   // Check if the experimental flag is turned on.
41   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
42   if (command_line->HasSwitch(
43           switches::kEnableIOSBlockUnpromptedExternalURLs)) {
44     return true;
45   } else if (command_line->HasSwitch(
46                  switches::kDisableIOSBlockUnpromptedExternalURLs)) {
47     return false;
48   }
50   // Check if the finch experiment is turned on.
51   return !base::StartsWith(group_name, "Disabled",
52                            base::CompareCase::INSENSITIVE_ASCII);
55 bool IsBookmarkCollectionEnabled() {
56   return enhanced_bookmarks::IsEnhancedBookmarksEnabled();
59 bool IsBookmarkImageFetchingOnVisitEnabled() {
60   if (!IsBookmarkCollectionEnabled())
61     return false;
63   NSUserDefaults* user_defaults = [NSUserDefaults standardUserDefaults];
64   if ([user_defaults boolForKey:kEnableBookmarkRefreshImageOnEachVisit])
65     return true;
67   const char kFieldTrialName[] = "EnhancedBookmarks";
68   std::string enable_fetching = variations::GetVariationParamValue(
69       kFieldTrialName, "EnableImagesFetchingOnVisit");
70   return !enable_fetching.empty();
73 bool IsWKWebViewEnabled() {
74   // If WKWebView isn't supported, don't activate the experiment at all. This
75   // avoids someone being slotted into the WKWebView bucket (and thus reporting
76   // as WKWebView), but actually running UIWebView.
77   if (!web::IsWKWebViewSupported())
78     return false;
80   std::string group_name =
81       base::FieldTrialList::FindFullName("IOSUseWKWebView");
83   // First check if the experimental flag is turned on.
84   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
85   if (command_line->HasSwitch(switches::kEnableIOSWKWebView)) {
86     return true;
87   } else if (command_line->HasSwitch(switches::kDisableIOSWKWebView)) {
88     return false;
89   }
91   // Check if the finch experiment is turned on.
92   return base::StartsWith(group_name, "Enabled",
93                           base::CompareCase::INSENSITIVE_ASCII);
96 bool AreKeyboardCommandsEnabled() {
97   return !base::CommandLine::ForCurrentProcess()->HasSwitch(
98       switches::kDisableKeyboardCommands);
101 bool IsViewCopyPasswordsEnabled() {
102   NSString* viewCopyPasswordFlag = [[NSUserDefaults standardUserDefaults]
103       objectForKey:kEnableViewCopyPasswords];
104   if ([viewCopyPasswordFlag isEqualToString:@"Enabled"])
105     return true;
106   return false;
109 }  // namespace experimental_flags