| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 // Implementation of about_flags for iOS that sets flags based on experimental | 5 // Implementation of about_flags for iOS that sets flags based on experimental |
| 6 // settings. | 6 // settings. |
| 7 | 7 |
| 8 #include "ios/chrome/browser/about_flags.h" | 8 #include "ios/chrome/browser/about_flags.h" |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 #import <UIKit/UIKit.h> | 12 #import <UIKit/UIKit.h> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/singleton.h" | 18 #include "base/memory/singleton.h" |
| 19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 20 #include "base/strings/sys_string_conversions.h" | 20 #include "base/strings/sys_string_conversions.h" |
| 21 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
| 22 #include "base/task_scheduler/switches.h" | 22 #include "base/task_scheduler/switches.h" |
| 23 #include "components/dom_distiller/core/dom_distiller_switches.h" | 23 #include "components/dom_distiller/core/dom_distiller_switches.h" |
| 24 #include "components/flags_ui/feature_entry.h" | 24 #include "components/flags_ui/feature_entry.h" |
| 25 #include "components/flags_ui/feature_entry_macros.h" | 25 #include "components/flags_ui/feature_entry_macros.h" |
| 26 #include "components/flags_ui/flags_storage.h" | 26 #include "components/flags_ui/flags_storage.h" |
| 27 #include "components/flags_ui/flags_ui_switches.h" | 27 #include "components/flags_ui/flags_ui_switches.h" |
| 28 #include "components/ntp_tiles/switches.h" | 28 #include "components/ntp_tiles/switches.h" |
| 29 #include "components/security_state/core/switches.h" |
| 29 #include "components/signin/core/common/signin_switches.h" | 30 #include "components/signin/core/common/signin_switches.h" |
| 30 #include "components/strings/grit/components_strings.h" | 31 #include "components/strings/grit/components_strings.h" |
| 31 #include "ios/chrome/browser/chrome_switches.h" | 32 #include "ios/chrome/browser/chrome_switches.h" |
| 32 #include "ios/chrome/browser/ios_chrome_flag_descriptions.h" | 33 #include "ios/chrome/browser/ios_chrome_flag_descriptions.h" |
| 33 #include "ios/chrome/grit/ios_strings.h" | 34 #include "ios/chrome/grit/ios_strings.h" |
| 34 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 35 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 35 #include "ios/web/public/user_agent.h" | 36 #include "ios/web/public/user_agent.h" |
| 36 #include "ios/web/public/web_view_creation_util.h" | 37 #include "ios/web/public/web_view_creation_util.h" |
| 37 | 38 |
| 38 #if !defined(OFFICIAL_BUILD) | 39 #if !defined(OFFICIAL_BUILD) |
| 39 #include "components/variations/variations_switches.h" | 40 #include "components/variations/variations_switches.h" |
| 40 #endif | 41 #endif |
| 41 | 42 |
| 42 #if !defined(__has_feature) || !__has_feature(objc_arc) | 43 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 43 #error "This file requires ARC support." | 44 #error "This file requires ARC support." |
| 44 #endif | 45 #endif |
| 45 | 46 |
| 47 using flags_ui::FeatureEntry; |
| 48 |
| 46 namespace { | 49 namespace { |
| 50 const FeatureEntry::Choice kMarkHttpAsChoices[] = { |
| 51 {flags_ui::kGenericExperimentChoiceDefault, "", ""}, |
| 52 {flag_descriptions::kMarkHttpAsNonSecureAfterEditing, |
| 53 security_state::switches::kMarkHttpAs, |
| 54 security_state::switches::kMarkHttpAsNonSecureAfterEditing}, |
| 55 {flag_descriptions::kMarkHttpAsNonSecureWhileIncognito, |
| 56 security_state::switches::kMarkHttpAs, |
| 57 security_state::switches::kMarkHttpAsNonSecureWhileIncognito}, |
| 58 {flag_descriptions::kMarkHttpAsNonSecureWhileIncognitoOrEditing, |
| 59 security_state::switches::kMarkHttpAs, |
| 60 security_state::switches::kMarkHttpAsNonSecureWhileIncognitoOrEditing}, |
| 61 {flag_descriptions::kMarkHttpAsDangerous, |
| 62 security_state::switches::kMarkHttpAs, |
| 63 security_state::switches::kMarkHttpAsDangerous}}; |
| 64 |
| 47 // To add a new entry, add to the end of kFeatureEntries. There are two | 65 // To add a new entry, add to the end of kFeatureEntries. There are two |
| 48 // distinct types of entries: | 66 // distinct types of entries: |
| 49 // . SINGLE_VALUE: entry is either on or off. Use the SINGLE_VALUE_TYPE | 67 // . SINGLE_VALUE: entry is either on or off. Use the SINGLE_VALUE_TYPE |
| 50 // macro for this type supplying the command line to the macro. | 68 // macro for this type supplying the command line to the macro. |
| 51 // . MULTI_VALUE: a list of choices, the first of which should correspond to a | 69 // . MULTI_VALUE: a list of choices, the first of which should correspond to a |
| 52 // deactivated state for this lab (i.e. no command line option). To specify | 70 // deactivated state for this lab (i.e. no command line option). To specify |
| 53 // this type of entry use the macro MULTI_VALUE_TYPE supplying it the | 71 // this type of entry use the macro MULTI_VALUE_TYPE supplying it the |
| 54 // array of choices. | 72 // array of choices. |
| 55 // See the documentation of FeatureEntry for details on the fields. | 73 // See the documentation of FeatureEntry for details on the fields. |
| 56 // | 74 // |
| 57 // When adding a new choice, add it to the end of the list. | 75 // When adding a new choice, add it to the end of the list. |
| 58 const flags_ui::FeatureEntry kFeatureEntries[] = { | 76 const flags_ui::FeatureEntry kFeatureEntries[] = { |
| 59 {"contextual-search", flag_descriptions::kContextualSearch, | 77 {"contextual-search", flag_descriptions::kContextualSearch, |
| 60 flag_descriptions::kContextualSearchDescription, flags_ui::kOsIos, | 78 flag_descriptions::kContextualSearchDescription, flags_ui::kOsIos, |
| 61 ENABLE_DISABLE_VALUE_TYPE(switches::kEnableContextualSearch, | 79 ENABLE_DISABLE_VALUE_TYPE(switches::kEnableContextualSearch, |
| 62 switches::kDisableContextualSearch)}, | 80 switches::kDisableContextualSearch)}, |
| 63 {"ios-physical-web", flag_descriptions::kPhysicalWeb, | 81 {"ios-physical-web", flag_descriptions::kPhysicalWeb, |
| 64 flag_descriptions::kPhysicalWebDescription, flags_ui::kOsIos, | 82 flag_descriptions::kPhysicalWebDescription, flags_ui::kOsIos, |
| 65 ENABLE_DISABLE_VALUE_TYPE(switches::kEnableIOSPhysicalWeb, | 83 ENABLE_DISABLE_VALUE_TYPE(switches::kEnableIOSPhysicalWeb, |
| 66 switches::kDisableIOSPhysicalWeb)}, | 84 switches::kDisableIOSPhysicalWeb)}, |
| 67 {"browser-task-scheduler", flag_descriptions::kBrowserTaskScheduler, | 85 {"browser-task-scheduler", flag_descriptions::kBrowserTaskScheduler, |
| 68 flag_descriptions::kBrowserTaskSchedulerDescription, flags_ui::kOsIos, | 86 flag_descriptions::kBrowserTaskSchedulerDescription, flags_ui::kOsIos, |
| 69 ENABLE_DISABLE_VALUE_TYPE(switches::kEnableBrowserTaskScheduler, | 87 ENABLE_DISABLE_VALUE_TYPE(switches::kEnableBrowserTaskScheduler, |
| 70 switches::kDisableBrowserTaskScheduler)}, | 88 switches::kDisableBrowserTaskScheduler)}, |
| 89 {"mark-non-secure-as", flag_descriptions::kMarkHttpAsName, |
| 90 flag_descriptions::kMarkHttpAsDescription, flags_ui::kOsIos, |
| 91 MULTI_VALUE_TYPE(kMarkHttpAsChoices)}, |
| 71 }; | 92 }; |
| 72 | 93 |
| 73 // Add all switches from experimental flags to |command_line|. | 94 // Add all switches from experimental flags to |command_line|. |
| 74 void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) { | 95 void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) { |
| 75 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | 96 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
| 76 | 97 |
| 77 // Populate command line flag for the tab strip auto scroll new tabs | 98 // Populate command line flag for the tab strip auto scroll new tabs |
| 78 // experiment from the configuration plist. | 99 // experiment from the configuration plist. |
| 79 if ([defaults boolForKey:@"TabStripAutoScrollNewTabsDisabled"]) | 100 if ([defaults boolForKey:@"TabStripAutoScrollNewTabsDisabled"]) |
| 80 command_line->AppendSwitch(switches::kDisableTabStripAutoScrollNewTabs); | 101 command_line->AppendSwitch(switches::kDisableTabStripAutoScrollNewTabs); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 332 } |
| 312 | 333 |
| 313 namespace testing { | 334 namespace testing { |
| 314 | 335 |
| 315 const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count) { | 336 const flags_ui::FeatureEntry* GetFeatureEntries(size_t* count) { |
| 316 *count = arraysize(kFeatureEntries); | 337 *count = arraysize(kFeatureEntries); |
| 317 return kFeatureEntries; | 338 return kFeatureEntries; |
| 318 } | 339 } |
| 319 | 340 |
| 320 } // namespace testing | 341 } // namespace testing |
| OLD | NEW |