diff options
author | yoz <yoz@chromium.org> | 2014-12-19 12:58:18 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-19 20:59:22 +0000 |
commit | 289ee7c3b41766e6996b6a7d6ecd5a574b2a147e (patch) | |
tree | 410510e9e2b211f6f98119af8ce12ef751dba93d /extensions/shell/app | |
parent | 9f60ea8024d81d8b1cfc9a88f465c41e853a0ef3 (diff) | |
download | chromium_src-289ee7c3b41766e6996b6a7d6ecd5a574b2a147e.zip chromium_src-289ee7c3b41766e6996b6a7d6ecd5a574b2a147e.tar.gz chromium_src-289ee7c3b41766e6996b6a7d6ecd5a574b2a147e.tar.bz2 |
AppShell support for Mac.
Very basic support for app_shell on Mac cocoa. It allows building and running app_shell, app_shell_unittests, and app_shell_browsertests on Mac. It introduces app_shell_framework and app_shell_helper targets. Much of the work is based on the content_shell equivalents.
The above targets build as part of 'all' on Mac, but are not yet covered by trybots.
Shortcomings compared to Aura:
- The AppShell desktop controller doesn't support tracking multiple app windows.
- Running App Shell --load-apps works (at least for the Calculator sample) but can only be exited via ^C at the command line, and there is no Mac menu.
BUG=399363
Review URL: https://codereview.chromium.org/745093002
Cr-Commit-Position: refs/heads/master@{#309256}
Diffstat (limited to 'extensions/shell/app')
-rw-r--r-- | extensions/shell/app/app-Info.plist | 34 | ||||
-rw-r--r-- | extensions/shell/app/framework-Info.plist | 18 | ||||
-rw-r--r-- | extensions/shell/app/helper-Info.plist | 30 | ||||
-rw-r--r-- | extensions/shell/app/paths_mac.h | 22 | ||||
-rw-r--r-- | extensions/shell/app/paths_mac.mm | 52 | ||||
-rw-r--r-- | extensions/shell/app/shell_main.cc | 27 | ||||
-rw-r--r-- | extensions/shell/app/shell_main_delegate.cc | 31 | ||||
-rw-r--r-- | extensions/shell/app/shell_main_delegate.h | 3 | ||||
-rw-r--r-- | extensions/shell/app/shell_main_mac.cc | 16 | ||||
-rw-r--r-- | extensions/shell/app/shell_main_mac.h | 16 |
10 files changed, 236 insertions, 13 deletions
diff --git a/extensions/shell/app/app-Info.plist b/extensions/shell/app/app-Info.plist new file mode 100644 index 0000000..269fd96 --- /dev/null +++ b/extensions/shell/app/app-Info.plist @@ -0,0 +1,34 @@ +<?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>CFBundleIconFile</key> + <string>app.icns</string> + <key>CFBundleIdentifier</key> + <string>org.chromium.AppShell</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>${PRODUCT_NAME}</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>NSMainNibFile</key> + <string>MainMenu</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> + <key>LSMinimumSystemVersion</key> + <string>${MACOSX_DEPLOYMENT_TARGET}.0</string> + <key>LSFileQuarantineEnabled</key> + <true/> + <key>NSSupportsAutomaticGraphicsSwitching</key> + <true/> +</dict> +</plist> diff --git a/extensions/shell/app/framework-Info.plist b/extensions/shell/app/framework-Info.plist new file mode 100644 index 0000000..ec58d37 --- /dev/null +++ b/extensions/shell/app/framework-Info.plist @@ -0,0 +1,18 @@ +<?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>CFBundleExecutable</key> + <string>${EXECUTABLE_NAME}</string> + <key>CFBundleIdentifier</key> + <string>org.chromium.AppShell.framework</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>FMWK</string> + <key>CFBundleSignature</key> + <string>????</string> +</dict> +</plist> diff --git a/extensions/shell/app/helper-Info.plist b/extensions/shell/app/helper-Info.plist new file mode 100644 index 0000000..dd654f1 --- /dev/null +++ b/extensions/shell/app/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.AppShell.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>${MACOSX_DEPLOYMENT_TARGET}.0</string> + <key>LSUIElement</key> + <string>1</string> + <key>NSSupportsAutomaticGraphicsSwitching</key> + <true/> +</dict> +</plist> diff --git a/extensions/shell/app/paths_mac.h b/extensions/shell/app/paths_mac.h new file mode 100644 index 0000000..8cdaee9 --- /dev/null +++ b/extensions/shell/app/paths_mac.h @@ -0,0 +1,22 @@ +// Copyright 2014 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. + +#ifndef EXTENSIONS_SHELL_APP_PATHS_MAC_H_ +#define EXTENSIONS_SHELL_APP_PATHS_MAC_H_ + +namespace base { +class FilePath; +} + +namespace extensions { + +// Override the framework bundle path. +void OverrideFrameworkBundlePath(); + +// Override the helper (child process) path. +void OverrideChildProcessFilePath(); + +} // namespace extensions + +#endif // EXTENSIONS_SHELL_APP_PATHS_MAC_H_ diff --git a/extensions/shell/app/paths_mac.mm b/extensions/shell/app/paths_mac.mm new file mode 100644 index 0000000..d10c3c8 --- /dev/null +++ b/extensions/shell/app/paths_mac.mm @@ -0,0 +1,52 @@ +// Copyright 2014 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 "extensions/shell/app/paths_mac.h" + +#include "base/files/file_path.h" +#include "base/logging.h" +#include "base/path_service.h" +#include "base/mac/bundle_locations.h" +#include "base/mac/foundation_util.h" +#include "content/public/common/content_paths.h" + +namespace extensions { + +namespace { + +base::FilePath GetFrameworksPath() { + base::FilePath path; + PathService::Get(base::FILE_EXE, &path); + // We now have a path .../App Shell.app/Contents/MacOS/App Shell, and want to + // transform it into + // .../App Shell.app/Contents/Frameworks/App Shell Framework.framework. + // But if it's App Shell Helper.app (inside Frameworks), we must go deeper. + if (base::mac::IsBackgroundOnlyProcess()) { + path = path.DirName().DirName().DirName().DirName().DirName(); + } else { + path = path.DirName().DirName(); + } + DCHECK_EQ("Contents", path.BaseName().value()); + path = path.Append("Frameworks"); + return path; +} + +} // namespace + +void OverrideFrameworkBundlePath() { + base::FilePath path = + GetFrameworksPath().Append("App Shell Framework.framework"); + base::mac::SetOverrideFrameworkBundlePath(path); +} + +void OverrideChildProcessFilePath() { + base::FilePath path = GetFrameworksPath() + .Append("App Shell Helper.app") + .Append("Contents") + .Append("MacOS") + .Append("App Shell Helper"); + PathService::Override(content::CHILD_PROCESS_EXE, path); +} + +} // namespace extensions diff --git a/extensions/shell/app/shell_main.cc b/extensions/shell/app/shell_main.cc index a58ab82..18a6e63 100644 --- a/extensions/shell/app/shell_main.cc +++ b/extensions/shell/app/shell_main.cc @@ -10,23 +10,36 @@ #include "sandbox/win/src/sandbox_types.h" #endif -#if defined(OS_WIN) -int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { -#else -int main(int argc, const char** argv) { +#if defined(OS_MACOSX) +#include "extensions/shell/app/shell_main_mac.h" #endif + +#if defined(OS_MACOSX) +int main(int argc, const char** argv) { + // Do the delegate work in shell_main_mac to avoid having to export the + // delegate types. + return ::ContentMain(argc, argv); +} +#elif defined(OS_WIN) +int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { extensions::ShellMainDelegate delegate; content::ContentMainParams params(&delegate); -#if defined(OS_WIN) sandbox::SandboxInterfaceInfo sandbox_info = {0}; content::InitializeSandboxInfo(&sandbox_info); params.instance = instance; params.sandbox_info = &sandbox_info; -#else + + return content::ContentMain(params); +} +#else // non-Mac POSIX +int main(int argc, const char** argv) { + extensions::ShellMainDelegate delegate; + content::ContentMainParams params(&delegate); + params.argc = argc; params.argv = argv; -#endif return content::ContentMain(params); } +#endif diff --git a/extensions/shell/app/shell_main_delegate.cc b/extensions/shell/app/shell_main_delegate.cc index 69f0e61..51390f9 100644 --- a/extensions/shell/app/shell_main_delegate.cc +++ b/extensions/shell/app/shell_main_delegate.cc @@ -22,6 +22,11 @@ #include "chromeos/chromeos_paths.h" #endif +#if defined(OS_MACOSX) +#include "base/mac/foundation_util.h" +#include "extensions/shell/app/paths_mac.h" +#endif + #if !defined(DISABLE_NACL) #include "components/nacl/common/nacl_switches.h" #if defined(OS_LINUX) @@ -46,6 +51,21 @@ void InitLogging() { logging::SetLogItems(true, true, true, true); } +// Returns the path to the extensions_shell_and_test.pak file. +base::FilePath GetResourcesPakFilePath() { +#if defined(OS_MACOSX) + return base::mac::PathForFrameworkBundleResource( + CFSTR("extensions_shell_and_test.pak")); +#else + base::FilePath extensions_shell_and_test_pak_path; + PathService::Get(base::DIR_MODULE, &extensions_shell_and_test_pak_path); + extensions_shell_and_test_pak_path = + extensions_shell_and_test_pak_path.AppendASCII( + "extensions_shell_and_test.pak"); + return extensions_shell_and_test_pak_path; +#endif // OS_MACOSX +} + } // namespace namespace extensions { @@ -61,6 +81,12 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { content_client_.reset(CreateContentClient()); SetContentClient(content_client_.get()); +#if defined(OS_MACOSX) + OverrideChildProcessFilePath(); + // This must happen before InitializeResourceBundle. + OverrideFrameworkBundlePath(); +#endif + #if defined(OS_CHROMEOS) chromeos::RegisterPathProvider(); #endif @@ -124,11 +150,8 @@ ShellMainDelegate::CreateShellContentUtilityClient() { } void ShellMainDelegate::InitializeResourceBundle() { - base::FilePath extensions_shell_and_test_pak_path; - PathService::Get(base::DIR_MODULE, &extensions_shell_and_test_pak_path); ui::ResourceBundle::InitSharedInstanceWithPakPath( - extensions_shell_and_test_pak_path.AppendASCII( - "extensions_shell_and_test.pak")); + GetResourcesPakFilePath()); } // static diff --git a/extensions/shell/app/shell_main_delegate.h b/extensions/shell/app/shell_main_delegate.h index e736602..587de92 100644 --- a/extensions/shell/app/shell_main_delegate.h +++ b/extensions/shell/app/shell_main_delegate.h @@ -30,8 +30,7 @@ class ShellMainDelegate : public content::ContentMainDelegate { content::ContentBrowserClient* CreateContentBrowserClient() override; content::ContentRendererClient* CreateContentRendererClient() override; content::ContentUtilityClient* CreateContentUtilityClient() override; -#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \ - !defined(OS_IOS) +#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) void ZygoteStarting( ScopedVector<content::ZygoteForkDelegate>* delegates) override; #endif diff --git a/extensions/shell/app/shell_main_mac.cc b/extensions/shell/app/shell_main_mac.cc new file mode 100644 index 0000000..85195c5 --- /dev/null +++ b/extensions/shell/app/shell_main_mac.cc @@ -0,0 +1,16 @@ +// Copyright 2014 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 "extensions/shell/app/shell_main_mac.h" + +#include "content/public/app/content_main.h" +#include "extensions/shell/app/shell_main_delegate.h" + +int ContentMain(int argc, const char** argv) { + extensions::ShellMainDelegate delegate; + content::ContentMainParams params(&delegate); + params.argc = argc; + params.argv = argv; + return content::ContentMain(params); +} diff --git a/extensions/shell/app/shell_main_mac.h b/extensions/shell/app/shell_main_mac.h new file mode 100644 index 0000000..457806f --- /dev/null +++ b/extensions/shell/app/shell_main_mac.h @@ -0,0 +1,16 @@ +// Copyright 2014 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. + +#ifndef EXTENSIONS_SHELL_APP_SHELL_MAIN_MAC_H_ +#define EXTENSIONS_SHELL_APP_SHELL_MAIN_MAC_H_ + +#include "build/build_config.h" + +extern "C" { +__attribute__((visibility("default"))) int ContentMain(int argc, + const char** argv); +} // extern "C" + +#endif // EXTENSIONS_SHELL_APP_SHELL_MAIN_MAC_H_ + |