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

Side by Side Diff: components/browser_sync/profile_sync_service.cc

Issue 2953253002: [DICE] Enable sync for an account that is already present in the token service. (Closed)
Patch Set: Protect sync for DICE Created 3 years, 5 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 (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 "components/browser_sync/profile_sync_service.h" 5 #include "components/browser_sync/profile_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 19 matching lines...) Expand all
30 #include "components/history/core/browser/typed_url_data_type_controller.h" 30 #include "components/history/core/browser/typed_url_data_type_controller.h"
31 #include "components/invalidation/impl/invalidation_prefs.h" 31 #include "components/invalidation/impl/invalidation_prefs.h"
32 #include "components/invalidation/public/invalidation_service.h" 32 #include "components/invalidation/public/invalidation_service.h"
33 #include "components/pref_registry/pref_registry_syncable.h" 33 #include "components/pref_registry/pref_registry_syncable.h"
34 #include "components/prefs/json_pref_store.h" 34 #include "components/prefs/json_pref_store.h"
35 #include "components/reading_list/features/reading_list_enable_flags.h" 35 #include "components/reading_list/features/reading_list_enable_flags.h"
36 #include "components/signin/core/browser/about_signin_internals.h" 36 #include "components/signin/core/browser/about_signin_internals.h"
37 #include "components/signin/core/browser/profile_oauth2_token_service.h" 37 #include "components/signin/core/browser/profile_oauth2_token_service.h"
38 #include "components/signin/core/browser/signin_manager.h" 38 #include "components/signin/core/browser/signin_manager.h"
39 #include "components/signin/core/browser/signin_metrics.h" 39 #include "components/signin/core/browser/signin_metrics.h"
40 #include "components/signin/core/common/profile_management_switches.h"
40 #include "components/strings/grit/components_strings.h" 41 #include "components/strings/grit/components_strings.h"
41 #include "components/sync/base/bind_to_task_runner.h" 42 #include "components/sync/base/bind_to_task_runner.h"
42 #include "components/sync/base/cryptographer.h" 43 #include "components/sync/base/cryptographer.h"
43 #include "components/sync/base/passphrase_type.h" 44 #include "components/sync/base/passphrase_type.h"
44 #include "components/sync/base/pref_names.h" 45 #include "components/sync/base/pref_names.h"
45 #include "components/sync/base/report_unrecoverable_error.h" 46 #include "components/sync/base/report_unrecoverable_error.h"
46 #include "components/sync/base/stop_source.h" 47 #include "components/sync/base/stop_source.h"
47 #include "components/sync/base/system_encryptor.h" 48 #include "components/sync/base/system_encryptor.h"
48 #include "components/sync/device_info/device_info.h" 49 #include "components/sync/device_info/device_info.h"
49 #include "components/sync/device_info/device_info_sync_bridge.h" 50 #include "components/sync/device_info/device_info_sync_bridge.h"
(...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 // engine starts up. 1955 // engine starts up.
1955 crypto_->ConsumeCachedPassphraseIfPossible(); 1956 crypto_->ConsumeCachedPassphraseIfPossible();
1956 } 1957 }
1957 #if defined(OS_CHROMEOS) 1958 #if defined(OS_CHROMEOS)
1958 RefreshSpareBootstrapToken(password); 1959 RefreshSpareBootstrapToken(password);
1959 #endif 1960 #endif
1960 if (!IsEngineInitialized() || GetAuthError().state() != AuthError::NONE) { 1961 if (!IsEngineInitialized() || GetAuthError().state() != AuthError::NONE) {
1961 // Track the fact that we're still waiting for auth to complete. 1962 // Track the fact that we're still waiting for auth to complete.
1962 is_auth_in_progress_ = true; 1963 is_auth_in_progress_ = true;
1963 } 1964 }
1965
1966 if (switches::IsAccountConsistencyDiceEnabled() &&
1967 oauth2_token_service_->RefreshTokenIsAvailable(account_id)) {
1968 // When Dice is enabled, the refresh token may be available before the user
1969 // enables sync. Start sync if the refresh token is already available in the
1970 // token service when the authenticated account is set.
1971 OnRefreshTokenAvailable(account_id);
Nicolas Zea 2017/06/28 19:43:24 Why isn't OnRefresTokenAvailable automatically bei
msarda2 2017/06/28 19:58:30 The problem is the order here: Take the following
1972 }
1964 } 1973 }
1965 1974
1966 void ProfileSyncService::GoogleSignedOut(const std::string& account_id, 1975 void ProfileSyncService::GoogleSignedOut(const std::string& account_id,
1967 const std::string& username) { 1976 const std::string& username) {
1968 DCHECK(thread_checker_.CalledOnValidThread()); 1977 DCHECK(thread_checker_.CalledOnValidThread());
1969 sync_disabled_by_admin_ = false; 1978 sync_disabled_by_admin_ = false;
1970 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::SIGN_OUT, 1979 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::SIGN_OUT,
1971 syncer::STOP_SOURCE_LIMIT); 1980 syncer::STOP_SOURCE_LIMIT);
1972 RequestStop(CLEAR_DATA); 1981 RequestStop(CLEAR_DATA);
1973 } 1982 }
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 return; 2437 return;
2429 2438
2430 DCHECK(startup_controller_->IsSetupInProgress()); 2439 DCHECK(startup_controller_->IsSetupInProgress());
2431 startup_controller_->SetSetupInProgress(false); 2440 startup_controller_->SetSetupInProgress(false);
2432 2441
2433 if (IsEngineInitialized()) 2442 if (IsEngineInitialized())
2434 ReconfigureDatatypeManager(); 2443 ReconfigureDatatypeManager();
2435 NotifyObservers(); 2444 NotifyObservers();
2436 } 2445 }
2437 } // namespace browser_sync 2446 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698