Skip to content

Commit

Permalink
Upgrade to 74.0.3729.75
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdh committed Apr 16, 2019
1 parent 69a6588 commit 3dc3465
Show file tree
Hide file tree
Showing 38 changed files with 228 additions and 273 deletions.
4 changes: 4 additions & 0 deletions app/brave_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "chrome/common/chrome_switches.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "components/unified_consent/feature.h"
#include "content/public/common/content_features.h"
#include "extensions/common/extension_features.h"
Expand Down Expand Up @@ -145,6 +146,9 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) {
autofill::features::kAutofillServerCommunication.name,
features::kAudioServiceOutOfProcess.name,
features::kDefaultEnableOopRasterization.name,
// TODO(darkdh): remove this when USS bookmarks is mature
// 84919fdb99b162030a1113d5990667885b774064
switches::kSyncUSSBookmarks.name,
network::features::kNetworkService.name,
unified_consent::kUnifiedConsent.name,
};
Expand Down
2 changes: 1 addition & 1 deletion browser/extensions/api/brave_sync_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace api {
namespace {

ProfileSyncService* GetProfileSyncService(BrowserContext* browser_context) {
return ProfileSyncServiceFactory::GetForProfile(
return ProfileSyncServiceFactory::GetAsProfileSyncServiceForProfile(
Profile::FromBrowserContext(browser_context));
}

Expand Down
2 changes: 1 addition & 1 deletion browser/ui/webui/sync/sync_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void SyncUIDOMHandler::Init() {
Profile* profile = Profile::FromWebUI(web_ui());
sync_service_ =
static_cast<brave_sync::BraveSyncService*>(
ProfileSyncServiceFactory::GetForProfile(profile));
ProfileSyncServiceFactory::GetAsProfileSyncServiceForProfile(profile));
if (sync_service_)
sync_service_->AddObserver(this);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "chrome/browser/bookmarks/chrome_bookmark_client.h"
#include "brave/browser/bookmarks/brave_bookmark_client.h"
#define ChromeBookmarkClient BraveBookmarkClient
// Stop loading old Brave permanent nodes, GetEntityForBookmarkNode will fail
// see 9645795920481e2a80613a72aeddba1a65490dac
// #define ChromeBookmarkClient BraveBookmarkClient
#include "../../../../../../chrome/browser/bookmarks/bookmark_model_factory.cc"
31 changes: 23 additions & 8 deletions chromium_src/components/browser_sync/profile_sync_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ syncer::SyncCredentials GetDummyCredentials();
AccountInfo GetDummyAccountInfo();
}
}
namespace syncer {
const int64_t kBraveDefaultShortPollIntervalSeconds = 60;
const int64_t kBraveDefaultLongPollIntervalSeconds = 90;
}

// For use_transport_only_mode
#define IsSyncFeatureEnabled IsBraveSyncEnabled
#include "../../../../components/browser_sync/profile_sync_service.cc"

#include "base/bind.h"
Expand All @@ -22,12 +21,18 @@ const int64_t kBraveDefaultLongPollIntervalSeconds = 90;
#include "brave/components/brave_sync/sync_devices.h"
#include "brave/components/brave_sync/tools.h"
#include "brave/components/brave_sync/values_conv.h"
#include "chrome/browser/sync/chrome_sync_client.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/sync/engine_impl/syncer.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/network_interfaces.h"
#include "ui/base/models/tree_node_iterator.h"

namespace syncer {
const int64_t kBraveDefaultShortPollIntervalSeconds = 60;
const int64_t kBraveDefaultLongPollIntervalSeconds = 90;
}

namespace browser_sync {

using brave_sync::GetRecordsCallback;
Expand Down Expand Up @@ -484,9 +489,6 @@ void ProfileSyncService::OnSaveInitData(const Uint8Array& seed,

brave_sync_configured_ = true;

user_settings_->SetChosenDataTypes(false, syncer::ModelTypeSet());
OnSetSyncBookmarks(true);

brave_sync_initializing_ = false;
}

Expand All @@ -504,6 +506,8 @@ void ProfileSyncService::OnSyncReady() {
DCHECK(false == brave_sync_initialized_);
brave_sync_initialized_ = true;

user_settings_->SetChosenDataTypes(false, syncer::ModelTypeSet());
OnSetSyncBookmarks(true);
user_settings_->SetSyncRequested(true);
}

Expand All @@ -524,7 +528,9 @@ void ProfileSyncService::OnGetExistingObjects(
std::make_unique<SyncRecordAndExistingList>();
CreateResolveList(
*records.get(), records_and_existing_objects.get(),
sync_client_->GetBookmarkModel(),
// TODO(darkdh): find another way to obtain bookmark model
// change introduced in 83b9663e3814ef7e53af5009d10033b89955db44
static_cast<ChromeSyncClient*>(sync_client_.get())->GetBookmarkModel(),
brave_sync_prefs_.get());
GetBraveSyncClient()->SendResolveSyncRecords(
category_name, std::move(records_and_existing_objects));
Expand Down Expand Up @@ -764,6 +770,15 @@ void ProfileSyncService::BraveEngineParamsInit(
params->poll_sync_cycle_delegate_function =
base::BindRepeating(&ProfileSyncService::OnPollSyncCycle,
sync_enabled_weak_factory_.GetWeakPtr());

params->credentials = GetDummyCredentials();

sync_prefs_.SetShortPollInterval(
base::TimeDelta::FromSeconds(
syncer::kBraveDefaultShortPollIntervalSeconds));
sync_prefs_.SetLongPollInterval(
base::TimeDelta::FromSeconds(
syncer::kBraveDefaultLongPollIntervalSeconds));
}

void ProfileSyncService::OnNudgeSyncCycle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ namespace syncer {
void SyncBackendHostCore::OnNudgeSyncCycle(
brave_sync::RecordsListPtr records_list) {
host_.Call(FROM_HERE,
&SyncBackendHostImpl::HandleNudgeSyncCycle,
&SyncEngineImpl::HandleNudgeSyncCycle,
base::Passed(&records_list));
}

void SyncBackendHostCore::OnPollSyncCycle(GetRecordsCallback cb,
base::WaitableEvent* wevent) {
host_.Call(FROM_HERE,
&SyncBackendHostImpl::HandlePollSyncCycle, cb, wevent);
&SyncEngineImpl::HandlePollSyncCycle, cb, wevent);
}

void SyncBackendHostCore::DoDispatchGetRecordsCallback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#include "../../../../../../components/sync/driver/glue/sync_backend_host_impl.cc"
#include "../../../../../../components/sync/driver/glue/sync_engine_impl.cc"

#include "brave/components/brave_sync/jslib_messages.h"

namespace syncer {

void SyncBackendHostImpl::HandleNudgeSyncCycle(
void SyncEngineImpl::HandleNudgeSyncCycle(
brave_sync::RecordsListPtr records_list) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(nudge_sync_cycle_delegate_function_);
nudge_sync_cycle_delegate_function_.Run(std::move(records_list));
}

void SyncBackendHostImpl::HandlePollSyncCycle(
void SyncEngineImpl::HandlePollSyncCycle(
GetRecordsCallback cb,
base::WaitableEvent* wevent) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(poll_sync_cycle_delegate_function_);
poll_sync_cycle_delegate_function_.Run(cb, wevent);
}

void SyncBackendHostImpl::DispatchGetRecordsCallback(
void SyncEngineImpl::DispatchGetRecordsCallback(
GetRecordsCallback cb, std::unique_ptr<RecordsList> records) {
sync_task_runner_->PostTask(
FROM_HERE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ namespace syncer {
using brave_sync::GetRecordsCallback;
using brave_sync::RecordsList;
} // namespace syncer
#include "../../../../../../components/sync/driver/glue/sync_backend_host_impl.h"
#include "../../../../../../components/sync/driver/glue/sync_engine_impl.h"
18 changes: 12 additions & 6 deletions chromium_src/components/sync/engine_impl/get_updates_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ namespace {
using brave_sync::jslib::Bookmark;
using brave_sync::jslib::SyncRecord;
using syncable::Id;
static const char kBookmarkBarTag[] = "bookmark_bar";
static const char kOtherBookmarksTag[] = "other_bookmarks";
static const char kBookmarkBarFolderServerTag[] = "bookmark_bar";
static const char kBookmarkBarFolderName[] = "Bookmark Bar";
static const char kOtherBookmarksFolderServerTag[] = "other_bookmarks";
static const char kOtherBookmarksFolderName[] = "Other Bookmarks";
static const char kSyncedBookmarksFolderServerTag[] = "synced_bookmarks";
static const char kSyncedBookmarksFolderName[] = "Synced Bookmarks";
// The parent tag for children of the root entity. Entities with this parent are
// referred to as top level enities.
static const char kRootParentTag[] = "0";
Expand Down Expand Up @@ -145,9 +147,9 @@ void AddBookmarkNode(sync_pb::SyncEntity* entity, const SyncRecord* record) {
if (!bookmark_record.parentFolderObjectId.empty())
entity->set_parent_id_string(bookmark_record.parentFolderObjectId);
else if (!bookmark_record.hideInToolbar)
entity->set_parent_id_string(std::string(kBookmarkBarTag));
entity->set_parent_id_string(std::string(kBookmarkBarFolderServerTag));
else
entity->set_parent_id_string(std::string(kOtherBookmarksTag));
entity->set_parent_id_string(std::string(kOtherBookmarksFolderServerTag));
entity->set_non_unique_name(bookmark_record.site.title);
entity->set_folder(bookmark_record.isFolder);

Expand Down Expand Up @@ -181,9 +183,13 @@ void ConstructUpdateResponse(sync_pb::GetUpdatesResponse* gu_response,
if (type == BOOKMARKS) {
google::protobuf::RepeatedPtrField<sync_pb::SyncEntity> entities;
AddRootForType(entities.Add(), BOOKMARKS);
AddPermanentNode(entities.Add(), kBookmarkBarFolderName, kBookmarkBarTag);
AddPermanentNode(entities.Add(), kBookmarkBarFolderName,
kBookmarkBarFolderServerTag);
AddPermanentNode(entities.Add(), kOtherBookmarksFolderName,
kOtherBookmarksTag);
kOtherBookmarksFolderServerTag);
// required since 84f01c4c006cf89941138f3591db129a5b3cde54
AddPermanentNode(entities.Add(), kSyncedBookmarksFolderName,
kSyncedBookmarksFolderServerTag);
if (records) {
for (const auto& record : *records.get()) {
AddBookmarkNode(entities.Add(), record.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void SyncSchedulerImpl::SetNudgeAndPollDelegate(

void SyncSchedulerImpl::TryBraveSyncCycleJob() {
SyncCycle cycle(cycle_context_, this);
if (mode_ != CONFIGURATION_MODE && mode_ != CLEAR_SERVER_DATA_MODE) {
if (mode_ != CONFIGURATION_MODE) {
syncer_->DownloadBraveRecords(&cycle);
}
}
Expand Down
12 changes: 6 additions & 6 deletions patches/chrome-browser-sync-chrome_sync_client.cc.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
diff --git a/chrome/browser/sync/chrome_sync_client.cc b/chrome/browser/sync/chrome_sync_client.cc
index 8c36199a7b7514d1ac5e710a938287a167da91a5..50e07746517364f85c93ee6feae38eea16de7892 100644
index 3efbe8f776e1ecfd212fee726fad5c360d9788c6..ce8f6e05186781e40a0224125ed248a6fa102dc9 100644
--- a/chrome/browser/sync/chrome_sync_client.cc
+++ b/chrome/browser/sync/chrome_sync_client.cc
@@ -159,7 +159,8 @@ syncer::ModelTypeSet GetDisabledTypesFromCommandLine() {
@@ -164,7 +164,8 @@ syncer::ModelTypeSet GetDisabledTypesFromCommandLine() {

} // namespace

-ChromeSyncClient::ChromeSyncClient(Profile* profile) : profile_(profile) {}
-ChromeSyncClient::ChromeSyncClient(Profile* profile) : profile_(profile) {
+ChromeSyncClient::ChromeSyncClient(Profile* profile) : profile_(profile),
+ brave_sync_client_(brave_sync::BraveSyncClient::Create(profile)) {}
+ brave_sync_client_(brave_sync::BraveSyncClient::Create(profile)) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);

ChromeSyncClient::~ChromeSyncClient() {
}
profile_web_data_service_ =
10 changes: 5 additions & 5 deletions patches/chrome-browser-sync-chrome_sync_client.h.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
diff --git a/chrome/browser/sync/chrome_sync_client.h b/chrome/browser/sync/chrome_sync_client.h
index ae728503c195e1c9cf6da57ce08641632d8ae3ae..5ddf2944e4393f270cb53bc926f36f49c303bcbf 100644
index c89058c8815f8983dafaeb88edf1a239f11a9b08..bb22a19336d91fcf476607a3399bbbe850fa5f47 100644
--- a/chrome/browser/sync/chrome_sync_client.h
+++ b/chrome/browser/sync/chrome_sync_client.h
@@ -62,6 +62,7 @@ class ChromeSyncClient : public syncer::SyncClient {
@@ -60,6 +60,7 @@ class ChromeSyncClient : public browser_sync::BrowserSyncClient {
scoped_refptr<syncer::ModelSafeWorker> CreateModelWorkerForGroup(
syncer::ModelSafeGroup group) override;
syncer::SyncApiComponentFactory* GetSyncApiComponentFactory() override;
+ brave_sync::BraveSyncClient* GetBraveSyncClient() override;

// Helpers for overriding getters in tests.
void SetSyncApiComponentFactoryForTesting(
@@ -85,6 +86,8 @@ class ChromeSyncClient : public syncer::SyncClient {
private:
Profile* const profile_;
@@ -82,6 +83,8 @@ class ChromeSyncClient : public browser_sync::BrowserSyncClient {
// Generates and monitors the ExtensionsActivity object used by sync.
ExtensionsActivityMonitor extensions_activity_monitor_;

Expand Down
63 changes: 12 additions & 51 deletions patches/components-browser_sync-profile_sync_service.cc.patch
Original file line number Diff line number Diff line change
@@ -1,84 +1,45 @@
diff --git a/components/browser_sync/profile_sync_service.cc b/components/browser_sync/profile_sync_service.cc
index a0355393caba17c8343ec2a771eeb29d731d27e4..08a9666b1ac5fcd6c6ab737b2874afc331e02a69 100644
index 787e2d24941cbaa469373ed5baad14d1ac9f3722..8f5a0b7a2d4e263992822375621ed624027913fd 100644
--- a/components/browser_sync/profile_sync_service.cc
+++ b/components/browser_sync/profile_sync_service.cc
@@ -198,6 +198,8 @@ ProfileSyncService::ProfileSyncService(InitParams init_params)
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
@@ -184,6 +184,8 @@ ProfileSyncService::ProfileSyncService(InitParams init_params)
DCHECK(sync_client_);
DCHECK(IsLocalSyncEnabled() || identity_manager_ != nullptr);

+ BraveSyncSetup();
+
// If Sync is disabled via command line flag, then ProfileSyncService
// shouldn't be instantiated.
DCHECK(IsSyncAllowedByFlag());
@@ -539,7 +541,10 @@ void ProfileSyncService::StartUpSlowEngineComponents() {
->GetLocalDeviceInfoProvider()
DCHECK(switches::IsSyncAllowedByFlag());
@@ -480,6 +482,8 @@ void ProfileSyncService::StartUpSlowEngineComponents() {
->GetSyncUserAgent();
params.http_factory_getter = MakeHttpPostProviderFactoryGetter();
- params.credentials = auth_manager_->GetCredentials();
+ if (IsBraveSyncEnabled())
+ params.credentials = GetDummyCredentials();
+ else
+ params.credentials = auth_manager_->GetCredentials();
params.credentials = auth_manager_->GetCredentials();
+ if (IsBraveSyncEnabled())
+ BraveEngineParamsInit(&params);
DCHECK(!params.credentials.account_id.empty() || IsLocalSyncEnabled());
if (!base::FeatureList::IsEnabled(switches::kSyncE2ELatencyMeasurement)) {
invalidation::InvalidationService* invalidator =
@@ -571,13 +576,14 @@ void ProfileSyncService::StartUpSlowEngineComponents() {
params.short_poll_interval = sync_prefs_.GetShortPollInterval();
if (params.short_poll_interval.is_zero()) {
params.short_poll_interval =
- base::TimeDelta::FromSeconds(syncer::kDefaultShortPollIntervalSeconds);
+ base::TimeDelta::FromSeconds(syncer::kBraveDefaultShortPollIntervalSeconds);
}
params.long_poll_interval = sync_prefs_.GetLongPollInterval();
if (params.long_poll_interval.is_zero()) {
params.long_poll_interval =
- base::TimeDelta::FromSeconds(syncer::kDefaultLongPollIntervalSeconds);
+ base::TimeDelta::FromSeconds(syncer::kBraveDefaultLongPollIntervalSeconds);
}
+ BraveEngineParamsInit(&params);

engine_->Initialize(std::move(params));

@@ -721,6 +727,7 @@ int ProfileSyncService::GetDisableReasons() const {
DCHECK(IsSyncAllowedByFlag());
@@ -663,6 +667,7 @@ int ProfileSyncService::GetDisableReasons() const {
DCHECK(switches::IsSyncAllowedByFlag());

int result = DISABLE_REASON_NONE;
+ if (IsBraveSyncEnabled()) return result;
if (!user_settings_->IsSyncAllowedByPlatform()) {
result = result | DISABLE_REASON_PLATFORM_OVERRIDE;
}
@@ -1465,7 +1472,7 @@ void ProfileSyncService::ConfigureDataTypeManager(
// Note: When local Sync is enabled, then we want full-sync mode (not just
// transport), even though Sync-the-feature is not considered enabled.
bool use_transport_only_mode =
- !IsSyncFeatureEnabled() && !IsLocalSyncEnabled();
+ !IsSyncFeatureEnabled() && !IsLocalSyncEnabled() && !IsBraveSyncEnabled();

syncer::ModelTypeSet types = GetPreferredDataTypes();
// In transport-only mode, only a subset of data types is supported.
@@ -1860,6 +1867,7 @@ void ProfileSyncService::GetAllNodes(

syncer::ModelTypeSet all_types = GetActiveDataTypes();
all_types.PutAll(syncer::ControlTypes());
+
scoped_refptr<GetAllNodesRequestHelper> helper =
new GetAllNodesRequestHelper(all_types, callback);

@@ -1891,12 +1899,14 @@ void ProfileSyncService::GetAllNodes(
@@ -1753,12 +1758,12 @@ void ProfileSyncService::GetAllNodes(

AccountInfo ProfileSyncService::GetAuthenticatedAccountInfo() const {
CoreAccountInfo ProfileSyncService::GetAuthenticatedAccountInfo() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
- return auth_manager_->GetActiveAccountInfo().account_info;
+ return GetDummyAccountInfo();
+ // return auth_manager_->GetActiveAccountInfo().account_info;
}

bool ProfileSyncService::IsAuthenticatedAccountPrimary() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
- return auth_manager_->GetActiveAccountInfo().is_primary;
+ return true;
+ // return auth_manager_->GetActiveAccountInfo().is_primary;
}

void ProfileSyncService::SetInvalidationsForSessionsEnabled(bool enabled) {
Loading

0 comments on commit 3dc3465

Please sign in to comment.