| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "ios/chrome/browser/ios_chrome_main_parts.h" | 5 #include "ios/chrome/browser/ios_chrome_main_parts.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 const base::CommandLine* command_line = | 239 const base::CommandLine* command_line = |
| 240 base::CommandLine::ForCurrentProcess(); | 240 base::CommandLine::ForCurrentProcess(); |
| 241 // Ensure any field trials specified on the command line are initialized. | 241 // Ensure any field trials specified on the command line are initialized. |
| 242 // Also stop the metrics service so that we don't pollute UMA. | 242 // Also stop the metrics service so that we don't pollute UMA. |
| 243 if (command_line->HasSwitch(switches::kForceFieldTrials)) { | 243 if (command_line->HasSwitch(switches::kForceFieldTrials)) { |
| 244 // Create field trials without activating them, so that this behaves in a | 244 // Create field trials without activating them, so that this behaves in a |
| 245 // consistent manner with field trials created from the server. | 245 // consistent manner with field trials created from the server. |
| 246 bool result = base::FieldTrialList::CreateTrialsFromString( | 246 bool result = base::FieldTrialList::CreateTrialsFromString( |
| 247 command_line->GetSwitchValueASCII(switches::kForceFieldTrials), | 247 command_line->GetSwitchValueASCII(switches::kForceFieldTrials), |
| 248 std::set<std::string>()); | 248 std::set<std::string>()); |
| 249 CHECK(result) << "Invalid --" << switches::kForceFieldTrials | 249 CHECK(result); |
| 250 << " list specified."; | |
| 251 } | 250 } |
| 252 | 251 |
| 253 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 252 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 254 | 253 |
| 255 // Associate parameters chosen in about:flags and create trial/group for them. | 254 // Associate parameters chosen in about:flags and create trial/group for them. |
| 256 flags_ui::PrefServiceFlagsStorage flags_storage( | 255 flags_ui::PrefServiceFlagsStorage flags_storage( |
| 257 application_context_->GetLocalState()); | 256 application_context_->GetLocalState()); |
| 258 std::vector<std::string> variation_ids = | 257 std::vector<std::string> variation_ids = |
| 259 RegisterAllFeatureVariationParameters(&flags_storage, feature_list.get()); | 258 RegisterAllFeatureVariationParameters(&flags_storage, feature_list.get()); |
| 260 | 259 |
| 261 variations::VariationsHttpHeaderProvider* http_header_provider = | 260 variations::VariationsHttpHeaderProvider* http_header_provider = |
| 262 variations::VariationsHttpHeaderProvider::GetInstance(); | 261 variations::VariationsHttpHeaderProvider::GetInstance(); |
| 263 // Force the variation ids selected in chrome://flags and/or specified using | 262 // Force the variation ids selected in chrome://flags and/or specified using |
| 264 // the command-line flag. | 263 // the command-line flag. |
| 265 bool result = http_header_provider->ForceVariationIds( | 264 bool result = http_header_provider->ForceVariationIds( |
| 266 command_line->GetSwitchValueASCII(switches::kIOSForceVariationIds), | 265 command_line->GetSwitchValueASCII(switches::kIOSForceVariationIds), |
| 267 &variation_ids); | 266 &variation_ids); |
| 268 CHECK(result) << "Invalid list of variation ids specified (either in --" | 267 CHECK(result); |
| 269 << switches::kIOSForceVariationIds << " or in chrome://flags)"; | |
| 270 | 268 |
| 271 feature_list->InitializeFromCommandLine( | 269 feature_list->InitializeFromCommandLine( |
| 272 command_line->GetSwitchValueASCII(switches::kEnableIOSFeatures), | 270 command_line->GetSwitchValueASCII(switches::kEnableIOSFeatures), |
| 273 command_line->GetSwitchValueASCII(switches::kDisableIOSFeatures)); | 271 command_line->GetSwitchValueASCII(switches::kDisableIOSFeatures)); |
| 274 | 272 |
| 275 #if defined(FIELDTRIAL_TESTING_ENABLED) | 273 #if defined(FIELDTRIAL_TESTING_ENABLED) |
| 276 if (!command_line->HasSwitch( | 274 if (!command_line->HasSwitch( |
| 277 variations::switches::kDisableFieldTrialTestingConfig) && | 275 variations::switches::kDisableFieldTrialTestingConfig) && |
| 278 !command_line->HasSwitch(switches::kForceFieldTrials) && | 276 !command_line->HasSwitch(switches::kForceFieldTrials) && |
| 279 !command_line->HasSwitch(variations::switches::kVariationsServerURL)) { | 277 !command_line->HasSwitch(variations::switches::kVariationsServerURL)) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 301 | 299 |
| 302 void IOSChromeMainParts::StartMetricsRecording() { | 300 void IOSChromeMainParts::StartMetricsRecording() { |
| 303 bool wifiOnly = local_state_->GetBoolean(prefs::kMetricsReportingWifiOnly); | 301 bool wifiOnly = local_state_->GetBoolean(prefs::kMetricsReportingWifiOnly); |
| 304 bool isConnectionCellular = net::NetworkChangeNotifier::IsConnectionCellular( | 302 bool isConnectionCellular = net::NetworkChangeNotifier::IsConnectionCellular( |
| 305 net::NetworkChangeNotifier::GetConnectionType()); | 303 net::NetworkChangeNotifier::GetConnectionType()); |
| 306 bool mayUpload = !wifiOnly || !isConnectionCellular; | 304 bool mayUpload = !wifiOnly || !isConnectionCellular; |
| 307 | 305 |
| 308 application_context_->GetMetricsServicesManager()->UpdateUploadPermissions( | 306 application_context_->GetMetricsServicesManager()->UpdateUploadPermissions( |
| 309 mayUpload); | 307 mayUpload); |
| 310 } | 308 } |
| OLD | NEW |