Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Sync 1.18.x Uplift #7371

Merged
merged 9 commits into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@
<output filename="brave_generated_resources_en-GB.pak" type="data_package" lang="en-GB" />
<output filename="brave_generated_resources_en-US.pak" type="data_package" lang="en" />
<output filename="brave_generated_resources_es.pak" type="data_package" lang="es" />
<output filename="brave_generated_resources_es-419.pak" type="data_package" lang="es-419" />
<if expr="is_ios">
<!-- iOS uses es-MX for es-419 -->
<output filename="brave_generated_resources_es-MX.pak" type="data_package" lang="es-419" />
</if>
<if expr="not is_ios">
<output filename="brave_generated_resources_es-419.pak" type="data_package" lang="es-419" />
</if>
<output filename="brave_generated_resources_et.pak" type="data_package" lang="et" />
<output filename="brave_generated_resources_fa.pak" type="data_package" lang="fa" />
<output filename="brave_generated_resources_fake-bidi.pak" type="data_package" lang="fake-bidi" />
Expand Down
8 changes: 7 additions & 1 deletion app/brave_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ If you update this file, be sure also to update google_chrome_strings.grd. -->
<output filename="chromium_strings_en-GB.pak" type="data_package" lang="en-GB" />
<output filename="chromium_strings_en-US.pak" type="data_package" lang="en" />
<output filename="chromium_strings_es.pak" type="data_package" lang="es" />
<output filename="chromium_strings_es-419.pak" type="data_package" lang="es-419" />
<if expr="is_ios">
<!-- iOS uses es-MX for es-419 -->
<output filename="chromium_strings_es-MX.pak" type="data_package" lang="es-419" />
</if>
<if expr="not is_ios">
<output filename="chromium_strings_es-419.pak" type="data_package" lang="es-419" />
</if>
<output filename="chromium_strings_et.pak" type="data_package" lang="et" />
<output filename="chromium_strings_fa.pak" type="data_package" lang="fa" />
<output filename="chromium_strings_fake-bidi.pak" type="data_package" lang="fake-bidi" />
Expand Down
8 changes: 7 additions & 1 deletion app/generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ are declared in tools/grit/grit_rule.gni.
<output filename="generated_resources_en-US.pak" type="data_package" lang="en" />
<output filename="generated_resources_en-GB.pak" type="data_package" lang="en-GB" />
<output filename="generated_resources_es.pak" type="data_package" lang="es" />
<output filename="generated_resources_es-419.pak" type="data_package" lang="es-419" />
<if expr="is_ios">
<!-- iOS uses es-MX for es-419 -->
<output filename="generated_resources_es-MX.pak" type="data_package" lang="es-419" />
</if>
<if expr="not is_ios">
<output filename="generated_resources_es-419.pak" type="data_package" lang="es-419" />
</if>
<output filename="generated_resources_et.pak" type="data_package" lang="et" />
<output filename="generated_resources_fa.pak" type="data_package" lang="fa" />
<output filename="generated_resources_fake-bidi.pak" type="data_package" lang="fake-bidi" />
Expand Down
3 changes: 1 addition & 2 deletions browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ source_set("browser_process") {
"search_engines/search_engine_tracker.h",
"search_engines/tor_window_search_engine_provider_service.cc",
"search_engines/tor_window_search_engine_provider_service.h",
"sync/brave_profile_sync_service_delegate.cc",
"sync/brave_profile_sync_service_delegate.h",
"update_util.cc",
"update_util.h",
]
Expand Down Expand Up @@ -121,6 +119,7 @@ source_set("browser_process") {
"profiles",
"renderer_context_menu",
"search",
"sync",
"themes",
"ui",
"//base",
Expand Down
14 changes: 14 additions & 0 deletions browser/sync/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
source_set("sync") {
check_includes = false

sources = [
"brave_profile_sync_service_delegate.cc",
"brave_profile_sync_service_delegate.h",
]

deps = [
"//base",
"//components/sync/driver",
"//components/sync_device_info",
]
}
30 changes: 9 additions & 21 deletions browser/sync/brave_profile_sync_service_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,19 @@
#include <utility>

#include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "brave/components/sync/driver/brave_sync_profile_sync_service.h"
#include "chrome/browser/sync/device_info_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "components/sync_device_info/device_info_sync_service.h"
#include "components/sync_device_info/device_info_tracker.h"
#include "components/sync_device_info/local_device_info_provider.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"

namespace syncer {

namespace {
syncer::BraveProfileSyncService* GetSyncService(Profile* profile) {
return ProfileSyncServiceFactory::IsSyncAllowed(profile)
? static_cast<syncer::BraveProfileSyncService*>(
ProfileSyncServiceFactory::GetForProfile(profile))
: nullptr;
}
} // namespace

BraveProfileSyncServiceDelegate::BraveProfileSyncServiceDelegate(
Profile* profile)
: device_info_sync_service_(
DeviceInfoSyncServiceFactory::GetForProfile(profile)),
profile_(profile),
DeviceInfoSyncService* device_info_sync_service)
: device_info_sync_service_(device_info_sync_service),
weak_ptr_factory_(this) {
DCHECK(device_info_sync_service_);

Expand All @@ -48,7 +36,8 @@ BraveProfileSyncServiceDelegate::BraveProfileSyncServiceDelegate(
BraveProfileSyncServiceDelegate::~BraveProfileSyncServiceDelegate() {}

void BraveProfileSyncServiceDelegate::OnDeviceInfoChange() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(profile_sync_service_);

const syncer::DeviceInfo* local_device_info =
local_device_info_provider_->GetLocalDeviceInfo();

Expand All @@ -66,17 +55,16 @@ void BraveProfileSyncServiceDelegate::OnDeviceInfoChange() {
if (!found_local_device) {
// We can't call OnSelfDeviceInfoDeleted directly because we are on
// remove device execution path, so posting task
base::PostTask(
FROM_HERE, {content::BrowserThread::UI},
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(
&BraveProfileSyncServiceDelegate::OnSelfDeviceInfoDeleted,
weak_ptr_factory_.GetWeakPtr()));
}
}

void BraveProfileSyncServiceDelegate::OnSelfDeviceInfoDeleted(void) {
syncer::BraveProfileSyncService* sync_service = GetSyncService(profile_);
sync_service->OnSelfDeviceInfoDeleted(base::DoNothing::Once());
void BraveProfileSyncServiceDelegate::OnSelfDeviceInfoDeleted() {
profile_sync_service_->OnSelfDeviceInfoDeleted(base::DoNothing::Once());
}

void BraveProfileSyncServiceDelegate::SuspendDeviceObserverForOwnReset() {
Expand Down
5 changes: 3 additions & 2 deletions browser/sync/brave_profile_sync_service_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Profile;

namespace syncer {

class DeviceInfoSyncService;
class DeviceInfoTracker;
class LocalDeviceInfoProvider;

Expand All @@ -26,7 +27,8 @@ class BraveProfileSyncServiceDelegate
: public ProfileSyncServiceDelegate,
public syncer::DeviceInfoTracker::Observer {
public:
explicit BraveProfileSyncServiceDelegate(Profile* profile);
explicit BraveProfileSyncServiceDelegate(
DeviceInfoSyncService* device_info_sync_service);
~BraveProfileSyncServiceDelegate() override;

void SuspendDeviceObserverForOwnReset() override;
Expand All @@ -44,7 +46,6 @@ class BraveProfileSyncServiceDelegate
device_info_observer_{this};

DeviceInfoSyncService* device_info_sync_service_;
Profile* profile_;

base::WeakPtrFactory<BraveProfileSyncServiceDelegate> weak_ptr_factory_;

Expand Down
2 changes: 1 addition & 1 deletion build/commands/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var packageConfig = function(key){

const getNPMConfig = (key) => {
if (!NpmConfig) {
const list = run(npmCommand, ['config', 'list', '--json'], {cwd: rootDir})
const list = run(npmCommand, ['config', 'list', '--json', '--userconfig=' + path.join(rootDir, '.npmrc')])
NpmConfig = JSON.parse(list.stdout.toString())
}

Expand Down
7 changes: 6 additions & 1 deletion chromium_src/base/mac/foundation_util.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
// build and chrome::GetChannel() will always return stable in test build.
//
// For safe in non-test build, current seems fine in official build.
#if defined(OS_IOS)
#include "ios/chrome/common/channel_info.h"
#else
#include "chrome/common/channel_info.h"
using chrome::GetChannel;
#endif
#endif

namespace base {
Expand All @@ -39,7 +44,7 @@
#if !defined(OFFICIAL_BUILD)
return "com.brave.Browser.development";
#else
switch (chrome::GetChannel()) {
switch (GetChannel()) {
case version_info::Channel::CANARY:
return "com.brave.Browser.nightly";
case version_info::Channel::DEV:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#define BRAVE_BUILD_SERVICE_INSTANCE_FOR \
std::make_unique<syncer::BraveProfileSyncService>( \
std::move(init_params), \
std::make_unique<syncer::BraveProfileSyncServiceDelegate>(profile));
std::make_unique<syncer::BraveProfileSyncServiceDelegate>( \
DeviceInfoSyncServiceFactory::GetForProfile(profile)));

#include "../../../../../chrome/browser/sync/profile_sync_service_factory.cc"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* 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 "base/build_config.h"

#if defined(OS_IOS)
#define SettingsAllowSigninCookies SettingsAllowSigninCookies_ChromiumImpl
#define SettingsDeleteSigninCookiesOnExit \
SettingsDeleteSigninCookiesOnExit_ChromiumImpl
#endif

#include "../../../../../../components/content_settings/core/browser/cookie_settings_utils.cc"

#if defined(OS_IOS)
bool SettingsAllowSigninCookies(
const content_settings::CookieSettings* cookie_settings) {
return false;
}

bool SettingsDeleteSigninCookiesOnExit(
const content_settings::CookieSettings* cookie_settings) {
return true;
}
#endif
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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 "build/build_config.h"

#if defined(OS_IOS)
#include "../../../../../../components/content_settings/core/browser/host_content_settings_map.cc"
#else
#include "brave/components/content_settings/core/browser/brave_content_settings_ephemeral_provider.h"
#include "brave/components/content_settings/core/browser/brave_content_settings_pref_provider.h"

Expand All @@ -10,3 +16,4 @@
#include "../../../../../../components/content_settings/core/browser/host_content_settings_map.cc"
#undef EphemeralProvider
#undef PrefProvider
#endif
26 changes: 26 additions & 0 deletions chromium_src/components/sync_device_info/device_info.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* 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 "components/sync_device_info/device_info.h"

#include <algorithm>

#define ToValue ToValue_ChromiumImpl
#include "../../../../components/sync_device_info/device_info.cc"
#undef ToValue

namespace syncer {
std::unique_ptr<base::DictionaryValue> DeviceInfo::ToValue() const {
std::unique_ptr<base::DictionaryValue> value = ToValue_ChromiumImpl();
if ((device_type_ == sync_pb::SyncEnums_DeviceType_TYPE_PHONE ||
device_type_ == sync_pb::SyncEnums_DeviceType_TYPE_TABLET) &&
sync_user_agent_.find("IOS") != std::string::npos) {
value->SetString("os", "ios");
} else {
value->SetString("os", GetOSString());
}
return value;
}
} // namespace syncer
18 changes: 18 additions & 0 deletions chromium_src/components/sync_device_info/device_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* 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 https://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_H_
#define BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_H_

#include <string>

#define ToValue \
ToValue_ChromiumImpl() const; \
std::unique_ptr<base::DictionaryValue> ToValue

#include "../../../../components/sync_device_info/device_info.h"
#undef ToValue

#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_H_
Loading