| OLD | NEW |
| 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 #import <Foundation/Foundation.h> | 10 #import <Foundation/Foundation.h> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 void SetWKWebViewTrialEligibility(bool eligible) { | 48 void SetWKWebViewTrialEligibility(bool eligible) { |
| 49 // It's critical that the enabled state be consistently reported throughout | 49 // It's critical that the enabled state be consistently reported throughout |
| 50 // the life of the app, so ensure that this has not already been set. | 50 // the life of the app, so ensure that this has not already been set. |
| 51 DCHECK(g_wkwebview_trial_eligibility == WKWebViewEligibility::UNSET); | 51 DCHECK(g_wkwebview_trial_eligibility == WKWebViewEligibility::UNSET); |
| 52 | 52 |
| 53 g_wkwebview_trial_eligibility = eligible ? WKWebViewEligibility::ELIGIBLE | 53 g_wkwebview_trial_eligibility = eligible ? WKWebViewEligibility::ELIGIBLE |
| 54 : WKWebViewEligibility::INELIGIBLE; | 54 : WKWebViewEligibility::INELIGIBLE; |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool IsLRUSnapshotCacheEnabled() { |
| 58 // Check if the experimental flag is forced on or off. |
| 59 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 60 if (command_line->HasSwitch(switches::kEnableLRUSnapshotCache)) { |
| 61 return true; |
| 62 } else if (command_line->HasSwitch(switches::kDisableLRUSnapshotCache)) { |
| 63 return false; |
| 64 } |
| 65 |
| 66 // Check if the finch experiment is turned on. |
| 67 std::string group_name = |
| 68 base::FieldTrialList::FindFullName("IOSLRUSnapshotCache"); |
| 69 return base::StartsWith(group_name, "Enabled", |
| 70 base::CompareCase::INSENSITIVE_ASCII); |
| 71 } |
| 72 |
| 57 bool IsWKWebViewEnabled() { | 73 bool IsWKWebViewEnabled() { |
| 58 // If g_wkwebview_trial_eligibility hasn't been set, default it to | 74 // If g_wkwebview_trial_eligibility hasn't been set, default it to |
| 59 // ineligibile. This ensures future calls to try to set it will DCHECK. | 75 // ineligibile. This ensures future calls to try to set it will DCHECK. |
| 60 if (g_wkwebview_trial_eligibility == WKWebViewEligibility::UNSET) { | 76 if (g_wkwebview_trial_eligibility == WKWebViewEligibility::UNSET) { |
| 61 g_wkwebview_trial_eligibility = WKWebViewEligibility::INELIGIBLE; | 77 g_wkwebview_trial_eligibility = WKWebViewEligibility::INELIGIBLE; |
| 62 } | 78 } |
| 63 | 79 |
| 64 // If WKWebView isn't supported, don't activate the experiment at all. This | 80 // If WKWebView isn't supported, don't activate the experiment at all. This |
| 65 // avoids someone being slotted into the WKWebView bucket (and thus reporting | 81 // avoids someone being slotted into the WKWebView bucket (and thus reporting |
| 66 // as WKWebView), but actually running UIWebView. | 82 // as WKWebView), but actually running UIWebView. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 120 |
| 105 bool IsViewCopyPasswordsEnabled() { | 121 bool IsViewCopyPasswordsEnabled() { |
| 106 NSString* viewCopyPasswordFlag = [[NSUserDefaults standardUserDefaults] | 122 NSString* viewCopyPasswordFlag = [[NSUserDefaults standardUserDefaults] |
| 107 objectForKey:kEnableViewCopyPasswords]; | 123 objectForKey:kEnableViewCopyPasswords]; |
| 108 if ([viewCopyPasswordFlag isEqualToString:@"Enabled"]) | 124 if ([viewCopyPasswordFlag isEqualToString:@"Enabled"]) |
| 109 return true; | 125 return true; |
| 110 return false; | 126 return false; |
| 111 } | 127 } |
| 112 | 128 |
| 113 } // namespace experimental_flags | 129 } // namespace experimental_flags |
| OLD | NEW |