diff options
-rwxr-xr-x | build/mac/make_more_helpers.sh (renamed from chrome/tools/build/mac/make_more_helpers.sh) | 20 | ||||
-rw-r--r-- | chrome/chrome_exe.gypi | 4 | ||||
-rwxr-xr-x | chrome/tools/build/mac/dump_product_syms | 4 | ||||
-rw-r--r-- | content/content_shell.gypi | 93 | ||||
-rw-r--r-- | content/shell/mac/helper-Info.plist | 30 | ||||
-rw-r--r-- | content/shell/shell_browser_main.cc | 5 | ||||
-rw-r--r-- | content/shell/shell_browser_main.h | 2 | ||||
-rw-r--r-- | content/shell/shell_browser_main_mac.mm | 21 | ||||
-rw-r--r-- | content/shell/shell_main_delegate.cc | 41 |
9 files changed, 203 insertions, 17 deletions
diff --git a/chrome/tools/build/mac/make_more_helpers.sh b/build/mac/make_more_helpers.sh index 0acffc9..6f5c474 100755 --- a/chrome/tools/build/mac/make_more_helpers.sh +++ b/build/mac/make_more_helpers.sh @@ -4,7 +4,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# Usage: make_more_helpers.sh <version> <app_name> +# Usage: make_more_helpers.sh <directory_within_contents> <app_name> # # This script creates additional helper .app bundles for Chromium, based on # the existing helper .app bundle, changing their Mach-O header's flags to @@ -24,13 +24,13 @@ set -eu make_helper() { - local versioned_dir="${1}" + local containing_dir="${1}" local app_name="${2}" local feature="${3}" local flags="${4}" local helper_name="${app_name} Helper" - local helper_stem="${versioned_dir}/${helper_name}" + local helper_stem="${containing_dir}/${helper_name}" local original_helper="${helper_stem}.app" if [[ ! -d "${original_helper}" ]]; then echo "${0}: error: ${original_helper} is a required directory" >& 2 @@ -50,8 +50,7 @@ make_helper() { local helper_feature_exe="${feature_helper}/Contents/MacOS/${helper_feature}" mv "${feature_helper}/Contents/MacOS/${helper_name}" "${helper_feature_exe}" - local change_flags="\ -$(dirname "${0}")/../../../../build/mac/change_mach_o_flags.py" + local change_flags="$(dirname "${0}")/change_mach_o_flags.py" "${change_flags}" ${flags} "${helper_feature_exe}" local feature_info="${feature_helper}/Contents/Info" @@ -78,16 +77,15 @@ $(dirname "${0}")/../../../../build/mac/change_mach_o_flags.py" } if [[ ${#} -ne 2 ]]; then - echo "usage: ${0} <version> <app_name>" >& 2 + echo "usage: ${0} <directory_within_contents> <app_name>" >& 2 exit 1 fi -VERSION="${1}" +DIRECTORY_WITHIN_CONTENTS="${1}" APP_NAME="${2}" CONTENTS_DIR="${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}" -VERSIONED_DIR="${CONTENTS_DIR}/Versions" -CURRENT_VERSIONED_DIR="${VERSIONED_DIR}/${VERSION}" +CONTAINING_DIR="${CONTENTS_DIR}/${DIRECTORY_WITHIN_CONTENTS}" -make_helper "${CURRENT_VERSIONED_DIR}" "${APP_NAME}" "EH" "--executable-heap" -make_helper "${CURRENT_VERSIONED_DIR}" "${APP_NAME}" "NP" "--no-pie" +make_helper "${CONTAINING_DIR}" "${APP_NAME}" "EH" "--executable-heap" +make_helper "${CONTAINING_DIR}" "${APP_NAME}" "NP" "--no-pie" diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi index d35f2a7..92016b5 100644 --- a/chrome/chrome_exe.gypi +++ b/chrome/chrome_exe.gypi @@ -361,8 +361,8 @@ # prepare their Breakpad symbol files. 'postbuild_name': 'Make More Helpers', 'action': [ - 'tools/build/mac/make_more_helpers.sh', - '<(version_full)', + '../build/mac/make_more_helpers.sh', + 'Versions/<(version_full)', '<(mac_product_name)', ], }, diff --git a/chrome/tools/build/mac/dump_product_syms b/chrome/tools/build/mac/dump_product_syms index c46ffac..605bc2c 100755 --- a/chrome/tools/build/mac/dump_product_syms +++ b/chrome/tools/build/mac/dump_product_syms @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -127,7 +127,7 @@ for SRC_NAME in "${SRC_NAMES[@]}"; do "${SRC_APP_NAME} Helper.app") # Google Chrome Helper EH and Google Chrome Helper NP are produced by - # chrome/tools/build/mac/make_more_helpers.sh. + # build/mac/make_more_helpers.sh. redump_syms_variant "${BPAD_SYM_PATH}" "${SRC_STEM}" \ "${SRC_STEM} EH" "${SRC_STEM} EH.app" redump_syms_variant "${BPAD_SYM_PATH}" "${SRC_STEM}" \ diff --git a/content/content_shell.gypi b/content/content_shell.gypi index d809c85..3d7176e 100644 --- a/content/content_shell.gypi +++ b/content/content_shell.gypi @@ -57,6 +57,7 @@ 'shell/shell_browser_context.h', 'shell/shell_browser_main.cc', 'shell/shell_browser_main.h', + 'shell/shell_browser_main_mac.mm', 'shell/shell_content_browser_client.cc', 'shell/shell_content_browser_client.h', 'shell/shell_content_client.cc', @@ -273,6 +274,15 @@ ], 'dependencies': [ 'content_shell_framework', + 'content_shell_helper_app', + ], + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/<(content_shell_product_name).app/Contents/Frameworks', + 'files': [ + '<(PRODUCT_DIR)/<(content_shell_product_name) Helper.app', + ], + }, ], 'postbuilds': [ { @@ -300,6 +310,22 @@ '--svn=1'], }, { + # This postbuid step is responsible for creating the following + # helpers: + # + # Content Shell Helper EH.app and Content Shell Helper NP.app are + # created from Content Shell Helper.app. + # + # The EH helper is marked for an executable heap. The NP helper + # is marked for no PIE (ASLR). + 'postbuild_name': 'Make More Helpers', + 'action': [ + '../build/mac/make_more_helpers.sh', + 'Frameworks', + '<(content_shell_product_name)', + ], + }, + { # Make sure there isn't any Objective-C in the shell's # executable. 'postbuild_name': 'Verify No Objective-C', @@ -334,7 +360,72 @@ 'shell/shell_content_main.cc', 'shell/shell_content_main.h', ], - }, + }, # target content_shell_framework + { + 'target_name': 'content_shell_helper_app', + 'type': 'executable', + 'variables': { 'enable_wexit_time_destructors': 1, }, + 'product_name': '<(content_shell_product_name) Helper', + 'mac_bundle': 1, + 'dependencies': [ + 'content_shell_framework', + ], + 'sources': [ + 'shell/shell_main.cc', + 'shell/mac/helper-Info.plist', + ], + # TODO(mark): Come up with a fancier way to do this. It should only + # be necessary to list helper-Info.plist once, not the three times it + # is listed here. + 'mac_bundle_resources!': [ + 'shell/mac/helper-Info.plist', + ], + # TODO(mark): For now, don't put any resources into this app. Its + # resources directory will be a symbolic link to the browser app's + # resources directory. + 'mac_bundle_resources/': [ + ['exclude', '.*'], + ], + 'xcode_settings': { + 'INFOPLIST_FILE': 'shell/mac/helper-Info.plist', + }, + 'postbuilds': [ + { + # The framework defines its load-time path + # (DYLIB_INSTALL_NAME_BASE) relative to the main executable + # (chrome). A different relative path needs to be used in + # content_shell_helper_app. + 'postbuild_name': 'Fix Framework Link', + 'action': [ + 'install_name_tool', + '-change', + '/Library/Frameworks/<(content_shell_product_name) Framework.framework/Versions/A/<(content_shell_product_name) Framework', + '@executable_path/../../../../Frameworks/<(content_shell_product_name) Framework.framework/<(content_shell_product_name) Framework', + '${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}' + ], + }, + { + # Modify the Info.plist as needed. The script explains why this + # is needed. This is also done in the chrome and chrome_dll + # targets. In this case, --breakpad=0, --keystone=0, and --svn=0 + # are used because Breakpad, Keystone, and Subversion keys are + # never placed into the helper. + 'postbuild_name': 'Tweak Info.plist', + 'action': ['../build/mac/tweak_info_plist.py', + '--breakpad=0', + '--keystone=0', + '--svn=0'], + }, + { + # Make sure there isn't any Objective-C in the helper app's + # executable. + 'postbuild_name': 'Verify No Objective-C', + 'action': [ + '../build/mac/verify_no_objc.sh', + ], + }, + ], + }, # target content_shell_helper_app ], }], # OS=="mac" ], diff --git a/content/shell/mac/helper-Info.plist b/content/shell/mac/helper-Info.plist new file mode 100644 index 0000000..2208e70 --- /dev/null +++ b/content/shell/mac/helper-Info.plist @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleDisplayName</key> + <string>${EXECUTABLE_NAME}</string> + <key>CFBundleExecutable</key> + <string>${EXECUTABLE_NAME}</string> + <key>CFBundleIdentifier</key> + <string>org.chromium.ContentShell.helper</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>${PRODUCT_NAME}</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>LSFileQuarantineEnabled</key> + <true/> + <key>LSMinimumSystemVersion</key> + <string>10.5.0</string> + <key>LSUIElement</key> + <string>1</string> + <key>NSSupportsAutomaticGraphicsSwitching</key> + <true/> +</dict> +</plist> diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc index 7f7b30d..eeaa23f6 100644 --- a/content/shell/shell_browser_main.cc +++ b/content/shell/shell_browser_main.cc @@ -46,6 +46,11 @@ ShellBrowserMainParts::ShellBrowserMainParts( ShellBrowserMainParts::~ShellBrowserMainParts() { } +#if !defined(OS_MACOSX) +void ShellBrowserMainParts::PreMainMessageLoopStart() { +} +#endif + MessageLoop* ShellBrowserMainParts::GetMainMessageLoop() { return NULL; } diff --git a/content/shell/shell_browser_main.h b/content/shell/shell_browser_main.h index 4e836d8..f91fad3 100644 --- a/content/shell/shell_browser_main.h +++ b/content/shell/shell_browser_main.h @@ -31,7 +31,7 @@ class ShellBrowserMainParts : public BrowserMainParts { virtual void PreEarlyInitialization() OVERRIDE {} virtual void PostEarlyInitialization() OVERRIDE {} - virtual void PreMainMessageLoopStart() OVERRIDE {} + virtual void PreMainMessageLoopStart() OVERRIDE; virtual MessageLoop* GetMainMessageLoop() OVERRIDE; virtual void PostMainMessageLoopStart() OVERRIDE {} virtual void ToolkitInitialized() OVERRIDE {} diff --git a/content/shell/shell_browser_main_mac.mm b/content/shell/shell_browser_main_mac.mm new file mode 100644 index 0000000..5b8eacc --- /dev/null +++ b/content/shell/shell_browser_main_mac.mm @@ -0,0 +1,21 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/shell/shell_browser_main.h" + +#import <Cocoa/Cocoa.h> + +#include "base/mac/bundle_locations.h" +#include "base/memory/scoped_nsobject.h" + +namespace content { + +void ShellBrowserMainParts::PreMainMessageLoopStart() { + scoped_nsobject<NSNib> + nib([[NSNib alloc] initWithNibNamed:@"MainMenu" + bundle:base::mac::FrameworkBundle()]); + [nib instantiateNibWithOwner:NSApp topLevelObjects:nil]; +} + +} // namespace content diff --git a/content/shell/shell_main_delegate.cc b/content/shell/shell_main_delegate.cc index 0a3977b..91a92d1 100644 --- a/content/shell/shell_main_delegate.cc +++ b/content/shell/shell_main_delegate.cc @@ -7,6 +7,7 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/path_service.h" +#include "content/public/common/content_paths.h" #include "content/public/common/content_switches.h" #include "content/shell/shell_content_browser_client.h" #include "content/shell/shell_content_plugin_client.h" @@ -16,6 +17,42 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_paths.h" +#if defined(OS_MACOSX) +#include "base/mac/foundation_util.h" +#endif + +#if defined(OS_MACOSX) +namespace { + +void OverrideChildProcessPath() { + if (base::mac::IsBackgroundOnlyProcess()) { + // The background-only process is the helper; no overriding needed. + return; + } + + // Start out with the path to the running executable. + FilePath helper_path; + PathService::Get(base::FILE_EXE, &helper_path); + + // One step up to MacOS, another to Contents. + helper_path = helper_path.DirName().DirName(); + DCHECK_EQ(helper_path.BaseName().value(), "Contents"); + + // Go into the frameworks directory. + helper_path = helper_path.Append("Frameworks"); + + // And the app path. + helper_path = helper_path.Append("Content Shell Helper.app") + .Append("Contents") + .Append("MacOS") + .Append("Content Shell Helper"); + + PathService::Override(content::CHILD_PROCESS_EXE, helper_path); +} + +} // namespace +#endif // OS_MACOSX + ShellMainDelegate::ShellMainDelegate() { } @@ -27,6 +64,10 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { } void ShellMainDelegate::PreSandboxStartup() { +#if defined(OS_MACOSX) + OverrideChildProcessPath(); +#endif // OS_MACOSX + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); std::string process_type = command_line.GetSwitchValueASCII(switches::kProcessType); |