Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "components/autofill/core/common/autofill_switches.h" | 17 #include "components/autofill/core/common/autofill_switches.h" |
| 18 #include "components/enhanced_bookmarks/enhanced_bookmark_features.h" | |
| 19 #include "components/variations/variations_associated_data.h" | 18 #include "components/variations/variations_associated_data.h" |
| 20 #include "ios/chrome/browser/chrome_switches.h" | 19 #include "ios/chrome/browser/chrome_switches.h" |
| 21 #include "ios/web/public/web_view_creation_util.h" | 20 #include "ios/web/public/web_view_creation_util.h" |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 NSString* const kEnableAlertOnBackgroundUpload = | 23 NSString* const kEnableAlertOnBackgroundUpload = |
| 25 @"EnableAlertsOnBackgroundUpload"; | 24 @"EnableAlertsOnBackgroundUpload"; |
| 26 NSString* const kEnableViewCopyPasswords = @"EnableViewCopyPasswords"; | 25 NSString* const kEnableViewCopyPasswords = @"EnableViewCopyPasswords"; |
| 27 NSString* const kHeuristicsForPasswordGeneration = | 26 NSString* const kHeuristicsForPasswordGeneration = |
| 28 @"HeuristicsForPasswordGeneration"; | 27 @"HeuristicsForPasswordGeneration"; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 39 } // namespace | 38 } // namespace |
| 40 | 39 |
| 41 namespace experimental_flags { | 40 namespace experimental_flags { |
| 42 | 41 |
| 43 bool IsAlertOnBackgroundUploadEnabled() { | 42 bool IsAlertOnBackgroundUploadEnabled() { |
| 44 return [[NSUserDefaults standardUserDefaults] | 43 return [[NSUserDefaults standardUserDefaults] |
| 45 boolForKey:kEnableAlertOnBackgroundUpload]; | 44 boolForKey:kEnableAlertOnBackgroundUpload]; |
| 46 } | 45 } |
| 47 | 46 |
| 48 bool IsBookmarkCollectionEnabled() { | 47 bool IsBookmarkCollectionEnabled() { |
| 49 return enhanced_bookmarks::IsEnhancedBookmarksEnabled(); | 48 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". "" - |
|
lpromero
2015/12/02 17:37:08
This doesn't wrap nicely. Add a new line after "0"
stkhapugin
2015/12/04 16:55:59
Done.
| |
| 49 // default, "0" - user opted out, "1" - user opted in. Tests also use the | |
| 50 // command line flag to force enhanced bookmark to be on. | |
| 51 // The default behavior is Opt In. | |
|
lpromero
2015/12/02 17:37:08
I wouldn’t add this comment here. The following li
stkhapugin
2015/12/04 16:55:59
Done.
| |
| 52 std::string switch_value = | |
| 53 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
| 54 switches::kEnhancedBookmarksExperiment); | |
| 55 if (switch_value == "1") | |
| 56 return true; | |
| 57 if (switch_value == "0") | |
| 58 return false; | |
| 59 | |
| 60 // Check if the finch experiment is turned on. | |
| 61 std::string group_name = | |
| 62 base::FieldTrialList::FindFullName("IOSNewBookmarksUI"); | |
| 63 return !base::StartsWith(group_name, "Disabled", | |
| 64 base::CompareCase::INSENSITIVE_ASCII); | |
| 50 } | 65 } |
| 51 | 66 |
| 52 void SetWKWebViewTrialEligibility(bool eligible) { | 67 void SetWKWebViewTrialEligibility(bool eligible) { |
| 53 // It's critical that the enabled state be consistently reported throughout | 68 // It's critical that the enabled state be consistently reported throughout |
| 54 // the life of the app, so ensure that this has not already been set. | 69 // the life of the app, so ensure that this has not already been set. |
| 55 DCHECK(g_wkwebview_trial_eligibility == WKWebViewEligibility::UNSET); | 70 DCHECK(g_wkwebview_trial_eligibility == WKWebViewEligibility::UNSET); |
| 56 | 71 |
| 57 g_wkwebview_trial_eligibility = eligible ? WKWebViewEligibility::ELIGIBLE | 72 g_wkwebview_trial_eligibility = eligible ? WKWebViewEligibility::ELIGIBLE |
| 58 : WKWebViewEligibility::INELIGIBLE; | 73 : WKWebViewEligibility::INELIGIBLE; |
| 59 } | 74 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 if ([[NSUserDefaults standardUserDefaults] | 162 if ([[NSUserDefaults standardUserDefaults] |
| 148 boolForKey:kHeuristicsForPasswordGeneration]) { | 163 boolForKey:kHeuristicsForPasswordGeneration]) { |
| 149 return true; | 164 return true; |
| 150 } | 165 } |
| 151 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 166 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 152 return command_line->HasSwitch( | 167 return command_line->HasSwitch( |
| 153 autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration); | 168 autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration); |
| 154 } | 169 } |
| 155 | 170 |
| 156 } // namespace experimental_flags | 171 } // namespace experimental_flags |
| OLD | NEW |