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

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 153913009: Make some field trials unforceable via command-line in the official build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "chrome/browser/chrome_browser_main.h" 5 #include "chrome/browser/chrome_browser_main.h"
6 6
7 #if defined(TOOLKIT_GTK) 7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 chrome::HOST_DESKTOP_TYPE_NATIVE, 476 chrome::HOST_DESKTOP_TYPE_NATIVE,
477 "127.0.0.1", 477 "127.0.0.1",
478 port, 478 port,
479 frontend_str); 479 frontend_str);
480 } else { 480 } else {
481 DLOG(WARNING) << "Invalid http debugger port number " << port; 481 DLOG(WARNING) << "Invalid http debugger port number " << port;
482 } 482 }
483 } 483 }
484 } 484 }
485 485
486 // Returns true if the field trial described by |name| is allowed to be forced
487 // via --force-fieldtrials.
488 bool IsForceableFieldTrial(const std::string& name) {
489 #if defined(OFFICIAL_BUILD)
490 // A list of field trials which cannot be forced to a different value in the
491 // official build.
492 static const char* const kUnforceableFieldTrials[] = {
493 "SettingsEnforcement",
494 };
495 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(KUnforceableFieldTrials); ++i) {
496 if (name == KUnforceableFieldTrials[i])
Alexei Svitkine (slow) 2014/02/12 14:26:47 KUnforceableFieldTrials -> kUnforceableFieldTrials
gab 2014/02/12 15:59:19 Right, I've already confirmed that it compiles/wor
497 return false;
498 }
499 #endif // defined(OFFICIAL_BUILD)
500
501 return true;
502 }
503
486 // Heap allocated class that listens for first page load, kicks off stat 504 // Heap allocated class that listens for first page load, kicks off stat
487 // recording and then deletes itself. 505 // recording and then deletes itself.
488 class LoadCompleteListener : public content::NotificationObserver { 506 class LoadCompleteListener : public content::NotificationObserver {
489 public: 507 public:
490 LoadCompleteListener() { 508 LoadCompleteListener() {
491 registrar_.Add(this, 509 registrar_.Add(this,
492 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 510 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
493 content::NotificationService::AllSources()); 511 content::NotificationService::AllSources());
494 } 512 }
495 virtual ~LoadCompleteListener() {} 513 virtual ~LoadCompleteListener() {}
(...skipping 15 matching lines...) Expand all
511 void InitializeAllPrefHashStores() { 529 void InitializeAllPrefHashStores() {
512 ProfileInfoCache& profile_info_cache = 530 ProfileInfoCache& profile_info_cache =
513 g_browser_process->profile_manager()->GetProfileInfoCache(); 531 g_browser_process->profile_manager()->GetProfileInfoCache();
514 size_t n_profiles = profile_info_cache.GetNumberOfProfiles(); 532 size_t n_profiles = profile_info_cache.GetNumberOfProfiles();
515 for (size_t i = 0; i < n_profiles; ++i) { 533 for (size_t i = 0; i < n_profiles; ++i) {
516 base::FilePath profile_path = 534 base::FilePath profile_path =
517 profile_info_cache.GetPathOfProfileAtIndex(i); 535 profile_info_cache.GetPathOfProfileAtIndex(i);
518 chrome_prefs::InitializePrefHashStoreIfRequired(profile_path); 536 chrome_prefs::InitializePrefHashStoreIfRequired(profile_path);
519 } 537 }
520 } 538 }
539
521 } // namespace 540 } // namespace
522 541
523 namespace chrome_browser { 542 namespace chrome_browser {
524 543
525 // This error message is not localized because we failed to load the 544 // This error message is not localized because we failed to load the
526 // localization data files. 545 // localization data files.
527 #if defined(OS_WIN) 546 #if defined(OS_WIN)
528 const char kMissingLocaleDataTitle[] = "Missing File Error"; 547 const char kMissingLocaleDataTitle[] = "Missing File Error";
529 #endif 548 #endif
530 549
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 if (command_line->HasSwitch(switches::kEnableBenchmarking)) 618 if (command_line->HasSwitch(switches::kEnableBenchmarking))
600 base::FieldTrial::EnableBenchmarking(); 619 base::FieldTrial::EnableBenchmarking();
601 620
602 // Ensure any field trials specified on the command line are initialized. 621 // Ensure any field trials specified on the command line are initialized.
603 // Also stop the metrics service so that we don't pollute UMA. 622 // Also stop the metrics service so that we don't pollute UMA.
604 if (command_line->HasSwitch(switches::kForceFieldTrials)) { 623 if (command_line->HasSwitch(switches::kForceFieldTrials)) {
605 // Create field trials without activating them, so that this behaves in a 624 // Create field trials without activating them, so that this behaves in a
606 // consistent manner with field trials created from the server. 625 // consistent manner with field trials created from the server.
607 bool result = base::FieldTrialList::CreateTrialsFromString( 626 bool result = base::FieldTrialList::CreateTrialsFromString(
608 command_line->GetSwitchValueASCII(switches::kForceFieldTrials), 627 command_line->GetSwitchValueASCII(switches::kForceFieldTrials),
609 base::FieldTrialList::DONT_ACTIVATE_TRIALS); 628 base::FieldTrialList::DONT_ACTIVATE_TRIALS,
629 base::Bind(&IsForceableFieldTrial));
610 CHECK(result) << "Invalid --" << switches::kForceFieldTrials 630 CHECK(result) << "Invalid --" << switches::kForceFieldTrials
611 << " list specified."; 631 << " list specified.";
612 } 632 }
613 if (command_line->HasSwitch(switches::kForceVariationIds)) { 633 if (command_line->HasSwitch(switches::kForceVariationIds)) {
614 // Create default variation ids which will always be included in the 634 // Create default variation ids which will always be included in the
615 // X-Client-Data request header. 635 // X-Client-Data request header.
616 chrome_variations::VariationsHttpHeaderProvider* provider = 636 chrome_variations::VariationsHttpHeaderProvider* provider =
617 chrome_variations::VariationsHttpHeaderProvider::GetInstance(); 637 chrome_variations::VariationsHttpHeaderProvider::GetInstance();
618 bool result = provider->SetDefaultVariationIds( 638 bool result = provider->SetDefaultVariationIds(
619 command_line->GetSwitchValueASCII(switches::kForceVariationIds)); 639 command_line->GetSwitchValueASCII(switches::kForceVariationIds));
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 chromeos::CrosSettings::Shutdown(); 1717 chromeos::CrosSettings::Shutdown();
1698 #endif 1718 #endif
1699 #endif 1719 #endif
1700 } 1720 }
1701 1721
1702 // Public members: 1722 // Public members:
1703 1723
1704 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { 1724 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
1705 chrome_extra_parts_.push_back(parts); 1725 chrome_extra_parts_.push_back(parts);
1706 } 1726 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698