From 025b4dd6db8210c55420241745a51a7dedb26b3e Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Mon, 17 Sep 2018 23:31:44 -0400 Subject: [PATCH 01/11] Remove patch for chrome/app/chrome_command_ids.h --- chromium_src/chrome/app/chrome_command_ids.h | 11 +++++++++++ patches/chrome-app-chrome_command_ids.h.patch | 15 --------------- 2 files changed, 11 insertions(+), 15 deletions(-) create mode 100644 chromium_src/chrome/app/chrome_command_ids.h delete mode 100644 patches/chrome-app-chrome_command_ids.h.patch diff --git a/chromium_src/chrome/app/chrome_command_ids.h b/chromium_src/chrome/app/chrome_command_ids.h new file mode 100644 index 000000000000..5a257946785a --- /dev/null +++ b/chromium_src/chrome/app/chrome_command_ids.h @@ -0,0 +1,11 @@ +/* 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_CHROMIUM_SRC_CHROME_APP_CHROME_COMMAND_IDS_H_ +#define BRAVE_CHROMIUM_SRC_CHROME_APP_CHROME_COMMAND_IDS_H_ + +#include "brave/app/brave_command_ids.h" +#include "../../../../chrome/app/chrome_command_ids.h" + +#endif // BRAVE_CHROMIUM_SRC_CHROME_APP_CHROME_COMMAND_IDS_H_ diff --git a/patches/chrome-app-chrome_command_ids.h.patch b/patches/chrome-app-chrome_command_ids.h.patch deleted file mode 100644 index b587249c3ee8..000000000000 --- a/patches/chrome-app-chrome_command_ids.h.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/chrome/app/chrome_command_ids.h b/chrome/app/chrome_command_ids.h -index 1f25ecad4be9fc5863888dba76b70b22dafed861..92e61f7ad1bd1ba5384647ed4b028a41fdc9b1ae 100644 ---- a/chrome/app/chrome_command_ids.h -+++ b/chrome/app/chrome_command_ids.h -@@ -5,6 +5,10 @@ - #ifndef CHROME_APP_CHROME_COMMAND_IDS_H_ - #define CHROME_APP_CHROME_COMMAND_IDS_H_ - -+#if defined(BRAVE_CHROMIUM_BUILD) -+#include "brave/app/brave_command_ids.h" -+#endif -+ - // This file lists all the command IDs understood by e.g. the browser. - // It is used by Windows RC files, Mac NIB files, and other platforms too. - From 8985c43ce12c790e0da1759f1c43dd877e9eb115 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Tue, 18 Sep 2018 00:01:33 -0400 Subject: [PATCH 02/11] Remove patch for chrome/app/chrome_main.cc --- chromium_src/chrome/app/chrome_main.cc | 9 +++++++++ patches/chrome-app-chrome_main.cc.patch | 21 --------------------- 2 files changed, 9 insertions(+), 21 deletions(-) create mode 100644 chromium_src/chrome/app/chrome_main.cc delete mode 100644 patches/chrome-app-chrome_main.cc.patch diff --git a/chromium_src/chrome/app/chrome_main.cc b/chromium_src/chrome/app/chrome_main.cc new file mode 100644 index 000000000000..298899d584cd --- /dev/null +++ b/chromium_src/chrome/app/chrome_main.cc @@ -0,0 +1,9 @@ +/* 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/app/brave_main_delegate.h" + +#define ChromeMainDelegate BraveMainDelegate +#include "../../../../chrome/app/chrome_main.cc" +#undef ChromeMainDelegate diff --git a/patches/chrome-app-chrome_main.cc.patch b/patches/chrome-app-chrome_main.cc.patch deleted file mode 100644 index 185ed56e25ac..000000000000 --- a/patches/chrome-app-chrome_main.cc.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc -index 9ff589299bff368efca05c9739031c7f6b63b263..5d23a4c05067f0c5856cd2441e760da40ee2231d 100644 ---- a/chrome/app/chrome_main.cc -+++ b/chrome/app/chrome_main.cc -@@ -7,6 +7,7 @@ - #include "base/callback_helpers.h" - #include "base/command_line.h" - #include "base/time/time.h" -+#include "brave/app/brave_main_delegate.h" - #include "build/build_config.h" - #include "chrome/app/chrome_main_delegate.h" - #include "chrome/common/buildflags.h" -@@ -56,7 +57,7 @@ int ChromeMain(int argc, const char** argv) { - install_static::InitializeFromPrimaryModule(); - #endif - -- ChromeMainDelegate chrome_main_delegate( -+ BraveMainDelegate chrome_main_delegate( - base::TimeTicks::FromInternalValue(exe_entry_point_ticks)); - content::ContentMainParams params(&chrome_main_delegate); - From c53db9d42480bc4d6b9400bc7ca7701188fadfe6 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Tue, 18 Sep 2018 00:08:22 -0400 Subject: [PATCH 03/11] Remove patch for chrome/browser/browser_process_impl.cc --- .../chrome/browser/browser_process_impl.cc | 9 ++++++++ ...rome-browser-browser_process_impl.cc.patch | 21 ------------------- 2 files changed, 9 insertions(+), 21 deletions(-) create mode 100644 chromium_src/chrome/browser/browser_process_impl.cc delete mode 100644 patches/chrome-browser-browser_process_impl.cc.patch diff --git a/chromium_src/chrome/browser/browser_process_impl.cc b/chromium_src/chrome/browser/browser_process_impl.cc new file mode 100644 index 000000000000..bae639d802fd --- /dev/null +++ b/chromium_src/chrome/browser/browser_process_impl.cc @@ -0,0 +1,9 @@ +/* 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/brave_shields/browser/brave_resource_dispatcher_host_delegate.h" + +#define ChromeResourceDispatcherHostDelegate BraveResourceDispatcherHostDelegate +#include "../../../../chrome/browser/browser_process_impl.cc" +#undef ChromeResourceDispatcherHostDelegate diff --git a/patches/chrome-browser-browser_process_impl.cc.patch b/patches/chrome-browser-browser_process_impl.cc.patch deleted file mode 100644 index 83dfe06a064d..000000000000 --- a/patches/chrome-browser-browser_process_impl.cc.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc -index e7b4c97c4849e3da9c4b444fdfc5e8eb63ecdfa7..c08591a4e86ff559abd37e43cda81831fd8e9367 100644 ---- a/chrome/browser/browser_process_impl.cc -+++ b/chrome/browser/browser_process_impl.cc -@@ -33,6 +33,7 @@ - #include "base/time/default_clock.h" - #include "base/time/default_tick_clock.h" - #include "base/trace_event/trace_event.h" -+#include "brave/components/brave_shields/browser/brave_resource_dispatcher_host_delegate.h" - #include "build/build_config.h" - #include "chrome/browser/chrome_browser_main.h" - #include "chrome/browser/chrome_child_process_watcher.h" -@@ -1064,7 +1065,7 @@ BrowserProcessImpl::supervised_user_whitelist_installer() { - - void BrowserProcessImpl::ResourceDispatcherHostCreated() { - resource_dispatcher_host_delegate_ = -- std::make_unique(); -+ std::make_unique(); - ResourceDispatcherHost::Get()->SetDelegate( - resource_dispatcher_host_delegate_.get()); - From b2decc64d15fa3cdbe785a67c13fb5ee91750e25 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Tue, 18 Sep 2018 00:27:34 -0400 Subject: [PATCH 04/11] Remove patch for chrome/browser/io_thread.cc --- chromium_src/chrome/browser/io_thread.cc | 9 +++++++++ patches/chrome-browser-io_thread.cc.patch | 21 --------------------- 2 files changed, 9 insertions(+), 21 deletions(-) create mode 100644 chromium_src/chrome/browser/io_thread.cc delete mode 100644 patches/chrome-browser-io_thread.cc.patch diff --git a/chromium_src/chrome/browser/io_thread.cc b/chromium_src/chrome/browser/io_thread.cc new file mode 100644 index 000000000000..c6a5eee13eee --- /dev/null +++ b/chromium_src/chrome/browser/io_thread.cc @@ -0,0 +1,9 @@ +/* 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/net/brave_system_network_delegate.h" + +#define ChromeNetworkDelegate BraveSystemNetworkDelegate +#include "../../../../chrome/browser/io_thread.cc" +#undef ChromeNetworkDelegate diff --git a/patches/chrome-browser-io_thread.cc.patch b/patches/chrome-browser-io_thread.cc.patch deleted file mode 100644 index 451916a21437..000000000000 --- a/patches/chrome-browser-io_thread.cc.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc -index bafbc9a18efd6d6d9119a069f5152f6485907025..bd4692653fcdae151868e7b9632ec9effbc32663 100644 ---- a/chrome/browser/io_thread.cc -+++ b/chrome/browser/io_thread.cc -@@ -27,6 +27,7 @@ - #include "base/threading/thread.h" - #include "base/time/time.h" - #include "base/trace_event/trace_event.h" -+#include "brave/browser/net/brave_system_network_delegate.h" - #include "build/build_config.h" - #include "chrome/browser/browser_process.h" - #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber.h" -@@ -437,7 +438,7 @@ void IOThread::ConstructSystemRequestContext() { - std::unique_ptr builder = - std::make_unique(); - -- auto chrome_network_delegate = std::make_unique( -+ auto chrome_network_delegate = std::make_unique( - extension_event_router_forwarder()); - builder->set_network_delegate( - globals_->data_use_ascriber->CreateNetworkDelegate( From 91efb86dfb6bc02fdf1cd968d98f0369b893274b Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Tue, 18 Sep 2018 00:39:33 -0400 Subject: [PATCH 05/11] Remove patch for chrome/browser/ui/browser.cc --- chromium_src/chrome/browser/ui/browser.cc | 14 +++++++++++ patches/chrome-browser-ui-browser.cc.patch | 29 ---------------------- 2 files changed, 14 insertions(+), 29 deletions(-) create mode 100644 chromium_src/chrome/browser/ui/browser.cc delete mode 100644 patches/chrome-browser-ui-browser.cc.patch diff --git a/chromium_src/chrome/browser/ui/browser.cc b/chromium_src/chrome/browser/ui/browser.cc new file mode 100644 index 000000000000..8a2594db4b37 --- /dev/null +++ b/chromium_src/chrome/browser/ui/browser.cc @@ -0,0 +1,14 @@ +/* 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 "chrome/browser/ui/browser_command_controller.h" +#include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" +#include "brave/browser/ui/brave_browser_content_setting_bubble_model_delegate.h" +#include "brave/browser/ui/brave_browser_command_controller.h" + +#define BrowserContentSettingBubbleModelDelegate BraveBrowserContentSettingBubbleModelDelegate +#define BrowserCommandController BraveBrowserCommandController +#include "../../../../../chrome/browser/ui/browser.cc" +#undef BrowserContentSettingBubbleModelDelegate +#undef BrowserCommandController diff --git a/patches/chrome-browser-ui-browser.cc.patch b/patches/chrome-browser-ui-browser.cc.patch deleted file mode 100644 index ad2e6d1d5934..000000000000 --- a/patches/chrome-browser-ui-browser.cc.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc -index 8bdc956a05f1b3f2bd0b025de6305c998770a06d..b5a14dcd36d2705fc802fef85ce13dcd208c2ac2 100644 ---- a/chrome/browser/ui/browser.cc -+++ b/chrome/browser/ui/browser.cc -@@ -28,6 +28,8 @@ - #include "base/threading/thread_restrictions.h" - #include "base/threading/thread_task_runner_handle.h" - #include "base/time/time.h" -+#include "brave/browser/ui/brave_browser_content_setting_bubble_model_delegate.h" -+#include "brave/browser/ui/brave_browser_command_controller.h" - #include "build/build_config.h" - #include "chrome/app/chrome_command_ids.h" - #include "chrome/browser/app_mode/app_mode_utils.h" -@@ -392,13 +394,13 @@ Browser::Browser(const CreateParams& params) - initial_workspace_(params.initial_workspace), - is_session_restore_(params.is_session_restore), - content_setting_bubble_model_delegate_( -- new BrowserContentSettingBubbleModelDelegate(this)), -+ new BraveBrowserContentSettingBubbleModelDelegate(this)), - toolbar_model_delegate_(new BrowserToolbarModelDelegate(this)), - live_tab_context_(new BrowserLiveTabContext(this)), - synced_window_delegate_(new BrowserSyncedWindowDelegate(this)), - hosted_app_controller_(MaybeCreateHostedAppController(this)), - bookmark_bar_state_(BookmarkBar::HIDDEN), -- command_controller_(new chrome::BrowserCommandController(this)), -+ command_controller_(new BraveBrowserCommandController(this)), - window_has_shown_(false), - chrome_updater_factory_(this), - weak_factory_(this) { From 3a0d49a8757044142423a4ed1cf52b6061ff88d4 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Tue, 18 Sep 2018 01:17:38 -0400 Subject: [PATCH 06/11] Remove patch for chrome/browser/extensions/extension_service.cc --- browser/extensions/BUILD.gn | 2 + browser/extensions/brave_extension_service.cc | 44 +++++++++++++++++++ browser/extensions/brave_extension_service.h | 33 ++++++++++++++ .../ui/brave_browser_command_controller.cc | 4 ++ browser/ui/brave_browser_command_controller.h | 5 +++ .../browser/extensions/extension_service.cc | 11 +++++ .../extensions/extension_system_impl.cc | 11 +++++ ...wser-extensions-extension_service.cc.patch | 43 ------------------ ...owser-extensions-extension_service.h.patch | 12 +++++ 9 files changed, 122 insertions(+), 43 deletions(-) create mode 100644 browser/extensions/brave_extension_service.cc create mode 100644 browser/extensions/brave_extension_service.h create mode 100644 chromium_src/chrome/browser/extensions/extension_service.cc create mode 100644 chromium_src/chrome/browser/extensions/extension_system_impl.cc delete mode 100644 patches/chrome-browser-extensions-extension_service.cc.patch create mode 100644 patches/chrome-browser-extensions-extension_service.h.patch diff --git a/browser/extensions/BUILD.gn b/browser/extensions/BUILD.gn index 365fd9149e03..28807f092afc 100644 --- a/browser/extensions/BUILD.gn +++ b/browser/extensions/BUILD.gn @@ -20,6 +20,8 @@ source_set("extensions") { "brave_extension_management.h", "brave_extension_provider.cc", "brave_extension_provider.h", + "brave_extension_service.cc", + "brave_extension_service.h", "brave_tor_client_updater.cc", "brave_tor_client_updater.h", "brave_webstore_inline_installer.cc", diff --git a/browser/extensions/brave_extension_service.cc b/browser/extensions/brave_extension_service.cc new file mode 100644 index 000000000000..2cc2cbc5b7c5 --- /dev/null +++ b/browser/extensions/brave_extension_service.cc @@ -0,0 +1,44 @@ +/* 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/extensions/brave_extension_service.h" +#include "chrome/browser/extensions/api/content_settings/content_settings_service.h" +#include "chrome/browser/profiles/profile.h" + +namespace extensions { + +BraveExtensionService::BraveExtensionService(Profile* profile, + const base::CommandLine* command_line, + const base::FilePath& install_directory, + ExtensionPrefs* extension_prefs, + Blacklist* blacklist, + bool autoupdate_enabled, + bool extensions_enabled, + OneShotEvent* ready) : + ExtensionService(profile, command_line, install_directory, extension_prefs, + blacklist, autoupdate_enabled, extensions_enabled, ready) { +} + +BraveExtensionService::~BraveExtensionService() { +} + +void BraveExtensionService::AddComponentExtension(const Extension* extension) { + ExtensionService::AddComponentExtension(extension); + + // ContentSettingsStore::RegisterExtension is only called for default components + // on the first run with a fresh profile. All restarts of the browser after that do not call it. + // This causes ContentSettingsStore's `entries_` to never insert the component ID + // and then ContentSettingsStore::GetValueMap always returns nullptr. + // I don't think Chromium is affected by this simply because they don't use content settings + // from default component extensions. + extension_prefs_->OnExtensionInstalled(extension, Extension::ENABLED, + syncer::StringOrdinal(), + extensions::kInstallFlagNone, + std::string(), + base::nullopt); + extensions::ContentSettingsService::Get(profile_)->OnExtensionPrefsLoaded( + extension->id(), extension_prefs_); +} + +} // namespace extensions diff --git a/browser/extensions/brave_extension_service.h b/browser/extensions/brave_extension_service.h new file mode 100644 index 000000000000..867fdc8cbf1e --- /dev/null +++ b/browser/extensions/brave_extension_service.h @@ -0,0 +1,33 @@ +/* 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_BROWSER_EXTENSIONS_BRAVE_EXTENSION_SERVICE_H_ +#define BRAVE_BROWSER_EXTENSIONS_BRAVE_EXTENSION_SERVICE_H_ + +#include "chrome/browser/extensions/extension_service.h" + +namespace extensions { + +class BraveExtensionService : public ExtensionService { + public: + // Constructor stores pointers to |profile| and |extension_prefs| but + // ownership remains at caller. + BraveExtensionService(Profile* profile, + const base::CommandLine* command_line, + const base::FilePath& install_directory, + ExtensionPrefs* extension_prefs, + Blacklist* blacklist, + bool autoupdate_enabled, + bool extensions_enabled, + OneShotEvent* ready); + ~BraveExtensionService() override; + + void AddComponentExtension(const Extension* extension) override; + + DISALLOW_COPY_AND_ASSIGN(BraveExtensionService); +}; + +} // namespace extensions + +#endif // BRAVE_BROWSER_EXTENSIONS_BRAVE_EXTENSION_SERVICE_H_ diff --git a/browser/ui/brave_browser_command_controller.cc b/browser/ui/brave_browser_command_controller.cc index 0193769e5d7a..30b8aacdb870 100644 --- a/browser/ui/brave_browser_command_controller.cc +++ b/browser/ui/brave_browser_command_controller.cc @@ -17,6 +17,8 @@ bool IsBraveCommands(int id) { } } +namespace chrome { + BraveBrowserCommandController::BraveBrowserCommandController(Browser* browser) : BrowserCommandController(browser), browser_(browser), @@ -119,3 +121,5 @@ bool BraveBrowserCommandController::ExecuteBraveCommandWithDisposition( return true; } + +} // namespace chrome diff --git a/browser/ui/brave_browser_command_controller.h b/browser/ui/brave_browser_command_controller.h index 3af7b4bb3091..120a2dcbf70b 100644 --- a/browser/ui/brave_browser_command_controller.h +++ b/browser/ui/brave_browser_command_controller.h @@ -7,6 +7,9 @@ #include "chrome/browser/ui/browser_command_controller.h" +// This namespace is needed for a chromium_src override +namespace chrome { + class BraveBrowserCommandController : public chrome::BrowserCommandController { public: explicit BraveBrowserCommandController(Browser* browser); @@ -37,4 +40,6 @@ class BraveBrowserCommandController : public chrome::BrowserCommandController { DISALLOW_COPY_AND_ASSIGN(BraveBrowserCommandController); }; +} // namespace chrome + #endif // BRAVE_BROWSER_UI_BRAVE_BROWSER_COMMAND_CONTROLLER_H_ diff --git a/chromium_src/chrome/browser/extensions/extension_service.cc b/chromium_src/chrome/browser/extensions/extension_service.cc new file mode 100644 index 000000000000..726a6e7a849f --- /dev/null +++ b/chromium_src/chrome/browser/extensions/extension_service.cc @@ -0,0 +1,11 @@ +/* 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/extensions/brave_component_loader.h" +#include "chrome/browser/extensions/component_loader.h" +#include "chrome/browser/extensions/extension_service.h" + +#define ComponentLoader BraveComponentLoader +#include "../../../../../chrome/browser/extensions/extension_service.cc" +#undef ComponentLoader diff --git a/chromium_src/chrome/browser/extensions/extension_system_impl.cc b/chromium_src/chrome/browser/extensions/extension_system_impl.cc new file mode 100644 index 000000000000..0b7b4a432a07 --- /dev/null +++ b/chromium_src/chrome/browser/extensions/extension_system_impl.cc @@ -0,0 +1,11 @@ +/* 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/extensions/brave_extension_service.h" +#include "chrome/browser/extensions/crx_installer.h" +#include "chrome/browser/extensions/update_install_gate.h" + +#define ExtensionService BraveExtensionService +#include "../../../../../chrome/browser/extensions/extension_system_impl.cc" +#undef ExtensionService diff --git a/patches/chrome-browser-extensions-extension_service.cc.patch b/patches/chrome-browser-extensions-extension_service.cc.patch deleted file mode 100644 index 3d4f7d9206db..000000000000 --- a/patches/chrome-browser-extensions-extension_service.cc.patch +++ /dev/null @@ -1,43 +0,0 @@ -diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc -index d685521a0adcbad6fcd2a3db206d28c4d8fc02ca..943be4d1ec67f5037d6b4492105d724e529c8c91 100644 ---- a/chrome/browser/extensions/extension_service.cc -+++ b/chrome/browser/extensions/extension_service.cc -@@ -28,6 +28,7 @@ - #include "base/threading/thread_task_runner_handle.h" - #include "base/time/time.h" - #include "base/trace_event/trace_event.h" -+#include "brave/browser/extensions/brave_component_loader.h" - #include "build/build_config.h" - #include "chrome/browser/browser_process.h" - #include "chrome/browser/chrome_notification_types.h" -@@ -326,7 +327,7 @@ ExtensionService::ExtensionService(Profile* profile, - profile))); - } - -- component_loader_.reset(new ComponentLoader( -+ component_loader_.reset(new BraveComponentLoader( - this, profile->GetPrefs(), g_browser_process->local_state(), profile)); - - if (extensions_enabled_) { -@@ -1248,6 +1249,21 @@ void ExtensionService::AddComponentExtension(const Extension* extension) { - } - - AddExtension(extension); -+#if defined(BRAVE_CHROMIUM_BUILD) -+ // ContentSettingsStore::RegisterExtension is only called for default components -+ // on the first run with a fresh profile. All restarts of the browser after that do not call it. -+ // This causes ContentSettingsStore's `entries_` to never insert the component ID -+ // and then ContentSettingsStore::GetValueMap always returns nullptr. -+ // I don't think Chromium is affeced by this simply because they don't use content settings -+ // from default component extensions. -+ extension_prefs_->OnExtensionInstalled(extension, Extension::ENABLED, -+ syncer::StringOrdinal(), -+ extensions::kInstallFlagNone, -+ std::string(), -+ base::nullopt); -+ extensions::ContentSettingsService::Get(profile_)->OnExtensionPrefsLoaded( -+ extension->id(), extension_prefs_); -+#endif - } - - void ExtensionService::CheckPermissionsIncrease(const Extension* extension, diff --git a/patches/chrome-browser-extensions-extension_service.h.patch b/patches/chrome-browser-extensions-extension_service.h.patch new file mode 100644 index 000000000000..8e34a4c4c832 --- /dev/null +++ b/patches/chrome-browser-extensions-extension_service.h.patch @@ -0,0 +1,12 @@ +diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h +index ec6b2a2c10919c32a811da32b52508bef8a592ba..ddb0900d764e46a9eaf8e498122e30b2915360dc 100644 +--- a/chrome/browser/extensions/extension_service.h ++++ b/chrome/browser/extensions/extension_service.h +@@ -446,6 +446,7 @@ class ExtensionService : public ExtensionServiceInterface, + } + + private: ++ friend class BraveExtensionService; + // Loads extensions specified via a command line flag/switch. + void LoadExtensionsFromCommandLineFlag(const char* switch_name); + From d27b61d13fb8bb1fa3bd8aeb003309dec3f264fe Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Tue, 18 Sep 2018 07:36:12 -0400 Subject: [PATCH 07/11] Remove patch for chrome/browser/ui/app_list/search/omnibox_provider.cc --- .../ui/app_list/search/omnibox_provider.cc | 10 +++++++++ ...-app_list-search-omnibox_provider.cc.patch | 21 ------------------- 2 files changed, 10 insertions(+), 21 deletions(-) create mode 100644 chromium_src/chrome/browser/ui/app_list/search/omnibox_provider.cc delete mode 100644 patches/chrome-browser-ui-app_list-search-omnibox_provider.cc.patch diff --git a/chromium_src/chrome/browser/ui/app_list/search/omnibox_provider.cc b/chromium_src/chrome/browser/ui/app_list/search/omnibox_provider.cc new file mode 100644 index 000000000000..12b912048a46 --- /dev/null +++ b/chromium_src/chrome/browser/ui/app_list/search/omnibox_provider.cc @@ -0,0 +1,10 @@ +/* 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/omnibox/browser/brave_autocomplete_controller.h" +#include "components/omnibox/browser/autocomplete_controller.h" + +#define AutocompleteController BraveAutocompleteController +#include "../../../../../../../chrome/browser/ui/app_list/search/omnibox_provider.cc" +#undef AutocompleteController diff --git a/patches/chrome-browser-ui-app_list-search-omnibox_provider.cc.patch b/patches/chrome-browser-ui-app_list-search-omnibox_provider.cc.patch deleted file mode 100644 index ec62fc788f64..000000000000 --- a/patches/chrome-browser-ui-app_list-search-omnibox_provider.cc.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/chrome/browser/ui/app_list/search/omnibox_provider.cc b/chrome/browser/ui/app_list/search/omnibox_provider.cc -index 93a7674e27bad112990ce3ff17408de59fc79949..1669808d792eabb834e2b180abbf50e9a34a5ec5 100644 ---- a/chrome/browser/ui/app_list/search/omnibox_provider.cc -+++ b/chrome/browser/ui/app_list/search/omnibox_provider.cc -@@ -5,6 +5,7 @@ - #include "chrome/browser/ui/app_list/search/omnibox_provider.h" - - #include "base/memory/ptr_util.h" -+#include "brave/components/omnibox/browser/brave_autocomplete_controller.h" - #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" - #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" - #include "chrome/browser/profiles/profile.h" -@@ -23,7 +24,7 @@ OmniboxProvider::OmniboxProvider(Profile* profile, - AppListControllerDelegate* list_controller) - : profile_(profile), - list_controller_(list_controller), -- controller_(std::make_unique( -+ controller_(std::make_unique( - std::make_unique(profile), - this, - AutocompleteClassifier::DefaultOmniboxProviders() & From 2d71075e61be9c9287747fdf869ca66b7816b093 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Tue, 18 Sep 2018 07:50:23 -0400 Subject: [PATCH 08/11] Remove patch for components/omnibox/browser/omnibox_controller.cc --- .../omnibox/browser/omnibox_controller.cc | 10 ++++++++++ ...mnibox-browser-omnibox_controller.cc.patch | 20 ------------------- 2 files changed, 10 insertions(+), 20 deletions(-) create mode 100644 chromium_src/components/omnibox/browser/omnibox_controller.cc delete mode 100644 patches/components-omnibox-browser-omnibox_controller.cc.patch diff --git a/chromium_src/components/omnibox/browser/omnibox_controller.cc b/chromium_src/components/omnibox/browser/omnibox_controller.cc new file mode 100644 index 000000000000..885aff90e098 --- /dev/null +++ b/chromium_src/components/omnibox/browser/omnibox_controller.cc @@ -0,0 +1,10 @@ +/* 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/omnibox/browser/brave_autocomplete_controller.h" +#include "components/omnibox/browser/autocomplete_controller.h" + +#define AutocompleteController BraveAutocompleteController +#include "../../../../../../../components/omnibox/browser/omnibox_controller.cc" +#undef AutocompleteController diff --git a/patches/components-omnibox-browser-omnibox_controller.cc.patch b/patches/components-omnibox-browser-omnibox_controller.cc.patch deleted file mode 100644 index 71e023cde13b..000000000000 --- a/patches/components-omnibox-browser-omnibox_controller.cc.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/components/omnibox/browser/omnibox_controller.cc b/components/omnibox/browser/omnibox_controller.cc -index e2bc11edcf6721fd36462b87ba2852e5e76385d2..a36a62afa38a3c20b856515c2887ed5e2cd4bd22 100644 ---- a/components/omnibox/browser/omnibox_controller.cc -+++ b/components/omnibox/browser/omnibox_controller.cc -@@ -14,12 +14,14 @@ - #include "components/omnibox/browser/omnibox_popup_view.h" - #include "ui/gfx/geometry/rect.h" - -+#include "brave/components/omnibox/browser/brave_autocomplete_controller.h" -+ - OmniboxController::OmniboxController(OmniboxEditModel* omnibox_edit_model, - OmniboxClient* client) - : omnibox_edit_model_(omnibox_edit_model), - client_(client), - popup_(nullptr), -- autocomplete_controller_(new AutocompleteController( -+ autocomplete_controller_(new BraveAutocompleteController( - client_->CreateAutocompleteProviderClient(), - this, - AutocompleteClassifier::DefaultOmniboxProviders())), From 00b745a4c25ed9ba1622447a39494e9c66f8d5cf Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Tue, 18 Sep 2018 08:01:19 -0400 Subject: [PATCH 09/11] Remove patch for chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc --- .../ui/webui/omnibox/omnibox_page_handler.cc | 11 ++++++++++ ...ebui-omnibox-omnibox_page_handler.cc.patch | 21 ------------------- 2 files changed, 11 insertions(+), 21 deletions(-) create mode 100644 chromium_src/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc delete mode 100644 patches/chrome-browser-ui-webui-omnibox-omnibox_page_handler.cc.patch diff --git a/chromium_src/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc b/chromium_src/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc new file mode 100644 index 000000000000..432944180359 --- /dev/null +++ b/chromium_src/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc @@ -0,0 +1,11 @@ +/* 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/omnibox/browser/brave_autocomplete_controller.h" +#include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" +#include "components/omnibox/browser/autocomplete_controller.h" + +#define AutocompleteController BraveAutocompleteController +#include "../../../../../../../chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc" +#undef AutocompleteController diff --git a/patches/chrome-browser-ui-webui-omnibox-omnibox_page_handler.cc.patch b/patches/chrome-browser-ui-webui-omnibox-omnibox_page_handler.cc.patch deleted file mode 100644 index a58a89ebd18c..000000000000 --- a/patches/chrome-browser-ui-webui-omnibox-omnibox_page_handler.cc.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc b/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc -index d6c5b06681cb755106b75e4b18b67770cb8146ac..19500729c4ccf4c76cb2c0725c1cbad58f68ed9a 100644 ---- a/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc -+++ b/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc -@@ -15,6 +15,7 @@ - #include "base/strings/utf_string_conversions.h" - #include "base/time/time.h" - #include "base/values.h" -+#include "brave/components/omnibox/browser/brave_autocomplete_controller.h" - #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" - #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" - #include "chrome/browser/bookmarks/bookmark_model_factory.h" -@@ -211,7 +212,7 @@ void OmniboxPageHandler::StartOmniboxQuery(const std::string& input_string, - } - - void OmniboxPageHandler::ResetController() { -- controller_.reset(new AutocompleteController( -+ controller_.reset(new BraveAutocompleteController( - std::make_unique(profile_), this, - AutocompleteClassifier::DefaultOmniboxProviders())); - } From e75c58d2d4ee3d35adf5e44d35ea489b51a9e85a Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Tue, 18 Sep 2018 08:13:08 -0400 Subject: [PATCH 10/11] Remove patch for chrome/browser/autocomplete/autocomplete_classifier_factory.cc --- .../autocomplete_classifier_factory.cc | 15 +++++++++++ ...e-autocomplete_classifier_factory.cc.patch | 26 ------------------- 2 files changed, 15 insertions(+), 26 deletions(-) create mode 100644 chromium_src/chrome/browser/autocomplete/autocomplete_classifier_factory.cc delete mode 100644 patches/chrome-browser-autocomplete-autocomplete_classifier_factory.cc.patch diff --git a/chromium_src/chrome/browser/autocomplete/autocomplete_classifier_factory.cc b/chromium_src/chrome/browser/autocomplete/autocomplete_classifier_factory.cc new file mode 100644 index 000000000000..c2e881e9dfcb --- /dev/null +++ b/chromium_src/chrome/browser/autocomplete/autocomplete_classifier_factory.cc @@ -0,0 +1,15 @@ +/* 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_scheme_classifier.h" +#include "brave/components/omnibox/browser/brave_autocomplete_controller.h" +#include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" +#include "components/omnibox/browser/autocomplete_classifier.h" +#include "components/omnibox/browser/autocomplete_controller.h" + +#define AutocompleteController BraveAutocompleteController +#define ChromeAutocompleteSchemeClassifier BraveAutocompleteSchemeClassifier +#include "../../../../../chrome/browser/autocomplete/autocomplete_classifier_factory.cc" +#undef ChromeAutocompleteSchemeClassifier +#undef AutocompleteController diff --git a/patches/chrome-browser-autocomplete-autocomplete_classifier_factory.cc.patch b/patches/chrome-browser-autocomplete-autocomplete_classifier_factory.cc.patch deleted file mode 100644 index 058b6a07c720..000000000000 --- a/patches/chrome-browser-autocomplete-autocomplete_classifier_factory.cc.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/chrome/browser/autocomplete/autocomplete_classifier_factory.cc b/chrome/browser/autocomplete/autocomplete_classifier_factory.cc -index e3159144a0b7892e5580bfa910f2db97a81179a9..e39e356bf3605e6a92a2a1001cff06ff55514abb 100644 ---- a/chrome/browser/autocomplete/autocomplete_classifier_factory.cc -+++ b/chrome/browser/autocomplete/autocomplete_classifier_factory.cc -@@ -6,6 +6,8 @@ - - #include - -+#include "brave/browser/autocomplete/brave_autocomplete_scheme_classifier.h" -+#include "brave/components/omnibox/browser/brave_autocomplete_controller.h" - #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" - #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" - #include "chrome/browser/autocomplete/contextual_suggestions_service_factory.h" -@@ -41,10 +43,10 @@ std::unique_ptr AutocompleteClassifierFactory::BuildInstanceFor( - content::BrowserContext* context) { - Profile* profile = static_cast(context); - return std::make_unique( -- std::make_unique( -+ std::make_unique( - std::make_unique(profile), nullptr, - AutocompleteClassifier::DefaultOmniboxProviders()), -- std::make_unique(profile)); -+ std::make_unique(profile)); - } - - AutocompleteClassifierFactory::AutocompleteClassifierFactory() From a732007e5c934673deadc9aa29c569b4d8771caf Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Tue, 18 Sep 2018 08:25:25 -0400 Subject: [PATCH 11/11] Remove patches we don't use for BraveAutocompleteController chrome/browser/android/omnibox/autocomplete_controller_android.cc for now chrome/browser/ui/views/frame/test_with_browser_view.cc for now --- ...x-autocomplete_controller_android.cc.patch | 39 ------------------- ...iews-frame-test_with_browser_view.cc.patch | 13 ------- 2 files changed, 52 deletions(-) delete mode 100644 patches/chrome-browser-android-omnibox-autocomplete_controller_android.cc.patch delete mode 100644 patches/chrome-browser-ui-views-frame-test_with_browser_view.cc.patch diff --git a/patches/chrome-browser-android-omnibox-autocomplete_controller_android.cc.patch b/patches/chrome-browser-android-omnibox-autocomplete_controller_android.cc.patch deleted file mode 100644 index cb109fefda83..000000000000 --- a/patches/chrome-browser-android-omnibox-autocomplete_controller_android.cc.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff --git a/chrome/browser/android/omnibox/autocomplete_controller_android.cc b/chrome/browser/android/omnibox/autocomplete_controller_android.cc -index d2f549913162b2def9316840e61ebd3b8e9c86f4..a9fc95c23d5a0110ac2a4596c34e865b6ba4847f 100644 ---- a/chrome/browser/android/omnibox/autocomplete_controller_android.cc -+++ b/chrome/browser/android/omnibox/autocomplete_controller_android.cc -@@ -17,6 +17,7 @@ - #include "base/strings/utf_string_conversions.h" - #include "base/time/time.h" - #include "base/timer/timer.h" -+#include "brave/components/omnibox/browser/brave_autocomplete_controller.h" - #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" - #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" - #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" -@@ -99,7 +100,7 @@ class ZeroSuggestPrefetcher : public AutocompleteControllerDelegate { - }; - - ZeroSuggestPrefetcher::ZeroSuggestPrefetcher(Profile* profile) -- : controller_(new AutocompleteController( -+ : controller_(new BraveAutocompleteController( - std::make_unique(profile), - this, - AutocompleteProvider::TYPE_ZERO_SUGGEST)) { -@@ -136,7 +137,7 @@ void ZeroSuggestPrefetcher::OnResultChanged(bool default_match_changed) { - } // namespace - - AutocompleteControllerAndroid::AutocompleteControllerAndroid(Profile* profile) -- : autocomplete_controller_(new AutocompleteController( -+ : autocomplete_controller_(new BraveAutocompleteController( - std::make_unique(profile), - this, - AutocompleteClassifier::DefaultOmniboxProviders())), -@@ -364,7 +365,7 @@ AutocompleteControllerAndroid::Factory::~Factory() { - - KeyedService* AutocompleteControllerAndroid::Factory::BuildServiceInstanceFor( - content::BrowserContext* profile) const { -- return new AutocompleteControllerAndroid(static_cast(profile)); -+ return new BraveAutocompleteControllerAndroid(static_cast(profile)); - } - - AutocompleteControllerAndroid::~AutocompleteControllerAndroid() { diff --git a/patches/chrome-browser-ui-views-frame-test_with_browser_view.cc.patch b/patches/chrome-browser-ui-views-frame-test_with_browser_view.cc.patch deleted file mode 100644 index 365fde133bd2..000000000000 --- a/patches/chrome-browser-ui-views-frame-test_with_browser_view.cc.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/chrome/browser/ui/views/frame/test_with_browser_view.cc b/chrome/browser/ui/views/frame/test_with_browser_view.cc -index 71e2d0d115afe42838287cccc8830f07cafc977c..fc15c1c6712300ea28b2238fbce92d390b204662 100644 ---- a/chrome/browser/ui/views/frame/test_with_browser_view.cc -+++ b/chrome/browser/ui/views/frame/test_with_browser_view.cc -@@ -53,7 +53,7 @@ std::unique_ptr CreateAutocompleteClassifier( - content::BrowserContext* context) { - Profile* profile = static_cast(context); - return std::make_unique( -- std::make_unique( -+ std::make_unique( - std::make_unique(profile), nullptr, - AutocompleteClassifier::DefaultOmniboxProviders()), - std::make_unique());