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

Brave syncer (uplift to 0.69.x) #3230

Merged
merged 4 commits into from
Aug 28, 2019
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
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ deps = {
"vendor/bip39wally-core-native": "https://github.com/brave-intl/bip39wally-core-native.git@13bb40a215248cfbdd87d0a6b425c8397402e9e6",
"vendor/bat-native-anonize": "https://github.com/brave-intl/bat-native-anonize.git@e3742ba3e8942eea9e4755d91532491871bd3116",
"vendor/bat-native-tweetnacl": "https://github.com/brave-intl/bat-native-tweetnacl.git@1b4362968c8f22720bfb75af6f506d4ecc0f3116",
"components/brave_sync/extension/brave-sync": "https://github.com/brave/sync.git@e97e9e912552cd789cb2c1b1f327c77b32175317",
"components/brave_sync/extension/brave-sync": "https://github.com/brave/sync.git@91a68fdebc8962ca409045177438671f06a3c26a",
"components/brave_sync/extension/brave-crypto": "https://github.com/brave/crypto@0231e65ba211b152d742278319c545a83cb13fc0",
"vendor/bat-native-usermodel": "https://github.com/brave-intl/bat-native-usermodel.git@c1745b906079285fc01e3079ac49b0e65fde0f98",
"vendor/challenge_bypass_ristretto_ffi": "https://github.com/brave-intl/challenge-bypass-ristretto-ffi.git@f88d942ddfaf61a4a6703355a77c4ef71bc95c35",
Expand Down
2 changes: 0 additions & 2 deletions browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ source_set("browser_process") {
"autocomplete/brave_autocomplete_provider_client.h",
"autocomplete/brave_autocomplete_scheme_classifier.cc",
"autocomplete/brave_autocomplete_scheme_classifier.h",
"bookmarks/brave_bookmark_client.cc",
"bookmarks/brave_bookmark_client.h",
"brave_browser_main_extra_parts.cc",
"brave_browser_main_extra_parts.h",
"brave_browser_main_parts.cc",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* Copyright (c) 2019 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/browser/autocomplete/brave_autocomplete_provider_client.h"

#include <memory>
#include <utility>
#include <vector>

#include "base/strings/utf_string_conversions.h"
#include "brave/common/webui_url_constants.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/testing_profile.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/fake_service_worker_context.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"

class BraveAutocompleteProviderClientUnitTest : public testing::Test {
public:
void SetUp() override {
profile_ = std::make_unique<TestingProfile>();
profile_ = CreateProfile();
client_ =
std::make_unique<BraveAutocompleteProviderClient>(profile_.get());
}
Expand All @@ -26,14 +33,24 @@ class BraveAutocompleteProviderClientUnitTest : public testing::Test {
return it != v.end();
}

protected:
private:
std::unique_ptr<TestingProfile> CreateProfile() {
TestingProfile::Builder builder;
auto prefs =
std::make_unique<sync_preferences::TestingPrefServiceSyncable>();
RegisterUserProfilePrefs(prefs->registry());
builder.SetPrefService(std::move(prefs));
return builder.Build();
}

content::TestBrowserThreadBundle test_browser_thread_bundle_;
std::unique_ptr<TestingProfile> profile_;
std::unique_ptr<BraveAutocompleteProviderClient> client_;
};

TEST_F(BraveAutocompleteProviderClientUnitTest,
SyncURLSuggestedNotSyncInternal) {
ASSERT_FALSE(BuiltinExists(base::ASCIIToUTF16(chrome::kChromeUISyncInternalsHost)));
ASSERT_FALSE(
BuiltinExists(base::ASCIIToUTF16(chrome::kChromeUISyncInternalsHost)));
ASSERT_TRUE(BuiltinExists(base::ASCIIToUTF16(kBraveUISyncHost)));
}
3 changes: 0 additions & 3 deletions browser/autoplay/autoplay_permission_context_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include "base/bind.h"
#include "base/macros.h"
#include "brave/common/pref_names.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/permissions/permission_request_id.h"
#include "chrome/browser/permissions/permission_request_manager.h"
Expand Down Expand Up @@ -77,8 +76,6 @@ class AutoplayPermissionContextTests : public ChromeRenderViewHostTestHarness {
auto prefs =
std::make_unique<sync_preferences::TestingPrefServiceSyncable>();
RegisterUserProfilePrefs(prefs->registry());
prefs->registry()->
RegisterBooleanPref(kGoogleLoginControlType, true);
builder.SetPrefService(std::move(prefs));
return builder.Build().release();
}
Expand Down
40 changes: 0 additions & 40 deletions browser/bookmarks/brave_bookmark_client.cc

This file was deleted.

25 changes: 0 additions & 25 deletions browser/bookmarks/brave_bookmark_client.h

This file was deleted.

9 changes: 7 additions & 2 deletions browser/brave_content_browser_client_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "brave/common/pref_names.h"
#include "brave/components/brave_rewards/browser/buildflags/buildflags.h"
#include "brave/components/brave_shields/common/brave_shield_constants.h"
#include "brave/components/brave_sync/buildflags/buildflags.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/extensions/extension_service.h"
Expand Down Expand Up @@ -151,9 +152,11 @@ IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest, CanLoadCustomBravePages) {
std::vector<std::string> pages {
"adblock",
#if BUILDFLAG(BRAVE_REWARDS_ENABLED)
"rewards",
"rewards",
#endif
#if BUILDFLAG(ENABLE_BRAVE_SYNC)
chrome::kChromeUISyncHost,
#endif
chrome::kChromeUISyncHost,
};

std::vector<std::string> schemes {
Expand Down Expand Up @@ -205,6 +208,7 @@ IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest, CanLoadAboutHost) {
}
}

#if BUILDFLAG(ENABLE_BRAVE_SYNC)
IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest,
RewriteChromeSyncInternals) {
std::vector<std::string> schemes {
Expand All @@ -230,6 +234,7 @@ IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest,
"chrome://sync/");
}
}
#endif

IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest,
RewriteWelcomeWin10Host) {
Expand Down
35 changes: 2 additions & 33 deletions browser/brave_profile_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@

#include "brave/browser/brave_profile_prefs.h"

#include "brave/browser/themes/brave_theme_service.h"
#include "brave/browser/tor/buildflags.h"
#include "brave/common/pref_names.h"
#include "brave/components/brave_rewards/browser/rewards_service.h"
#include "brave/components/brave_shields/browser/brave_shields_web_contents_observer.h"
#include "brave/components/brave_sync/brave_sync_prefs.h"
#include "brave/components/brave_webtorrent/browser/buildflags/buildflags.h"
#include "chrome/browser/net/prediction_options.h"
#include "chrome/browser/prefs/session_startup_pref.h"
Expand All @@ -18,7 +16,6 @@
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/safe_browsing/common/safe_browsing_prefs.h"
#include "components/signin/core/browser/signin_pref_names.h"
#include "components/spellcheck/browser/pref_names.h"
#include "components/sync/base/pref_names.h"
#include "extensions/buildflags/buildflags.h"
#include "extensions/common/feature_switch.h"
Expand All @@ -32,29 +29,19 @@
#include "brave/components/brave_webtorrent/browser/webtorrent_util.h"
#endif

#if BUILDFLAG(ENABLE_TOR)
#include "brave/browser/tor/tor_profile_service.h"
#endif

using extensions::FeatureSwitch;

namespace brave {

void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
brave_rewards::RewardsService::RegisterProfilePrefs(registry);
brave_shields::BraveShieldsWebContentsObserver::RegisterProfilePrefs(
registry);

// appearance
#if !defined(OS_ANDROID)
BraveThemeService::RegisterProfilePrefs(registry);
#endif
registry->RegisterBooleanPref(kLocationBarIsWide, false);
registry->RegisterBooleanPref(kHideBraveRewardsButton, false);

#if BUILDFLAG(ENABLE_TOR)
tor::TorProfileService::RegisterProfilePrefs(registry);
#endif
brave_sync::prefs::Prefs::RegisterProfilePrefs(registry);

registry->RegisterBooleanPref(kWidevineOptedIn, false);
#if BUILDFLAG(BUNDLE_WIDEVINE_CDM)
Expand All @@ -75,11 +62,6 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
webtorrent::RegisterProfilePrefs(registry);
#endif

#if defined(OS_LINUX)
// Use brave theme by default instead of gtk theme.
registry->SetDefaultPrefValue(prefs::kUsesSystemTheme, base::Value(false));
#endif

// Hangouts
registry->RegisterBooleanPref(kHangoutsEnabled, true);

Expand All @@ -95,9 +77,6 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
FeatureSwitch::load_media_router_component_extension()->IsEnabled());
#endif

// No sign into Brave functionality
registry->SetDefaultPrefValue(prefs::kSigninAllowed, base::Value(false));

// Restore last profile on restart
registry->SetDefaultPrefValue(
prefs::kRestoreOnStartup,
Expand All @@ -110,10 +89,6 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->SetDefaultPrefValue(prefs::kAlternateErrorPagesEnabled,
base::Value(false));

// Disable spell check service
registry->SetDefaultPrefValue(
spellcheck::prefs::kSpellCheckUseSpellingService, base::Value(false));

// Disable safebrowsing reporting
registry->SetDefaultPrefValue(
prefs::kSafeBrowsingExtendedReportingOptInAllowed, base::Value(false));
Expand All @@ -130,12 +105,6 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
// Make sync managed to dsiable some UI after password saving.
registry->SetDefaultPrefValue(syncer::prefs::kSyncManaged, base::Value(true));

// Make sure sign into Brave is not enabled
// The older kSigninAllowed is deprecated and only in use in Android until
// C71.
registry->SetDefaultPrefValue(prefs::kSigninAllowedOnNextStartup,
base::Value(false));

// Disable cloud print
// Cloud Print: Don't allow this browser to act as Cloud Print server
registry->SetDefaultPrefValue(prefs::kCloudPrintProxyEnabled,
Expand Down
2 changes: 0 additions & 2 deletions browser/browser_context_keyed_service_factories.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
#include "brave/browser/tor/tor_profile_service_factory.h"
#include "brave/components/brave_ads/browser/ads_service_factory.h"
#include "brave/components/brave_rewards/browser/rewards_service_factory.h"
#include "brave/components/brave_sync/brave_sync_service_factory.h"

namespace brave {

void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
brave_ads::AdsServiceFactory::GetInstance();
brave_rewards::RewardsServiceFactory::GetInstance();
brave_sync::BraveSyncServiceFactory::GetInstance();
greaselion::GreaselionServiceFactory::GetInstance();
TorProfileServiceFactory::GetInstance();
SearchEngineProviderServiceFactory::GetInstance();
Expand Down
34 changes: 21 additions & 13 deletions browser/extensions/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
import("//brave/components/brave_rewards/browser/buildflags/buildflags.gni")
import("//brave/components/brave_sync/buildflags/buildflags.gni")
import("//brave/components/brave_wallet/browser/buildflags/buildflags.gni")
import("//brave/components/brave_webtorrent/browser/buildflags/buildflags.gni")
import("//build/config/features.gni")

source_set("extensions") {
sources = [
"api/rewards_notifications_api.cc",
"api/rewards_notifications_api.h",
"api/brave_extensions_api_client.cc",
"api/brave_extensions_api_client.h",
"api/brave_rewards_api.cc",
"api/brave_rewards_api.h",
"api/brave_shields_api.cc",
"api/brave_shields_api.h",
"api/brave_sync_api.cc",
"api/brave_sync_api.h",
"api/brave_sync_event_router.cc",
"api/brave_sync_event_router.h",
"api/brave_theme_api.cc",
"api/brave_theme_api.h",
"api/rewards_notifications_api.cc",
"api/rewards_notifications_api.h",
"api/settings_private/brave_prefs_util.cc",
"api/settings_private/brave_prefs_util.h",
"brave_component_extension_resource_manager.cc",
"brave_component_extension_resource_manager.h",
"brave_component_loader.cc",
"brave_component_loader.h",
"brave_extensions_browser_api_provider.cc",
"brave_extensions_browser_api_provider.h",
"brave_extension_install_prompt.cc",
"brave_extension_install_prompt.h",
"brave_extension_management.cc",
Expand All @@ -35,12 +30,14 @@ source_set("extensions") {
"brave_extension_provider.h",
"brave_extension_service.cc",
"brave_extension_service.h",
"brave_extensions_browser_api_provider.cc",
"brave_extensions_browser_api_provider.h",
"brave_theme_event_router.cc",
"brave_theme_event_router.h",
"brave_tor_client_updater.cc",
"brave_tor_client_updater.h",
"updater/brave_update_client_config.cc",
"updater/brave_update_client_config.h"
"updater/brave_update_client_config.h",
]

if (brave_wallet_enabled) {
Expand All @@ -58,11 +55,8 @@ source_set("extensions") {
"//brave/common:pref_names",
"//brave/common/extensions/api",
"//brave/components/brave_component_updater/browser",
"//brave/components/brave_extension:static_resources",
"//brave/components/brave_extension:generated_resources",
"//brave/components/brave_sync",
"//brave/components/brave_sync:generated_resources",
"//brave/components/brave_sync:static_resources",
"//brave/components/brave_extension:static_resources",
"//components/prefs",
"//components/update_client:patch_impl",
"//components/update_client:unzip_impl",
Expand All @@ -78,6 +72,20 @@ source_set("extensions") {
"//brave/components/brave_rewards/resources/extension:static_resources",
]
}
if (enable_brave_sync) {
sources += [
"api/brave_sync_api.cc",
"api/brave_sync_api.h",
"api/brave_sync_event_router.cc",
"api/brave_sync_event_router.h",
]

deps += [
"//brave/components/brave_sync",
"//brave/components/brave_sync:generated_resources",
"//brave/components/brave_sync:static_resources",
]
}
if (enable_brave_webtorrent) {
deps += [
"//brave/components/brave_webtorrent:generated_resources",
Expand Down
Loading