diff --git a/brightray/.gitignore b/brightray/.gitignore index 4f72578167..4ee8ba8eac 100644 --- a/brightray/.gitignore +++ b/brightray/.gitignore @@ -4,3 +4,6 @@ /brightray.vcxproj* /brightray.xcodeproj/ /build/ + +# Vim +*.swp diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index 71f73b98b5..2732d5c9a1 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -13,6 +13,7 @@ ], 'direct_dependent_settings': { 'include_dirs': [ + '..', '<(libchromiumcontent_include_dir)', '<(libchromiumcontent_include_dir)/third_party/skia/include/config', ], @@ -51,6 +52,7 @@ 'browser/url_request_context_getter.h', 'common/application_info.h', 'common/application_info_mac.mm', + 'common/application_info_win.cc', 'common/content_client.cc', 'common/content_client.h', 'common/mac/foundation_util.h', @@ -68,6 +70,25 @@ '$(SDKROOT)/System/Library/Frameworks/AppKit.framework', ], }, + }, { + 'sources/': [ + ['exclude', '/mac/'], + ['exclude', '_mac\.(mm|h)$'], + ], + }], + ['OS=="win"', { + 'link_settings': { + 'libraries': [ + '<(libchromiumcontent_library_dir)/base_static.lib', + '<(libchromiumcontent_library_dir)/chromiumcontent.dll.lib', + '<(libchromiumcontent_library_dir)/sandbox_static.lib', + ], + }, + }, { + 'sources/': [ + ['exclude', '/win/'], + ['exclude', '_win\.(cc|h)$'], + ], }], ], }, diff --git a/brightray/brightray.gypi b/brightray/brightray.gypi index bc07c9da19..3f426666d9 100644 --- a/brightray/brightray.gypi +++ b/brightray/brightray.gypi @@ -2,15 +2,33 @@ 'variables': { 'libchromiumcontent_dir': 'vendor/download/libchromiumcontent', 'libchromiumcontent_library_dir': '<(libchromiumcontent_dir)/Release', - 'libchromiumcontent_include_dir': '<(libchromiumcontent_dir)/include', + 'libchromiumcontent_include_dir': '<(libchromiumcontent_dir)/src', 'libchromiumcontent_resources_dir': '<(libchromiumcontent_library_dir)', + 'libchromiumcontent_src_dir': '<(libchromiumcontent_dir)/src', 'mac_deployment_target%': '10.8', 'mac_sdkroot%': 'macosx', + + 'win_release_RuntimeLibrary%': '2', # /MD (nondebug DLL) + 'win_debug_RuntimeLibrary%': '3', # /MTd (debug DLL) + + # See http://msdn.microsoft.com/en-us/library/aa652360(VS.71).aspx + 'win_release_Optimization%': '2', # 2 = /Os + 'win_debug_Optimization%': '0', # 0 = /Od + + # See http://msdn.microsoft.com/en-us/library/2kxx5t2c(v=vs.80).aspx + # Tri-state: blank is default, 1 on, 0 off + 'win_release_OmitFramePointers%': '0', + # Tri-state: blank is default, 1 on, 0 off + 'win_debug_OmitFramePointers%': '', + + # See http://msdn.microsoft.com/en-us/library/8wtf2dfz(VS.71).aspx + 'win_debug_RuntimeChecks%': '3', # 3 = all checks enabled, 0 = off + + # See http://msdn.microsoft.com/en-us/library/47238hez(VS.71).aspx + 'win_debug_InlineFunctionExpansion%': '', # empty = default, 0 = off, + 'win_release_InlineFunctionExpansion%': '2', # 1 = only __inline, 2 = max }, 'target_defaults': { - 'defines': [ - 'NDEBUG', - ], 'xcode_settings': { 'ALWAYS_SEARCH_USER_PATHS': 'NO', 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++11', @@ -33,16 +51,67 @@ 'configurations': { 'Common_Base': { 'abstract': 1, + 'defines': [ + 'COMPONENT_BUILD', + 'GURL_DLL', + 'SKIA_DLL', + 'NDEBUG', + 'USING_V8_SHARED', + 'WEBKIT_DLL', + ], 'msvs_configuration_attributes': { 'OutputDirectory': '<(DEPTH)\\build\\$(ConfigurationName)', 'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)', 'CharacterSet': '1', }, + 'msvs_settings': { + 'VCLinkerTool': { + 'AdditionalDependencies': [ + 'advapi32.lib', + 'user32.lib', + ], + }, + }, }, 'Debug': { 'inherit_from': [ 'Common_Base', ], + 'msvs_settings': { + 'VCCLCompilerTool': { + 'Optimization': '<(win_debug_Optimization)', + 'PreprocessorDefinitions': ['_DEBUG'], + 'BasicRuntimeChecks': '<(win_debug_RuntimeChecks)', + # We use Release to match the version of chromiumcontent.dll we + # link against. + 'RuntimeLibrary': '<(win_release_RuntimeLibrary)', + 'conditions': [ + # According to MSVS, InlineFunctionExpansion=0 means + # "default inlining", not "/Ob0". + # Thus, we have to handle InlineFunctionExpansion==0 separately. + ['win_debug_InlineFunctionExpansion==0', { + 'AdditionalOptions': ['/Ob0'], + }], + ['win_debug_InlineFunctionExpansion!=""', { + 'InlineFunctionExpansion': + '<(win_debug_InlineFunctionExpansion)', + }], + # if win_debug_OmitFramePointers is blank, leave as default + ['win_debug_OmitFramePointers==1', { + 'OmitFramePointers': 'true', + }], + ['win_debug_OmitFramePointers==0', { + 'OmitFramePointers': 'false', + # The above is not sufficient (http://crbug.com/106711): it + # simply eliminates an explicit "/Oy", but both /O2 and /Ox + # perform FPO regardless, so we must explicitly disable. + # We still want the false setting above to avoid having + # "/Oy /Oy-" and warnings about overriding. + 'AdditionalOptions': ['/Oy-'], + }], + ], + }, + }, 'xcode_settings': { 'COPY_PHASE_STRIP': 'NO', 'GCC_OPTIMIZATION_LEVEL': '0', @@ -52,6 +121,37 @@ 'inherit_from': [ 'Common_Base', ], + 'msvs_settings': { + 'VCCLCompilerTool': { + 'Optimization': '<(win_release_Optimization)', + 'RuntimeLibrary': '<(win_release_RuntimeLibrary)', + 'conditions': [ + # According to MSVS, InlineFunctionExpansion=0 means + # "default inlining", not "/Ob0". + # Thus, we have to handle InlineFunctionExpansion==0 separately. + ['win_release_InlineFunctionExpansion==0', { + 'AdditionalOptions': ['/Ob0'], + }], + ['win_release_InlineFunctionExpansion!=""', { + 'InlineFunctionExpansion': + '<(win_release_InlineFunctionExpansion)', + }], + # if win_release_OmitFramePointers is blank, leave as default + ['win_release_OmitFramePointers==1', { + 'OmitFramePointers': 'true', + }], + ['win_release_OmitFramePointers==0', { + 'OmitFramePointers': 'false', + # The above is not sufficient (http://crbug.com/106711): it + # simply eliminates an explicit "/Oy", but both /O2 and /Ox + # perform FPO regardless, so we must explicitly disable. + # We still want the false setting above to avoid having + # "/Oy /Oy-" and warnings about overriding. + 'AdditionalOptions': ['/Oy-'], + }], + ], + }, + }, }, }, }, diff --git a/brightray/browser/browser_client.cc b/brightray/browser/browser_client.cc index 9dc99f18a3..72626a5226 100644 --- a/brightray/browser/browser_client.cc +++ b/brightray/browser/browser_client.cc @@ -34,8 +34,10 @@ BrowserContext* BrowserClient::browser_context() { } NotificationPresenter* BrowserClient::notification_presenter() { +#if defined(OS_MACOSX) if (!notification_presenter_) notification_presenter_.reset(NotificationPresenter::Create()); +#endif return notification_presenter_.get(); } diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 7f694ad54f..c6c6f00f4c 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -41,7 +41,9 @@ InspectableWebContentsImpl::InspectableWebContentsImpl(content::WebContents* web auto context = static_cast(web_contents_->GetBrowserContext()); dock_side_ = context->prefs()->GetString(kDockSidePref); +#if defined(OS_MACOSX) view_.reset(CreateInspectableContentsView(this)); +#endif } InspectableWebContentsImpl::~InspectableWebContentsImpl() { diff --git a/brightray/common/application_info_win.cc b/brightray/common/application_info_win.cc new file mode 100644 index 0000000000..1133301586 --- /dev/null +++ b/brightray/common/application_info_win.cc @@ -0,0 +1,13 @@ +#include "common/application_info.h" + +namespace brightray { + +std::string GetApplicationName() { + return std::string(); +} + +std::string GetApplicationVersion() { + return std::string(); +} + +} diff --git a/brightray/common/main_delegate.cc b/brightray/common/main_delegate.cc index 7c1fa903bc..5578fc7c3a 100644 --- a/brightray/common/main_delegate.cc +++ b/brightray/common/main_delegate.cc @@ -8,7 +8,9 @@ #include "common/content_client.h" #include "base/command_line.h" +#include "base/path_service.h" #include "content/public/common/content_switches.h" +#include "ui/base/resource/resource_bundle.h" namespace brightray { @@ -36,4 +38,22 @@ void MainDelegate::PreSandboxStartup() { InitializeResourceBundle(); } +void MainDelegate::InitializeResourceBundle() { + base::FilePath path; +#if defined(OS_MACOSX) + path = GetResourcesPakFilePath(); +#else + base::FilePath pak_dir; + PathService::Get(base::DIR_MODULE, &pak_dir); + path = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")); +#endif + + ui::ResourceBundle::InitSharedInstanceWithPakPath(path); + + std::vector pak_paths; + AddPakPaths(&pak_paths); + for (auto it = pak_paths.begin(), end = pak_paths.end(); it != end; ++it) + ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(*it, ui::SCALE_FACTOR_NONE); +} + } diff --git a/brightray/common/main_delegate.h b/brightray/common/main_delegate.h index 34ebfef9d7..f5cbe88d4e 100644 --- a/brightray/common/main_delegate.h +++ b/brightray/common/main_delegate.h @@ -36,6 +36,7 @@ protected: private: void InitializeResourceBundle(); #if defined(OS_MACOSX) + static base::FilePath GetResourcesPakFilePath(); static void OverrideChildProcessPath(); static void OverrideFrameworkBundlePath(); #endif diff --git a/brightray/common/main_delegate_mac.mm b/brightray/common/main_delegate_mac.mm index 72ae553ff8..aa7bf0f462 100644 --- a/brightray/common/main_delegate_mac.mm +++ b/brightray/common/main_delegate_mac.mm @@ -12,7 +12,6 @@ #include "base/mac/bundle_locations.h" #include "base/path_service.h" #include "content/public/common/content_paths.h" -#include "ui/base/resource/resource_bundle.h" namespace brightray { @@ -24,15 +23,9 @@ base::FilePath GetFrameworksPath() { } -void MainDelegate::InitializeResourceBundle() { +base::FilePath MainDelegate::GetResourcesPakFilePath() { auto path = [base::mac::FrameworkBundle() pathForResource:@"content_shell" ofType:@"pak"]; - - ui::ResourceBundle::InitSharedInstanceWithPakPath(base::mac::NSStringToFilePath(path)); - - std::vector pak_paths; - AddPakPaths(&pak_paths); - for (const auto& path : pak_paths) - ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(path, ui::SCALE_FACTOR_NONE); + return base::mac::NSStringToFilePath(path); } void MainDelegate::OverrideFrameworkBundlePath() { diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index ad588f54dc..e436974fc1 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit ad588f54dc342716e55fd23ce69d6e2c176a1df7 +Subproject commit e436974fc1a470311879056b93f9bf0c3e2408fc