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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 291153012: Consolidated enhanced bookmarks experiment logic in one place. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/sync/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 else 1030 else
1031 gcm_profile_service->driver()->Enable(); 1031 gcm_profile_service->driver()->Enable();
1032 } 1032 }
1033 } else { 1033 } else {
1034 profile()->GetPrefs()->ClearPref(prefs::kGCMChannelEnabled); 1034 profile()->GetPrefs()->ClearPref(prefs::kGCMChannelEnabled);
1035 } 1035 }
1036 1036
1037 profile()->GetPrefs()->SetBoolean(prefs::kInvalidationServiceUseGCMChannel, 1037 profile()->GetPrefs()->SetBoolean(prefs::kInvalidationServiceUseGCMChannel,
1038 experiments.gcm_invalidations_enabled); 1038 experiments.gcm_invalidations_enabled);
1039 1039
1040 int bookmarks_experiment_state_before = profile_->GetPrefs()->GetInteger( 1040 if (experiments.enhanced_bookmarks_enabled) {
1041 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled);
1042 // kEnhancedBookmarksExperiment flag could have values "", "1" and "0".
1043 // "" and "1" means experiment is enabled.
1044 if ((CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
1045 switches::kEnhancedBookmarksExperiment) != "0")) {
1046 profile_->GetPrefs()->SetInteger(
1047 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled,
1048 experiments.enhanced_bookmarks_enabled ? kBookmarksExperimentEnabled
1049 : kNoBookmarksExperiment);
1050 profile_->GetPrefs()->SetString( 1041 profile_->GetPrefs()->SetString(
1051 sync_driver::prefs::kEnhancedBookmarksExtensionId, 1042 sync_driver::prefs::kEnhancedBookmarksExtensionId,
1052 experiments.enhanced_bookmarks_ext_id); 1043 experiments.enhanced_bookmarks_ext_id);
1053 } else { 1044 } else {
1054 // User opt-out from chrome://flags 1045 profile_->GetPrefs()->ClearPref(
1055 if (experiments.enhanced_bookmarks_enabled) { 1046 sync_driver::prefs::kEnhancedBookmarksExtensionId);
1056 profile_->GetPrefs()->SetInteger(
1057 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled,
1058 kBookmarksExperimentEnabledUserOptOut);
1059 // Keep extension id up-to-date in case will opt-in later.
1060 profile_->GetPrefs()->SetString(
1061 sync_driver::prefs::kEnhancedBookmarksExtensionId,
1062 experiments.enhanced_bookmarks_ext_id);
1063 } else {
1064 profile_->GetPrefs()->ClearPref(
1065 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled);
1066 profile_->GetPrefs()->ClearPref(
1067 sync_driver::prefs::kEnhancedBookmarksExtensionId);
1068 }
1069 } 1047 }
1070 BookmarksExperimentState bookmarks_experiment_state = 1048 UpdateBookmarksExperimentState(
1071 static_cast<BookmarksExperimentState>(profile_->GetPrefs()->GetInteger( 1049 profile_->GetPrefs(), g_browser_process->local_state(), true,
1072 sync_driver::prefs::kEnhancedBookmarksExperimentEnabled)); 1050 experiments.enhanced_bookmarks_enabled ? kBookmarksExperimentEnabled :
1073 // If bookmark experiment state was changed update about flags experiment. 1051 kNoBookmarksExperiment);
1074 if (bookmarks_experiment_state_before != bookmarks_experiment_state) {
1075 ForceFinchBookmarkExperimentIfNeeded(g_browser_process->local_state(),
1076 bookmarks_experiment_state);
1077 }
1078 1052
1079 // If this is a first time sync for a client, this will be called before 1053 // If this is a first time sync for a client, this will be called before
1080 // OnBackendInitialized() to ensure the new datatypes are available at sync 1054 // OnBackendInitialized() to ensure the new datatypes are available at sync
1081 // setup. As a result, the migrator won't exist yet. This is fine because for 1055 // setup. As a result, the migrator won't exist yet. This is fine because for
1082 // first time sync cases we're only concerned with making the datatype 1056 // first time sync cases we're only concerned with making the datatype
1083 // available. 1057 // available.
1084 if (migrator_.get() && 1058 if (migrator_.get() &&
1085 migrator_->state() != browser_sync::BackendMigrator::IDLE) { 1059 migrator_->state() != browser_sync::BackendMigrator::IDLE) {
1086 DVLOG(1) << "Dropping OnExperimentsChanged due to migrator busy."; 1060 DVLOG(1) << "Dropping OnExperimentsChanged due to migrator busy.";
1087 return; 1061 return;
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 status.last_get_token_error = last_get_token_error_; 2346 status.last_get_token_error = last_get_token_error_;
2373 if (request_access_token_retry_timer_.IsRunning()) 2347 if (request_access_token_retry_timer_.IsRunning())
2374 status.next_token_request_time = next_token_request_time_; 2348 status.next_token_request_time = next_token_request_time_;
2375 return status; 2349 return status;
2376 } 2350 }
2377 2351
2378 void ProfileSyncService::OverrideNetworkResourcesForTest( 2352 void ProfileSyncService::OverrideNetworkResourcesForTest(
2379 scoped_ptr<syncer::NetworkResources> network_resources) { 2353 scoped_ptr<syncer::NetworkResources> network_resources) {
2380 network_resources_ = network_resources.Pass(); 2354 network_resources_ = network_resources.Pass();
2381 } 2355 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698