From 9e2dc66d051878d8eb7ab41d66d4e8228b5c336e Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Thu, 18 Oct 2018 02:36:15 +0200 Subject: [PATCH] refactor: eliminate brightray --- .gitignore | 7 - BUILD.gn | 7 +- atom/app/atom_content_client.cc | 18 + atom/app/atom_content_client.h | 8 +- atom/app/atom_library_main.mm | 4 +- atom/app/atom_main_delegate.cc | 79 ++++- atom/app/atom_main_delegate.h | 19 +- atom/app/atom_main_delegate_mac.mm | 11 +- atom/browser/api/atom_api_app.cc | 14 +- atom/browser/api/atom_api_session.cc | 4 +- atom/browser/api/atom_api_web_contents.h | 4 +- atom/browser/atom_browser_client.cc | 64 +++- atom/browser/atom_browser_client.h | 17 +- atom/browser/atom_browser_context.cc | 24 +- atom/browser/atom_browser_context.h | 4 +- atom/browser/atom_browser_main_parts.cc | 303 ++++++++++++++-- atom/browser/atom_browser_main_parts.h | 26 +- atom/browser/atom_browser_main_parts_mac.mm | 32 +- .../browser/atom_paths.h | 10 +- atom/browser/browser.cc | 14 +- atom/browser/browser_linux.cc | 6 +- atom/browser/browser_mac.mm | 6 +- atom/browser/browser_win.cc | 8 +- atom/browser/common_web_contents_delegate.h | 4 +- .../media/media_capture_devices_dispatcher.cc | 6 +- .../media/media_capture_devices_dispatcher.h | 10 +- .../browser/media/media_device_id_salt.cc | 9 +- .../browser/media/media_device_id_salt.h | 10 +- .../media/media_stream_devices_controller.cc | 8 +- .../media/media_stream_devices_controller.h | 10 +- atom/browser/net/atom_cert_verifier.cc | 4 +- atom/browser/net/atom_cert_verifier.h | 13 +- .../browser/net/require_ct_delegate.cc | 6 +- .../browser/net/require_ct_delegate.h | 10 +- .../browser/net/url_request_context_getter.cc | 6 +- atom/browser/net/url_request_context_getter.h | 7 +- .../linux/libnotify_notification.cc | 8 +- .../win/windows_toast_notification.cc | 8 +- .../bry_inspectable_web_contents_view.mm | 2 +- atom/browser/ui/devtools_manager_delegate.cc | 1 - .../ui/inspectable_web_contents_impl.cc | 6 +- atom/browser/ui/tray_icon_gtk.cc | 4 +- .../browser/web_contents_permission_helper.cc | 5 +- .../browser/win/scoped_hstring.cc | 6 +- .../browser/win/scoped_hstring.h | 10 +- .../browser/zoom_level_delegate.cc | 6 +- .../browser/zoom_level_delegate.h | 10 +- atom/common/api/atom_bindings.cc | 4 +- .../common/application_info.cc | 10 +- {brightray => atom}/common/application_info.h | 16 +- ...tion_info.cc => application_info_linux.cc} | 10 +- .../common/application_info_mac.mm | 12 +- .../common/application_info_win.cc | 12 +- atom/common/mac/main_application_bundle.h | 26 ++ .../common/mac/main_application_bundle.mm | 6 +- atom/common/platform_util.h | 6 + atom/common/platform_util_linux.cc | 15 + .../atom_sandboxed_renderer_client.cc | 4 +- brightray/BUILD.gn | 53 --- brightray/CPPLINT.cfg | 1 - brightray/LICENSE | 19 - brightray/LICENSE-CHROMIUM | 27 -- brightray/browser/browser_client.cc | 90 ----- brightray/browser/browser_client.h | 51 --- brightray/browser/browser_main_parts.cc | 326 ------------------ brightray/browser/browser_main_parts.h | 62 ---- brightray/browser/browser_main_parts_mac.mm | 37 -- brightray/common/content_client.cc | 61 ---- brightray/common/content_client.h | 36 -- .../common/mac/main_application_bundle.h | 21 -- brightray/common/main_delegate.cc | 116 ------- brightray/common/main_delegate.h | 65 ---- brightray/common/main_delegate_mac.mm | 47 --- brightray/common/platform_util.h | 24 -- brightray/common/platform_util_linux.cc | 30 -- docs/development/build-system-overview.md | 3 +- .../development/debug-instructions-windows.md | 3 +- .../debugging-instructions-macos.md | 3 +- docs/development/pull-requests.md | 2 +- .../source-code-directory-structure.md | 1 - docs/glossary.md | 8 +- filenames.gni | 20 ++ package.json | 6 +- patches/common/chromium/.patches.yaml | 2 +- patches/common/chromium/gtk_visibility.patch | 9 +- script/lint.js | 2 +- 86 files changed, 781 insertions(+), 1323 deletions(-) rename brightray/browser/brightray_paths.h => atom/browser/atom_paths.h (82%) rename {brightray => atom}/browser/media/media_capture_devices_dispatcher.cc (97%) rename {brightray => atom}/browser/media/media_capture_devices_dispatcher.h (92%) rename {brightray => atom}/browser/media/media_device_id_salt.cc (88%) rename {brightray => atom}/browser/media/media_device_id_salt.h (80%) rename {brightray => atom}/browser/media/media_stream_devices_controller.cc (97%) rename {brightray => atom}/browser/media/media_stream_devices_controller.h (82%) rename {brightray => atom}/browser/net/require_ct_delegate.cc (90%) rename {brightray => atom}/browser/net/require_ct_delegate.h (78%) rename {brightray => atom}/browser/win/scoped_hstring.cc (90%) rename {brightray => atom}/browser/win/scoped_hstring.h (82%) rename {brightray => atom}/browser/zoom_level_delegate.cc (98%) rename {brightray => atom}/browser/zoom_level_delegate.h (90%) rename {brightray => atom}/common/application_info.cc (73%) rename {brightray => atom}/common/application_info.h (61%) rename atom/common/{linux/application_info.cc => application_info_linux.cc} (89%) rename {brightray => atom}/common/application_info_mac.mm (70%) rename {brightray => atom}/common/application_info_win.cc (92%) create mode 100644 atom/common/mac/main_application_bundle.h rename {brightray => atom}/common/mac/main_application_bundle.mm (94%) delete mode 100644 brightray/BUILD.gn delete mode 100644 brightray/CPPLINT.cfg delete mode 100644 brightray/LICENSE delete mode 100644 brightray/LICENSE-CHROMIUM delete mode 100644 brightray/browser/browser_client.cc delete mode 100644 brightray/browser/browser_client.h delete mode 100644 brightray/browser/browser_main_parts.cc delete mode 100644 brightray/browser/browser_main_parts.h delete mode 100644 brightray/browser/browser_main_parts_mac.mm delete mode 100644 brightray/common/content_client.cc delete mode 100644 brightray/common/content_client.h delete mode 100644 brightray/common/mac/main_application_bundle.h delete mode 100644 brightray/common/main_delegate.cc delete mode 100644 brightray/common/main_delegate.h delete mode 100644 brightray/common/main_delegate_mac.mm delete mode 100644 brightray/common/platform_util.h delete mode 100644 brightray/common/platform_util_linux.cc diff --git a/.gitignore b/.gitignore index 63272ea1e3fb0..fab8743120908 100644 --- a/.gitignore +++ b/.gitignore @@ -16,13 +16,6 @@ *.vcxproj.user *.xcodeproj /.idea/ -/brightray/brightray.opensdf -/brightray/brightray.sdf -/brightray/brightray.sln -/brightray/brightray.suo -/brightray/brightray.v12.suo -/brightray/brightray.vcxproj* -/brightray/brightray.xcodeproj/ /dist/ /external_binaries/ /out/ diff --git a/BUILD.gn b/BUILD.gn index 16479b4ed6d1d..92db789eccfb9 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -4,6 +4,7 @@ import("buildflags/buildflags.gni") import("electron_paks.gni") import("filenames.gni") import("//build/config/locales.gni") +import("//build/config/ui.gni") import("//build/config/win/manifest.gni") import("//pdf/features.gni") import("//services/service_manager/public/service_manifest.gni") @@ -200,11 +201,11 @@ static_library("electron_lib") { deps = [ ":atom_js2c", - "brightray", "buildflags", "chromium_src:chrome", "native_mate", "//base", + "//base:base_static", "//base:i18n", "//chrome/common", "//components/certificate_transparency", @@ -213,11 +214,15 @@ static_library("electron_lib") { "//components/prefs", "//components/viz/service", "//content/public/app:both", + "//content/public/browser", "//content/public/child", "//content/public/common:service_names", + "//content/shell:copy_shell_resources", "//gin", "//media/mojo/interfaces", + "//net:extras", "//net:net_resources", + "//net:net_with_v8", "//ppapi/host", "//ppapi/proxy", "//ppapi/shared_impl", diff --git a/atom/app/atom_content_client.cc b/atom/app/atom_content_client.cc index 4107656c52afe..f7fb4bb3cf687 100644 --- a/atom/app/atom_content_client.cc +++ b/atom/app/atom_content_client.cc @@ -21,6 +21,7 @@ #include "electron/buildflags/buildflags.h" #include "ppapi/shared_impl/ppapi_permissions.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" #include "url/url_constants.h" // In SHARED_INTERMEDIATE_DIR. #include "widevine_cdm_version.h" // NOLINT(build/include) @@ -193,6 +194,23 @@ base::string16 AtomContentClient::GetLocalizedString(int message_id) const { return l10n_util::GetStringUTF16(message_id); } +base::StringPiece AtomContentClient::GetDataResource( + int resource_id, + ui::ScaleFactor scale_factor) const { + return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( + resource_id, scale_factor); +} + +gfx::Image& AtomContentClient::GetNativeImageNamed(int resource_id) const { + return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( + resource_id); +} + +base::RefCountedMemory* AtomContentClient::GetDataResourceBytes( + int resource_id) const { + return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( + resource_id); +} void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) { schemes->standard_schemes.push_back("chrome-extension"); diff --git a/atom/app/atom_content_client.h b/atom/app/atom_content_client.h index b6ecc3407d0e9..bf07825c474cd 100644 --- a/atom/app/atom_content_client.h +++ b/atom/app/atom_content_client.h @@ -9,11 +9,11 @@ #include #include -#include "brightray/common/content_client.h" +#include "content/public/common/content_client.h" namespace atom { -class AtomContentClient : public brightray::ContentClient { +class AtomContentClient : public content::ContentClient { public: AtomContentClient(); ~AtomContentClient() override; @@ -23,6 +23,10 @@ class AtomContentClient : public brightray::ContentClient { std::string GetProduct() const override; std::string GetUserAgent() const override; base::string16 GetLocalizedString(int message_id) const override; + base::StringPiece GetDataResource(int resource_id, + ui::ScaleFactor) const override; + gfx::Image& GetNativeImageNamed(int resource_id) const override; + base::RefCountedMemory* GetDataResourceBytes(int resource_id) const override; void AddAdditionalSchemes(Schemes* schemes) override; void AddPepperPlugins( std::vector* plugins) override; diff --git a/atom/app/atom_library_main.mm b/atom/app/atom_library_main.mm index f1bf7bb97a8c8..bd241ca2f74f1 100644 --- a/atom/app/atom_library_main.mm +++ b/atom/app/atom_library_main.mm @@ -7,11 +7,11 @@ #include "atom/app/atom_main_delegate.h" #include "atom/app/node_main.h" #include "atom/common/atom_command_line.h" +#include "atom/common/mac/main_application_bundle.h" #include "base/at_exit.h" #include "base/i18n/icu_util.h" #include "base/mac/bundle_locations.h" #include "base/mac/scoped_nsautorelease_pool.h" -#include "brightray/common/mac/main_application_bundle.h" #include "content/public/app/content_main.h" int AtomMain(int argc, char* argv[]) { @@ -28,7 +28,7 @@ int AtomInitializeICUandStartNode(int argc, char* argv[]) { base::AtExitManager atexit_manager; base::mac::ScopedNSAutoreleasePool pool; base::mac::SetOverrideFrameworkBundlePath( - brightray::MainApplicationBundlePath() + atom::MainApplicationBundlePath() .Append("Contents") .Append("Frameworks") .Append(ATOM_PRODUCT_NAME " Framework.framework")); diff --git a/atom/app/atom_main_delegate.cc b/atom/app/atom_main_delegate.cc index 668501a7c49bb..cd9f79f92bb68 100644 --- a/atom/app/atom_main_delegate.cc +++ b/atom/app/atom_main_delegate.cc @@ -20,12 +20,17 @@ #include "base/debug/stack_trace.h" #include "base/environment.h" #include "base/logging.h" +#include "base/mac/bundle_locations.h" +#include "base/path_service.h" #include "chrome/common/chrome_paths.h" #include "content/public/common/content_switches.h" +#include "electron/buildflags/buildflags.h" #include "ipc/ipc_buildflags.h" +#include "services/service_manager/embedder/switches.h" #include "services/service_manager/sandbox/switches.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/base/ui_base_switches.h" #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) #define IPC_MESSAGE_MACROS_LOG_ENABLED @@ -50,6 +55,25 @@ bool IsBrowserProcess(base::CommandLine* cmd) { return process_type.empty(); } +// Returns true if this subprocess type needs the ResourceBundle initialized +// and resources loaded. +bool SubprocessNeedsResourceBundle(const std::string& process_type) { + return +#if defined(OS_POSIX) && !defined(OS_MACOSX) + // The zygote process opens the resources for the renderers. + process_type == service_manager::switches::kZygoteProcess || +#endif +#if defined(OS_MACOSX) + // Mac needs them too for scrollbar related images and for sandbox + // profiles. + process_type == ::switches::kPpapiPluginProcess || + process_type == ::switches::kPpapiBrokerProcess || + process_type == ::switches::kGpuProcess || +#endif + process_type == ::switches::kRendererProcess || + process_type == ::switches::kUtilityProcess; +} + #if defined(OS_WIN) void InvalidParameterHandler(const wchar_t*, const wchar_t*, @@ -62,6 +86,37 @@ void InvalidParameterHandler(const wchar_t*, } // namespace +void LoadResourceBundle(const std::string& locale) { + const bool initialized = ui::ResourceBundle::HasSharedInstance(); + if (initialized) + ui::ResourceBundle::CleanupSharedInstance(); + + // Load other resource files. + base::FilePath pak_dir; +#if defined(OS_MACOSX) + pak_dir = + base::mac::FrameworkBundlePath().Append(FILE_PATH_LITERAL("Resources")); +#else + base::PathService::Get(base::DIR_MODULE, &pak_dir); +#endif + + ui::ResourceBundle::InitSharedInstanceWithLocale( + locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES); + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); + bundle.ReloadLocaleResources(locale); + bundle.AddDataPackFromPath(pak_dir.Append(FILE_PATH_LITERAL("resources.pak")), + ui::SCALE_FACTOR_NONE); +#if BUILDFLAG(ENABLE_PDF_VIEWER) + NOTIMPLEMENTED() + << "Hi, whoever's fixing PDF support! Thanks! The pdf " + "viewer resources haven't been ported over to the GN build yet, so " + "you'll probably need to change this bit of code."; + bundle.AddDataPackFromPath( + pak_dir.Append(FILE_PATH_LITERAL("pdf_viewer_resources.pak")), + ui::GetSupportedScaleFactors()[0]); +#endif // BUILDFLAG(ENABLE_PDF_VIEWER) +} + AtomMainDelegate::AtomMainDelegate() {} AtomMainDelegate::~AtomMainDelegate() {} @@ -118,6 +173,8 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) { chrome::RegisterPathProvider(); #if defined(OS_MACOSX) + OverrideChildProcessPath(); + OverrideFrameworkBundlePath(); SetUpBundleOverrides(); #endif @@ -129,13 +186,24 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) { base::win::DisableHandleVerifier(); #endif - return brightray::MainDelegate::BasicStartupComplete(exit_code); + content_client_ = std::make_unique(); + SetContentClient(content_client_.get()); + + return false; } void AtomMainDelegate::PreSandboxStartup() { - brightray::MainDelegate::PreSandboxStartup(); - auto* command_line = base::CommandLine::ForCurrentProcess(); + std::string process_type = + command_line->GetSwitchValueASCII(::switches::kProcessType); + + // Initialize ResourceBundle which handles files loaded from external + // sources. The language should have been passed in to us from the + // browser process as a command line flag. + if (SubprocessNeedsResourceBundle(process_type)) { + std::string locale = command_line->GetSwitchValueASCII(::switches::kLang); + LoadResourceBundle(locale); + } // Only append arguments for browser process. if (!IsBrowserProcess(command_line)) @@ -212,9 +280,4 @@ bool AtomMainDelegate::DelaySandboxInitialization( } #endif -std::unique_ptr -AtomMainDelegate::CreateContentClient() { - return std::make_unique(); -} - } // namespace atom diff --git a/atom/app/atom_main_delegate.h b/atom/app/atom_main_delegate.h index 83d2c6e2ae52a..21cd63d82db72 100644 --- a/atom/app/atom_main_delegate.h +++ b/atom/app/atom_main_delegate.h @@ -8,12 +8,15 @@ #include #include -#include "brightray/common/content_client.h" -#include "brightray/common/main_delegate.h" +#include "atom/app/atom_main_delegate.h" +#include "content/public/app/content_main_delegate.h" +#include "content/public/common/content_client.h" namespace atom { -class AtomMainDelegate : public brightray::MainDelegate { +void LoadResourceBundle(const std::string& locale); + +class AtomMainDelegate : public content::ContentMainDelegate { public: AtomMainDelegate(); ~AtomMainDelegate() override; @@ -34,19 +37,15 @@ class AtomMainDelegate : public brightray::MainDelegate { bool DelaySandboxInitialization(const std::string& process_type) override; #endif - // brightray::MainDelegate: - std::unique_ptr CreateContentClient() override; -#if defined(OS_MACOSX) - void OverrideChildProcessPath() override; - void OverrideFrameworkBundlePath() override; -#endif - private: #if defined(OS_MACOSX) + void OverrideChildProcessPath(); + void OverrideFrameworkBundlePath(); void SetUpBundleOverrides(); #endif std::unique_ptr browser_client_; + std::unique_ptr content_client_; std::unique_ptr renderer_client_; std::unique_ptr utility_client_; diff --git a/atom/app/atom_main_delegate_mac.mm b/atom/app/atom_main_delegate_mac.mm index 21104ae23e741..8f20dcaab35cc 100644 --- a/atom/app/atom_main_delegate_mac.mm +++ b/atom/app/atom_main_delegate_mac.mm @@ -5,6 +5,8 @@ #include "atom/app/atom_main_delegate.h" #include "atom/browser/mac/atom_application.h" +#include "atom/common/application_info.h" +#include "atom/common/mac/main_application_bundle.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/mac/bundle_locations.h" @@ -12,8 +14,6 @@ #include "base/mac/scoped_nsautorelease_pool.h" #include "base/path_service.h" #include "base/strings/sys_string_conversions.h" -#include "brightray/common/application_info.h" -#include "brightray/common/mac/main_application_bundle.h" #include "content/public/common/content_paths.h" namespace atom { @@ -21,7 +21,7 @@ namespace { base::FilePath GetFrameworksPath() { - return brightray::MainApplicationBundlePath() + return atom::MainApplicationBundlePath() .Append("Contents") .Append("Frameworks"); } @@ -46,8 +46,7 @@ base::FilePath helper_path = GetHelperAppPath(frameworks_path, ATOM_PRODUCT_NAME); if (!base::PathExists(helper_path)) - helper_path = - GetHelperAppPath(frameworks_path, brightray::GetApplicationName()); + helper_path = GetHelperAppPath(frameworks_path, GetApplicationName()); if (!base::PathExists(helper_path)) LOG(FATAL) << "Unable to find helper app"; base::PathService::Override(content::CHILD_PROCESS_EXE, helper_path); @@ -55,7 +54,7 @@ void AtomMainDelegate::SetUpBundleOverrides() { base::mac::ScopedNSAutoreleasePool pool; - NSBundle* bundle = brightray::MainApplicationBundle(); + NSBundle* bundle = MainApplicationBundle(); std::string base_bundle_id = base::SysNSStringToUTF8([bundle bundleIdentifier]); NSString* team_id = [bundle objectForInfoDictionaryKey:@"ElectronTeamID"]; diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index dafde725c47d8..c9d3660a1633f 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -13,6 +13,7 @@ #include "atom/browser/api/gpuinfo_manager.h" #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_main_parts.h" +#include "atom/browser/atom_paths.h" #include "atom/browser/login_handler.h" #include "atom/browser/relauncher.h" #include "atom/common/atom_command_line.h" @@ -31,7 +32,6 @@ #include "base/path_service.h" #include "base/strings/string_util.h" #include "base/sys_info.h" -#include "brightray/browser/brightray_paths.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/icon_manager.h" #include "chrome/common/chrome_paths.h" @@ -395,15 +395,15 @@ IconLoader::IconSize GetIconSizeByString(const std::string& size) { // Return the path constant from string. int GetPathConstant(const std::string& name) { if (name == "appData") - return brightray::DIR_APP_DATA; + return DIR_APP_DATA; else if (name == "userData") - return brightray::DIR_USER_DATA; + return DIR_USER_DATA; else if (name == "cache") - return brightray::DIR_CACHE; + return DIR_CACHE; else if (name == "userCache") - return brightray::DIR_USER_CACHE; + return DIR_USER_CACHE; else if (name == "logs") - return brightray::DIR_APP_LOGS; + return DIR_APP_LOGS; else if (name == "home") return base::DIR_HOME; else if (name == "temp") @@ -895,7 +895,7 @@ bool App::RequestSingleInstanceLock() { return true; base::FilePath user_dir; - base::PathService::Get(brightray::DIR_USER_DATA, &user_dir); + base::PathService::Get(DIR_USER_DATA, &user_dir); auto cb = base::Bind(&App::OnSecondInstance, base::Unretained(this)); diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index f3ee77b9241b0..76bb78b8227e4 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -19,6 +19,7 @@ #include "atom/browser/atom_browser_main_parts.h" #include "atom/browser/atom_permission_manager.h" #include "atom/browser/browser.h" +#include "atom/browser/media/media_device_id_salt.h" #include "atom/browser/net/atom_cert_verifier.h" #include "atom/browser/session_preferences.h" #include "atom/common/native_mate_converters/callback.h" @@ -31,7 +32,6 @@ #include "base/guid.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" -#include "brightray/browser/media/media_device_id_salt.h" #include "chrome/browser/browser_process.h" #include "chrome/common/pref_names.h" #include "components/download/public/common/download_danger_type.h" @@ -440,7 +440,7 @@ void Session::ClearStorageData(mate::Arguments* args) { if (options.storage_types & StoragePartition::REMOVE_DATA_MASK_COOKIES) { // Reset media device id salt when cookies are cleared. // https://w3c.github.io/mediacapture-main/#dom-mediadeviceinfo-deviceid - brightray::MediaDeviceIDSalt::Reset(browser_context()->prefs()); + MediaDeviceIDSalt::Reset(browser_context()->prefs()); } storage_partition->ClearData( options.storage_types, options.quota_types, options.origin, diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 5586321326ff6..f2ce2c0865140 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -400,10 +400,10 @@ class WebContents : public mate::TrackableObject, content::WebContentsObserver::MediaStoppedReason reason) override; void DidChangeThemeColor(SkColor theme_color) override; - // brightray::InspectableWebContentsDelegate: + // content::InspectableWebContentsDelegate: void DevToolsReloadPage() override; - // brightray::InspectableWebContentsViewDelegate: + // content::InspectableWebContentsViewDelegate: void DevToolsFocused() override; void DevToolsOpened() override; void DevToolsClosed() override; diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index a79bb5a1d3a4a..cde178baa5a2b 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -17,11 +17,13 @@ #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_main_parts.h" #include "atom/browser/atom_navigation_throttle.h" +#include "atom/browser/atom_paths.h" #include "atom/browser/atom_quota_permission_context.h" #include "atom/browser/atom_resource_dispatcher_host_delegate.h" #include "atom/browser/atom_speech_recognition_manager_delegate.h" #include "atom/browser/child_web_contents_tracker.h" #include "atom/browser/io_thread.h" +#include "atom/browser/media/media_capture_devices_dispatcher.h" #include "atom/browser/native_window.h" #include "atom/browser/notifications/notification_presenter.h" #include "atom/browser/notifications/platform_notification_service.h" @@ -37,7 +39,9 @@ #include "base/environment.h" #include "base/files/file_util.h" #include "base/json/json_reader.h" +#include "base/lazy_instance.h" #include "base/no_destructor.h" +#include "base/path_service.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" @@ -120,6 +124,18 @@ bool IsSameWebSite(content::BrowserContext* browser_context, src_url; } +AtomBrowserClient* g_browser_client = nullptr; + +base::LazyInstance::DestructorAtExit + g_io_thread_application_locale = LAZY_INSTANCE_INITIALIZER; + +base::NoDestructor g_application_locale; + +void SetApplicationLocaleOnIOThread(const std::string& locale) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + g_io_thread_application_locale.Get() = locale; +} + } // namespace // static @@ -132,9 +148,32 @@ void AtomBrowserClient::SetCustomServiceWorkerSchemes( *g_custom_service_worker_schemes = base::JoinString(schemes, ","); } -AtomBrowserClient::AtomBrowserClient() {} +AtomBrowserClient* AtomBrowserClient::Get() { + return g_browser_client; +} + +// static +void AtomBrowserClient::SetApplicationLocale(const std::string& locale) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + + if (!BrowserThread::IsThreadInitialized(BrowserThread::IO) || + !BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::BindOnce(&SetApplicationLocaleOnIOThread, locale))) { + g_io_thread_application_locale.Get() = locale; + } + *g_application_locale = locale; +} + +AtomBrowserClient::AtomBrowserClient() { + DCHECK(!g_browser_client); + g_browser_client = this; +} -AtomBrowserClient::~AtomBrowserClient() {} +AtomBrowserClient::~AtomBrowserClient() { + DCHECK(g_browser_client); + g_browser_client = nullptr; +} content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID( int process_id) { @@ -578,7 +617,7 @@ net::NetLog* AtomBrowserClient::GetNetLog() { return AtomBrowserMainParts::Get()->net_log(); } -brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts( +content::BrowserMainParts* AtomBrowserClient::CreateBrowserMainParts( const content::MainFunctionParams& params) { return new AtomBrowserMainParts(params); } @@ -683,6 +722,10 @@ AtomBrowserClient::CreateThrottlesForNavigation( return throttles; } +content::MediaObserver* AtomBrowserClient::GetMediaObserver() { + return MediaCaptureDevicesDispatcher::GetInstance(); +} + content::DevToolsManagerDelegate* AtomBrowserClient::GetDevToolsManagerDelegate() { return new DevToolsManagerDelegate; @@ -703,4 +746,19 @@ AtomBrowserClient::GetPlatformNotificationService() { return notification_service_.get(); } +base::FilePath AtomBrowserClient::GetDefaultDownloadDirectory() { + // ~/Downloads + base::FilePath path; + if (base::PathService::Get(base::DIR_HOME, &path)) + path = path.Append(FILE_PATH_LITERAL("Downloads")); + + return path; +} + +std::string AtomBrowserClient::GetApplicationLocale() { + if (BrowserThread::CurrentlyOn(BrowserThread::IO)) + return g_io_thread_application_locale.Get(); + return *g_application_locale; +} + } // namespace atom diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index d4a018b0334a5..7a36efea72f51 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -11,7 +11,7 @@ #include #include -#include "brightray/browser/browser_client.h" +#include "content/public/browser/content_browser_client.h" #include "content/public/browser/render_process_host_observer.h" #include "net/ssl/client_cert_identity.h" @@ -30,9 +30,12 @@ class AtomResourceDispatcherHostDelegate; class NotificationPresenter; class PlatformNotificationService; -class AtomBrowserClient : public brightray::BrowserClient, +class AtomBrowserClient : public content::ContentBrowserClient, public content::RenderProcessHostObserver { public: + static AtomBrowserClient* Get(); + static void SetApplicationLocale(const std::string& locale); + AtomBrowserClient(); ~AtomBrowserClient() override; @@ -58,8 +61,10 @@ class AtomBrowserClient : public brightray::BrowserClient, std::vector> CreateThrottlesForNavigation(content::NavigationHandle* handle) override; - protected: // content::ContentBrowserClient: + std::string GetApplicationLocale() override; + + protected: void RenderProcessWillLaunch( content::RenderProcessHost* host, service_manager::mojom::ServiceRequest* service_request) override; @@ -127,13 +132,13 @@ class AtomBrowserClient : public brightray::BrowserClient, std::unique_ptr GetServiceManifestOverlay( base::StringPiece name) override; net::NetLog* GetNetLog() override; + content::MediaObserver* GetMediaObserver() override; content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override; content::PlatformNotificationService* GetPlatformNotificationService() override; - - // brightray::BrowserClient: - brightray::BrowserMainParts* OverrideCreateBrowserMainParts( + content::BrowserMainParts* CreateBrowserMainParts( const content::MainFunctionParams&) override; + base::FilePath GetDefaultDownloadDirectory() override; // content::RenderProcessHostObserver: void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index 3cebe4f4e7226..1b6fff16919d6 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -9,6 +9,7 @@ #include "atom/browser/atom_blob_reader.h" #include "atom/browser/atom_browser_main_parts.h" #include "atom/browser/atom_download_manager_delegate.h" +#include "atom/browser/atom_paths.h" #include "atom/browser/atom_permission_manager.h" #include "atom/browser/browser.h" #include "atom/browser/cookie_change_notifier.h" @@ -17,6 +18,8 @@ #include "atom/browser/special_storage_policy.h" #include "atom/browser/ui/inspectable_web_contents_impl.h" #include "atom/browser/web_view_manager.h" +#include "atom/browser/zoom_level_delegate.h" +#include "atom/common/application_info.h" #include "atom/common/atom_version.h" #include "atom/common/chrome_version.h" #include "atom/common/options_switches.h" @@ -27,9 +30,6 @@ #include "base/strings/stringprintf.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/thread_restrictions.h" -#include "brightray/browser/brightray_paths.h" -#include "brightray/browser/zoom_level_delegate.h" -#include "brightray/common/application_info.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/pref_names.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" @@ -100,11 +100,10 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition, base::StringToInt(command_line->GetSwitchValueASCII(switches::kDiskCacheSize), &max_cache_size_); - if (!base::PathService::Get(brightray::DIR_USER_DATA, &path_)) { - base::PathService::Get(brightray::DIR_APP_DATA, &path_); - path_ = path_.Append( - base::FilePath::FromUTF8Unsafe(brightray::GetApplicationName())); - base::PathService::Override(brightray::DIR_USER_DATA, path_); + if (!base::PathService::Get(DIR_USER_DATA, &path_)) { + base::PathService::Get(DIR_APP_DATA, &path_); + path_ = path_.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); + base::PathService::Override(DIR_USER_DATA, path_); } if (!in_memory && !partition.empty()) @@ -153,8 +152,8 @@ void AtomBrowserContext::InitPrefs() { download_dir); registry->RegisterDictionaryPref(prefs::kDevToolsFileSystemPaths); InspectableWebContentsImpl::RegisterPrefs(registry.get()); - brightray::MediaDeviceIDSalt::RegisterPrefs(registry.get()); - brightray::ZoomLevelDelegate::RegisterPrefs(registry.get()); + MediaDeviceIDSalt::RegisterPrefs(registry.get()); + ZoomLevelDelegate::RegisterPrefs(registry.get()); PrefProxyConfigTrackerImpl::RegisterPrefs(registry.get()); prefs_ = prefs_factory.Create( @@ -210,7 +209,7 @@ content::ResourceContext* AtomBrowserContext::GetResourceContext() { std::string AtomBrowserContext::GetMediaDeviceIDSalt() { if (!media_device_id_salt_.get()) - media_device_id_salt_.reset(new brightray::MediaDeviceIDSalt(prefs_.get())); + media_device_id_salt_.reset(new MediaDeviceIDSalt(prefs_.get())); return media_device_id_salt_->GetSalt(); } @@ -218,8 +217,7 @@ std::unique_ptr AtomBrowserContext::CreateZoomLevelDelegate( const base::FilePath& partition_path) { if (!IsOffTheRecord()) { - return std::make_unique(prefs(), - partition_path); + return std::make_unique(prefs(), partition_path); } return std::unique_ptr(); } diff --git a/atom/browser/atom_browser_context.h b/atom/browser/atom_browser_context.h index 01e8208aa72d5..782d04f2a61a5 100644 --- a/atom/browser/atom_browser_context.h +++ b/atom/browser/atom_browser_context.h @@ -10,10 +10,10 @@ #include #include +#include "atom/browser/media/media_device_id_salt.h" #include "atom/browser/net/url_request_context_getter.h" #include "base/memory/ref_counted_delete_on_sequence.h" #include "base/memory/weak_ptr.h" -#include "brightray/browser/media/media_device_id_salt.h" #include "chrome/browser/net/proxy_config_monitor.h" #include "content/public/browser/browser_context.h" @@ -152,7 +152,7 @@ class AtomBrowserContext std::unique_ptr guest_manager_; std::unique_ptr permission_manager_; std::unique_ptr blob_reader_; - std::unique_ptr media_device_id_salt_; + std::unique_ptr media_device_id_salt_; scoped_refptr resolve_proxy_helper_; scoped_refptr storage_policy_; diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 3f11b9d3a66d4..d093443fc2ed2 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -6,6 +6,11 @@ #include +#if defined(OS_LINUX) +#include // for g_setenv() +#endif + +#include "atom/app/atom_main_delegate.h" #include "atom/browser/api/atom_api_app.h" #include "atom/browser/api/trackable_object.h" #include "atom/browser/atom_browser_client.h" @@ -14,33 +19,67 @@ #include "atom/browser/browser.h" #include "atom/browser/io_thread.h" #include "atom/browser/javascript_environment.h" +#include "atom/browser/media/media_capture_devices_dispatcher.h" #include "atom/browser/node_debugger.h" #include "atom/browser/ui/devtools_manager_delegate.h" #include "atom/common/api/atom_bindings.h" +#include "atom/common/application_info.h" #include "atom/common/asar/asar_util.h" #include "atom/common/node_bindings.h" +#include "base/base_switches.h" #include "base/command_line.h" -#include "base/threading/thread_task_runner_handle.h" +#include "base/feature_list.h" +#include "base/message_loop/message_loop.h" +#include "base/strings/string_number_conversions.h" +#include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process_impl.h" #include "chrome/browser/icon_manager.h" #include "chrome/browser/net/chrome_net_log_helper.h" #include "components/net_log/chrome_net_log.h" #include "components/net_log/net_export_file_writer.h" +#include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/web_ui_controller_factory.h" +#include "content/public/common/content_features.h" #include "content/public/common/content_switches.h" #include "content/public/common/result_codes.h" #include "content/public/common/service_manager_connection.h" #include "electron/buildflags/buildflags.h" +#include "media/base/localized_strings.h" #include "services/device/public/mojom/constants.mojom.h" #include "services/network/public/cpp/network_switches.h" #include "services/service_manager/public/cpp/connector.h" #include "ui/base/idle/idle.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/base/material_design/material_design_controller.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/base/ui_base_switches.h" + +#if defined(USE_AURA) +#include "ui/display/display.h" +#include "ui/display/screen.h" +#include "ui/views/widget/desktop_aura/desktop_screen.h" +#include "ui/wm/core/wm_state.h" +#endif #if defined(USE_X11) +#include "atom/browser/atom_paths.h" +#include "base/environment.h" +#include "base/nix/xdg_util.h" +#include "base/path_service.h" +#include "base/threading/thread_task_runner_handle.h" +#include "chrome/browser/ui/libgtkui/gtk_ui.h" #include "chrome/browser/ui/libgtkui/gtk_util.h" +#include "ui/base/x/x11_util.h" +#include "ui/base/x/x11_util_internal.h" #include "ui/events/devices/x11/touch_factory_x11.h" +#include "ui/views/linux_ui/linux_ui.h" +#endif + +#if defined(OS_WIN) +#include "ui/base/cursor/cursor_loader_win.h" +#include "ui/base/l10n/l10n_util_win.h" +#include "ui/gfx/platform_font_win.h" #endif #if defined(OS_MACOSX) @@ -49,6 +88,11 @@ #include "atom/browser/ui/views/atom_views_delegate.h" #endif +#if defined(OS_LINUX) +#include "device/bluetooth/bluetooth_adapter_factory.h" +#include "device/bluetooth/dbus/dbus_bluez_manager_wrapper_linux.h" +#endif + // Must be included after all other headers. #include "atom/common/node_includes.h" @@ -61,8 +105,133 @@ void Erase(T* container, typename T::iterator iter) { container->erase(iter); } +#if defined(OS_WIN) +// gfx::Font callbacks +void AdjustUIFont(LOGFONT* logfont) { + l10n_util::AdjustUIFont(logfont); +} + +int GetMinimumFontSize() { + return 10; +} +#endif + +base::string16 MediaStringProvider(media::MessageId id) { + switch (id) { + case media::DEFAULT_AUDIO_DEVICE_NAME: + return base::ASCIIToUTF16("Default"); +#if defined(OS_WIN) + case media::COMMUNICATIONS_AUDIO_DEVICE_NAME: + return base::ASCIIToUTF16("Communications"); +#endif + default: + return base::string16(); + } +} + +#if defined(USE_X11) +// Indicates that we're currently responding to an IO error (by shutting down). +bool g_in_x11_io_error_handler = false; + +// Number of seconds to wait for UI thread to get an IO error if we get it on +// the background thread. +const int kWaitForUIThreadSeconds = 10; + +void OverrideLinuxAppDataPath() { + base::FilePath path; + if (base::PathService::Get(DIR_APP_DATA, &path)) + return; + std::unique_ptr env(base::Environment::Create()); + path = base::nix::GetXDGDirectory(env.get(), base::nix::kXdgConfigHomeEnvVar, + base::nix::kDotConfigDir); + base::PathService::Override(DIR_APP_DATA, path); +} + +int BrowserX11ErrorHandler(Display* d, XErrorEvent* error) { + if (!g_in_x11_io_error_handler && base::ThreadTaskRunnerHandle::IsSet()) { + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&ui::LogErrorEventDescription, d, *error)); + } + return 0; +} + +// This function is used to help us diagnose crash dumps that happen +// during the shutdown process. +NOINLINE void WaitingForUIThreadToHandleIOError() { + // Ensure function isn't optimized away. + asm(""); + sleep(kWaitForUIThreadSeconds); +} + +int BrowserX11IOErrorHandler(Display* d) { + if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { + // Wait for the UI thread (which has a different connection to the X server) + // to get the error. We can't call shutdown from this thread without + // tripping an error. Doing it through a function so that we'll be able + // to see it in any crash dumps. + WaitingForUIThreadToHandleIOError(); + return 0; + } + + // If there's an IO error it likely means the X server has gone away. + // If this CHECK fails, then that means SessionEnding() below triggered some + // code that tried to talk to the X server, resulting in yet another error. + CHECK(!g_in_x11_io_error_handler); + + g_in_x11_io_error_handler = true; + LOG(ERROR) << "X IO error received (X server probably went away)"; + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated()); + + return 0; +} + +int X11EmptyErrorHandler(Display* d, XErrorEvent* error) { + return 0; +} + +int X11EmptyIOErrorHandler(Display* d) { + return 0; +} +#endif + } // namespace +void AtomBrowserMainParts::InitializeFeatureList() { + auto* cmd_line = base::CommandLine::ForCurrentProcess(); + auto enable_features = + cmd_line->GetSwitchValueASCII(::switches::kEnableFeatures); + // Node depends on SharedArrayBuffer support, which was temporarily disabled + // by https://chromium-review.googlesource.com/c/chromium/src/+/849429 (in + // M64) and reenabled by + // https://chromium-review.googlesource.com/c/chromium/src/+/1159358 (in + // M70). Once Electron upgrades to M70, we can remove this. + enable_features += std::string(",") + features::kSharedArrayBuffer.name; + auto disable_features = + cmd_line->GetSwitchValueASCII(::switches::kDisableFeatures); +#if defined(OS_MACOSX) + // Disable the V2 sandbox on macOS. + // Chromium is going to use the system sandbox API of macOS for the sandbox + // implmentation, we may have to deprecate --mixed-sandbox for macOS once + // Chromium drops support for the old sandbox implmentation. + disable_features += std::string(",") + features::kMacV2Sandbox.name; +#endif + auto feature_list = std::make_unique(); + feature_list->InitializeFromCommandLine(enable_features, disable_features); + base::FeatureList::SetInstance(std::move(feature_list)); +} + +#if !defined(OS_MACOSX) +void AtomBrowserMainParts::OverrideAppLogsPath() { + base::FilePath path; + if (base::PathService::Get(DIR_APP_DATA, &path)) { + path = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); + path = path.Append(base::FilePath::FromUTF8Unsafe("logs")); + base::PathService::Override(DIR_APP_LOGS, path); + } +} +#endif + // static AtomBrowserMainParts* AtomBrowserMainParts::self_ = nullptr; @@ -119,10 +288,22 @@ void AtomBrowserMainParts::RegisterDestructionCallback( destructors_.insert(destructors_.begin(), std::move(callback)); } +bool AtomBrowserMainParts::ShouldContentCreateFeatureList() { + return false; +} + int AtomBrowserMainParts::PreEarlyInitialization() { - const int result = brightray::BrowserMainParts::PreEarlyInitialization(); - if (result != service_manager::RESULT_CODE_NORMAL_EXIT) - return result; + InitializeFeatureList(); + OverrideAppLogsPath(); +#if defined(USE_X11) + views::LinuxUI::SetInstance(BuildGtkUi()); + OverrideLinuxAppDataPath(); + + // Installs the X11 error handlers for the browser process used during + // startup. They simply print error messages and exit because + // we can't shutdown properly while creating and initializing services. + ui::SetX11ErrorHandlers(nullptr, nullptr); +#endif #if defined(OS_POSIX) HandleSIGCHLD(); @@ -132,8 +313,6 @@ int AtomBrowserMainParts::PreEarlyInitialization() { } void AtomBrowserMainParts::PostEarlyInitialization() { - brightray::BrowserMainParts::PostEarlyInitialization(); - // A workaround was previously needed because there was no ThreadTaskRunner // set. If this check is failing we may need to re-add that workaround DCHECK(base::ThreadTaskRunnerHandle::IsSet()); @@ -161,21 +340,35 @@ void AtomBrowserMainParts::PostEarlyInitialization() { // Wrap the uv loop with global env. node_bindings_->set_uv_env(env); - // We already initialized the feature list in - // brightray::BrowserMainParts::PreEarlyInitialization(), but + // We already initialized the feature list in PreEarlyInitialization(), but // the user JS script would not have had a chance to alter the command-line // switches at that point. Lets reinitialize it here to pick up the // command-line changes. base::FeatureList::ClearInstanceForTesting(); - brightray::BrowserMainParts::InitializeFeatureList(); + InitializeFeatureList(); } int AtomBrowserMainParts::PreCreateThreads() { - const int result = brightray::BrowserMainParts::PreCreateThreads(); - if (!result) { - fake_browser_process_->SetApplicationLocale( - brightray::BrowserClient::Get()->GetApplicationLocale()); - } +#if defined(USE_AURA) + display::Screen* screen = views::CreateDesktopScreen(); + display::Screen::SetScreenInstance(screen); +#if defined(USE_X11) + views::LinuxUI::instance()->UpdateDeviceScaleFactor(); +#endif +#endif + + if (!views::LayoutProvider::Get()) + layout_provider_.reset(new views::LayoutProvider()); + + // Initialize the app locale. + atom::AtomBrowserClient::SetApplicationLocale( + l10n_util::GetApplicationLocale(custom_locale_)); + + fake_browser_process_->SetApplicationLocale( + AtomBrowserClient::Get()->GetApplicationLocale()); + + // Force MediaCaptureDevicesDispatcher to be created on UI thread. + MediaCaptureDevicesDispatcher::GetInstance(); #if defined(OS_MACOSX) ui::InitIdleMonitor(); @@ -199,16 +392,37 @@ int AtomBrowserMainParts::PreCreateThreads() { // Manage global state of net and other IO thread related. io_thread_ = std::make_unique(net_log_.get()); - return result; + return 0; } void AtomBrowserMainParts::PostDestroyThreads() { - brightray::BrowserMainParts::PostDestroyThreads(); +#if defined(OS_LINUX) + device::BluetoothAdapterFactory::Shutdown(); + bluez::DBusBluezManagerWrapperLinux::Shutdown(); +#endif io_thread_.reset(); } void AtomBrowserMainParts::ToolkitInitialized() { - brightray::BrowserMainParts::ToolkitInitialized(); + ui::MaterialDesignController::Initialize(); + +#if defined(USE_AURA) && defined(USE_X11) + views::LinuxUI::instance()->Initialize(); +#endif + +#if defined(USE_AURA) + wm_state_.reset(new wm::WMState); +#endif + +#if defined(OS_WIN) + gfx::PlatformFontWin::adjust_font_callback = &AdjustUIFont; + gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize; + + wchar_t module_name[MAX_PATH] = {0}; + if (GetModuleFileName(NULL, module_name, MAX_PATH)) + ui::CursorLoaderWin::SetCursorResourceModule(module_name); +#endif + #if defined(OS_MACOSX) views_delegate_.reset(new ViewsDelegateMac); #else @@ -256,7 +470,7 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() { bool AtomBrowserMainParts::MainMessageLoopRun(int* result_code) { js_env_->OnMessageLoopCreated(); exit_code_ = result_code; - return brightray::BrowserMainParts::MainMessageLoopRun(result_code); + return content::BrowserMainParts::MainMessageLoopRun(result_code); } void AtomBrowserMainParts::PreDefaultMainMessageLoopRun( @@ -265,14 +479,27 @@ void AtomBrowserMainParts::PreDefaultMainMessageLoopRun( } void AtomBrowserMainParts::PostMainMessageLoopStart() { - brightray::BrowserMainParts::PostMainMessageLoopStart(); +#if defined(USE_X11) + // Installs the X11 error handlers for the browser process after the + // main message loop has started. This will allow us to exit cleanly + // if X exits before us. + ui::SetX11ErrorHandlers(BrowserX11ErrorHandler, BrowserX11IOErrorHandler); +#endif +#if defined(OS_LINUX) + bluez::DBusBluezManagerWrapperLinux::Initialize(); +#endif #if defined(OS_POSIX) HandleShutdownSignals(); #endif } void AtomBrowserMainParts::PostMainMessageLoopRun() { - brightray::BrowserMainParts::PostMainMessageLoopRun(); +#if defined(USE_X11) + // Unset the X11 error handlers. The X11 error handlers log the errors using a + // |PostTask()| on the message-loop. But since the message-loop is in the + // process of terminating, this can cause errors. + ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); +#endif js_env_->OnMessageLoopDestroying(); @@ -293,6 +520,42 @@ void AtomBrowserMainParts::PostMainMessageLoopRun() { } } +#if !defined(OS_MACOSX) +void AtomBrowserMainParts::PreMainMessageLoopStart() { + PreMainMessageLoopStartCommon(); +} +#endif + +void AtomBrowserMainParts::PreMainMessageLoopStartCommon() { + // Initialize ui::ResourceBundle. + ui::ResourceBundle::InitSharedInstanceWithLocale( + "", nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); + auto* cmd_line = base::CommandLine::ForCurrentProcess(); + if (cmd_line->HasSwitch(switches::kLang)) { + const std::string locale = cmd_line->GetSwitchValueASCII(switches::kLang); + const base::FilePath locale_file_path = + ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale, true); + if (!locale_file_path.empty()) { + custom_locale_ = locale; +#if defined(OS_LINUX) + /* When built with USE_GLIB, libcc's GetApplicationLocaleInternal() uses + * glib's g_get_language_names(), which keys off of getenv("LC_ALL") */ + g_setenv("LC_ALL", custom_locale_.c_str(), TRUE); +#endif + } + } + +#if defined(OS_MACOSX) + if (custom_locale_.empty()) + l10n_util::OverrideLocaleWithCocoaLocale(); +#endif + LoadResourceBundle(custom_locale_); +#if defined(OS_MACOSX) + InitializeMainNib(); +#endif + media::SetLocalizedStringProvider(MediaStringProvider); +} + device::mojom::GeolocationControl* AtomBrowserMainParts::GetGeolocationControl() { if (geolocation_control_) diff --git a/atom/browser/atom_browser_main_parts.h b/atom/browser/atom_browser_main_parts.h index 28b31661f60a9..7e66f37a80540 100644 --- a/atom/browser/atom_browser_main_parts.h +++ b/atom/browser/atom_browser_main_parts.h @@ -11,10 +11,11 @@ #include "base/callback.h" #include "base/timer/timer.h" -#include "brightray/browser/browser_main_parts.h" #include "content/public/browser/browser_context.h" +#include "content/public/browser/browser_main_parts.h" #include "content/public/common/main_function_params.h" #include "services/device/public/mojom/geolocation_control.mojom.h" +#include "ui/views/layout/layout_provider.h" class BrowserProcess; class IconManager; @@ -42,7 +43,13 @@ class ViewsDelegate; class ViewsDelegateMac; #endif -class AtomBrowserMainParts : public brightray::BrowserMainParts { +#if defined(USE_AURA) +namespace wm { +class WMState; +} +#endif + +class AtomBrowserMainParts : public content::BrowserMainParts { public: explicit AtomBrowserMainParts(const content::MainFunctionParams& params); ~AtomBrowserMainParts() override; @@ -73,6 +80,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { protected: // content::BrowserMainParts: + bool ShouldContentCreateFeatureList() override; int PreEarlyInitialization() override; void PostEarlyInitialization() override; int PreCreateThreads() override; @@ -82,12 +90,14 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { void PreDefaultMainMessageLoopRun(base::OnceClosure quit_closure) override; void PostMainMessageLoopStart() override; void PostMainMessageLoopRun() override; -#if defined(OS_MACOSX) void PreMainMessageLoopStart() override; -#endif void PostDestroyThreads() override; private: + void InitializeFeatureList(); + void OverrideAppLogsPath(); + void PreMainMessageLoopStartCommon(); + #if defined(OS_POSIX) // Set signal handlers. void HandleSIGCHLD(); @@ -96,6 +106,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { #if defined(OS_MACOSX) void FreeAppDelegate(); + void InitializeMainNib(); #endif #if defined(OS_MACOSX) @@ -104,6 +115,13 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { std::unique_ptr views_delegate_; #endif +#if defined(USE_AURA) + std::unique_ptr wm_state_; +#endif + + std::unique_ptr layout_provider_; + std::string custom_locale_; + // A fake BrowserProcess object that used to feed the source code from chrome. std::unique_ptr fake_browser_process_; diff --git a/atom/browser/atom_browser_main_parts_mac.mm b/atom/browser/atom_browser_main_parts_mac.mm index 92af70cf3830a..073945fbecafc 100644 --- a/atom/browser/atom_browser_main_parts_mac.mm +++ b/atom/browser/atom_browser_main_parts_mac.mm @@ -4,9 +4,11 @@ #include "atom/browser/atom_browser_main_parts.h" +#include "atom/browser/atom_paths.h" #include "atom/browser/mac/atom_application_delegate.h" #include "base/mac/bundle_locations.h" #include "base/mac/foundation_util.h" +#include "base/path_service.h" #include "ui/base/l10n/l10n_util_mac.h" namespace atom { @@ -16,7 +18,7 @@ AtomApplicationDelegate* delegate = [[AtomApplicationDelegate alloc] init]; [NSApp setDelegate:delegate]; - brightray::BrowserMainParts::PreMainMessageLoopStart(); + PreMainMessageLoopStartCommon(); // Prevent Cocoa from turning command-line arguments into // |-application:openFiles:|, since we already handle them directly. @@ -30,4 +32,32 @@ [NSApp setDelegate:nil]; } +void AtomBrowserMainParts::OverrideAppLogsPath() { + base::FilePath path; + NSString* bundleName = + [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; + NSString* logsPath = + [NSString stringWithFormat:@"Library/Logs/%@", bundleName]; + NSString* libraryPath = + [NSHomeDirectory() stringByAppendingPathComponent:logsPath]; + + base::PathService::Override(DIR_APP_LOGS, + base::FilePath([libraryPath UTF8String])); +} + +// Replicates NSApplicationMain, but doesn't start a run loop. +void AtomBrowserMainParts::InitializeMainNib() { + auto infoDictionary = base::mac::OuterBundle().infoDictionary; + + auto principalClass = + NSClassFromString([infoDictionary objectForKey:@"NSPrincipalClass"]); + auto application = [principalClass sharedApplication]; + + NSString* mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"]; + auto mainNib = [[NSNib alloc] initWithNibNamed:mainNibName + bundle:base::mac::FrameworkBundle()]; + [mainNib instantiateWithOwner:application topLevelObjects:nil]; + [mainNib release]; +} + } // namespace atom diff --git a/brightray/browser/brightray_paths.h b/atom/browser/atom_paths.h similarity index 82% rename from brightray/browser/brightray_paths.h rename to atom/browser/atom_paths.h index 5c6c6d9e7adb9..bf018839e7ef0 100644 --- a/brightray/browser/brightray_paths.h +++ b/atom/browser/atom_paths.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BRIGHTRAY_BROWSER_BRIGHTRAY_PATHS_H_ -#define BRIGHTRAY_BROWSER_BRIGHTRAY_PATHS_H_ +#ifndef ATOM_BROWSER_ATOM_PATHS_H_ +#define ATOM_BROWSER_ATOM_PATHS_H_ #if defined(OS_WIN) #include "base/base_paths_win.h" @@ -15,7 +15,7 @@ #include "base/base_paths_posix.h" #endif -namespace brightray { +namespace atom { enum { PATH_START = 11000, @@ -39,6 +39,6 @@ enum { PATH_END }; -} // namespace brightray +} // namespace atom -#endif // BRIGHTRAY_BROWSER_BRIGHTRAY_PATHS_H_ +#endif // ATOM_BROWSER_ATOM_PATHS_H_ diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index f172a77e72bcb..e37de81042881 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -9,10 +9,12 @@ #include #include "atom/browser/atom_browser_main_parts.h" +#include "atom/browser/atom_paths.h" #include "atom/browser/browser_observer.h" #include "atom/browser/login_handler.h" #include "atom/browser/native_window.h" #include "atom/browser/window_list.h" +#include "atom/common/application_info.h" #include "base/files/file_util.h" #include "base/message_loop/message_loop.h" #include "base/no_destructor.h" @@ -20,8 +22,6 @@ #include "base/run_loop.h" #include "base/threading/thread_restrictions.h" #include "base/threading/thread_task_runner_handle.h" -#include "brightray/browser/brightray_paths.h" -#include "brightray/common/application_info.h" namespace atom { @@ -104,25 +104,25 @@ void Browser::Shutdown() { } std::string Browser::GetVersion() const { - std::string ret = brightray::GetOverriddenApplicationVersion(); + std::string ret = GetOverriddenApplicationVersion(); if (ret.empty()) ret = GetExecutableFileVersion(); return ret; } void Browser::SetVersion(const std::string& version) { - brightray::OverrideApplicationVersion(version); + OverrideApplicationVersion(version); } std::string Browser::GetName() const { - std::string ret = brightray::GetOverriddenApplicationName(); + std::string ret = GetOverriddenApplicationName(); if (ret.empty()) ret = GetExecutableFileProductName(); return ret; } void Browser::SetName(const std::string& name) { - brightray::OverrideApplicationName(name); + OverrideApplicationName(name); } int Browser::GetBadgeCount() { @@ -156,7 +156,7 @@ void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) { // Make sure the userData directory is created. base::ThreadRestrictions::ScopedAllowIO allow_io; base::FilePath user_data; - if (base::PathService::Get(brightray::DIR_USER_DATA, &user_data)) + if (base::PathService::Get(DIR_USER_DATA, &user_data)) base::CreateDirectoryAndGetError(user_data, nullptr); is_ready_ = true; diff --git a/atom/browser/browser_linux.cc b/atom/browser/browser_linux.cc index 0b4868f711ec2..06f8ee47105e6 100644 --- a/atom/browser/browser_linux.cc +++ b/atom/browser/browser_linux.cc @@ -9,11 +9,11 @@ #include "atom/browser/native_window.h" #include "atom/browser/window_list.h" +#include "atom/common/application_info.h" #include "atom/common/atom_version.h" #include "base/command_line.h" #include "base/environment.h" #include "base/process/launch.h" -#include "brightray/common/application_info.h" #if defined(USE_X11) #include "chrome/browser/ui/libgtkui/gtk_util.h" @@ -131,11 +131,11 @@ Browser::LoginItemSettings Browser::GetLoginItemSettings( } std::string Browser::GetExecutableFileVersion() const { - return brightray::GetApplicationVersion(); + return GetApplicationVersion(); } std::string Browser::GetExecutableFileProductName() const { - return brightray::GetApplicationName(); + return GetApplicationName(); } bool Browser::IsUnityRunning() { diff --git a/atom/browser/browser_mac.mm b/atom/browser/browser_mac.mm index 735e07b2f3be5..d4edb3f577ef8 100644 --- a/atom/browser/browser_mac.mm +++ b/atom/browser/browser_mac.mm @@ -9,13 +9,13 @@ #include "atom/browser/mac/dict_util.h" #include "atom/browser/native_window.h" #include "atom/browser/window_list.h" +#include "atom/common/application_info.h" #include "atom/common/platform_util.h" #include "base/mac/bundle_locations.h" #include "base/mac/foundation_util.h" #include "base/mac/mac_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/sys_string_conversions.h" -#include "brightray/common/application_info.h" #include "net/base/mac/url_conversions.h" #include "ui/gfx/image/image.h" #include "url/gurl.h" @@ -289,11 +289,11 @@ void RemoveFromLoginItems() { } std::string Browser::GetExecutableFileVersion() const { - return brightray::GetApplicationVersion(); + return GetApplicationVersion(); } std::string Browser::GetExecutableFileProductName() const { - return brightray::GetApplicationName(); + return GetApplicationName(); } int Browser::DockBounce(BounceType type) { diff --git a/atom/browser/browser_win.cc b/atom/browser/browser_win.cc index f5f7465e03661..3f4414849b182 100644 --- a/atom/browser/browser_win.cc +++ b/atom/browser/browser_win.cc @@ -11,6 +11,7 @@ #include #include "atom/browser/ui/win/jump_list.h" +#include "atom/common/application_info.h" #include "atom/common/atom_version.h" #include "atom/common/native_mate_converters/string16_converter.h" #include "base/base_paths.h" @@ -24,7 +25,6 @@ #include "base/win/registry.h" #include "base/win/win_util.h" #include "base/win/windows_version.h" -#include "brightray/common/application_info.h" namespace atom { @@ -120,7 +120,7 @@ void Browser::ClearRecentDocuments() { } void Browser::SetAppUserModelID(const base::string16& name) { - brightray::SetAppUserModelID(name); + SetAppUserModelID(name); } bool Browser::SetUserTasks(const std::vector& tasks) { @@ -324,7 +324,7 @@ Browser::LoginItemSettings Browser::GetLoginItemSettings( } PCWSTR Browser::GetAppUserModelID() { - return brightray::GetRawAppUserModelID(); + return GetRawAppUserModelID(); } std::string Browser::GetExecutableFileVersion() const { @@ -340,7 +340,7 @@ std::string Browser::GetExecutableFileVersion() const { } std::string Browser::GetExecutableFileProductName() const { - return brightray::GetApplicationName(); + return GetApplicationName(); } } // namespace atom diff --git a/atom/browser/common_web_contents_delegate.h b/atom/browser/common_web_contents_delegate.h index 9481eddbac767..f8d9c7e9aa7fa 100644 --- a/atom/browser/common_web_contents_delegate.h +++ b/atom/browser/common_web_contents_delegate.h @@ -114,7 +114,7 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate, void HideAutofillPopup(); #endif - // brightray::InspectableWebContentsDelegate: + // content::InspectableWebContentsDelegate: void DevToolsSaveToFile(const std::string& url, const std::string& content, bool save_as) override; @@ -133,7 +133,7 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate, const std::string& file_system_path, const std::string& query) override; - // brightray::InspectableWebContentsViewDelegate: + // content::InspectableWebContentsViewDelegate: #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) gfx::ImageSkia GetDevToolsWindowIcon() override; #endif diff --git a/brightray/browser/media/media_capture_devices_dispatcher.cc b/atom/browser/media/media_capture_devices_dispatcher.cc similarity index 97% rename from brightray/browser/media/media_capture_devices_dispatcher.cc rename to atom/browser/media/media_capture_devices_dispatcher.cc index 5b0897e6c19e7..4bcc29b2f1c65 100644 --- a/brightray/browser/media/media_capture_devices_dispatcher.cc +++ b/atom/browser/media/media_capture_devices_dispatcher.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-CHROMIUM file. -#include "brightray/browser/media/media_capture_devices_dispatcher.h" +#include "atom/browser/media/media_capture_devices_dispatcher.h" #include "base/logging.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/media_capture_devices.h" #include "content/public/common/media_stream_request.h" -namespace brightray { +namespace atom { using content::BrowserThread; using content::MediaStreamDevices; @@ -149,4 +149,4 @@ void MediaCaptureDevicesDispatcher::OnSetCapturingLinkSecured( content::MediaStreamType stream_type, bool is_secure) {} -} // namespace brightray +} // namespace atom diff --git a/brightray/browser/media/media_capture_devices_dispatcher.h b/atom/browser/media/media_capture_devices_dispatcher.h similarity index 92% rename from brightray/browser/media/media_capture_devices_dispatcher.h rename to atom/browser/media/media_capture_devices_dispatcher.h index b82a96712f696..3c27a403de2ab 100644 --- a/brightray/browser/media/media_capture_devices_dispatcher.h +++ b/atom/browser/media/media_capture_devices_dispatcher.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-CHROMIUM file. -#ifndef BRIGHTRAY_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ -#define BRIGHTRAY_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ +#ifndef ATOM_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ +#define ATOM_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ #include @@ -11,7 +11,7 @@ #include "content/public/browser/media_observer.h" #include "content/public/common/media_stream_request.h" -namespace brightray { +namespace atom { // This singleton is used to receive updates about media events from the content // layer. @@ -78,6 +78,6 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver { DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); }; -} // namespace brightray +} // namespace atom -#endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ +#endif // ATOM_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ diff --git a/brightray/browser/media/media_device_id_salt.cc b/atom/browser/media/media_device_id_salt.cc similarity index 88% rename from brightray/browser/media/media_device_id_salt.cc rename to atom/browser/media/media_device_id_salt.cc index 811b12a5b66d5..f7fb66d1584fd 100644 --- a/brightray/browser/media/media_device_id_salt.cc +++ b/atom/browser/media/media_device_id_salt.cc @@ -1,7 +1,8 @@ // Copyright 2013 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 "brightray/browser/media/media_device_id_salt.h" + +#include "atom/browser/media/media_device_id_salt.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" @@ -10,11 +11,11 @@ using content::BrowserThread; -namespace brightray { +namespace atom { namespace { -const char kMediaDeviceIdSalt[] = "brightray.media.device_id_salt"; +const char kMediaDeviceIdSalt[] = "electron.media.device_id_salt"; } // namespace @@ -50,4 +51,4 @@ void MediaDeviceIDSalt::Reset(PrefService* pref_service) { content::BrowserContext::CreateRandomMediaDeviceIDSalt()); } -} // namespace brightray +} // namespace atom diff --git a/brightray/browser/media/media_device_id_salt.h b/atom/browser/media/media_device_id_salt.h similarity index 80% rename from brightray/browser/media/media_device_id_salt.h rename to atom/browser/media/media_device_id_salt.h index 6162f4bd870b4..ffe862c3c9a3b 100644 --- a/brightray/browser/media/media_device_id_salt.h +++ b/atom/browser/media/media_device_id_salt.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BRIGHTRAY_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ -#define BRIGHTRAY_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ +#ifndef ATOM_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ +#define ATOM_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ #include @@ -13,7 +13,7 @@ class PrefRegistrySimple; class PrefService; -namespace brightray { +namespace atom { // MediaDeviceIDSalt is responsible for creating and retrieving a salt string // that is used for creating MediaSource IDs that can be cached by a web @@ -34,6 +34,6 @@ class MediaDeviceIDSalt { DISALLOW_COPY_AND_ASSIGN(MediaDeviceIDSalt); }; -} // namespace brightray +} // namespace atom -#endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ +#endif // ATOM_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ diff --git a/brightray/browser/media/media_stream_devices_controller.cc b/atom/browser/media/media_stream_devices_controller.cc similarity index 97% rename from brightray/browser/media/media_stream_devices_controller.cc rename to atom/browser/media/media_stream_devices_controller.cc index a94c7944f049d..534bd675d77d6 100644 --- a/brightray/browser/media/media_stream_devices_controller.cc +++ b/atom/browser/media/media_stream_devices_controller.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-CHROMIUM file. -#include "brightray/browser/media/media_stream_devices_controller.h" +#include "atom/browser/media/media_stream_devices_controller.h" #include #include -#include "brightray/browser/media/media_capture_devices_dispatcher.h" +#include "atom/browser/media/media_capture_devices_dispatcher.h" #include "content/public/browser/desktop_media_id.h" #include "content/public/common/media_stream_request.h" -namespace brightray { +namespace atom { namespace { @@ -188,4 +188,4 @@ void MediaStreamDevicesController::HandleUserMediaRequest() { std::unique_ptr()); } -} // namespace brightray +} // namespace atom diff --git a/brightray/browser/media/media_stream_devices_controller.h b/atom/browser/media/media_stream_devices_controller.h similarity index 82% rename from brightray/browser/media/media_stream_devices_controller.h rename to atom/browser/media/media_stream_devices_controller.h index 29308aced5941..5326a0ab058bf 100644 --- a/brightray/browser/media/media_stream_devices_controller.h +++ b/atom/browser/media/media_stream_devices_controller.h @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-CHROMIUM file. -#ifndef BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ -#define BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ +#ifndef ATOM_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ +#define ATOM_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ #include "content/public/browser/web_contents_delegate.h" -namespace brightray { +namespace atom { class MediaStreamDevicesController { public: @@ -40,6 +40,6 @@ class MediaStreamDevicesController { DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); }; -} // namespace brightray +} // namespace atom -#endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ +#endif // ATOM_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ diff --git a/atom/browser/net/atom_cert_verifier.cc b/atom/browser/net/atom_cert_verifier.cc index db97d9670ebdc..5f73b49ef2d91 100644 --- a/atom/browser/net/atom_cert_verifier.cc +++ b/atom/browser/net/atom_cert_verifier.cc @@ -7,10 +7,10 @@ #include #include "atom/browser/browser.h" +#include "atom/browser/net/require_ct_delegate.h" #include "atom/common/native_mate_converters/net_converter.h" #include "base/containers/linked_list.h" #include "base/memory/weak_ptr.h" -#include "brightray/browser/net/require_ct_delegate.h" #include "content/public/browser/browser_thread.h" #include "net/base/net_errors.h" #include "net/cert/cert_verify_result.h" @@ -150,7 +150,7 @@ class CertVerifierRequest : public AtomCertVerifier::Request { base::WeakPtrFactory weak_ptr_factory_; }; -AtomCertVerifier::AtomCertVerifier(brightray::RequireCTDelegate* ct_delegate) +AtomCertVerifier::AtomCertVerifier(RequireCTDelegate* ct_delegate) : default_cert_verifier_(net::CertVerifier::CreateDefault()), ct_delegate_(ct_delegate) {} diff --git a/atom/browser/net/atom_cert_verifier.h b/atom/browser/net/atom_cert_verifier.h index 0fd689a05a8cc..d3b66acaf3692 100644 --- a/atom/browser/net/atom_cert_verifier.h +++ b/atom/browser/net/atom_cert_verifier.h @@ -11,15 +11,10 @@ #include "net/cert/cert_verifier.h" -namespace brightray { - -class RequireCTDelegate; - -} // namespace brightray - namespace atom { class CertVerifierRequest; +class RequireCTDelegate; struct VerifyRequestParams { std::string hostname; @@ -34,7 +29,7 @@ struct VerifyRequestParams { class AtomCertVerifier : public net::CertVerifier { public: - explicit AtomCertVerifier(brightray::RequireCTDelegate* ct_delegate); + explicit AtomCertVerifier(RequireCTDelegate* ct_delegate); ~AtomCertVerifier() override; using VerifyProc = base::Callback inflight_requests_; VerifyProc verify_proc_; std::unique_ptr default_cert_verifier_; - brightray::RequireCTDelegate* ct_delegate_; + RequireCTDelegate* ct_delegate_; DISALLOW_COPY_AND_ASSIGN(AtomCertVerifier); }; diff --git a/brightray/browser/net/require_ct_delegate.cc b/atom/browser/net/require_ct_delegate.cc similarity index 90% rename from brightray/browser/net/require_ct_delegate.cc rename to atom/browser/net/require_ct_delegate.cc index cc1d0f082012f..1cca0decda2e4 100644 --- a/brightray/browser/net/require_ct_delegate.cc +++ b/atom/browser/net/require_ct_delegate.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#include "brightray/browser/net/require_ct_delegate.h" +#include "atom/browser/net/require_ct_delegate.h" #include "content/public/browser/browser_thread.h" -namespace brightray { +namespace atom { RequireCTDelegate::RequireCTDelegate() {} @@ -33,4 +33,4 @@ RequireCTDelegate::CTRequirementLevel RequireCTDelegate::IsCTRequiredForHost( return CTRequirementLevel::DEFAULT; } -} // namespace brightray +} // namespace atom diff --git a/brightray/browser/net/require_ct_delegate.h b/atom/browser/net/require_ct_delegate.h similarity index 78% rename from brightray/browser/net/require_ct_delegate.h rename to atom/browser/net/require_ct_delegate.h index f1fb2c144ad1d..15ec3ec170a79 100644 --- a/brightray/browser/net/require_ct_delegate.h +++ b/atom/browser/net/require_ct_delegate.h @@ -2,15 +2,15 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#ifndef BRIGHTRAY_BROWSER_NET_REQUIRE_CT_DELEGATE_H_ -#define BRIGHTRAY_BROWSER_NET_REQUIRE_CT_DELEGATE_H_ +#ifndef ATOM_BROWSER_NET_REQUIRE_CT_DELEGATE_H_ +#define ATOM_BROWSER_NET_REQUIRE_CT_DELEGATE_H_ #include #include #include "net/http/transport_security_state.h" -namespace brightray { +namespace atom { class RequireCTDelegate : public net::TransportSecurityState::RequireCTDelegate { @@ -32,6 +32,6 @@ class RequireCTDelegate DISALLOW_COPY_AND_ASSIGN(RequireCTDelegate); }; -} // namespace brightray +} // namespace atom -#endif // BRIGHTRAY_BROWSER_NET_REQUIRE_CT_DELEGATE_H_ +#endif // ATOM_BROWSER_NET_REQUIRE_CT_DELEGATE_H_ diff --git a/atom/browser/net/url_request_context_getter.cc b/atom/browser/net/url_request_context_getter.cc index be3af544a92dc..ec719e73b3c84 100644 --- a/atom/browser/net/url_request_context_getter.cc +++ b/atom/browser/net/url_request_context_getter.cc @@ -17,10 +17,10 @@ #include "atom/browser/net/atom_network_delegate.h" #include "atom/browser/net/atom_url_request_job_factory.h" #include "atom/browser/net/http_protocol_handler.h" +#include "atom/browser/net/require_ct_delegate.h" #include "base/command_line.h" #include "base/strings/string_util.h" #include "base/task_scheduler/post_task.h" -#include "brightray/browser/net/require_ct_delegate.h" #include "chrome/browser/net/chrome_mojo_proxy_resolver_factory.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" @@ -81,7 +81,7 @@ network::mojom::NetworkContextParamsPtr CreateDefaultNetworkContextParams( network_context_params->http_cache_enabled = use_cache; network_context_params->accept_language = net::HttpUtil::GenerateAcceptLanguageHeader( - brightray::BrowserClient::Get()->GetApplicationLocale()); + AtomBrowserClient::Get()->GetApplicationLocale()); network_context_params->enable_data_url_support = false; network_context_params->proxy_resolver_factory = ChromeMojoProxyResolverFactory::CreateWithStrongBinding().PassInterface(); @@ -317,7 +317,7 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { network_delegate_ = network_delegate.get(); builder->set_network_delegate(std::move(network_delegate)); - ct_delegate_.reset(new brightray::RequireCTDelegate); + ct_delegate_.reset(new RequireCTDelegate); auto cert_verifier = std::make_unique(ct_delegate_.get()); builder->SetCertVerifier(std::move(cert_verifier)); diff --git a/atom/browser/net/url_request_context_getter.h b/atom/browser/net/url_request_context_getter.h index f35d451943a30..8e38fc9788e5d 100644 --- a/atom/browser/net/url_request_context_getter.h +++ b/atom/browser/net/url_request_context_getter.h @@ -19,15 +19,12 @@ #include "base/debug/leak_tracker.h" #endif -namespace brightray { -class RequireCTDelegate; -} // namespace brightray - namespace atom { class AtomBrowserContext; class AtomNetworkDelegate; class AtomURLRequestJobFactory; +class RequireCTDelegate; class ResourceContext; class URLRequestContextGetter : public net::URLRequestContextGetter { @@ -96,7 +93,7 @@ class URLRequestContextGetter : public net::URLRequestContextGetter { base::debug::LeakTracker leak_tracker_; #endif - std::unique_ptr ct_delegate_; + std::unique_ptr ct_delegate_; std::unique_ptr top_job_factory_; std::unique_ptr network_context_; diff --git a/atom/browser/notifications/linux/libnotify_notification.cc b/atom/browser/notifications/linux/libnotify_notification.cc index dfe007aedf638..553057f03941e 100644 --- a/atom/browser/notifications/linux/libnotify_notification.cc +++ b/atom/browser/notifications/linux/libnotify_notification.cc @@ -9,12 +9,12 @@ #include #include "atom/browser/notifications/notification_delegate.h" +#include "atom/common/application_info.h" +#include "atom/common/platform_util.h" #include "base/files/file_enumerator.h" #include "base/logging.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" -#include "brightray/common/application_info.h" -#include "brightray/common/platform_util.h" #include "chrome/browser/ui/libgtkui/gtk_util.h" #include "chrome/browser/ui/libgtkui/skia_utils_gtk.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -66,7 +66,7 @@ bool LibnotifyNotification::Initialize() { return false; } if (!libnotify_loader_.notify_is_initted() && - !libnotify_loader_.notify_init(brightray::GetApplicationName().c_str())) { + !libnotify_loader_.notify_init(GetApplicationName().c_str())) { LOG(WARNING) << "Unable to initialize libnotify; notifications disabled"; return false; } @@ -127,7 +127,7 @@ void LibnotifyNotification::Show(const NotificationOptions& options) { // Send the desktop name to identify the application // The desktop-entry is the part before the .desktop std::string desktop_id; - if (brightray::platform_util::GetDesktopName(&desktop_id)) { + if (platform_util::GetDesktopName(&desktop_id)) { const std::string suffix{".desktop"}; if (base::EndsWith(desktop_id, suffix, base::CompareCase::INSENSITIVE_ASCII)) { diff --git a/atom/browser/notifications/win/windows_toast_notification.cc b/atom/browser/notifications/win/windows_toast_notification.cc index f1e210019bee9..c74326d752596 100644 --- a/atom/browser/notifications/win/windows_toast_notification.cc +++ b/atom/browser/notifications/win/windows_toast_notification.cc @@ -13,10 +13,10 @@ #include "atom/browser/notifications/notification_delegate.h" #include "atom/browser/notifications/win/notification_presenter_win.h" +#include "atom/browser/win/scoped_hstring.h" +#include "atom/common/application_info.h" #include "base/environment.h" #include "base/strings/utf_string_conversions.h" -#include "brightray/browser/win/scoped_hstring.h" -#include "brightray/common/application_info.h" #include "content/public/browser/browser_thread.h" using ABI::Windows::Data::Xml::Dom::IXmlAttribute; @@ -58,13 +58,13 @@ bool WindowsToastNotification::Initialize() { &toast_manager_))) return false; - if (brightray::IsRunningInDesktopBridge()) { + if (IsRunningInDesktopBridge()) { // Ironically, the Desktop Bridge / UWP environment // requires us to not give Windows an appUserModelId. return SUCCEEDED(toast_manager_->CreateToastNotifier(&toast_notifier_)); } else { ScopedHString app_id; - if (!brightray::GetAppUserModelID(&app_id)) + if (!GetAppUserModelID(&app_id)) return false; return SUCCEEDED( diff --git a/atom/browser/ui/cocoa/bry_inspectable_web_contents_view.mm b/atom/browser/ui/cocoa/bry_inspectable_web_contents_view.mm index 4823d9dc83d67..82c5518bf3f0e 100644 --- a/atom/browser/ui/cocoa/bry_inspectable_web_contents_view.mm +++ b/atom/browser/ui/cocoa/bry_inspectable_web_contents_view.mm @@ -150,7 +150,7 @@ - (void)setIsDocked:(BOOL)docked { backing:NSBackingStoreBuffered defer:YES]); [devtools_window_ setDelegate:self]; - [devtools_window_ setFrameAutosaveName:@"brightray.devtools"]; + [devtools_window_ setFrameAutosaveName:@"electron.devtools"]; [devtools_window_ setTitle:@"Developer Tools"]; [devtools_window_ setReleasedWhenClosed:NO]; [devtools_window_ setAutorecalculatesContentBorderThickness:NO diff --git a/atom/browser/ui/devtools_manager_delegate.cc b/atom/browser/ui/devtools_manager_delegate.cc index e5dd5d7e5d530..2361dfa83c13d 100644 --- a/atom/browser/ui/devtools_manager_delegate.cc +++ b/atom/browser/ui/devtools_manager_delegate.cc @@ -13,7 +13,6 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" -#include "brightray/common/content_client.h" #include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/devtools_frontend_host.h" #include "content/public/browser/devtools_socket_factory.h" diff --git a/atom/browser/ui/inspectable_web_contents_impl.cc b/atom/browser/ui/inspectable_web_contents_impl.cc index 9fc86a0b337a4..aa3e0d9cb498c 100644 --- a/atom/browser/ui/inspectable_web_contents_impl.cc +++ b/atom/browser/ui/inspectable_web_contents_impl.cc @@ -59,9 +59,9 @@ const char kChromeUIDevToolsRemoteFrontendBase[] = "https://chrome-devtools-frontend.appspot.com/"; const char kChromeUIDevToolsRemoteFrontendPath[] = "serve_file"; -const char kDevToolsBoundsPref[] = "brightray.devtools.bounds"; -const char kDevToolsZoomPref[] = "brightray.devtools.zoom"; -const char kDevToolsPreferences[] = "brightray.devtools.preferences"; +const char kDevToolsBoundsPref[] = "electron.devtools.bounds"; +const char kDevToolsZoomPref[] = "electron.devtools.zoom"; +const char kDevToolsPreferences[] = "electron.devtools.preferences"; const char kFrontendHostId[] = "id"; const char kFrontendHostMethod[] = "method"; diff --git a/atom/browser/ui/tray_icon_gtk.cc b/atom/browser/ui/tray_icon_gtk.cc index 4c780285c80a1..a1eb3b32b11cc 100644 --- a/atom/browser/ui/tray_icon_gtk.cc +++ b/atom/browser/ui/tray_icon_gtk.cc @@ -5,9 +5,9 @@ #include "atom/browser/ui/tray_icon_gtk.h" #include "atom/browser/browser.h" +#include "atom/common/application_info.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" -#include "brightray/common/application_info.h" #include "chrome/browser/ui/libgtkui/app_indicator_icon.h" #include "chrome/browser/ui/libgtkui/gtk_status_icon.h" #include "ui/gfx/image/image.h" @@ -31,7 +31,7 @@ void TrayIconGtk::SetImage(const gfx::Image& image) { return; } - const auto toolTip = base::UTF8ToUTF16(brightray::GetApplicationName()); + const auto toolTip = base::UTF8ToUTF16(GetApplicationName()); if (libgtkui::AppIndicatorIcon::CouldOpen()) { ++indicators_count; diff --git a/atom/browser/web_contents_permission_helper.cc b/atom/browser/web_contents_permission_helper.cc index f62b38268918d..b9533e481bbbf 100644 --- a/atom/browser/web_contents_permission_helper.cc +++ b/atom/browser/web_contents_permission_helper.cc @@ -9,8 +9,8 @@ #include #include "atom/browser/atom_permission_manager.h" +#include "atom/browser/media/media_stream_devices_controller.h" #include "atom/common/native_mate_converters/gurl_converter.h" -#include "brightray/browser/media/media_stream_devices_controller.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/render_process_host.h" @@ -38,8 +38,7 @@ namespace { void MediaAccessAllowed(const content::MediaStreamRequest& request, content::MediaResponseCallback callback, bool allowed) { - brightray::MediaStreamDevicesController controller(request, - std::move(callback)); + MediaStreamDevicesController controller(request, std::move(callback)); if (allowed) controller.TakeAction(); else diff --git a/brightray/browser/win/scoped_hstring.cc b/atom/browser/win/scoped_hstring.cc similarity index 90% rename from brightray/browser/win/scoped_hstring.cc rename to atom/browser/win/scoped_hstring.cc index 6c9e0a3ec787c..437e45f5123f5 100644 --- a/brightray/browser/win/scoped_hstring.cc +++ b/atom/browser/win/scoped_hstring.cc @@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-CHROMIUM file. -#include "brightray/browser/win/scoped_hstring.h" +#include "atom/browser/win/scoped_hstring.h" #include +namespace atom { + ScopedHString::ScopedHString(const wchar_t* source) : str_(nullptr) { Reset(source); } @@ -36,3 +38,5 @@ void ScopedHString::Reset(const std::wstring& source) { Reset(); WindowsCreateString(source.c_str(), source.length(), &str_); } + +} // namespace atom diff --git a/brightray/browser/win/scoped_hstring.h b/atom/browser/win/scoped_hstring.h similarity index 82% rename from brightray/browser/win/scoped_hstring.h rename to atom/browser/win/scoped_hstring.h index 879e62cd39b89..2b4b8658ce43b 100644 --- a/brightray/browser/win/scoped_hstring.h +++ b/atom/browser/win/scoped_hstring.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-CHROMIUM file. -#ifndef BRIGHTRAY_BROWSER_WIN_SCOPED_HSTRING_H_ -#define BRIGHTRAY_BROWSER_WIN_SCOPED_HSTRING_H_ +#ifndef ATOM_BROWSER_WIN_SCOPED_HSTRING_H_ +#define ATOM_BROWSER_WIN_SCOPED_HSTRING_H_ #include #include @@ -12,6 +12,8 @@ #include "base/macros.h" +namespace atom { + class ScopedHString { public: // Copy from |source|. @@ -38,4 +40,6 @@ class ScopedHString { DISALLOW_COPY_AND_ASSIGN(ScopedHString); }; -#endif // BRIGHTRAY_BROWSER_WIN_SCOPED_HSTRING_H_ +} // namespace atom + +#endif // ATOM_BROWSER_WIN_SCOPED_HSTRING_H_ diff --git a/brightray/browser/zoom_level_delegate.cc b/atom/browser/zoom_level_delegate.cc similarity index 98% rename from brightray/browser/zoom_level_delegate.cc rename to atom/browser/zoom_level_delegate.cc index f58f11cd64686..7044056df950b 100644 --- a/brightray/browser/zoom_level_delegate.cc +++ b/atom/browser/zoom_level_delegate.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "brightray/browser/zoom_level_delegate.h" +#include "atom/browser/zoom_level_delegate.h" #include #include @@ -19,7 +19,7 @@ #include "content/public/browser/browser_thread.h" #include "content/public/common/page_zoom.h" -namespace brightray { +namespace atom { namespace { @@ -164,4 +164,4 @@ void ZoomLevelDelegate::InitHostZoomMap(content::HostZoomMap* host_zoom_map) { &ZoomLevelDelegate::OnZoomLevelChanged, base::Unretained(this))); } -} // namespace brightray +} // namespace atom diff --git a/brightray/browser/zoom_level_delegate.h b/atom/browser/zoom_level_delegate.h similarity index 90% rename from brightray/browser/zoom_level_delegate.h rename to atom/browser/zoom_level_delegate.h index 84021264d7315..6b5ec94fc0e75 100644 --- a/brightray/browser/zoom_level_delegate.h +++ b/atom/browser/zoom_level_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BRIGHTRAY_BROWSER_ZOOM_LEVEL_DELEGATE_H_ -#define BRIGHTRAY_BROWSER_ZOOM_LEVEL_DELEGATE_H_ +#ifndef ATOM_BROWSER_ZOOM_LEVEL_DELEGATE_H_ +#define ATOM_BROWSER_ZOOM_LEVEL_DELEGATE_H_ #include #include @@ -20,7 +20,7 @@ class DictionaryValue; class PrefRegistrySimple; -namespace brightray { +namespace atom { // A class to manage per-partition default and per-host zoom levels. // It implements an interface between the content/ zoom @@ -59,6 +59,6 @@ class ZoomLevelDelegate : public content::ZoomLevelDelegate { DISALLOW_COPY_AND_ASSIGN(ZoomLevelDelegate); }; -} // namespace brightray +} // namespace atom -#endif // BRIGHTRAY_BROWSER_ZOOM_LEVEL_DELEGATE_H_ +#endif // ATOM_BROWSER_ZOOM_LEVEL_DELEGATE_H_ diff --git a/atom/common/api/atom_bindings.cc b/atom/common/api/atom_bindings.cc index 51a85c1297ba6..5590797d4ea34 100644 --- a/atom/common/api/atom_bindings.cc +++ b/atom/common/api/atom_bindings.cc @@ -9,6 +9,7 @@ #include #include "atom/common/api/locker.h" +#include "atom/common/application_info.h" #include "atom/common/atom_version.h" #include "atom/common/chrome_version.h" #include "atom/common/heap_snapshot.h" @@ -20,7 +21,6 @@ #include "base/process/process_metrics_iocounters.h" #include "base/sys_info.h" #include "base/threading/thread_restrictions.h" -#include "brightray/common/application_info.h" #include "native_mate/dictionary.h" namespace atom { @@ -76,7 +76,7 @@ void AtomBindings::BindTo(v8::Isolate* isolate, v8::Local process) { #endif #if defined(OS_WIN) - if (brightray::IsRunningInDesktopBridge()) + if (IsRunningInDesktopBridge()) dict.Set("windowsStore", true); #endif diff --git a/brightray/common/application_info.cc b/atom/common/application_info.cc similarity index 73% rename from brightray/common/application_info.cc rename to atom/common/application_info.cc index 728c8dcdf6d52..53a1b0a52dcfb 100644 --- a/brightray/common/application_info.cc +++ b/atom/common/application_info.cc @@ -1,8 +1,12 @@ -#include "brightray/common/application_info.h" +// Copyright (c) 2013 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/common/application_info.h" #include "base/no_destructor.h" -namespace brightray { +namespace atom { namespace { @@ -27,4 +31,4 @@ std::string GetOverriddenApplicationVersion() { return *g_overridden_application_version; } -} // namespace brightray +} // namespace atom diff --git a/brightray/common/application_info.h b/atom/common/application_info.h similarity index 61% rename from brightray/common/application_info.h rename to atom/common/application_info.h index b11893f51ccf2..6243f288682cc 100644 --- a/brightray/common/application_info.h +++ b/atom/common/application_info.h @@ -1,14 +1,18 @@ -#ifndef BRIGHTRAY_COMMON_APPLICATION_INFO_H_ -#define BRIGHTRAY_COMMON_APPLICATION_INFO_H_ +// Copyright (c) 2013 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef ATOM_COMMON_APPLICATION_INFO_H_ +#define ATOM_COMMON_APPLICATION_INFO_H_ #if defined(OS_WIN) +#include "atom/browser/win/scoped_hstring.h" #include "base/strings/string16.h" -#include "brightray/browser/win/scoped_hstring.h" #endif #include -namespace brightray { +namespace atom { void OverrideApplicationName(const std::string& name); std::string GetOverriddenApplicationName(); @@ -26,6 +30,6 @@ void SetAppUserModelID(const base::string16& name); bool IsRunningInDesktopBridge(); #endif -} // namespace brightray +} // namespace atom -#endif // BRIGHTRAY_COMMON_APPLICATION_INFO_H_ +#endif // ATOM_COMMON_APPLICATION_INFO_H_ diff --git a/atom/common/linux/application_info.cc b/atom/common/application_info_linux.cc similarity index 89% rename from atom/common/linux/application_info.cc rename to atom/common/application_info_linux.cc index 3354c73b8b60f..2bf0e802efc95 100644 --- a/atom/common/linux/application_info.cc +++ b/atom/common/application_info_linux.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#include "brightray/common/application_info.h" +#include "atom/common/application_info.h" #include #include @@ -11,9 +11,9 @@ #include #include "atom/common/atom_version.h" +#include "atom/common/platform_util.h" #include "base/environment.h" #include "base/logging.h" -#include "brightray/common/platform_util.h" #include "chrome/browser/ui/libgtkui/gtk_util.h" namespace { @@ -22,7 +22,7 @@ GDesktopAppInfo* get_desktop_app_info() { GDesktopAppInfo* ret = nullptr; std::string desktop_id; - if (brightray::platform_util::GetDesktopName(&desktop_id)) + if (atom::platform_util::GetDesktopName(&desktop_id)) ret = g_desktop_app_info_new(desktop_id.c_str()); return ret; @@ -30,7 +30,7 @@ GDesktopAppInfo* get_desktop_app_info() { } // namespace -namespace brightray { +namespace atom { std::string GetApplicationName() { // attempt #1: the string set in app.setName() @@ -76,4 +76,4 @@ std::string GetApplicationVersion() { return ret; } -} // namespace brightray +} // namespace atom diff --git a/brightray/common/application_info_mac.mm b/atom/common/application_info_mac.mm similarity index 70% rename from brightray/common/application_info_mac.mm rename to atom/common/application_info_mac.mm index 63db8c9b4c7df..163d0e22c75e9 100644 --- a/brightray/common/application_info_mac.mm +++ b/atom/common/application_info_mac.mm @@ -1,10 +1,14 @@ -#import "brightray/common/application_info.h" +// Copyright (c) 2013 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. +#import "atom/common/application_info.h" + +#import "atom/common/mac/main_application_bundle.h" #import "base/mac/foundation_util.h" #import "base/strings/sys_string_conversions.h" -#import "brightray/common/mac/main_application_bundle.h" -namespace brightray { +namespace atom { namespace { @@ -27,4 +31,4 @@ return ApplicationInfoDictionaryValue(@"CFBundleShortVersionString"); } -} // namespace brightray +} // namespace atom diff --git a/brightray/common/application_info_win.cc b/atom/common/application_info_win.cc similarity index 92% rename from brightray/common/application_info_win.cc rename to atom/common/application_info_win.cc index abd28eee4fd57..a6f4e939f49a3 100644 --- a/brightray/common/application_info_win.cc +++ b/atom/common/application_info_win.cc @@ -1,4 +1,8 @@ -#include "brightray/common/application_info.h" +// Copyright (c) 2013 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/common/application_info.h" #include // windows.h must be included first @@ -8,13 +12,13 @@ #include +#include "atom/browser/win/scoped_hstring.h" #include "base/file_version_info.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" -#include "brightray/browser/win/scoped_hstring.h" -namespace brightray { +namespace atom { namespace { @@ -106,4 +110,4 @@ bool IsRunningInDesktopBridge() { return result; } -} // namespace brightray +} // namespace atom diff --git a/atom/common/mac/main_application_bundle.h b/atom/common/mac/main_application_bundle.h new file mode 100644 index 0000000000000..ab1ea6d614daf --- /dev/null +++ b/atom/common/mac/main_application_bundle.h @@ -0,0 +1,26 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2013 Adam Roben . All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE-CHROMIUM file. + +#ifndef ATOM_COMMON_MAC_MAIN_APPLICATION_BUNDLE_H_ +#define ATOM_COMMON_MAC_MAIN_APPLICATION_BUNDLE_H_ + +@class NSBundle; + +namespace base { +class FilePath; +} + +namespace atom { + +// The "main" application bundle is the outermost bundle for this logical +// application. E.g., if you have MyApp.app and +// MyApp.app/Contents/Frameworks/MyApp Helper.app, the main application bundle +// is MyApp.app, no matter which executable is currently running. +NSBundle* MainApplicationBundle(); +base::FilePath MainApplicationBundlePath(); + +} // namespace atom + +#endif // ATOM_COMMON_MAC_MAIN_APPLICATION_BUNDLE_H_ diff --git a/brightray/common/mac/main_application_bundle.mm b/atom/common/mac/main_application_bundle.mm similarity index 94% rename from brightray/common/mac/main_application_bundle.mm rename to atom/common/mac/main_application_bundle.mm index 9a26b079f59ef..6971424e9cd8a 100644 --- a/brightray/common/mac/main_application_bundle.mm +++ b/atom/common/mac/main_application_bundle.mm @@ -3,7 +3,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-CHROMIUM file. -#import "brightray/common/mac/main_application_bundle.h" +#import "atom/common/mac/main_application_bundle.h" #include "base/files/file_path.h" #include "base/mac/bundle_locations.h" @@ -11,7 +11,7 @@ #include "base/path_service.h" #include "base/strings/string_util.h" -namespace brightray { +namespace atom { namespace { @@ -53,4 +53,4 @@ bool HasMainProcessKey() { MainApplicationBundlePath())]; } -} // namespace brightray +} // namespace atom diff --git a/atom/common/platform_util.h b/atom/common/platform_util.h index 6686a4f4e1ee9..bab1bbf793130 100644 --- a/atom/common/platform_util.h +++ b/atom/common/platform_util.h @@ -64,6 +64,12 @@ bool GetLoginItemEnabled(); void SetLoginItemEnabled(bool enabled); #endif +#if defined(OS_LINUX) +// Returns a success flag. +// Unlike libgtkui, does *not* use "chromium-browser.desktop" as a fallback. +bool GetDesktopName(std::string* setme); +#endif + } // namespace platform_util #endif // ATOM_COMMON_PLATFORM_UTIL_H_ diff --git a/atom/common/platform_util_linux.cc b/atom/common/platform_util_linux.cc index f17cbda11c812..4d386ead4a2b1 100644 --- a/atom/common/platform_util_linux.cc +++ b/atom/common/platform_util_linux.cc @@ -12,6 +12,7 @@ #include "base/nix/xdg_util.h" #include "base/process/kill.h" #include "base/process/launch.h" +#include "chrome/browser/ui/libgtkui/gtk_util.h" #include "url/gurl.h" #define ELECTRON_TRASH "ELECTRON_TRASH" @@ -145,4 +146,18 @@ void Beep() { fclose(console); } +bool GetDesktopName(std::string* setme) { + bool found = false; + + std::unique_ptr env(base::Environment::Create()); + std::string desktop_id = libgtkui::GetDesktopName(env.get()); + constexpr char const* libcc_default_id = "chromium-browser.desktop"; + if (!desktop_id.empty() && (desktop_id != libcc_default_id)) { + *setme = desktop_id; + found = true; + } + + return found; +} + } // namespace platform_util diff --git a/atom/renderer/atom_sandboxed_renderer_client.cc b/atom/renderer/atom_sandboxed_renderer_client.cc index 688f33bc165b0..db05f967188c5 100644 --- a/atom/renderer/atom_sandboxed_renderer_client.cc +++ b/atom/renderer/atom_sandboxed_renderer_client.cc @@ -6,6 +6,7 @@ #include "atom/common/api/api_messages.h" #include "atom/common/api/atom_bindings.h" +#include "atom/common/application_info.h" #include "atom/common/native_mate_converters/string16_converter.h" #include "atom/common/native_mate_converters/value_converter.h" #include "atom/common/node_bindings.h" @@ -17,7 +18,6 @@ #include "base/files/file_path.h" #include "base/path_service.h" #include "base/process/process_handle.h" -#include "brightray/common/application_info.h" #include "content/public/renderer/render_frame.h" #include "native_mate/dictionary.h" #include "third_party/blink/public/web/blink.h" @@ -168,7 +168,7 @@ void AtomSandboxedRendererClient::InitializeBindings( #endif #if defined(OS_WIN) - if (brightray::IsRunningInDesktopBridge()) + if (IsRunningInDesktopBridge()) process.Set("windowsStore", true); #endif diff --git a/brightray/BUILD.gn b/brightray/BUILD.gn deleted file mode 100644 index b02c40b69d9b2..0000000000000 --- a/brightray/BUILD.gn +++ /dev/null @@ -1,53 +0,0 @@ -import("//build/config/ui.gni") - -static_library("brightray") { - deps = [ - "//base", - "//base:base_static", - "//content/public/browser", - "//content/shell:copy_shell_resources", - "//net:extras", - "//net:net_with_v8", - "//ui/views", - ] - - include_dirs = [ ".." ] - - if (is_linux) { - deps += [ "//build/config/linux/gtk" ] - } - - sources = [ - "browser/brightray_paths.h", - "browser/browser_client.cc", - "browser/browser_client.h", - "browser/browser_main_parts.cc", - "browser/browser_main_parts.h", - "browser/browser_main_parts_mac.mm", - "browser/media/media_capture_devices_dispatcher.cc", - "browser/media/media_capture_devices_dispatcher.h", - "browser/media/media_device_id_salt.cc", - "browser/media/media_device_id_salt.h", - "browser/media/media_stream_devices_controller.cc", - "browser/media/media_stream_devices_controller.h", - "browser/net/require_ct_delegate.cc", - "browser/net/require_ct_delegate.h", - "browser/win/scoped_hstring.cc", - "browser/win/scoped_hstring.h", - "browser/zoom_level_delegate.cc", - "browser/zoom_level_delegate.h", - "common/application_info.cc", - "common/application_info.h", - "common/application_info_mac.mm", - "common/application_info_win.cc", - "common/content_client.cc", - "common/content_client.h", - "common/mac/main_application_bundle.h", - "common/mac/main_application_bundle.mm", - "common/main_delegate.cc", - "common/main_delegate.h", - "common/main_delegate_mac.mm", - "common/platform_util.h", - "common/platform_util_linux.cc", - ] -} diff --git a/brightray/CPPLINT.cfg b/brightray/CPPLINT.cfg deleted file mode 100644 index 88c6f99113d51..0000000000000 --- a/brightray/CPPLINT.cfg +++ /dev/null @@ -1 +0,0 @@ -filter=-legal/copyright diff --git a/brightray/LICENSE b/brightray/LICENSE deleted file mode 100644 index fe24a3c65fbd7..0000000000000 --- a/brightray/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2013-2014 Adam Roben - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/brightray/LICENSE-CHROMIUM b/brightray/LICENSE-CHROMIUM deleted file mode 100644 index 3d0f7d3edfd81..0000000000000 --- a/brightray/LICENSE-CHROMIUM +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/brightray/browser/browser_client.cc b/brightray/browser/browser_client.cc deleted file mode 100644 index 4ae108486c122..0000000000000 --- a/brightray/browser/browser_client.cc +++ /dev/null @@ -1,90 +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-CHROMIUM file. - -#include "brightray/browser/browser_client.h" - -#include "base/lazy_instance.h" -#include "base/no_destructor.h" -#include "base/path_service.h" -#include "brightray/browser/browser_main_parts.h" -#include "brightray/browser/media/media_capture_devices_dispatcher.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/common/url_constants.h" - -using content::BrowserThread; - -namespace brightray { - -namespace { - -BrowserClient* g_browser_client; - -base::LazyInstance::DestructorAtExit - g_io_thread_application_locale = LAZY_INSTANCE_INITIALIZER; - -base::NoDestructor g_application_locale; - -void SetApplicationLocaleOnIOThread(const std::string& locale) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - g_io_thread_application_locale.Get() = locale; -} - -} // namespace - -// static -void BrowserClient::SetApplicationLocale(const std::string& locale) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - - if (!BrowserThread::IsThreadInitialized(BrowserThread::IO) || - !BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::BindOnce(&SetApplicationLocaleOnIOThread, locale))) { - g_io_thread_application_locale.Get() = locale; - } - *g_application_locale = locale; -} - -BrowserClient* BrowserClient::Get() { - return g_browser_client; -} - -BrowserClient::BrowserClient() : browser_main_parts_(nullptr) { - DCHECK(!g_browser_client); - g_browser_client = this; -} - -BrowserClient::~BrowserClient() {} - -BrowserMainParts* BrowserClient::OverrideCreateBrowserMainParts( - const content::MainFunctionParams&) { - return new BrowserMainParts; -} - -content::BrowserMainParts* BrowserClient::CreateBrowserMainParts( - const content::MainFunctionParams& parameters) { - DCHECK(!browser_main_parts_); - browser_main_parts_ = OverrideCreateBrowserMainParts(parameters); - return browser_main_parts_; -} - -content::MediaObserver* BrowserClient::GetMediaObserver() { - return MediaCaptureDevicesDispatcher::GetInstance(); -} - -base::FilePath BrowserClient::GetDefaultDownloadDirectory() { - // ~/Downloads - base::FilePath path; - if (base::PathService::Get(base::DIR_HOME, &path)) - path = path.Append(FILE_PATH_LITERAL("Downloads")); - - return path; -} - -std::string BrowserClient::GetApplicationLocale() { - if (BrowserThread::CurrentlyOn(BrowserThread::IO)) - return g_io_thread_application_locale.Get(); - return *g_application_locale; -} - -} // namespace brightray diff --git a/brightray/browser/browser_client.h b/brightray/browser/browser_client.h deleted file mode 100644 index 7fbf1722a8cc4..0000000000000 --- a/brightray/browser/browser_client.h +++ /dev/null @@ -1,51 +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-CHROMIUM file. - -#ifndef BRIGHTRAY_BROWSER_BROWSER_CLIENT_H_ -#define BRIGHTRAY_BROWSER_BROWSER_CLIENT_H_ - -#include -#include -#include - -#include "content/public/browser/content_browser_client.h" - -namespace brightray { - -class BrowserMainParts; - -class BrowserClient : public content::ContentBrowserClient { - public: - static BrowserClient* Get(); - static void SetApplicationLocale(const std::string& locale); - - BrowserClient(); - ~BrowserClient() override; - - BrowserMainParts* browser_main_parts() { return browser_main_parts_; } - - // Subclasses that override this (e.g., to provide their own protocol - // handlers) should call this implementation after doing their own work. - content::BrowserMainParts* CreateBrowserMainParts( - const content::MainFunctionParams&) override; - content::MediaObserver* GetMediaObserver() override; - base::FilePath GetDefaultDownloadDirectory() override; - std::string GetApplicationLocale() override; - - protected: - // Subclasses should override this to provide their own BrowserMainParts - // implementation. The lifetime of the returned instance is managed by the - // caller. - virtual BrowserMainParts* OverrideCreateBrowserMainParts( - const content::MainFunctionParams&); - - private: - BrowserMainParts* browser_main_parts_; - - DISALLOW_COPY_AND_ASSIGN(BrowserClient); -}; - -} // namespace brightray - -#endif // BRIGHTRAY_BROWSER_BROWSER_CLIENT_H_ diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc deleted file mode 100644 index 72637a2dc9029..0000000000000 --- a/brightray/browser/browser_main_parts.cc +++ /dev/null @@ -1,326 +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-CHROMIUM file. - -#include "brightray/browser/browser_main_parts.h" - -#if defined(OS_POSIX) -#include -#endif - -#include -#include -#include - -#if defined(OS_LINUX) -#include // for g_setenv() -#endif - -#include "base/base_switches.h" -#include "base/command_line.h" -#include "base/feature_list.h" -#include "base/message_loop/message_loop.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/utf_string_conversions.h" -#include "brightray/browser/browser_client.h" -#include "brightray/browser/media/media_capture_devices_dispatcher.h" -#include "brightray/common/application_info.h" -#include "brightray/common/main_delegate.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/common/content_features.h" -#include "content/public/common/content_switches.h" -#include "content/public/common/result_codes.h" -#include "media/base/localized_strings.h" -#include "net/proxy_resolution/proxy_resolver_v8.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/material_design/material_design_controller.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/base/ui_base_switches.h" - -#if defined(USE_AURA) -#include "ui/display/display.h" -#include "ui/display/screen.h" -#include "ui/views/widget/desktop_aura/desktop_screen.h" -#include "ui/wm/core/wm_state.h" -#endif - -#if defined(USE_X11) -#include "base/environment.h" -#include "base/nix/xdg_util.h" -#include "base/path_service.h" -#include "base/threading/thread_task_runner_handle.h" -#include "brightray/browser/brightray_paths.h" -#include "chrome/browser/ui/libgtkui/gtk_ui.h" -#include "ui/base/x/x11_util.h" -#include "ui/base/x/x11_util_internal.h" -#include "ui/views/linux_ui/linux_ui.h" -#endif - -#if defined(OS_WIN) -#include "ui/base/cursor/cursor_loader_win.h" -#include "ui/base/l10n/l10n_util_win.h" -#include "ui/gfx/platform_font_win.h" -#endif - -#if defined(OS_LINUX) -#include "device/bluetooth/bluetooth_adapter_factory.h" -#include "device/bluetooth/dbus/dbus_bluez_manager_wrapper_linux.h" -#endif - -namespace brightray { - -namespace { - -#if defined(OS_WIN) -// gfx::Font callbacks -void AdjustUIFont(LOGFONT* logfont) { - l10n_util::AdjustUIFont(logfont); -} - -int GetMinimumFontSize() { - return 10; -} -#endif - -#if defined(USE_X11) -// Indicates that we're currently responding to an IO error (by shutting down). -bool g_in_x11_io_error_handler = false; - -// Number of seconds to wait for UI thread to get an IO error if we get it on -// the background thread. -const int kWaitForUIThreadSeconds = 10; - -void OverrideLinuxAppDataPath() { - base::FilePath path; - if (base::PathService::Get(DIR_APP_DATA, &path)) - return; - std::unique_ptr env(base::Environment::Create()); - path = base::nix::GetXDGDirectory(env.get(), base::nix::kXdgConfigHomeEnvVar, - base::nix::kDotConfigDir); - base::PathService::Override(DIR_APP_DATA, path); -} - -int BrowserX11ErrorHandler(Display* d, XErrorEvent* error) { - if (!g_in_x11_io_error_handler && base::ThreadTaskRunnerHandle::IsSet()) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&ui::LogErrorEventDescription, d, *error)); - } - return 0; -} - -// This function is used to help us diagnose crash dumps that happen -// during the shutdown process. -NOINLINE void WaitingForUIThreadToHandleIOError() { - // Ensure function isn't optimized away. - asm(""); - sleep(kWaitForUIThreadSeconds); -} - -int BrowserX11IOErrorHandler(Display* d) { - if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { - // Wait for the UI thread (which has a different connection to the X server) - // to get the error. We can't call shutdown from this thread without - // tripping an error. Doing it through a function so that we'll be able - // to see it in any crash dumps. - WaitingForUIThreadToHandleIOError(); - return 0; - } - - // If there's an IO error it likely means the X server has gone away. - // If this CHECK fails, then that means SessionEnding() below triggered some - // code that tried to talk to the X server, resulting in yet another error. - CHECK(!g_in_x11_io_error_handler); - - g_in_x11_io_error_handler = true; - LOG(ERROR) << "X IO error received (X server probably went away)"; - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated()); - - return 0; -} - -int X11EmptyErrorHandler(Display* d, XErrorEvent* error) { - return 0; -} - -int X11EmptyIOErrorHandler(Display* d) { - return 0; -} -#endif - -base::string16 MediaStringProvider(media::MessageId id) { - switch (id) { - case media::DEFAULT_AUDIO_DEVICE_NAME: - return base::ASCIIToUTF16("Default"); -#if defined(OS_WIN) - case media::COMMUNICATIONS_AUDIO_DEVICE_NAME: - return base::ASCIIToUTF16("Communications"); -#endif - default: - return base::string16(); - } -} - -} // namespace - -BrowserMainParts::BrowserMainParts() {} - -BrowserMainParts::~BrowserMainParts() {} - -#if defined(OS_WIN) || defined(OS_LINUX) -void OverrideAppLogsPath() { - base::FilePath path; - if (base::PathService::Get(brightray::DIR_APP_DATA, &path)) { - path = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); - path = path.Append(base::FilePath::FromUTF8Unsafe("logs")); - base::PathService::Override(DIR_APP_LOGS, path); - } -} -#endif - -void BrowserMainParts::InitializeFeatureList() { - auto* cmd_line = base::CommandLine::ForCurrentProcess(); - auto enable_features = - cmd_line->GetSwitchValueASCII(switches::kEnableFeatures); - // Node depends on SharedArrayBuffer support, which was temporarily disabled - // by https://chromium-review.googlesource.com/c/chromium/src/+/849429 (in - // M64) and reenabled by - // https://chromium-review.googlesource.com/c/chromium/src/+/1159358 (in - // M70). Once Electron upgrades to M70, we can remove this. - enable_features += std::string(",") + features::kSharedArrayBuffer.name; - auto disable_features = - cmd_line->GetSwitchValueASCII(switches::kDisableFeatures); -#if defined(OS_MACOSX) - // Disable the V2 sandbox on macOS. - // Chromium is going to use the system sandbox API of macOS for the sandbox - // implmentation, we may have to deprecate --mixed-sandbox for macOS once - // Chromium drops support for the old sandbox implmentation. - disable_features += std::string(",") + features::kMacV2Sandbox.name; -#endif - auto feature_list = std::make_unique(); - feature_list->InitializeFromCommandLine(enable_features, disable_features); - base::FeatureList::SetInstance(std::move(feature_list)); -} - -bool BrowserMainParts::ShouldContentCreateFeatureList() { - return false; -} - -int BrowserMainParts::PreEarlyInitialization() { - InitializeFeatureList(); - OverrideAppLogsPath(); -#if defined(USE_X11) - views::LinuxUI::SetInstance(BuildGtkUi()); - OverrideLinuxAppDataPath(); - - // Installs the X11 error handlers for the browser process used during - // startup. They simply print error messages and exit because - // we can't shutdown properly while creating and initializing services. - ui::SetX11ErrorHandlers(nullptr, nullptr); -#endif - - return service_manager::RESULT_CODE_NORMAL_EXIT; -} - -void BrowserMainParts::ToolkitInitialized() { - ui::MaterialDesignController::Initialize(); - -#if defined(USE_AURA) && defined(USE_X11) - views::LinuxUI::instance()->Initialize(); -#endif - -#if defined(USE_AURA) - wm_state_.reset(new wm::WMState); -#endif - -#if defined(OS_WIN) - gfx::PlatformFontWin::adjust_font_callback = &AdjustUIFont; - gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize; - - wchar_t module_name[MAX_PATH] = {0}; - if (GetModuleFileName(NULL, module_name, MAX_PATH)) - ui::CursorLoaderWin::SetCursorResourceModule(module_name); -#endif -} - -void BrowserMainParts::PreMainMessageLoopStart() { - // Initialize ui::ResourceBundle. - ui::ResourceBundle::InitSharedInstanceWithLocale( - "", nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); - auto* cmd_line = base::CommandLine::ForCurrentProcess(); - if (cmd_line->HasSwitch(switches::kLang)) { - const std::string locale = cmd_line->GetSwitchValueASCII(switches::kLang); - const base::FilePath locale_file_path = - ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale, true); - if (!locale_file_path.empty()) { - custom_locale_ = locale; -#if defined(OS_LINUX) - /* When built with USE_GLIB, libcc's GetApplicationLocaleInternal() uses - * glib's g_get_language_names(), which keys off of getenv("LC_ALL") */ - g_setenv("LC_ALL", custom_locale_.c_str(), TRUE); -#endif - } - } - -#if defined(OS_MACOSX) - if (custom_locale_.empty()) - l10n_util::OverrideLocaleWithCocoaLocale(); -#endif - LoadResourceBundle(custom_locale_); -#if defined(OS_MACOSX) - InitializeMainNib(); -#endif - media::SetLocalizedStringProvider(MediaStringProvider); -} - -void BrowserMainParts::PostMainMessageLoopStart() { -#if defined(USE_X11) - // Installs the X11 error handlers for the browser process after the - // main message loop has started. This will allow us to exit cleanly - // if X exits before us. - ui::SetX11ErrorHandlers(BrowserX11ErrorHandler, BrowserX11IOErrorHandler); -#endif -#if defined(OS_LINUX) - bluez::DBusBluezManagerWrapperLinux::Initialize(); -#endif -} - -void BrowserMainParts::PostMainMessageLoopRun() { -#if defined(USE_X11) - // Unset the X11 error handlers. The X11 error handlers log the errors using a - // |PostTask()| on the message-loop. But since the message-loop is in the - // process of terminating, this can cause errors. - ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); -#endif -} - -int BrowserMainParts::PreCreateThreads() { -#if defined(USE_AURA) - display::Screen* screen = views::CreateDesktopScreen(); - display::Screen::SetScreenInstance(screen); -#if defined(USE_X11) - views::LinuxUI::instance()->UpdateDeviceScaleFactor(); -#endif -#endif - - // Force MediaCaptureDevicesDispatcher to be created on UI thread. - MediaCaptureDevicesDispatcher::GetInstance(); - - if (!views::LayoutProvider::Get()) - layout_provider_.reset(new views::LayoutProvider()); - - // Initialize the app locale. - BrowserClient::SetApplicationLocale( - l10n_util::GetApplicationLocale(custom_locale_)); - - return 0; -} - -void BrowserMainParts::PostDestroyThreads() { -#if defined(OS_LINUX) - device::BluetoothAdapterFactory::Shutdown(); - bluez::DBusBluezManagerWrapperLinux::Shutdown(); -#endif -} - -} // namespace brightray diff --git a/brightray/browser/browser_main_parts.h b/brightray/browser/browser_main_parts.h deleted file mode 100644 index 505689e6704c8..0000000000000 --- a/brightray/browser/browser_main_parts.h +++ /dev/null @@ -1,62 +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-CHROMIUM file. - -#ifndef BRIGHTRAY_BROWSER_BROWSER_MAIN_PARTS_H_ -#define BRIGHTRAY_BROWSER_BROWSER_MAIN_PARTS_H_ - -#include -#include - -#include "base/compiler_specific.h" -#include "base/macros.h" -#include "base/path_service.h" -#include "brightray/browser/brightray_paths.h" -#include "content/public/browser/browser_main_parts.h" -#include "ui/views/layout/layout_provider.h" - -#if defined(USE_AURA) -namespace wm { -class WMState; -} -#endif - -namespace brightray { - -class BrowserMainParts : public content::BrowserMainParts { - public: - BrowserMainParts(); - ~BrowserMainParts() override; - - protected: - // content::BrowserMainParts: - bool ShouldContentCreateFeatureList() override; - int PreEarlyInitialization() override; - void ToolkitInitialized() override; - void PreMainMessageLoopStart() override; - void PostMainMessageLoopStart() override; - void PostMainMessageLoopRun() override; - int PreCreateThreads() override; - void PostDestroyThreads() override; - - void InitializeFeatureList(); - - private: -#if defined(OS_MACOSX) - void InitializeMainNib(); - void OverrideAppLogsPath(); -#endif - -#if defined(USE_AURA) - std::unique_ptr wm_state_; -#endif - - std::unique_ptr layout_provider_; - std::string custom_locale_; - - DISALLOW_COPY_AND_ASSIGN(BrowserMainParts); -}; - -} // namespace brightray - -#endif // BRIGHTRAY_BROWSER_BROWSER_MAIN_PARTS_H_ diff --git a/brightray/browser/browser_main_parts_mac.mm b/brightray/browser/browser_main_parts_mac.mm deleted file mode 100644 index b0deae60828c9..0000000000000 --- a/brightray/browser/browser_main_parts_mac.mm +++ /dev/null @@ -1,37 +0,0 @@ -#import "brightray/browser/browser_main_parts.h" - -#import -#import "base/logging.h" -#import "base/mac/bundle_locations.h" - -namespace brightray { - -void BrowserMainParts::OverrideAppLogsPath() { - base::FilePath path; - NSString* bundleName = - [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; - NSString* logsPath = - [NSString stringWithFormat:@"Library/Logs/%@", bundleName]; - NSString* libraryPath = - [NSHomeDirectory() stringByAppendingPathComponent:logsPath]; - - base::PathService::Override(DIR_APP_LOGS, - base::FilePath([libraryPath UTF8String])); -} - -// Replicates NSApplicationMain, but doesn't start a run loop. -void BrowserMainParts::InitializeMainNib() { - auto infoDictionary = base::mac::OuterBundle().infoDictionary; - - auto principalClass = - NSClassFromString([infoDictionary objectForKey:@"NSPrincipalClass"]); - auto application = [principalClass sharedApplication]; - - NSString* mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"]; - auto mainNib = [[NSNib alloc] initWithNibNamed:mainNibName - bundle:base::mac::FrameworkBundle()]; - [mainNib instantiateWithOwner:application topLevelObjects:nil]; - [mainNib release]; -} - -} // namespace brightray diff --git a/brightray/common/content_client.cc b/brightray/common/content_client.cc deleted file mode 100644 index 2a8331c53cec4..0000000000000 --- a/brightray/common/content_client.cc +++ /dev/null @@ -1,61 +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-CHROMIUM file. - -#include "brightray/common/content_client.h" - -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" -#include "brightray/common/application_info.h" -#include "content/public/common/user_agent.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" - -namespace brightray { - -std::string GetProductInternal() { - auto name = GetApplicationName(); - base::RemoveChars(name, base::kWhitespaceASCII, &name); - return base::StringPrintf("%s/%s", name.c_str(), - GetApplicationVersion().c_str()); -} - -std::string GetBrightrayUserAgent() { - return content::BuildUserAgentFromProduct(GetProductInternal()); -} - -ContentClient::ContentClient() {} - -ContentClient::~ContentClient() {} - -std::string ContentClient::GetProduct() const { - return GetProductInternal(); -} - -std::string ContentClient::GetUserAgent() const { - return GetBrightrayUserAgent(); -} - -base::string16 ContentClient::GetLocalizedString(int message_id) const { - return l10n_util::GetStringUTF16(message_id); -} - -base::StringPiece ContentClient::GetDataResource( - int resource_id, - ui::ScaleFactor scale_factor) const { - return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( - resource_id, scale_factor); -} - -gfx::Image& ContentClient::GetNativeImageNamed(int resource_id) const { - return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( - resource_id); -} - -base::RefCountedMemory* ContentClient::GetDataResourceBytes( - int resource_id) const { - return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( - resource_id); -} - -} // namespace brightray diff --git a/brightray/common/content_client.h b/brightray/common/content_client.h deleted file mode 100644 index 0089ebc9d8106..0000000000000 --- a/brightray/common/content_client.h +++ /dev/null @@ -1,36 +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-CHROMIUM file. - -#ifndef BRIGHTRAY_COMMON_CONTENT_CLIENT_H_ -#define BRIGHTRAY_COMMON_CONTENT_CLIENT_H_ - -#include - -#include "base/compiler_specific.h" -#include "content/public/common/content_client.h" - -namespace brightray { - -std::string GetBrightrayUserAgent(); - -class ContentClient : public content::ContentClient { - public: - ContentClient(); - ~ContentClient() override; - - private: - std::string GetProduct() const override; - std::string GetUserAgent() const override; - base::string16 GetLocalizedString(int message_id) const override; - base::StringPiece GetDataResource(int resource_id, - ui::ScaleFactor) const override; - gfx::Image& GetNativeImageNamed(int resource_id) const override; - base::RefCountedMemory* GetDataResourceBytes(int resource_id) const override; - - DISALLOW_COPY_AND_ASSIGN(ContentClient); -}; - -} // namespace brightray - -#endif // BRIGHTRAY_COMMON_CONTENT_CLIENT_H_ diff --git a/brightray/common/mac/main_application_bundle.h b/brightray/common/mac/main_application_bundle.h deleted file mode 100644 index 555738023cfd6..0000000000000 --- a/brightray/common/mac/main_application_bundle.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef BRIGHTRAY_COMMON_MAC_MAIN_APPLICATION_BUNDLE_H_ -#define BRIGHTRAY_COMMON_MAC_MAIN_APPLICATION_BUNDLE_H_ - -@class NSBundle; - -namespace base { -class FilePath; -} - -namespace brightray { - -// The "main" application bundle is the outermost bundle for this logical -// application. E.g., if you have MyApp.app and -// MyApp.app/Contents/Frameworks/MyApp Helper.app, the main application bundle -// is MyApp.app, no matter which executable is currently running. -NSBundle* MainApplicationBundle(); -base::FilePath MainApplicationBundlePath(); - -} // namespace brightray - -#endif // BRIGHTRAY_COMMON_MAC_MAIN_APPLICATION_BUNDLE_H_ diff --git a/brightray/common/main_delegate.cc b/brightray/common/main_delegate.cc deleted file mode 100644 index 942e8b3504dd4..0000000000000 --- a/brightray/common/main_delegate.cc +++ /dev/null @@ -1,116 +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-CHROMIUM file. - -#include "brightray/common/main_delegate.h" - -#include - -#include "base/command_line.h" -#include "base/mac/bundle_locations.h" -#include "base/path_service.h" -#include "brightray/browser/browser_client.h" -#include "brightray/common/content_client.h" -#include "content/public/common/content_switches.h" -#include "electron/buildflags/buildflags.h" -#include "services/service_manager/embedder/switches.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/base/ui_base_switches.h" - -namespace brightray { - -namespace { - -// Returns true if this subprocess type needs the ResourceBundle initialized -// and resources loaded. -bool SubprocessNeedsResourceBundle(const std::string& process_type) { - return -#if defined(OS_POSIX) && !defined(OS_MACOSX) - // The zygote process opens the resources for the renderers. - process_type == service_manager::switches::kZygoteProcess || -#endif -#if defined(OS_MACOSX) - // Mac needs them too for scrollbar related images and for sandbox - // profiles. - process_type == switches::kPpapiPluginProcess || - process_type == switches::kPpapiBrokerProcess || - process_type == switches::kGpuProcess || -#endif - process_type == switches::kRendererProcess || - process_type == switches::kUtilityProcess; -} - -} // namespace - -void LoadResourceBundle(const std::string& locale) { - const bool initialized = ui::ResourceBundle::HasSharedInstance(); - if (initialized) - ui::ResourceBundle::CleanupSharedInstance(); - - // Load other resource files. - base::FilePath pak_dir; -#if defined(OS_MACOSX) - pak_dir = - base::mac::FrameworkBundlePath().Append(FILE_PATH_LITERAL("Resources")); -#else - base::PathService::Get(base::DIR_MODULE, &pak_dir); -#endif - - ui::ResourceBundle::InitSharedInstanceWithLocale( - locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES); - ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); - bundle.ReloadLocaleResources(locale); - bundle.AddDataPackFromPath(pak_dir.Append(FILE_PATH_LITERAL("resources.pak")), - ui::SCALE_FACTOR_NONE); -#if BUILDFLAG(ENABLE_PDF_VIEWER) - NOTIMPLEMENTED() - << "Hi, whoever's fixing PDF support! Thanks! The pdf " - "viewer resources haven't been ported over to the GN build yet, so " - "you'll probably need to change this bit of code."; - bundle.AddDataPackFromPath( - pak_dir.Append(FILE_PATH_LITERAL("pdf_viewer_resources.pak")), - ui::GetSupportedScaleFactors()[0]); -#endif // BUILDFLAG(ENABLE_PDF_VIEWER) -} - -MainDelegate::MainDelegate() {} - -MainDelegate::~MainDelegate() {} - -std::unique_ptr MainDelegate::CreateContentClient() { - return std::unique_ptr(new ContentClient); -} - -bool MainDelegate::BasicStartupComplete(int* exit_code) { - content_client_ = CreateContentClient(); - SetContentClient(content_client_.get()); -#if defined(OS_MACOSX) - OverrideChildProcessPath(); - OverrideFrameworkBundlePath(); -#endif - return false; -} - -void MainDelegate::PreSandboxStartup() { - auto cmd = *base::CommandLine::ForCurrentProcess(); - std::string process_type = cmd.GetSwitchValueASCII(switches::kProcessType); - - // Initialize ResourceBundle which handles files loaded from external - // sources. The language should have been passed in to us from the - // browser process as a command line flag. - if (SubprocessNeedsResourceBundle(process_type)) { - std::string locale = cmd.GetSwitchValueASCII(switches::kLang); - LoadResourceBundle(locale); - } -} - -content::ContentBrowserClient* MainDelegate::CreateContentBrowserClient() { - browser_client_ = CreateBrowserClient(); - return browser_client_.get(); -} - -std::unique_ptr MainDelegate::CreateBrowserClient() { - return std::unique_ptr(new BrowserClient); -} - -} // namespace brightray diff --git a/brightray/common/main_delegate.h b/brightray/common/main_delegate.h deleted file mode 100644 index 3160f9b252cf4..0000000000000 --- a/brightray/common/main_delegate.h +++ /dev/null @@ -1,65 +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-CHROMIUM file. - -#ifndef BRIGHTRAY_COMMON_MAIN_DELEGATE_H_ -#define BRIGHTRAY_COMMON_MAIN_DELEGATE_H_ - -#include -#include - -#include "base/macros.h" -#include "content/public/app/content_main_delegate.h" - -namespace base { -class FilePath; -} - -namespace ui { -class ResourceBundle; -} - -namespace brightray { - -class BrowserClient; -class ContentClient; - -void LoadResourceBundle(const std::string& locale); -void LoadCommonResources(); - -class MainDelegate : public content::ContentMainDelegate { - public: - MainDelegate(); - ~MainDelegate() override; - - protected: - // Subclasses can override this to provide their own ContentClient - // implementation. - virtual std::unique_ptr CreateContentClient(); - - // Subclasses can override this to provide their own BrowserClient - // implementation. - virtual std::unique_ptr CreateBrowserClient(); - -#if defined(OS_MACOSX) - // Subclasses can override this to custom the paths of child process and - // framework bundle. - virtual void OverrideChildProcessPath(); - virtual void OverrideFrameworkBundlePath(); -#endif - - bool BasicStartupComplete(int* exit_code) override; - void PreSandboxStartup() override; - - private: - content::ContentBrowserClient* CreateContentBrowserClient() override; - - std::unique_ptr content_client_; - std::unique_ptr browser_client_; - - DISALLOW_COPY_AND_ASSIGN(MainDelegate); -}; - -} // namespace brightray - -#endif // BRIGHTRAY_COMMON_MAIN_DELEGATE_H_ diff --git a/brightray/common/main_delegate_mac.mm b/brightray/common/main_delegate_mac.mm deleted file mode 100644 index e91a65ba4ce90..0000000000000 --- a/brightray/common/main_delegate_mac.mm +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Copyright (c) 2013 Adam Roben . All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-CHROMIUM file. - -#import "brightray/common/main_delegate.h" - -#include "base/command_line.h" -#include "base/mac/bundle_locations.h" -#include "base/mac/foundation_util.h" -#include "base/path_service.h" -#include "base/strings/stringprintf.h" -#include "base/strings/sys_string_conversions.h" -#include "brightray/common/application_info.h" -#include "brightray/common/mac/main_application_bundle.h" -#include "content/public/common/content_paths.h" -#include "content/public/common/content_switches.h" -#include "ui/base/resource/resource_bundle.h" - -namespace brightray { - -namespace { - -base::FilePath GetFrameworksPath() { - return MainApplicationBundlePath().Append("Contents").Append("Frameworks"); -} - -} // namespace - -void MainDelegate::OverrideFrameworkBundlePath() { - base::FilePath helper_path = - GetFrameworksPath().Append(GetApplicationName() + " Framework.framework"); - - base::mac::SetOverrideFrameworkBundlePath(helper_path); -} - -void MainDelegate::OverrideChildProcessPath() { - base::FilePath helper_path = GetFrameworksPath() - .Append(GetApplicationName() + " Helper.app") - .Append("Contents") - .Append("MacOS") - .Append(GetApplicationName() + " Helper"); - - base::PathService::Override(content::CHILD_PROCESS_EXE, helper_path); -} - -} // namespace brightray diff --git a/brightray/common/platform_util.h b/brightray/common/platform_util.h deleted file mode 100644 index 48b5b4f015ed8..0000000000000 --- a/brightray/common/platform_util.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2018 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef BRIGHTRAY_COMMON_PLATFORM_UTIL_H_ -#define BRIGHTRAY_COMMON_PLATFORM_UTIL_H_ - -#include - -namespace brightray { - -namespace platform_util { - -#if defined(OS_LINUX) -// Returns a success flag. -// Unlike libgtkui, does *not* use "chromium-browser.desktop" as a fallback. -bool GetDesktopName(std::string* setme); -#endif - -} // namespace platform_util - -} // namespace brightray - -#endif // BRIGHTRAY_COMMON_PLATFORM_UTIL_H_ diff --git a/brightray/common/platform_util_linux.cc b/brightray/common/platform_util_linux.cc deleted file mode 100644 index 994f755ca47bc..0000000000000 --- a/brightray/common/platform_util_linux.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2018 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "brightray/common/platform_util.h" - -#include "base/environment.h" -#include "chrome/browser/ui/libgtkui/gtk_util.h" - -namespace brightray { - -namespace platform_util { - -bool GetDesktopName(std::string* setme) { - bool found = false; - - std::unique_ptr env(base::Environment::Create()); - std::string desktop_id = libgtkui::GetDesktopName(env.get()); - constexpr char const* libcc_default_id = "chromium-browser.desktop"; - if (!desktop_id.empty() && (desktop_id != libcc_default_id)) { - *setme = desktop_id; - found = true; - } - - return found; -} - -} // namespace platform_util - -} // namespace brightray diff --git a/docs/development/build-system-overview.md b/docs/development/build-system-overview.md index 1983de07ec1c9..881e4cc653fd4 100644 --- a/docs/development/build-system-overview.md +++ b/docs/development/build-system-overview.md @@ -8,8 +8,7 @@ be found in the `.gn` and `.gni` files. The following `gn` files contain the main rules for building Electron: -* `BUILD.gn` defines how Electron itself is built. -* `brightray/BUILD.gn` defines how `brightray` is built and +* `BUILD.gn` defines how Electron itself is built and includes the default configurations for linking with Chromium. * `build/args/{debug,release,all}.gn` contain the default build arguments for building Electron. diff --git a/docs/development/debug-instructions-windows.md b/docs/development/debug-instructions-windows.md index 93f0ec7e2ea32..c2d79003cec78 100644 --- a/docs/development/debug-instructions-windows.md +++ b/docs/development/debug-instructions-windows.md @@ -48,8 +48,7 @@ still set breakpoints - Visual Studio will automatically figure out that the source code matches the code running in the attached process and break accordingly. -Relevant code files can be found in `./atom/` as well as in Brightray, found in -`./brightray/browser` and `./brightray/common`. +Relevant code files can be found in `./atom/`. ### Attaching diff --git a/docs/development/debugging-instructions-macos.md b/docs/development/debugging-instructions-macos.md index cf31b7184933d..630ab12113871 100644 --- a/docs/development/debugging-instructions-macos.md +++ b/docs/development/debugging-instructions-macos.md @@ -41,8 +41,7 @@ this basic introduction, let's assume that you're calling a command from JavaScr that isn't behaving correctly - so you'd like to break on that command's C++ counterpart inside the Electron source. -Relevant code files can be found in `./atom/` as well as in Brightray, found in -`./brightray/browser` and `./brightray/common`. +Relevant code files can be found in `./atom/`. Let's assume that you want to debug `app.setName()`, which is defined in `browser.cc` as `Browser::SetName()`. Set the breakpoint using the `breakpoint` command, specifying diff --git a/docs/development/pull-requests.md b/docs/development/pull-requests.md index 4af63ababded4..19960889ff956 100644 --- a/docs/development/pull-requests.md +++ b/docs/development/pull-requests.md @@ -55,7 +55,7 @@ $ git checkout -b my-branch -t upstream/master ### Step 4: Code Most pull requests opened against the `electron/electron` repository include -changes to either the C/C++ code in the `atom/` or `brightray/` folders, +changes to either the C/C++ code in the `atom/` folder, the JavaScript code in the `lib/` folder, the documentation in `docs/api/` or tests in the `spec/` folder. diff --git a/docs/development/source-code-directory-structure.md b/docs/development/source-code-directory-structure.md index c009c53465cff..5a0369c4a32e4 100644 --- a/docs/development/source-code-directory-structure.md +++ b/docs/development/source-code-directory-structure.md @@ -31,7 +31,6 @@ Electron | | message loop into Chromium's message loop. | └── api/ - The implementation of common APIs, and foundations of | Electron's built-in modules. -├── brightray/ - Thin shim over libcc that makes it easier to use. ├── chromium_src/ - Source code copied from Chromium. See below. ├── default_app/ - The default page to show when Electron is started without | providing an app. diff --git a/docs/glossary.md b/docs/glossary.md index da1ddd28f1def..dab5b97b3fc2f 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -10,12 +10,6 @@ arbitrary files from it without unpacking the whole file. The ASAR format was created primarily to improve performance on Windows... TODO -### Brightray - -Brightray [was](https://github.com/electron-archive/brightray) a static library -that made [libchromiumcontent] easier to use in applications. It is now -deprecated and has been merged into Electron's codebase. - ### CRT The C Run-time Library (CRT) is the part of the C++ Standard Library that @@ -74,7 +68,7 @@ MAS, see the [Mac App Store Submission Guide]. ### Mojo -An IPC system for communicating intra- or inter-process, and that's important because Chrome is keen on being able to split its work into separate processes or not, depending on memory pressures etc. +An IPC system for communicating intra- or inter-process, and that's important because Chrome is keen on being able to split its work into separate processes or not, depending on memory pressures etc. See https://chromium.googlesource.com/chromium/src/+/master/mojo/README.md diff --git a/filenames.gni b/filenames.gni index 2f5301c28765d..3262016fe5086 100644 --- a/filenames.gni +++ b/filenames.gni @@ -222,6 +222,7 @@ filenames = { "atom/browser/atom_javascript_dialog_manager.h", "atom/browser/atom_navigation_throttle.h", "atom/browser/atom_navigation_throttle.cc", + "atom/browser/atom_paths.h", "atom/browser/atom_permission_manager.cc", "atom/browser/atom_permission_manager.h", "atom/browser/atom_quota_permission_context.cc", @@ -287,6 +288,12 @@ filenames = { "atom/browser/native_window_mac.h", "atom/browser/native_window_mac.mm", "atom/browser/native_window_observer.h", + "atom/browser/media/media_capture_devices_dispatcher.cc", + "atom/browser/media/media_capture_devices_dispatcher.h", + "atom/browser/media/media_device_id_salt.cc", + "atom/browser/media/media_device_id_salt.h", + "atom/browser/media/media_stream_devices_controller.cc", + "atom/browser/media/media_stream_devices_controller.h", "atom/browser/net/about_protocol_handler.cc", "atom/browser/net/about_protocol_handler.h", "atom/browser/net/asar/asar_protocol_handler.cc", @@ -305,6 +312,8 @@ filenames = { "atom/browser/net/http_protocol_handler.h", "atom/browser/net/js_asker.cc", "atom/browser/net/js_asker.h", + "atom/browser/net/require_ct_delegate.cc", + "atom/netbrowser//require_ct_delegate.h", "atom/browser/net/resolve_proxy_helper.cc", "atom/browser/net/resolve_proxy_helper.h", "atom/browser/net/url_request_about_job.cc", @@ -487,6 +496,8 @@ filenames = { "atom/browser/ui/x/x_window_utils.h", "atom/browser/unresponsive_suppressor.cc", "atom/browser/unresponsive_suppressor.h", + "atom/browser/win/scoped_hstring.cc", + "atom/browser/win/scoped_hstring.h", "atom/browser/web_contents_permission_helper.cc", "atom/browser/web_contents_permission_helper.h", "atom/browser/web_contents_preferences.cc", @@ -502,6 +513,8 @@ filenames = { "atom/browser/window_list.cc", "atom/browser/window_list.h", "atom/browser/window_list_observer.h", + "atom/browser/zoom_level_delegate.cc", + "atom/browser/zoom_level_delegate.h", "atom/common/api/api_messages.h", "atom/common/api/atom_api_asar.cc", "atom/common/api/atom_api_clipboard.cc", @@ -534,6 +547,11 @@ filenames = { "atom/common/asar/asar_util.h", "atom/common/asar/scoped_temporary_file.cc", "atom/common/asar/scoped_temporary_file.h", + "atom/common/application_info_linux.cc", + "atom/common/application_info_mac.mm", + "atom/common/application_info_win.cc", + "atom/common/application_info.cc", + "atom/common/application_info.h", "atom/common/atom_command_line.cc", "atom/common/atom_command_line.h", "atom/common/atom_constants.cc", @@ -567,6 +585,8 @@ filenames = { "atom/common/mouse_util.cc", "atom/common/mouse_util.h", "atom/common/linux/application_info.cc", + "atom/common/mac/main_application_bundle.h", + "atom/common/mac/main_application_bundle.mm", "atom/common/native_mate_converters/accelerator_converter.cc", "atom/common/native_mate_converters/accelerator_converter.h", "atom/common/native_mate_converters/blink_converter.cc", diff --git a/package.json b/package.json index 65b0768bda7f5..cff865db05dfd 100644 --- a/package.json +++ b/package.json @@ -43,10 +43,10 @@ "browserify": "browserify", "bump-version": "./script/bump-version.py", "check-tls": "python ./script/tls.py", - "clang-format": "find atom/ brightray/ chromium_src/ -iname *.h -o -iname *.cc -o -iname *.mm | xargs clang-format -i", + "clang-format": "find atom/ chromium_src/ -iname *.h -o -iname *.cc -o -iname *.mm | xargs clang-format -i", "lint": "node ./script/lint.js && npm run lint:clang-format && npm run lint:docs", "lint:js": "node ./script/lint.js --js", - "lint:clang-format": "python script/run-clang-format.py -r -c atom/ chromium_src/ brightray/ || (echo \"\\nCode not formatted correctly.\" && exit 1)", + "lint:clang-format": "python script/run-clang-format.py -r -c atom/ chromium_src/ || (echo \"\\nCode not formatted correctly.\" && exit 1)", "lint:cpp": "node ./script/lint.js --cc", "lint:py": "node ./script/lint.js --py", "lint:gn": "node ./script/lint.js --gn", @@ -56,7 +56,7 @@ "create-api-json": "electron-docs-linter docs --outfile=electron-api.json", "create-typescript-definitions": "npm run create-api-json && electron-typescript-definitions --in=electron-api.json --out=electron.d.ts", "preinstall": "node -e 'process.exit(0)'", - "precommit": "python script/run-clang-format.py -r -c atom/ chromium_src/ brightray/ && node ./script/lint.js -c && remark docs -qf || (echo \"Code not formatted correctly.\" && exit 1)", + "precommit": "python script/run-clang-format.py -r -c atom/ chromium_src/ && node ./script/lint.js -c && remark docs -qf || (echo \"Code not formatted correctly.\" && exit 1)", "prepack": "check-for-leaks", "prepush": "check-for-leaks", "repl": "node ./script/start.js --interactive", diff --git a/patches/common/chromium/.patches.yaml b/patches/common/chromium/.patches.yaml index f4a0a020260f9..bc7e0eb65a6f7 100644 --- a/patches/common/chromium/.patches.yaml +++ b/patches/common/chromium/.patches.yaml @@ -261,7 +261,7 @@ patches: author: Jeremy Apthorp file: gtk_visibility.patch description: | - Allow electron and brightray to depend on GTK in the GN build. + Allow electron to depend on GTK in the GN build. - author: Jeremy Apthorp file: sysroot.patch diff --git a/patches/common/chromium/gtk_visibility.patch b/patches/common/chromium/gtk_visibility.patch index e9a0028887166..80cb06f871ffe 100644 --- a/patches/common/chromium/gtk_visibility.patch +++ b/patches/common/chromium/gtk_visibility.patch @@ -3,21 +3,20 @@ From: Jeremy Apthorp Date: Thu, 20 Sep 2018 17:48:38 -0700 Subject: gtk_visibility.patch -Allow electron and brightray to depend on GTK in the GN build. +Allow electron to depend on GTK in the GN build. diff --git a/build/config/linux/gtk/BUILD.gn b/build/config/linux/gtk/BUILD.gn -index deae4d3455a8..fd5d906b98b0 100644 +index deae4d3455a8..5f5db2fd6e5e 100644 --- a/build/config/linux/gtk/BUILD.gn +++ b/build/config/linux/gtk/BUILD.gn -@@ -18,6 +18,8 @@ group("gtk") { +@@ -18,6 +18,7 @@ group("gtk") { visibility = [ "//chrome/test:interactive_ui_tests", "//chrome/test:unit_tests", + "//electron:*", -+ "//electron/brightray:*", "//examples:peerconnection_client", "//gpu/gles2_conform_support:gles2_conform_test_windowless", "//remoting/host", --- +-- 2.17.0 diff --git a/script/lint.js b/script/lint.js index 24bbecdc3a464..987b552b893cc 100755 --- a/script/lint.js +++ b/script/lint.js @@ -40,7 +40,7 @@ function spawnAndCheckExitCode (cmd, args, opts) { const LINTERS = [ { key: 'c++', - roots: ['atom', 'brightray'], + roots: ['atom'], test: filename => filename.endsWith('.cc') || filename.endsWith('.h'), run: (opts, filenames) => { if (opts.fix) {