diff --git a/atom/app/atom_main_delegate.cc b/atom/app/atom_main_delegate.cc index c43c6d30d4..6ff932f531 100644 --- a/atom/app/atom_main_delegate.cc +++ b/atom/app/atom_main_delegate.cc @@ -375,10 +375,6 @@ int AtomMainDelegate::RunProcess( const std::string& process_type, const content::MainFunctionParams& main_function_params) { static const MainFunction kMainFunctions[] = { - #if BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(CHROME_MULTIPLE_DLL_CHILD) - { switches::kCloudPrintServiceProcess, CloudPrintServiceProcessMain }, - #endif - #if defined(OS_MACOSX) { switches::kRelauncherProcess, relauncher::RelauncherMain }, #else diff --git a/atom/browser/BUILD.gn b/atom/browser/BUILD.gn index 7f8f5585d7..5cfd0fc300 100644 --- a/atom/browser/BUILD.gn +++ b/atom/browser/BUILD.gn @@ -24,7 +24,7 @@ source_set("browser") { "//electron:common", "//electron/muon/app", # @todo(bridiver) fix circular dep - # "//electron/chromium_src:browser", + # "//electron/muon/browser", "//base", "//chrome/common:constants", "//storage/browser", diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 6e736bb237..415148e18f 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -39,7 +39,6 @@ #include "brave/browser/brave_content_browser_client.h" #include "brave/common/workers/v8_worker_thread.h" #include "brave/common/workers/worker_bindings.h" -#include "chrome/browser/browser_process_impl.h" #include "chrome/common/chrome_paths.h" #include "components/component_updater/component_updater_paths.h" #include "content/browser/plugin_service_impl.h" @@ -53,6 +52,7 @@ #include "content/public/browser/render_frame_host.h" #include "content/public/common/content_switches.h" #include "extensions/features/features.h" +#include "muon/browser/muon_browser_process_impl.h" #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" #include "net/ssl/client_cert_identity.h" @@ -476,7 +476,7 @@ App::App(v8::Isolate* isolate) { atom::Browser::Get()->AddObserver(this); content::GpuDataManager::GetInstance()->AddObserver(this); Init(isolate); - static_cast(g_browser_process)->set_app(this); + static_cast(g_browser_process)->set_app(this); #if BUILDFLAG(ENABLE_EXTENSIONS) registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index fdac30ff0e..d05df25c29 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -106,6 +106,10 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/display/screen.h" +#if BUILDFLAG(ENABLE_PRINTING) +#include "chrome/browser/printing/printing_init.h" +#endif + #if !defined(OS_MACOSX) #include "ui/aura/window.h" #endif @@ -469,6 +473,10 @@ void WebContents::CompleteInit(v8::Isolate* isolate, // Intialize security state client. SecurityStateTabHelper::CreateForWebContents(web_contents); +#if BUILDFLAG(ENABLE_PRINTING) + printing::InitializePrinting(web_contents); +#endif + std::string name; options.Get("name", &name); diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index faf2f79b12..d3853d16ae 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -29,7 +29,6 @@ #include "base/time/default_tick_clock.h" #include "base/trace_event/trace_event.h" #include "browser/media/media_capture_devices_dispatcher.h" -#include "chrome/browser/browser_process_impl.h" #include "chrome/browser/browser_shutdown.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" @@ -49,6 +48,7 @@ #include "device/geolocation/geolocation_delegate.h" #include "device/geolocation/geolocation_provider.h" #include "muon/app/muon_crash_reporter_client.h" +#include "muon/browser/muon_browser_process_impl.h" #include "v8/include/v8.h" #include "v8/include/v8-debug.h" @@ -205,8 +205,10 @@ int AtomBrowserMainParts::PreCreateThreads() { { TRACE_EVENT0("startup", "AtomBrowserMainParts::PreCreateThreads:InitBrowswerProcessImpl"); + auto command_line = base::CommandLine::ForCurrentProcess(); fake_browser_process_.reset( - new BrowserProcessImpl(local_state_task_runner.get())); + new MuonBrowserProcessImpl(local_state_task_runner.get(), + *command_line)); } if (parsed_command_line_.HasSwitch(switches::kEnableProfiling)) { diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index 4cab21bebe..c3d21410df 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -20,8 +20,6 @@ #include "base/strings/utf_string_conversions.h" #include "brave/browser/brave_javascript_dialog_manager.h" #include "chrome/browser/certificate_viewer.h" -#include "chrome/browser/printing/print_preview_message_handler.h" -#include "chrome/browser/printing/print_view_manager_basic.h" #include "chrome/browser/ssl/security_state_tab_helper.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_dialogs.h" @@ -185,9 +183,6 @@ void CommonWebContentsDelegate::InitWithWebContents( browser_context_ = browser_context; web_contents->SetDelegate(this); - printing::PrintViewManagerBasic::CreateForWebContents(web_contents); - printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents); - // Create InspectableWebContents. web_contents_.reset(brightray::InspectableWebContents::Create(web_contents)); web_contents_->SetDelegate(this); diff --git a/atom/browser/importer/profile_writer.cc b/atom/browser/importer/profile_writer.cc index f9cb1eb0bd..dca5a523e8 100644 --- a/atom/browser/importer/profile_writer.cc +++ b/atom/browser/importer/profile_writer.cc @@ -17,7 +17,6 @@ #include "base/strings/utf_string_conversions.h" #include "brave/common/importer/imported_cookie_entry.h" #include "build/build_config.h" -#include "chrome/browser/browser_process_impl.h" #include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" @@ -27,6 +26,7 @@ #include "components/keyed_service/core/service_access_type.h" #include "components/password_manager/core/browser/password_manager.h" #include "content/public/browser/browser_thread.h" +#include "muon/browser/muon_browser_process_impl.h" #if defined(OS_WIN) #include "components/password_manager/core/browser/webdata/password_web_data_service_win.h" @@ -36,7 +36,7 @@ namespace importer { void ShowImportLockDialog(gfx::NativeWindow parent, const base::Callback& callback) { atom::api::App *app = - static_cast(g_browser_process)->app(); + static_cast(g_browser_process)->app(); if (app) { app->Emit("show-warning-dialog"); } diff --git a/brave/browser/BUILD.gn b/brave/browser/BUILD.gn index 73210951b9..f15c1f8486 100644 --- a/brave/browser/BUILD.gn +++ b/brave/browser/BUILD.gn @@ -44,9 +44,9 @@ source_set("browser") { deps = [ ":apis", "//electron/atom/browser", - "//electron/chromium_src:browser", "//electron:common", "//electron/muon/app", + "//electron/muon/browser", "//chrome/common", "//components/autofill/content/browser:risk_proto", "//components/autofill/content/browser", @@ -141,6 +141,7 @@ source_set("apis") { deps = [ "//electron/build/node", + "//electron/muon/browser", "//v8:v8", "//v8:v8_libplatform", "//third_party/WebKit/public:blink_headers", diff --git a/brave/browser/api/brave_api_component_updater.cc b/brave/browser/api/brave_api_component_updater.cc index 0d5af1ee40..3102e9235d 100644 --- a/brave/browser/api/brave_api_component_updater.cc +++ b/brave/browser/api/brave_api_component_updater.cc @@ -7,9 +7,9 @@ #include "base/base64.h" #include "brave/browser/component_updater/extension_installer_traits.h" #include "brave/browser/component_updater/widevine_cdm_component_installer.h" -#include "chrome/browser/browser_process_impl.h" #include "components/component_updater/component_updater_service.h" #include "components/update_client/crx_update_item.h" +#include "muon/browser/muon_browser_process_impl.h" #include "native_mate/dictionary.h" #include "atom/common/node_includes.h" @@ -35,7 +35,7 @@ component_updater::ComponentUpdateService* ComponentsUI::GetCUSForID( if (component_id == kWidevineId) { return g_browser_process->component_updater(); } - return static_cast(g_browser_process)-> + return static_cast(g_browser_process)-> brave_component_updater(); } @@ -85,7 +85,7 @@ void ComponentUpdater::RegisterComponentForUpdate( const base::Closure& registered_callback, const ReadyCallback& ready_callback) { brave::RegisterExtension( - static_cast(g_browser_process)-> + static_cast(g_browser_process)-> brave_component_updater(), public_key, registered_callback, ready_callback); } @@ -104,7 +104,7 @@ void ComponentUpdater::OnComponentReady( void ComponentUpdater::RegisterComponent(mate::Arguments* args) { static bool registeredObserver = false; if (!registeredObserver) { - static_cast(g_browser_process)-> + static_cast(g_browser_process)-> brave_component_updater()->AddObserver(this); g_browser_process->component_updater()->AddObserver(this); registeredObserver = true; @@ -151,7 +151,7 @@ std::vector ComponentUpdater::GetComponentIDs() { std::vector components = g_browser_process->component_updater()->GetComponentIDs(); std::vector brave_components = - static_cast(g_browser_process)-> + static_cast(g_browser_process)-> brave_component_updater()->GetComponentIDs(); components.insert(components.end(), brave_components.begin(), brave_components.end()); diff --git a/chromium_src/BUILD.gn b/chromium_src/BUILD.gn index 070a70c1f1..8694409df9 100644 --- a/chromium_src/BUILD.gn +++ b/chromium_src/BUILD.gn @@ -133,7 +133,9 @@ source_set("browser") { configs += [ "//electron/build:electron_config" ] configs += [ ":chromium_src_config" ] - public_deps = [] + public_deps = [ + "//content/public/browser", + ] deps = [ ":bookmarks", @@ -150,9 +152,11 @@ source_set("browser") { "//electron/brave/browser:tab_manager", "//base", "//chrome/common", + "//chrome/common:service_process_mojom", "//chrome/utility", "//components/certificate_transparency", "//components/crash/content/app", + "//components/crash/core/browser", "//components/data_usage/core", "//components/prefs", "//components/ssl_config", @@ -169,7 +173,7 @@ source_set("browser") { "//chrome/browser/browser_process.cc", "//chrome/browser/browser_process.h", "chrome/browser/browser_process_impl.cc", - "chrome/browser/browser_process_impl.h", + "//chrome/browser/browser_process_impl.h", "//chrome/browser/browser_shutdown.cc", "//chrome/browser/chrome_notification_types.h", "chrome/browser/custom_handlers/protocol_handler_registry.cc", @@ -193,6 +197,16 @@ source_set("browser") { "//chrome/browser/first_run/upgrade_util.h", "chrome/browser/first_run/upgrade_util.cc", + "//chrome/browser/gpu/gpu_mode_manager.cc", + "//chrome/browser/gpu/gpu_mode_manager.h", + + "//chrome/browser/icon_loader.cc", + "//chrome/browser/icon_loader.h", + "//chrome/browser/icon_loader_mac.mm", + "//chrome/browser/icon_loader_win.cc", + "//chrome/browser/icon_manager.cc", + "//chrome/browser/icon_manager.h", + "//chrome/browser/lifetime/keep_alive_registry.cc", "//chrome/browser/lifetime/keep_alive_registry.h", "//chrome/browser/lifetime/keep_alive_types.cc", @@ -202,6 +216,8 @@ source_set("browser") { "//chrome/browser/net/chrome_mojo_proxy_resolver_factory.cc", "//chrome/browser/net/chrome_mojo_proxy_resolver_factory.h", + "chrome/browser/net/system_network_context_manager.cc", + "//chrome/browser/net/system_network_context_manager.h", "//chrome/browser/prefs/chrome_command_line_pref_store.cc", "//chrome/browser/prefs/chrome_command_line_pref_store.h", @@ -249,26 +265,7 @@ source_set("browser") { "//chrome/browser/content_settings/cookie_settings_factory.h", "chrome/browser/content_settings/host_content_settings_map_factory.cc", "chrome/browser/content_settings/host_content_settings_map_factory.h", - "//chrome/browser/printing/print_job.cc", - "//chrome/browser/printing/print_job.h", - "//chrome/browser/printing/print_job_manager.cc", - "//chrome/browser/printing/print_job_manager.h", - "//chrome/browser/printing/print_job_worker.cc", - "//chrome/browser/printing/print_job_worker.h", - "//chrome/browser/printing/print_job_worker_owner.cc", - "//chrome/browser/printing/print_job_worker_owner.h", - "chrome/browser/printing/print_preview_message_handler.cc", - "chrome/browser/printing/print_preview_message_handler.h", - "//chrome/browser/printing/print_view_manager_base.cc", - "//chrome/browser/printing/print_view_manager_base.h", - "//chrome/browser/printing/print_view_manager_basic.cc", - "//chrome/browser/printing/print_view_manager_basic.h", - "//chrome/browser/printing/print_view_manager_common.cc", - "//chrome/browser/printing/print_view_manager_common.h", - "//chrome/browser/printing/printer_query.cc", - "//chrome/browser/printing/printer_query.h", - "//chrome/browser/printing/printing_message_filter.cc", - "//chrome/browser/printing/printing_message_filter.h", + "//chrome/browser/ssl/security_state_tab_helper.cc", "//chrome/browser/ssl/security_state_tab_helper.h", "//chrome/browser/tab_contents/tab_util.cc", @@ -278,6 +275,13 @@ source_set("browser") { "//chrome/browser/cache_stats_recorder.cc", "//chrome/browser/cache_stats_recorder.h", + + "//chrome/browser/upgrade_detector.cc", + "//chrome/browser/upgrade_detector.h", + "chrome/browser/upgrade_detector_impl.cc", + "//chrome/browser/service_process/service_process_control.cc", + "//chrome/browser/service_process/service_process_control.h", + "//chrome/browser/service_process/service_process_control_mac.mm", ] if (is_win || is_mac) { @@ -287,11 +291,6 @@ source_set("browser") { ] } - deps += [ - "//components/crash/content/app", - "//components/crash/core/browser", - ] - if (is_win) { sources += [ "//chrome/browser/win/browser_util.h", @@ -357,10 +356,51 @@ source_set("browser") { } if (enable_basic_printing || enable_print_preview) { + sources += [ + "//chrome/browser/printing/background_printing_manager.cc", + "//chrome/browser/printing/background_printing_manager.h", + "//chrome/browser/printing/print_job.cc", + "//chrome/browser/printing/print_job.h", + "//chrome/browser/printing/print_job_manager.cc", + "//chrome/browser/printing/print_job_manager.h", + "//chrome/browser/printing/print_job_worker.cc", + "//chrome/browser/printing/print_job_worker.h", + "//chrome/browser/printing/print_job_worker_owner.cc", + "//chrome/browser/printing/print_job_worker_owner.h", + "//chrome/browser/printing/print_view_manager_base.cc", + "//chrome/browser/printing/print_view_manager_base.h", + "//chrome/browser/printing/print_view_manager_basic.cc", + "//chrome/browser/printing/print_view_manager_basic.h", + "//chrome/browser/printing/print_view_manager_common.cc", + "//chrome/browser/printing/print_view_manager_common.h", + "//chrome/browser/printing/printer_query.cc", + "//chrome/browser/printing/printer_query.h", + "//chrome/browser/printing/printing_init.cc", + "//chrome/browser/printing/printing_init.h", + "//chrome/browser/printing/printing_message_filter.cc", + "//chrome/browser/printing/printing_message_filter.h", + ] deps += [ "//components/printing/browser", "//printing", ] + + if (enable_print_preview) { + sources += [ + "chrome/browser/printing/print_error_dialog.cc", + "//chrome/browser/printing/print_error_dialog.h", + "//chrome/browser/printing/print_preview_data_service.cc", + "//chrome/browser/printing/print_preview_data_service.h", + "chrome/browser/printing/print_preview_dialog_controller.cc", + "//chrome/browser/printing/print_preview_dialog_controller.h", + "chrome/browser/printing/print_preview_message_handler.cc", + "chrome/browser/printing/print_preview_message_handler.h", + "//chrome/browser/printing/print_view_manager.cc", + "//chrome/browser/printing/print_view_manager.h", + "chrome/browser/ui/webui/print_preview/print_preview_ui.cc", + "//chrome/browser/ui/webui/print_preview/print_preview_ui.h", + ] + } } if (enable_webrtc) { @@ -777,8 +817,12 @@ source_set("downloads") { configs += [ ":chromium_src_config" ] sources = [ + "chrome/browser/download/download_core_service.cc", + "//chrome/browser/download/download_core_service.h", "//chrome/browser/download/download_path_reservation_tracker.cc", "//chrome/browser/download/download_path_reservation_tracker.h", + "chrome/browser/download/download_request_limiter.cc", + "//chrome/browser/download/download_request_limiter.h", ] deps = [ @@ -899,8 +943,6 @@ source_set("lifetime") { configs += [ ":chromium_src_config" ] sources = [ - "chrome/browser/download/download_core_service.cc", - "//chrome/browser/download/download_core_service.h", "chrome/browser/lifetime/browser_close_manager.cc", "//chrome/browser/lifetime/browser_close_manager.h", "//chrome/browser/lifetime/termination_notification.cc", @@ -923,6 +965,7 @@ source_set("lifetime") { deps = [ "//base", ":sessions", + ":downloads", "//chrome/common", "//components/metrics", "//components/prefs", diff --git a/chromium_src/chrome/app/vector_icons/vector_icons.h b/chromium_src/chrome/app/vector_icons/vector_icons.h new file mode 100644 index 0000000000..9faf7c3b25 --- /dev/null +++ b/chromium_src/chrome/app/vector_icons/vector_icons.h @@ -0,0 +1,22 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// vector_icons.h.template is used to generate vector_icons.h. Edit the former +// rather than the latter. + +#ifndef CHROME_APP_VECTOR_ICONS_VECTOR_ICONS_H_ +#define CHROME_APP_VECTOR_ICONS_VECTOR_ICONS_H_ + +namespace gfx { +struct VectorIcon; +} + +#define VECTOR_ICON_TEMPLATE_H(icon_name) \ +extern const gfx::VectorIcon icon_name; + +VECTOR_ICON_TEMPLATE_H(kBrowserToolsUpdateIcon) + +#undef VECTOR_ICON_TEMPLATE_H + +#endif // CHROME_APP_VECTOR_ICONS_VECTOR_ICONS_H_ diff --git a/chromium_src/chrome/browser/browser_process_impl.cc b/chromium_src/chrome/browser/browser_process_impl.cc index 1dfc4c5aff..ccad579f71 100644 --- a/chromium_src/chrome/browser/browser_process_impl.cc +++ b/chromium_src/chrome/browser/browser_process_impl.cc @@ -4,8 +4,6 @@ #include "chrome/browser/browser_process_impl.h" -#include "atom/browser/api/atom_api_app.h" -#include "atom/browser/atom_resource_dispatcher_host_delegate.h" #include "base/base_switches.h" #include "base/command_line.h" #include "base/metrics/field_trial.h" @@ -14,13 +12,13 @@ #include "base/threading/thread_restrictions.h" #include "base/trace_event/trace_event.h" #include "brave/browser/brave_content_browser_client.h" -#include "brave/browser/component_updater/brave_component_updater_configurator.h" #include "brave/browser/resource_coordinator/guest_tab_manager.h" #include "chrome/browser/background/background_mode_manager.h" #include "chrome/browser/browser_shutdown.h" #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" #include "chrome/browser/notifications/notification_ui_manager_stub.h" #include "chrome/browser/prefs/chrome_command_line_pref_store.h" +#include "chrome/browser/printing/background_printing_manager.h" #include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/shell_integration.h" @@ -38,13 +36,44 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/render_process_host.h" -#include "content/public/browser/resource_dispatcher_host.h" #include "content/public/common/content_switches.h" #include "ppapi/features/features.h" #include "ui/base/idle/idle.h" #include "ui/base/l10n/l10n_util.h" #include "ui/message_center/message_center.h" +// these are just to satisfy build errors for unused vars in +// browser_process_imp.h +// they should be moved above if/when they are actually used +#include "chrome/browser/chrome_child_process_watcher.h" +#include "chrome/browser/chrome_device_client.h" +#include "chrome/browser/devtools/remote_debugging_server.h" +#include "chrome/browser/gpu/gpu_mode_manager.h" +#include "chrome/browser/gpu/gpu_profile_cache.h" +#include "chrome/browser/icon_manager.h" +#include "chrome/browser/intranet_redirect_detector.h" +#include "chrome/browser/io_thread.h" +#include "chrome/browser/media/webrtc/webrtc_log_uploader.h" +#include "chrome/browser/media_galleries/media_file_system_registry.h" +#include "chrome/browser/metrics/thread_watcher.h" +#include "chrome/browser/net/crl_set_fetcher.h" +#include "chrome/browser/notifications/notification_platform_bridge.h" +#include "chrome/browser/plugins/plugins_resource_service.h" +#include "chrome/browser/safe_browsing/safe_browsing_service.h" +#include "components/gcm_driver/gcm_driver.h" +#include "components/network_time/network_time_tracker.h" +#include "components/net_log/chrome_net_log.h" +#include "components/physical_web/data_source/physical_web_data_source.h" +#include "components/policy/core/browser/browser_policy_connector.h" +#include "components/subresource_filter/content/browser/content_ruleset_service.h" +#include "services/preferences/public/cpp/in_process_service_factory.h" +#include "chrome/browser/component_updater/supervised_user_whitelist_installer.h" +#include "chrome/browser/devtools/devtools_auto_opener.h" +#include "chrome/browser/download/download_request_limiter.h" +#include "chrome/browser/download/download_status_updater.h" +#include "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h" +#include "chrome/browser/printing/print_preview_dialog_controller.h" + #if BUILDFLAG(ENABLE_EXTENSIONS) #include "atom/browser/extensions/atom_extensions_browser_client.h" #include "chrome/browser/extensions/event_router_forwarder.h" @@ -89,13 +118,20 @@ using content::ChildProcessSecurityPolicy; using content::PluginService; BrowserProcessImpl::BrowserProcessImpl( - base::SequencedTaskRunner* local_state_task_runner) : - local_state_task_runner_(local_state_task_runner), - tearing_down_(false), + base::SequencedTaskRunner* local_state_task_runner, + const base::CommandLine& command_line) : + created_watchdog_thread_(false), + created_browser_policy_connector_(false), created_profile_manager_(false), - locale_(l10n_util::GetApplicationLocale("")) { - g_browser_process = this; - + created_icon_manager_(false), + created_notification_ui_manager_(false), + created_notification_bridge_(false), + created_safe_browsing_service_(false), + created_subresource_filter_ruleset_service_(false), + shutting_down_(false), + tearing_down_(false), + locale_(l10n_util::GetApplicationLocale("")), + local_state_task_runner_(local_state_task_runner) { print_job_manager_.reset(new printing::PrintJobManager); #if defined(OS_MACOSX) @@ -133,7 +169,7 @@ void BrowserProcessImpl::CreateProfileManager() { } ProfileManager* BrowserProcessImpl::profile_manager() { - DCHECK(thread_checker_.CalledOnValidThread()); + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!created_profile_manager_) CreateProfileManager(); return profile_manager_.get(); @@ -147,44 +183,13 @@ ukm::UkmRecorder* BrowserProcessImpl::ukm_recorder() { return nullptr; } -component_updater::ComponentUpdateService* -BrowserProcessImpl::component_updater( - std::unique_ptr &component_updater, - bool use_brave_server) { - if (!component_updater.get()) { - if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) - return NULL; - Profile* profile = ProfileManager::GetPrimaryUserProfile(); - scoped_refptr configurator = - component_updater::MakeBraveComponentUpdaterConfigurator( - base::CommandLine::ForCurrentProcess(), - profile->GetRequestContext(), - use_brave_server); - // Creating the component updater does not do anything, components - // need to be registered and Start() needs to be called. - component_updater.reset(component_updater::ComponentUpdateServiceFactory( - configurator).release()); - } - return component_updater.get(); -} - -component_updater::ComponentUpdateService* -BrowserProcessImpl::brave_component_updater() { - return component_updater(brave_component_updater_, true); -} - -component_updater::ComponentUpdateService* -BrowserProcessImpl::component_updater() { - return component_updater(component_updater_, false); -} - extensions::EventRouterForwarder* BrowserProcessImpl::extension_event_router_forwarder() { return extension_event_router_forwarder_.get(); } message_center::MessageCenter* BrowserProcessImpl::message_center() { - DCHECK(thread_checker_.CalledOnValidThread()); + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); return message_center::MessageCenter::Get(); } @@ -257,7 +262,7 @@ void BrowserProcessImpl::CreateLocalState() { } PrefService* BrowserProcessImpl::local_state() { - DCHECK(thread_checker_.CalledOnValidThread()); + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!local_state_) CreateLocalState(); return local_state_.get(); @@ -267,13 +272,6 @@ bool BrowserProcessImpl::IsShuttingDown() { return tearing_down_; } -void BrowserProcessImpl::ResourceDispatcherHostCreated() { - resource_dispatcher_host_delegate_.reset( - new atom::AtomResourceDispatcherHostDelegate); - content::ResourceDispatcherHost::Get()->SetDelegate( - resource_dispatcher_host_delegate_.get()); -} - void BrowserProcessImpl::PreCreateThreads() { #if BUILDFLAG(ENABLE_EXTENSIONS) // Disable Isolate Extensions by default @@ -312,7 +310,7 @@ void BrowserProcessImpl::PreMainMessageLoopRun() { } resource_coordinator::TabManager* BrowserProcessImpl::GetTabManager() { - DCHECK(thread_checker_.CalledOnValidThread()); + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) if (!tab_manager_.get()) tab_manager_.reset(new resource_coordinator::GuestTabManager()); @@ -484,7 +482,7 @@ void BrowserProcessImpl::CreateNotificationUIManager() { } NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { - DCHECK(thread_checker_.CalledOnValidThread()); + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!created_notification_ui_manager_) CreateNotificationUIManager(); return notification_ui_manager_.get(); @@ -551,10 +549,14 @@ BrowserProcessImpl::print_preview_dialog_controller() { return nullptr; } -printing::BackgroundPrintingManager* -BrowserProcessImpl::background_printing_manager() { +void BrowserProcessImpl::CreateBackgroundPrintingManager() { +#if BUILDFLAG(ENABLE_PRINT_PREVIEW) + DCHECK(!background_printing_manager_); + background_printing_manager_ = + base::MakeUnique(); +#else NOTIMPLEMENTED(); - return nullptr; +#endif } IntranetRedirectDetector* BrowserProcessImpl::intranet_redirect_detector() { @@ -577,9 +579,22 @@ DownloadRequestLimiter* BrowserProcessImpl::download_request_limiter() { return nullptr; } +printing::BackgroundPrintingManager* + BrowserProcessImpl::background_printing_manager() { +#if BUILDFLAG(ENABLE_PRINT_PREVIEW) + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + if (!background_printing_manager_) + CreateBackgroundPrintingManager(); + return background_printing_manager_.get(); +#else + NOTIMPLEMENTED(); + return NULL; +#endif +} + BackgroundModeManager* BrowserProcessImpl::background_mode_manager() { NOTIMPLEMENTED(); - return nullptr; + return NULL; } void BrowserProcessImpl::set_background_mode_manager_for_test( @@ -659,6 +674,12 @@ BrowserProcessImpl::GetPhysicalWebDataSource() { return nullptr; } +component_updater::ComponentUpdateService* +BrowserProcessImpl::component_updater() {} +void BrowserProcessImpl::OnKeepAliveStateChanged(bool is_keeping_alive) {} +void BrowserProcessImpl::OnKeepAliveRestartStateChanged(bool can_restart) {} +void BrowserProcessImpl::ResourceDispatcherHostCreated() {} + void BrowserProcessImpl::ApplyMetricsReportingPolicy() { bool enabled = ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); diff --git a/chromium_src/chrome/browser/browser_process_impl.h b/chromium_src/chrome/browser/browser_process_impl.h deleted file mode 100644 index 527f31e82d..0000000000 --- a/chromium_src/chrome/browser/browser_process_impl.h +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// When each service is created, we set a flag indicating this. At this point, -// the service initialization could fail or succeed. This allows us to remember -// if we tried to create a service, and not try creating it over and over if -// the creation failed. - -#ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ -#define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ - -#include - -#include -#include - -#include "base/debug/stack_trace.h" -#include "base/macros.h" -#include "base/memory/ref_counted.h" -#include "base/threading/thread_checker.h" -#include "build/build_config.h" -#include "chrome/browser/browser_process.h" -#include "components/prefs/pref_change_registrar.h" -#include "extensions/features/features.h" -#include "net/log/net_log.h" - -class TabManager; - -namespace atom { - -class AtomResourceDispatcherHostDelegate; - -namespace api { -class App; -} - -} // namespace atom - -namespace ukm { -class UkmRecorder; -} - -namespace base { -class SequencedTaskRunner; -} - -namespace chrome { -class ChromeNetLog; -} - -#if BUILDFLAG(ENABLE_EXTENSIONS) -namespace extensions { -class EventRouterForwarder; -class ExtensionsBrowserClient; -} -#endif - -// Real implementation of BrowserProcess that creates and returns the services. -class BrowserProcessImpl : public BrowserProcess { - public: - // |local_state_task_runner| must be a shutdown-blocking task runner. - BrowserProcessImpl(base::SequencedTaskRunner* local_state_task_runner); - ~BrowserProcessImpl() override; - - void PreCreateThreads(); - void PreMainMessageLoopRun(); - const std::string& GetApplicationLocale() override; - - printing::PrintJobManager* print_job_manager() override; - - bool IsShuttingDown(); - void StartTearDown(); - - void set_app(atom::api::App* app) { app_ = app; } - atom::api::App* app() { return app_; } - - void ResourceDispatcherHostCreated() override; - metrics::MetricsService* metrics_service() override; - PrefService* local_state() override; - ProfileManager* profile_manager() override; - ukm::UkmRecorder* ukm_recorder() override; - rappor::RapporServiceImpl* rappor_service() override; - component_updater::ComponentUpdateService* brave_component_updater(); - component_updater::ComponentUpdateService* component_updater() override; - extensions::EventRouterForwarder* - extension_event_router_forwarder() override; - resource_coordinator::TabManager* GetTabManager() override; - StatusTray* status_tray() override; - message_center::MessageCenter* message_center() override; - void FlushLocalStateAndReply(base::OnceClosure reply) override; - net_log::ChromeNetLog* net_log() override; - - // NOTIMPLEMENTED - void EndSession() override; - metrics_services_manager::MetricsServicesManager* - GetMetricsServicesManager() override; - net::URLRequestContextGetter* system_request_context() override; - variations::VariationsService* variations_service() override; - BrowserProcessPlatformPart* platform_part() override; - NotificationUIManager* notification_ui_manager() override; - NotificationPlatformBridge* notification_platform_bridge() override; - IOThread* io_thread() override; - SystemNetworkContextManager* system_network_context_manager() override; - WatchDogThread* watchdog_thread() override; - policy::BrowserPolicyConnector* browser_policy_connector() override; - policy::PolicyService* policy_service() override; - IconManager* icon_manager() override; - GpuModeManager* gpu_mode_manager() override; - GpuProfileCache* gpu_profile_cache() override; - void CreateDevToolsHttpProtocolHandler(const std::string& ip, - uint16_t port) override; - void CreateDevToolsAutoOpener() override; - printing::PrintPreviewDialogController* print_preview_dialog_controller() - override; - printing::BackgroundPrintingManager* background_printing_manager() override; - IntranetRedirectDetector* intranet_redirect_detector() override; - void SetApplicationLocale(const std::string& locale) override; - DownloadStatusUpdater* download_status_updater() override; - DownloadRequestLimiter* download_request_limiter() override; - BackgroundModeManager* background_mode_manager() override; - void set_background_mode_manager_for_test( - std::unique_ptr manager) override; - safe_browsing::SafeBrowsingService* safe_browsing_service() override; - safe_browsing::ClientSideDetectionService* safe_browsing_detection_service() - override; - subresource_filter::ContentRulesetService* subresource_filter_ruleset_service() - override; - CRLSetFetcher* crl_set_fetcher() override; - component_updater::PnaclComponentInstaller* pnacl_component_installer() - override; - component_updater::SupervisedUserWhitelistInstaller* - supervised_user_whitelist_installer() override; - MediaFileSystemRegistry* media_file_system_registry() override; -#if BUILDFLAG(ENABLE_WEBRTC) - WebRtcLogUploader* webrtc_log_uploader() override; -#endif - network_time::NetworkTimeTracker* network_time_tracker() override; - gcm::GCMDriver* gcm_driver() override; - shell_integration::DefaultWebClientState CachedDefaultWebClientState() - override; - physical_web::PhysicalWebDataSource* GetPhysicalWebDataSource() override; -#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) - void StartAutoupdateTimer() override; -#endif - prefs::InProcessPrefServiceFactory* pref_service_factory() const override; - - private: - base::ThreadChecker thread_checker_; - - void CreateLocalState(); - void CreateProfileManager(); - void CreateStatusTray(); - void CreateNotificationUIManager(); - void ApplyMetricsReportingPolicy(); - - std::unique_ptr - metrics_services_manager_; - - const scoped_refptr local_state_task_runner_; - PrefChangeRegistrar pref_change_registrar_; - - bool tearing_down_; - bool created_profile_manager_; - - std::unique_ptr print_job_manager_; -#if BUILDFLAG(ENABLE_EXTENSIONS) - scoped_refptr - extension_event_router_forwarder_; - std::unique_ptr extensions_browser_client_; -#endif - - bool created_notification_ui_manager_; - std::unique_ptr notification_ui_manager_; - - std::string locale_; - - std::unique_ptr profile_manager_; - - atom::api::App* app_; // not owned - - std::unique_ptr - resource_dispatcher_host_delegate_; - - std::unique_ptr - brave_component_updater_; - std::unique_ptr - component_updater_; - component_updater::ComponentUpdateService* component_updater( - std::unique_ptr &, - bool use_brave_server); - -#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) - // Any change to this #ifdef must be reflected as well in - // chrome/browser/resource_coordinator/tab_manager_browsertest.cc - std::unique_ptr tab_manager_; -#endif - - std::unique_ptr local_state_; - - DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl); -}; - -#endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ diff --git a/chromium_src/chrome/browser/download/download_request_limiter.cc b/chromium_src/chrome/browser/download/download_request_limiter.cc new file mode 100644 index 0000000000..51ba02f60f --- /dev/null +++ b/chromium_src/chrome/browser/download/download_request_limiter.cc @@ -0,0 +1,8 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/download/download_request_limiter.h" + +DownloadRequestLimiter::DownloadRequestLimiter() : factory_(this) {} +DownloadRequestLimiter::~DownloadRequestLimiter() {} diff --git a/chromium_src/chrome/browser/net/system_network_context_manager.cc b/chromium_src/chrome/browser/net/system_network_context_manager.cc new file mode 100644 index 0000000000..2ef938c14e --- /dev/null +++ b/chromium_src/chrome/browser/net/system_network_context_manager.cc @@ -0,0 +1,8 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/net/system_network_context_manager.h" + +SystemNetworkContextManager::SystemNetworkContextManager() {} +SystemNetworkContextManager::~SystemNetworkContextManager() {} diff --git a/chromium_src/chrome/browser/printing/print_error_dialog.cc b/chromium_src/chrome/browser/printing/print_error_dialog.cc new file mode 100644 index 0000000000..091fb282e3 --- /dev/null +++ b/chromium_src/chrome/browser/printing/print_error_dialog.cc @@ -0,0 +1,11 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/printing/print_error_dialog.h" + +namespace chrome { + +void ShowPrintErrorDialog() {} + +} // namespace chrome diff --git a/chromium_src/chrome/browser/printing/print_preview_dialog_controller.cc b/chromium_src/chrome/browser/printing/print_preview_dialog_controller.cc new file mode 100644 index 0000000000..ac7fd4eba7 --- /dev/null +++ b/chromium_src/chrome/browser/printing/print_preview_dialog_controller.cc @@ -0,0 +1,56 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/printing/print_preview_dialog_controller.h" + +#include + +#include +#include +#include + +#include "base/macros.h" +#include "build/build_config.h" +#include "chrome/browser/printing/print_view_manager.h" +#include "chrome/common/url_constants.h" +#include "content/public/browser/web_contents.h" + +using content::WebContents; + +namespace printing { + +PrintPreviewDialogController::PrintPreviewDialogController() + : waiting_for_new_preview_page_(false), + is_creating_print_preview_dialog_(false) {} + +// static +PrintPreviewDialogController* PrintPreviewDialogController::GetInstance() { + return nullptr; +} + +// static +void PrintPreviewDialogController::PrintPreview(WebContents* initiator) { + if (initiator->ShowingInterstitialPage() || initiator->IsCrashed()) + return; + + PrintViewManager* print_view_manager = + PrintViewManager::FromWebContents(initiator); + if (print_view_manager) + print_view_manager->PrintPreviewDone(); +} + +WebContents* PrintPreviewDialogController::GetPrintPreviewForContents( + WebContents* contents) const { + return nullptr; +} + +// static +bool PrintPreviewDialogController::IsPrintPreviewURL(const GURL& url) { + return (url.SchemeIs(content::kChromeUIScheme) && + url.host_piece() == chrome::kChromeUIPrintHost); +} + +PrintPreviewDialogController::~PrintPreviewDialogController() {} + +} // namespace printing diff --git a/chromium_src/chrome/browser/printing/print_preview_message_handler.cc b/chromium_src/chrome/browser/printing/print_preview_message_handler.cc index 56bcd916c7..bb544de0a5 100644 --- a/chromium_src/chrome/browser/printing/print_preview_message_handler.cc +++ b/chromium_src/chrome/browser/printing/print_preview_message_handler.cc @@ -15,6 +15,7 @@ #include "base/memory/shared_memory.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/printing/print_job_manager.h" +#include "chrome/browser/printing/print_view_manager.h" #include "chrome/browser/printing/printer_query.h" #include "components/printing/common/print_messages.h" #include "content/public/browser/browser_thread.h" @@ -68,12 +69,12 @@ char* CopyPDFDataOnIOThread( PrintPreviewMessageHandler::PrintPreviewMessageHandler( WebContents* web_contents) - : content::WebContentsObserver(web_contents) { + : content::WebContentsObserver(web_contents), + weak_ptr_factory_(this) { DCHECK(web_contents); } -PrintPreviewMessageHandler::~PrintPreviewMessageHandler() { -} +PrintPreviewMessageHandler::~PrintPreviewMessageHandler() {} void PrintPreviewMessageHandler::OnMetafileReadyForPrinting( const PrintHostMsg_DidPreviewDocument_Params& params) { @@ -90,7 +91,7 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting( FROM_HERE, base::Bind(&CopyPDFDataOnIOThread, params), base::Bind(&PrintPreviewMessageHandler::RunPrintToPDFCallback, - base::Unretained(this), + weak_ptr_factory_.GetWeakPtr(), params.preview_request_id, params.data_size)); } @@ -102,7 +103,17 @@ void PrintPreviewMessageHandler::OnPrintPreviewFailed(int document_cookie) { bool PrintPreviewMessageHandler::OnMessageReceived( const IPC::Message& message, content::RenderFrameHost* render_frame_host) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(PrintPreviewMessageHandler, message, + render_frame_host) + IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview, + OnRequestPrintPreview) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + if (handled) + return true; + IPC_BEGIN_MESSAGE_MAP(PrintPreviewMessageHandler, message) IPC_MESSAGE_HANDLER(PrintHostMsg_MetafileReadyForPrinting, OnMetafileReadyForPrinting) @@ -113,17 +124,34 @@ bool PrintPreviewMessageHandler::OnMessageReceived( return handled; } +void PrintPreviewMessageHandler::OnRequestPrintPreview( + content::RenderFrameHost* render_frame_host, + const PrintHostMsg_RequestPrintPreview_Params& params) { + if (params.webnode_only) { + PrintViewManager::FromWebContents(web_contents())->PrintPreviewForWebNode( + render_frame_host); + } +} + void PrintPreviewMessageHandler::PrintToPDF( const base::DictionaryValue& options, const atom::api::WebContents::PrintToPDFCallback& callback) { - int request_id; + PrintViewManager::FromWebContents(web_contents())->PrintPreviewNow( + web_contents()->GetMainFrame(), false); + + int request_id = -1; options.GetInteger(kPreviewRequestID, &request_id); print_to_pdf_callback_map_[request_id] = callback; - content::RenderFrameHost* rfh = web_contents()->GetMainFrame(); + WebContents* initiator = web_contents(); + content::RenderFrameHost* rfh = + initiator + ? PrintViewManager::FromWebContents(initiator)->print_preview_rfh() + : nullptr; if (rfh) { std::unique_ptr new_options(options.DeepCopy()); + new_options->SetBoolean(printing::kSettingPrintToPDF, true); new_options->SetInteger(kPreviewInitiatorHostId, rfh->GetProcess()->GetID()); new_options->SetInteger(kPreviewInitiatorRoutingId, @@ -150,6 +178,11 @@ void PrintPreviewMessageHandler::RunPrintToPDFCallback( v8::Exception::Error(error_message), v8::Null(isolate)); } print_to_pdf_callback_map_.erase(request_id); + + auto manager = PrintViewManager::FromWebContents(web_contents()); + if (manager) { + manager->PrintPreviewDone(); + } } } // namespace printing diff --git a/chromium_src/chrome/browser/printing/print_preview_message_handler.h b/chromium_src/chrome/browser/printing/print_preview_message_handler.h index 981a98f0ed..3775bcfb1c 100644 --- a/chromium_src/chrome/browser/printing/print_preview_message_handler.h +++ b/chromium_src/chrome/browser/printing/print_preview_message_handler.h @@ -13,6 +13,7 @@ #include "content/public/browser/web_contents_user_data.h" struct PrintHostMsg_DidPreviewDocument_Params; +struct PrintHostMsg_RequestPrintPreview_Params; namespace content { class WebContents; @@ -44,6 +45,9 @@ class PrintPreviewMessageHandler friend class content::WebContentsUserData; // Message handlers. + void OnRequestPrintPreview( + content::RenderFrameHost* render_frame_host, + const PrintHostMsg_RequestPrintPreview_Params& params); void OnMetafileReadyForPrinting( const PrintHostMsg_DidPreviewDocument_Params& params); void OnPrintPreviewFailed(int document_cookie); @@ -52,6 +56,8 @@ class PrintPreviewMessageHandler PrintToPDFCallbackMap print_to_pdf_callback_map_; + base::WeakPtrFactory weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(PrintPreviewMessageHandler); }; diff --git a/chromium_src/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chromium_src/chrome/browser/ui/webui/print_preview/print_preview_ui.cc new file mode 100644 index 0000000000..24d644b194 --- /dev/null +++ b/chromium_src/chrome/browser/ui/webui/print_preview/print_preview_ui.cc @@ -0,0 +1,18 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" + +// static +void PrintPreviewUI::GetCurrentPrintPreviewStatus(int32_t preview_ui_id, + int request_id, + bool* cancel) { + // TODO(bridiver) - need a real implementation of this + return; +} + +// static +void PrintPreviewUI::SetInitialParams( + content::WebContents* print_preview_dialog, + const PrintHostMsg_RequestPrintPreview_Params& params) {} diff --git a/chromium_src/chrome/browser/upgrade_detector_impl.cc b/chromium_src/chrome/browser/upgrade_detector_impl.cc new file mode 100644 index 0000000000..c414a80de8 --- /dev/null +++ b/chromium_src/chrome/browser/upgrade_detector_impl.cc @@ -0,0 +1,11 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/upgrade_detector.h" + +// static +UpgradeDetector* UpgradeDetector::GetInstance() { + static auto* const instance = new UpgradeDetector(); + return instance; +} diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 2e400a57de..7c893f10b7 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -129,6 +129,8 @@ WebContents.prototype.attach = function(windowId, cb) { // Translate the options of printToPDF. WebContents.prototype.printToPDF = function (options, callback) { const printingSetting = Object.assign({}, defaultPrintingSetting) + printingSetting.previewUIID = getNextId() + if (options.landscape) { printingSetting.landscape = options.landscape } diff --git a/muon/browser/BUILD.gn b/muon/browser/BUILD.gn new file mode 100644 index 0000000000..1061261ddc --- /dev/null +++ b/muon/browser/BUILD.gn @@ -0,0 +1,16 @@ +import("//printing/features/features.gni") + +source_set("browser") { + public_configs = [ + "//electron/build:electron_config", + ] + + sources = [ + "muon_browser_process_impl.cc", + "muon_browser_process_impl.h", + ] + + public_deps = [ + "//electron/chromium_src:browser", + ] +} diff --git a/muon/browser/muon_browser_process_impl.cc b/muon/browser/muon_browser_process_impl.cc new file mode 100644 index 0000000000..0d61739fdb --- /dev/null +++ b/muon/browser/muon_browser_process_impl.cc @@ -0,0 +1,62 @@ +// Copyright (c) 2017 The Brave Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "muon/browser/muon_browser_process_impl.h" + +#include "atom/browser/api/atom_api_app.h" +#include "atom/browser/atom_resource_dispatcher_host_delegate.h" +#include "brave/browser/component_updater/brave_component_updater_configurator.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_manager.h" +#include "components/component_updater/component_updater_service.h" +#include "content/public/browser/resource_dispatcher_host.h" + +MuonBrowserProcessImpl::MuonBrowserProcessImpl( + base::SequencedTaskRunner* local_state_task_runner, + const base::CommandLine& command_line) : + BrowserProcessImpl(local_state_task_runner, command_line) { + g_browser_process = this; +} + +MuonBrowserProcessImpl::~MuonBrowserProcessImpl() { + g_browser_process = NULL; +} + +component_updater::ComponentUpdateService* +MuonBrowserProcessImpl::component_updater( + std::unique_ptr &component_updater, + bool use_brave_server) { + if (!component_updater.get()) { + if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) + return NULL; + Profile* profile = ProfileManager::GetPrimaryUserProfile(); + scoped_refptr configurator = + component_updater::MakeBraveComponentUpdaterConfigurator( + base::CommandLine::ForCurrentProcess(), + profile->GetRequestContext(), + use_brave_server); + // Creating the component updater does not do anything, components + // need to be registered and Start() needs to be called. + component_updater.reset(component_updater::ComponentUpdateServiceFactory( + configurator).release()); + } + return component_updater.get(); +} + +component_updater::ComponentUpdateService* +MuonBrowserProcessImpl::brave_component_updater() { + return component_updater(brave_component_updater_, true); +} + +component_updater::ComponentUpdateService* +MuonBrowserProcessImpl::component_updater() { + return component_updater(component_updater_, false); +} + +void MuonBrowserProcessImpl::ResourceDispatcherHostCreated() { + resource_dispatcher_host_delegate_.reset( + new atom::AtomResourceDispatcherHostDelegate); + content::ResourceDispatcherHost::Get()->SetDelegate( + resource_dispatcher_host_delegate_.get()); +} diff --git a/muon/browser/muon_browser_process_impl.h b/muon/browser/muon_browser_process_impl.h new file mode 100644 index 0000000000..5d4de792fe --- /dev/null +++ b/muon/browser/muon_browser_process_impl.h @@ -0,0 +1,52 @@ +// Copyright (c) 2017 The Brave Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MUON_BROWSER_MUON_BROWSER_PROCESS_IMPL_H_ +#define MUON_BROWSER_MUON_BROWSER_PROCESS_IMPL_H_ + +#include "build/build_config.h" +#include "chrome/browser/browser_process_impl.h" + +namespace atom { +namespace api { +class App; +} +} // namespace atom + +namespace atom { +class AtomResourceDispatcherHostDelegate; +} + +// Real implementation of BrowserProcess that creates and returns the services. +class MuonBrowserProcessImpl : public BrowserProcessImpl { + public: + MuonBrowserProcessImpl(base::SequencedTaskRunner* local_state_task_runner, + const base::CommandLine& command_line); + ~MuonBrowserProcessImpl() override; + + void set_app(atom::api::App* app) { app_ = app; } + atom::api::App* app() { return app_; } + + component_updater::ComponentUpdateService* brave_component_updater(); + component_updater::ComponentUpdateService* component_updater() override; + + void ResourceDispatcherHostCreated() override; + private: + atom::api::App* app_; // not owned + + std::unique_ptr + resource_dispatcher_host_delegate_; + + std::unique_ptr + brave_component_updater_; + std::unique_ptr + component_updater_; + component_updater::ComponentUpdateService* component_updater( + std::unique_ptr &, + bool use_brave_server); + + DISALLOW_COPY_AND_ASSIGN(MuonBrowserProcessImpl); +}; + +#endif // MUON_BROWSER_MUON_BROWSER_PROCESS_IMPL_H_ diff --git a/patches/master_patch.patch b/patches/master_patch.patch index cd2685a213..8346839623 100644 --- a/patches/master_patch.patch +++ b/patches/master_patch.patch @@ -654,26 +654,6 @@ index cca3bbb41ae25484c3e87c9aba09a8b07741e2b2..57abbcfd90dab7bbf1b5dffc35b17d3a const char* outer_app_dir_c = outer_app_dir.value().c_str(); NSString* outer_app_dir_ns = [NSString stringWithUTF8String:outer_app_dir_c]; -diff --git a/chrome/common/chrome_utility_printing_messages.h b/chrome/common/chrome_utility_printing_messages.h -index f5712a7a5bb8fabf279088631141cad405c8be8d..da8ff4065d721d49c1ca443a5c64c45e9f59ca4d 100644 ---- a/chrome/common/chrome_utility_printing_messages.h -+++ b/chrome/common/chrome_utility_printing_messages.h -@@ -26,7 +26,6 @@ - #define IPC_MESSAGE_START ChromeUtilityPrintingMsgStart - - // Preview and Cloud Print messages. --#if BUILDFLAG(ENABLE_PRINT_PREVIEW) - IPC_ENUM_TRAITS_MAX_VALUE(printing::PdfRenderSettings::Mode, - printing::PdfRenderSettings::Mode::LAST) - -@@ -44,6 +43,7 @@ IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults) - IPC_STRUCT_TRAITS_MEMBER(printer_defaults) - IPC_STRUCT_TRAITS_MEMBER(defaults_mime_type) - IPC_STRUCT_TRAITS_END() -+#if BUILDFLAG(ENABLE_PRINT_PREVIEW) - - IPC_ENUM_TRAITS_MAX_VALUE(printing::ColorModel, printing::PROCESSCOLORMODEL_RGB) - diff --git a/chrome/common/chrome_version.h.in b/chrome/common/chrome_version.h.in index f0a0bcd0098ec31b18bb00588ad8fd11b439fd6f..888572f87a71e6e8444bd6a302343e453aef4287 100644 --- a/chrome/common/chrome_version.h.in @@ -1318,68 +1298,6 @@ index 2b38db266f9aa1f4141c8649c021042ede4e5589..ea0387b11f4b00f87596d738c152aa4c OSStatus error = keychain_.FindGenericPassword( nullptr, strlen(service_name), service_name, strlen(account_name), account_name, &password_length, &password_data, NULL); -diff --git a/components/printing/common/print_messages.h b/components/printing/common/print_messages.h -index f9b1daf905f2d9a9eae724ebea0ab1f0e36e2707..ba4d6c91c7c4bfa02c20aee934890e0263f4804b 100644 ---- a/components/printing/common/print_messages.h -+++ b/components/printing/common/print_messages.h -@@ -221,7 +221,6 @@ IPC_STRUCT_TRAITS_BEGIN(PrintMsg_PrintPages_Params) - IPC_STRUCT_TRAITS_MEMBER(pages) - IPC_STRUCT_TRAITS_END() - --#if BUILDFLAG(ENABLE_PRINT_PREVIEW) - // Parameters to describe a rendered document. - IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params) - // A shared memory handle to metafile data. -@@ -243,6 +242,7 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params) - IPC_STRUCT_MEMBER(int, preview_request_id) - IPC_STRUCT_END() - -+#if BUILDFLAG(ENABLE_PRINT_PREVIEW) - // Parameters to describe a rendered preview page. - IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewPage_Params) - // A shared memory handle to metafile data for a draft document of the page. -@@ -348,13 +348,11 @@ IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone, - // Tells the RenderFrame whether printing is enabled or not. - IPC_MESSAGE_ROUTED1(PrintMsg_SetPrintingEnabled, bool /* enabled */) - --#if BUILDFLAG(ENABLE_PRINT_PREVIEW) - // Tells the RenderFrame to switch the CSS to print media type, renders every - // requested pages for print preview using the given |settings|. This gets - // called multiple times as the user updates settings. - IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview, - base::DictionaryValue /* settings */) --#endif - - // Messages sent from the renderer to the browser. - -@@ -439,13 +437,13 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_CheckForCancel, - int32_t /* PrintPreviewUI ID */, - int /* request id */, - bool /* print preview cancelled */) -+#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) - - // Sends back to the browser the complete rendered document (non-draft mode, - // used for printing) that was requested by a PrintMsg_PrintPreview message. - // The memory handle in this message is already valid in the browser process. - IPC_MESSAGE_ROUTED1(PrintHostMsg_MetafileReadyForPrinting, - PrintHostMsg_DidPreviewDocument_Params /* params */) --#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) - - // This is sent when there are invalid printer settings. - IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError) -@@ -454,11 +452,11 @@ IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError) - IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed, - int /* document cookie */) - --#if BUILDFLAG(ENABLE_PRINT_PREVIEW) - // Tell the browser print preview failed. - IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewFailed, - int /* document cookie */) - -+#if BUILDFLAG(ENABLE_PRINT_PREVIEW) - // Tell the browser print preview was cancelled. - IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewCancelled, - int /* document cookie */) diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc index 14ae19e07b467963ce5cac98d08495387892022e..a8d5610ad1ac2c864d563e4bdb65135216a35bfd 100644 --- a/content/app/content_main_runner.cc