| OLD | NEW |
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #include "sync/js/js_event_details.h" | 72 #include "sync/js/js_event_details.h" |
| 73 #include "sync/notifier/invalidator_registrar.h" | 73 #include "sync/notifier/invalidator_registrar.h" |
| 74 #include "sync/notifier/invalidator_state.h" | 74 #include "sync/notifier/invalidator_state.h" |
| 75 #include "sync/util/cryptographer.h" | 75 #include "sync/util/cryptographer.h" |
| 76 #include "ui/base/l10n/l10n_util.h" | 76 #include "ui/base/l10n/l10n_util.h" |
| 77 | 77 |
| 78 #if defined(OS_ANDROID) | 78 #if defined(OS_ANDROID) |
| 79 #include "sync/internal_api/public/read_transaction.h" | 79 #include "sync/internal_api/public/read_transaction.h" |
| 80 #endif | 80 #endif |
| 81 | 81 |
| 82 #if defined(OS_CHROMEOS) |
| 83 #include "chrome/browser/chromeos/login/user_manager.h" |
| 84 #endif |
| 85 |
| 82 using browser_sync::ChangeProcessor; | 86 using browser_sync::ChangeProcessor; |
| 83 using browser_sync::DataTypeController; | 87 using browser_sync::DataTypeController; |
| 84 using browser_sync::DataTypeManager; | 88 using browser_sync::DataTypeManager; |
| 85 using browser_sync::SyncBackendHost; | 89 using browser_sync::SyncBackendHost; |
| 86 using syncer::ModelType; | 90 using syncer::ModelType; |
| 87 using syncer::ModelTypeSet; | 91 using syncer::ModelTypeSet; |
| 88 using syncer::JsBackend; | 92 using syncer::JsBackend; |
| 89 using syncer::JsController; | 93 using syncer::JsController; |
| 90 using syncer::JsEventDetails; | 94 using syncer::JsEventDetails; |
| 91 using syncer::JsEventHandler; | 95 using syncer::JsEventHandler; |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 // Received notice to enable experimental type. Check if the type is | 930 // Received notice to enable experimental type. Check if the type is |
| 927 // registered, and if not register a new datatype controller. | 931 // registered, and if not register a new datatype controller. |
| 928 RegisterNewDataType(it.Get()); | 932 RegisterNewDataType(it.Get()); |
| 929 // Enable the about:flags switch for the experimental type so we don't have | 933 // Enable the about:flags switch for the experimental type so we don't have |
| 930 // to always perform this reconfiguration. Once we set this, the type will | 934 // to always perform this reconfiguration. Once we set this, the type will |
| 931 // remain registered on restart, so we will no longer go down this code | 935 // remain registered on restart, so we will no longer go down this code |
| 932 // path. | 936 // path. |
| 933 std::string experiment_name = GetExperimentNameForDataType(it.Get()); | 937 std::string experiment_name = GetExperimentNameForDataType(it.Get()); |
| 934 if (experiment_name.empty()) | 938 if (experiment_name.empty()) |
| 935 continue; | 939 continue; |
| 936 about_flags::SetExperimentEnabled(g_browser_process->local_state(), | 940 SetExperimentFlag(experiment_name); |
| 937 experiment_name, | |
| 938 true); | |
| 939 } | 941 } |
| 940 | 942 |
| 941 // Check if the user has "Keep Everything Synced" enabled. If so, we want | 943 // Check if the user has "Keep Everything Synced" enabled. If so, we want |
| 942 // to turn on all experimental types if they're not already on. Otherwise we | 944 // to turn on all experimental types if they're not already on. Otherwise we |
| 943 // leave them off. | 945 // leave them off. |
| 944 // Note: if any types are already registered, we don't turn them on. This | 946 // Note: if any types are already registered, we don't turn them on. This |
| 945 // covers the case where we're already in the process of reconfiguring | 947 // covers the case where we're already in the process of reconfiguring |
| 946 // to turn an experimental type on. | 948 // to turn an experimental type on. |
| 947 if (sync_prefs_.HasKeepEverythingSynced()) { | 949 if (sync_prefs_.HasKeepEverythingSynced()) { |
| 948 // Mark all data types as preferred. | 950 // Mark all data types as preferred. |
| 949 sync_prefs_.SetPreferredDataTypes(registered_types, registered_types); | 951 sync_prefs_.SetPreferredDataTypes(registered_types, registered_types); |
| 950 | 952 |
| 951 // Only automatically turn on types if we have already finished set up. | 953 // Only automatically turn on types if we have already finished set up. |
| 952 // Otherwise, just leave the experimental types on by default. | 954 // Otherwise, just leave the experimental types on by default. |
| 953 if (!to_register.Empty() && HasSyncSetupCompleted() && migrator_.get()) { | 955 if (!to_register.Empty() && HasSyncSetupCompleted() && migrator_.get()) { |
| 954 DVLOG(1) << "Dynamically enabling new datatypes: " | 956 DVLOG(1) << "Dynamically enabling new datatypes: " |
| 955 << syncer::ModelTypeSetToString(to_register); | 957 << syncer::ModelTypeSetToString(to_register); |
| 956 OnMigrationNeededForTypes(to_register); | 958 OnMigrationNeededForTypes(to_register); |
| 957 } | 959 } |
| 958 } | 960 } |
| 959 | 961 |
| 960 // Now enable any non-datatype features. | 962 // Now enable any non-datatype features. |
| 961 if (experiments.sync_tab_favicons) { | 963 if (experiments.sync_tab_favicons) { |
| 962 DVLOG(1) << "Enabling syncing of tab favicons."; | 964 DVLOG(1) << "Enabling syncing of tab favicons."; |
| 963 about_flags::SetExperimentEnabled(g_browser_process->local_state(), | 965 SetExperimentFlag("sync-tab-favicons"); |
| 964 "sync-tab-favicons", | |
| 965 true); | |
| 966 #if defined(OS_ANDROID) | 966 #if defined(OS_ANDROID) |
| 967 // Android does not support about:flags and experiments, so we need to force | 967 // Android does not support about:flags and experiments, so we need to force |
| 968 // setting the experiments as command line switches. | 968 // setting the experiments as command line switches. |
| 969 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kSyncTabFavicons); | 969 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kSyncTabFavicons); |
| 970 #endif | 970 #endif |
| 971 } | 971 } |
| 972 | 972 |
| 973 if (experiments.keystore_encryption) { | 973 if (experiments.keystore_encryption) |
| 974 about_flags::SetExperimentEnabled(g_browser_process->local_state(), | 974 SetExperimentFlag(syncer::kKeystoreEncryptionFlag); |
| 975 syncer::kKeystoreEncryptionFlag, | |
| 976 true); | |
| 977 } | |
| 978 | 975 |
| 979 if (experiments.full_history_sync) { | 976 if (experiments.full_history_sync) |
| 980 about_flags::SetExperimentEnabled(g_browser_process->local_state(), | 977 SetExperimentFlag(syncer::kFullHistorySyncFlag); |
| 981 syncer::kFullHistorySyncFlag, | |
| 982 true); | |
| 983 } | |
| 984 | 978 |
| 985 current_experiments_ = experiments; | 979 current_experiments_ = experiments; |
| 986 } | 980 } |
| 987 | 981 |
| 988 void ProfileSyncService::UpdateAuthErrorState(const AuthError& error) { | 982 void ProfileSyncService::UpdateAuthErrorState(const AuthError& error) { |
| 989 is_auth_in_progress_ = false; | 983 is_auth_in_progress_ = false; |
| 990 last_auth_error_ = error; | 984 last_auth_error_ = error; |
| 991 | 985 |
| 992 // Fan the notification out to interested UI-thread components. Notify the | 986 // Fan the notification out to interested UI-thread components. Notify the |
| 993 // SigninGlobalError first so it reflects the latest auth state before we | 987 // SigninGlobalError first so it reflects the latest auth state before we |
| (...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 2014 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
| 2021 ProfileSyncService* old_this = this; | 2015 ProfileSyncService* old_this = this; |
| 2022 this->~ProfileSyncService(); | 2016 this->~ProfileSyncService(); |
| 2023 new(old_this) ProfileSyncService( | 2017 new(old_this) ProfileSyncService( |
| 2024 new ProfileSyncComponentsFactoryImpl(profile, | 2018 new ProfileSyncComponentsFactoryImpl(profile, |
| 2025 CommandLine::ForCurrentProcess()), | 2019 CommandLine::ForCurrentProcess()), |
| 2026 profile, | 2020 profile, |
| 2027 signin, | 2021 signin, |
| 2028 behavior); | 2022 behavior); |
| 2029 } | 2023 } |
| 2024 |
| 2025 void ProfileSyncService::SetExperimentFlag(const std::string& experiment) { |
| 2026 #if defined(OS_CHROMEOS) |
| 2027 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) |
| 2028 about_flags::SetExperimentEnabled(NULL, experiment, true); |
| 2029 else |
| 2030 about_flags::SetExperimentEnabled(profile_->GetPrefs(), experiment, true); |
| 2031 #else |
| 2032 about_flags::SetExperimentEnabled(g_browser_process->local_state(), |
| 2033 experiment, |
| 2034 true); |
| 2035 #endif |
| 2036 } |
| OLD | NEW |