Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: ios/chrome/browser/ios_chrome_main_parts.mm

Issue 2182553002: Add other variations (with ids) for NTPSnippets to chrome://flags (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unittest fix Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Check the first run state early; this must be done before IO is disallowed 93 // Check the first run state early; this must be done before IO is disallowed
94 // so that later calls can use the cached value. (The return value is ignored 94 // so that later calls can use the cached value. (The return value is ignored
95 // because this is only to trigger the internal lookup and caching for later 95 // because this is only to trigger the internal lookup and caching for later
96 // use.) 96 // use.)
97 FirstRun::IsChromeFirstRun(); 97 FirstRun::IsChromeFirstRun();
98 98
99 // Initialize local state. 99 // Initialize local state.
100 local_state_ = application_context_->GetLocalState(); 100 local_state_ = application_context_->GetLocalState();
101 DCHECK(local_state_); 101 DCHECK(local_state_);
102 102
103 flags_ui::PrefServiceFlagsStorage flags_storage_( 103 flags_ui::PrefServiceFlagsStorage flags_storage(
104 application_context_->GetLocalState()); 104 application_context_->GetLocalState());
105 ConvertFlagsToSwitches(&flags_storage_, 105 ConvertFlagsToSwitches(&flags_storage,
106 base::CommandLine::ForCurrentProcess()); 106 base::CommandLine::ForCurrentProcess());
107 107
108 // Initialize tracking synchronizer system. 108 // Initialize tracking synchronizer system.
109 tracking_synchronizer_ = new metrics::TrackingSynchronizer( 109 tracking_synchronizer_ = new metrics::TrackingSynchronizer(
110 base::WrapUnique(new base::DefaultTickClock()), 110 base::WrapUnique(new base::DefaultTickClock()),
111 base::Bind(&metrics::IOSTrackingSynchronizerDelegate::Create)); 111 base::Bind(&metrics::IOSTrackingSynchronizerDelegate::Create));
112 112
113 // Now the command line has been mutated based on about:flags, we can setup 113 // Now the command line has been mutated based on about:flags, we can setup
114 // metrics and initialize field trials that are needed by IOSChromeIOThread's 114 // metrics and initialize field trials that are needed by IOSChromeIOThread's
115 // initialization which happens in ApplicationContext:PreCreateThreads. 115 // initialization which happens in ApplicationContext:PreCreateThreads.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // Also stop the metrics service so that we don't pollute UMA. 209 // Also stop the metrics service so that we don't pollute UMA.
210 if (command_line->HasSwitch(switches::kForceFieldTrials)) { 210 if (command_line->HasSwitch(switches::kForceFieldTrials)) {
211 // Create field trials without activating them, so that this behaves in a 211 // Create field trials without activating them, so that this behaves in a
212 // consistent manner with field trials created from the server. 212 // consistent manner with field trials created from the server.
213 bool result = base::FieldTrialList::CreateTrialsFromString( 213 bool result = base::FieldTrialList::CreateTrialsFromString(
214 command_line->GetSwitchValueASCII(switches::kForceFieldTrials), 214 command_line->GetSwitchValueASCII(switches::kForceFieldTrials),
215 std::set<std::string>()); 215 std::set<std::string>());
216 CHECK(result) << "Invalid --" << switches::kForceFieldTrials 216 CHECK(result) << "Invalid --" << switches::kForceFieldTrials
217 << " list specified."; 217 << " list specified.";
218 } 218 }
219 if (command_line->HasSwitch(switches::kIOSForceVariationIds)) { 219
220 // Create default variation ids which will always be included in the
221 // X-Client-Data request header.
222 variations::VariationsHttpHeaderProvider* provider =
223 variations::VariationsHttpHeaderProvider::GetInstance();
224 bool result = provider->SetDefaultVariationIds(
225 command_line->GetSwitchValueASCII(switches::kIOSForceVariationIds));
226 CHECK(result) << "Invalid --" << switches::kIOSForceVariationIds
227 << " list specified.";
228 }
229 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 220 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
221
222 // Associate parameters chosen in about:flags and create trial/group for them.
223 flags_ui::PrefServiceFlagsStorage flags_storage(
224 application_context_->GetLocalState());
225 std::vector<std::string> variation_ids =
226 RegisterAllFeatureVariationParameters(&flags_storage, feature_list.get());
227
228 // Create default variation ids which will always be included in the
229 // X-Client-Data request header.
230 variations::VariationsHttpHeaderProvider* http_header_provider =
231 variations::VariationsHttpHeaderProvider::GetInstance();
232 // Force the variation ids selected in chrome://flags and/or specified using
233 // the command-line flag.
234 bool result = http_header_provider->ForceVariationIds(
235 &variation_ids,
236 command_line->GetSwitchValueASCII(switches::kIOSForceVariationIds));
237 CHECK(result) << "Invalid list of variation ids specified (either in --"
238 << switches::kIOSForceVariationIds << " or in chrome://flags)";
239 metrics->AddSyntheticTrialObserver(http_header_provider);
240
230 feature_list->InitializeFromCommandLine( 241 feature_list->InitializeFromCommandLine(
231 command_line->GetSwitchValueASCII(switches::kEnableIOSFeatures), 242 command_line->GetSwitchValueASCII(switches::kEnableIOSFeatures),
232 command_line->GetSwitchValueASCII(switches::kDisableIOSFeatures)); 243 command_line->GetSwitchValueASCII(switches::kDisableIOSFeatures));
233 244
234 variations::VariationsService* variations_service = 245 variations::VariationsService* variations_service =
235 application_context_->GetVariationsService(); 246 application_context_->GetVariationsService();
236 if (variations_service) 247 if (variations_service)
237 variations_service->CreateTrialsFromSeed(feature_list.get()); 248 variations_service->CreateTrialsFromSeed(feature_list.get());
238 249
239 base::FeatureList::SetInstance(std::move(feature_list)); 250 base::FeatureList::SetInstance(std::move(feature_list));
240 251
241 SetupFieldTrials(parsed_command_line_, 252 SetupFieldTrials(parsed_command_line_,
242 base::Time::FromTimeT(metrics->GetInstallDate())); 253 base::Time::FromTimeT(metrics->GetInstallDate()));
243 254
244 // Now that field trials have been created, initializes metrics recording. 255 // Now that field trials have been created, initializes metrics recording.
245 metrics->InitializeMetricsRecordingState(); 256 metrics->InitializeMetricsRecordingState();
246 } 257 }
247 258
248 void IOSChromeMainParts::StartMetricsRecording() { 259 void IOSChromeMainParts::StartMetricsRecording() {
249 bool wifiOnly = local_state_->GetBoolean(prefs::kMetricsReportingWifiOnly); 260 bool wifiOnly = local_state_->GetBoolean(prefs::kMetricsReportingWifiOnly);
250 bool isConnectionCellular = net::NetworkChangeNotifier::IsConnectionCellular( 261 bool isConnectionCellular = net::NetworkChangeNotifier::IsConnectionCellular(
251 net::NetworkChangeNotifier::GetConnectionType()); 262 net::NetworkChangeNotifier::GetConnectionType());
252 bool mayUpload = !wifiOnly || !isConnectionCellular; 263 bool mayUpload = !wifiOnly || !isConnectionCellular;
253 264
254 application_context_->GetMetricsServicesManager()->UpdateUploadPermissions( 265 application_context_->GetMetricsServicesManager()->UpdateUploadPermissions(
255 mayUpload); 266 mayUpload);
256 } 267 }
OLDNEW
« components/variations/variations_http_header_provider.h ('K') | « ios/chrome/browser/about_flags.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698