-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6200 from brave/sync-setup-in-progress
Sync setup in progress
- Loading branch information
Showing
8 changed files
with
126 additions
and
77 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
chromium_src/chrome/browser/sync/profile_sync_service_factory.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/components/sync/driver/brave_sync_profile_sync_service.h" | ||
|
||
#include "../../../../../chrome/browser/sync/profile_sync_service_factory.cc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/components/sync/driver/brave_sync_profile_sync_service.h" | ||
|
||
#include <utility> | ||
|
||
#include "base/logging.h" | ||
#include "brave/components/brave_sync/brave_sync_prefs.h" | ||
#include "brave/components/sync/driver/brave_sync_auth_manager.h" | ||
#include "components/prefs/pref_service.h" | ||
|
||
namespace syncer { | ||
|
||
BraveProfileSyncService::BraveProfileSyncService(InitParams init_params) | ||
: ProfileSyncService(std::move(init_params)) { | ||
brave_sync_prefs_change_registrar_.Init(sync_client_->GetPrefService()); | ||
brave_sync_prefs_change_registrar_.Add( | ||
brave_sync::Prefs::GetSeedPath(), | ||
base::Bind(&BraveProfileSyncService::OnBraveSyncPrefsChanged, | ||
base::Unretained(this))); | ||
brave_sync::Prefs brave_sync_prefs(sync_client_->GetPrefService()); | ||
GetBraveSyncAuthManager()->DeriveSigningKeys(brave_sync_prefs.GetSeed()); | ||
if (!brave_sync_prefs.IsSyncV1Migrated()) { | ||
StopImpl(CLEAR_DATA); | ||
brave_sync_prefs.SetSyncV1Migrated(true); | ||
} | ||
} | ||
|
||
BraveProfileSyncService::~BraveProfileSyncService() { | ||
brave_sync_prefs_change_registrar_.RemoveAll(); | ||
} | ||
|
||
bool BraveProfileSyncService::IsSetupInProgress() const { | ||
return ProfileSyncService::IsSetupInProgress() && | ||
!user_settings_->IsFirstSetupComplete(); | ||
} | ||
|
||
BraveSyncAuthManager* BraveProfileSyncService::GetBraveSyncAuthManager() { | ||
return static_cast<BraveSyncAuthManager*>(auth_manager_.get()); | ||
} | ||
|
||
void BraveProfileSyncService::OnBraveSyncPrefsChanged(const std::string& path) { | ||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | ||
if (path == brave_sync::Prefs::GetSeedPath()) { | ||
brave_sync::Prefs brave_sync_prefs(sync_client_->GetPrefService()); | ||
const std::string seed = brave_sync_prefs.GetSeed(); | ||
if (!seed.empty()) { | ||
GetBraveSyncAuthManager()->DeriveSigningKeys(seed); | ||
// Default enabled types: Bookmarks | ||
syncer::UserSelectableTypeSet selected_types; | ||
selected_types.Put(UserSelectableType::kBookmarks); | ||
GetUserSettings()->SetSelectedTypes(false, selected_types); | ||
} else { | ||
VLOG(1) << "Brave sync seed cleared"; | ||
GetBraveSyncAuthManager()->ResetKeys(); | ||
} | ||
} | ||
} | ||
} // namespace syncer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_COMPONENTS_SYNC_DRIVER_BRAVE_SYNC_PROFILE_SYNC_SERVICE_H_ | ||
#define BRAVE_COMPONENTS_SYNC_DRIVER_BRAVE_SYNC_PROFILE_SYNC_SERVICE_H_ | ||
|
||
#include <string> | ||
|
||
#include "components/prefs/pref_change_registrar.h" | ||
#include "components/sync/driver/profile_sync_service.h" | ||
|
||
namespace syncer { | ||
|
||
class BraveSyncAuthManager; | ||
|
||
class BraveProfileSyncService : public ProfileSyncService { | ||
public: | ||
explicit BraveProfileSyncService(InitParams init_params); | ||
~BraveProfileSyncService() override; | ||
|
||
// SyncService implementation | ||
bool IsSetupInProgress() const override; | ||
|
||
private: | ||
BraveSyncAuthManager* GetBraveSyncAuthManager(); | ||
|
||
void OnBraveSyncPrefsChanged(const std::string& path); | ||
|
||
PrefChangeRegistrar brave_sync_prefs_change_registrar_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveProfileSyncService); | ||
}; | ||
} // namespace syncer | ||
|
||
#endif // BRAVE_COMPONENTS_SYNC_DRIVER_BRAVE_SYNC_PROFILE_SYNC_SERVICE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
patches/chrome-browser-sync-profile_sync_service_factory.cc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/chrome/browser/sync/profile_sync_service_factory.cc b/chrome/browser/sync/profile_sync_service_factory.cc | ||
index dca006daae56b4c31d838304a5b0493b92cd05ec..6bda62f4894b5939939d47774bc9563c3b2133b3 100644 | ||
--- a/chrome/browser/sync/profile_sync_service_factory.cc | ||
+++ b/chrome/browser/sync/profile_sync_service_factory.cc | ||
@@ -269,7 +269,7 @@ KeyedService* ProfileSyncServiceFactory::BuildServiceInstanceFor( | ||
} | ||
|
||
auto pss = | ||
- std::make_unique<syncer::ProfileSyncService>(std::move(init_params)); | ||
+ std::make_unique<syncer::BraveProfileSyncService>(std::move(init_params)); | ||
|
||
#if defined(OS_WIN) | ||
if (!local_sync_backend_enabled) |
20 changes: 0 additions & 20 deletions
20
patches/components-sync-driver-profile_sync_service.cc.patch
This file was deleted.
Oops, something went wrong.