diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/DEPS | 1 | ||||
-rw-r--r-- | apps/app_shim/app_shim_interactive_uitest_mac.mm | 91 | ||||
-rw-r--r-- | apps/app_window.h | 2 | ||||
-rw-r--r-- | apps/shell/browser/shell_desktop_controller.cc | 12 | ||||
-rw-r--r-- | apps/shell/browser/shell_extensions_browser_client.cc | 5 | ||||
-rw-r--r-- | apps/shell/browser/shell_extensions_browser_client.h | 2 |
6 files changed, 105 insertions, 8 deletions
@@ -32,7 +32,6 @@ include_rules = [ "+chrome/browser/extensions/api/file_handlers/app_file_handler_util.h", "+chrome/browser/extensions/api/file_system/file_system_api.h", "+chrome/browser/extensions/chrome_extension_web_contents_observer.h", - "+chrome/browser/extensions/extension_icon_image.h", "+chrome/browser/extensions/suggest_permission_util.h", "+chrome/browser/extensions/unpacked_installer.h", "+chrome/common/extensions/api/app_window.h", diff --git a/apps/app_shim/app_shim_interactive_uitest_mac.mm b/apps/app_shim/app_shim_interactive_uitest_mac.mm index 1cfdf7953d..a51cc9bdc0 100644 --- a/apps/app_shim/app_shim_interactive_uitest_mac.mm +++ b/apps/app_shim/app_shim_interactive_uitest_mac.mm @@ -15,6 +15,7 @@ #include "base/files/file_path_watcher.h" #include "base/mac/foundation_util.h" #include "base/mac/launch_services_util.h" +#include "base/mac/mac_util.h" #include "base/mac/scoped_nsobject.h" #include "base/path_service.h" #include "base/process/launch.h" @@ -215,8 +216,10 @@ namespace apps { // Shims require static libraries http://crbug.com/386024. #if defined(COMPONENT_BUILD) #define MAYBE_Launch DISABLED_Launch +#define MAYBE_RebuildShim DISABLED_RebuildShim #else #define MAYBE_Launch Launch +#define MAYBE_RebuildShim RebuildShim #endif // Test that launching the shim for an app starts the app, and vice versa. @@ -304,4 +307,92 @@ IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_Launch) { } } +#if defined(ARCH_CPU_64_BITS) + +// Tests that a 32 bit shim attempting to launch 64 bit Chrome will eventually +// be rebuilt. +IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_RebuildShim) { + // Get the 32 bit shim. + base::FilePath test_data_dir; + PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); + base::FilePath shim_path_32 = + test_data_dir.Append("app_shim").Append("app_shim_32_bit.app"); + EXPECT_TRUE(base::PathExists(shim_path_32)); + + // Install test app. + const extensions::Extension* app = InstallPlatformApp("minimal"); + + // Use WebAppShortcutCreator to create a 64 bit shim. + web_app::WebAppShortcutCreator shortcut_creator( + web_app::GetWebAppDataDirectory(profile()->GetPath(), app->id(), GURL()), + web_app::ShortcutInfoForExtensionAndProfile(app, profile()), + extensions::FileHandlersInfo()); + shortcut_creator.UpdateShortcuts(); + base::FilePath shim_path = shortcut_creator.GetInternalShortcutPath(); + NSMutableDictionary* plist_64 = [NSMutableDictionary + dictionaryWithContentsOfFile:base::mac::FilePathToNSString( + shim_path.Append("Contents").Append("Info.plist"))]; + + // Copy 32 bit shim to where it's expected to be. + // CopyDirectory doesn't seem to work when copying and renaming in one go. + ASSERT_TRUE(base::DeleteFile(shim_path, true)); + ASSERT_TRUE(base::PathExists(shim_path.DirName())); + ASSERT_TRUE(base::CopyDirectory(shim_path_32, shim_path.DirName(), true)); + ASSERT_TRUE(base::Move(shim_path.DirName().Append(shim_path_32.BaseName()), + shim_path)); + ASSERT_TRUE(base::PathExists( + shim_path.Append("Contents").Append("MacOS").Append("app_mode_loader"))); + + // Fix up the plist so that it matches the installed test app. + NSString* plist_path = base::mac::FilePathToNSString( + shim_path.Append("Contents").Append("Info.plist")); + NSMutableDictionary* plist = + [NSMutableDictionary dictionaryWithContentsOfFile:plist_path]; + + NSArray* keys_to_copy = @[ + base::mac::CFToNSCast(kCFBundleIdentifierKey), + base::mac::CFToNSCast(kCFBundleNameKey), + app_mode::kCrAppModeShortcutIDKey, + app_mode::kCrAppModeUserDataDirKey, + app_mode::kBrowserBundleIDKey + ]; + for (NSString* key in keys_to_copy) { + [plist setObject:[plist_64 objectForKey:key] + forKey:key]; + } + [plist writeToFile:plist_path + atomically:YES]; + + base::mac::RemoveQuarantineAttribute(shim_path); + + // Launch the shim, it should start the app and ultimately connect over IPC. + // This actually happens in multiple launches of the shim: + // (1) The shim will fail and instead launch Chrome with --app-id so that the + // app starts. + // (2) Chrome launches the shim in response to an app starting, this time the + // shim launches Chrome with --app-shim-error, which causes Chrome to + // rebuild the shim. + // (3) After rebuilding, Chrome again launches the shim and expects it to + // behave normally. + ExtensionTestMessageListener launched_listener("Launched", false); + CommandLine shim_cmdline(CommandLine::NO_PROGRAM); + ASSERT_TRUE(base::mac::OpenApplicationWithPath( + shim_path, shim_cmdline, kLSLaunchDefaults, NULL)); + + // Wait for the app to start (1). At this point there is no shim host. + ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); + EXPECT_FALSE(HasAppShimHost(profile(), app->id())); + + // Wait for the rebuilt shim to connect (3). This does not race with the app + // starting (1) because Chrome only launches the shim (2) after the app + // starts. Then Chrome must handle --app-shim-error on the UI thread before + // the shim is rebuilt. + WindowedAppShimLaunchObserver(app->id()).Wait(); + + EXPECT_TRUE(GetFirstAppWindow()); + EXPECT_TRUE(HasAppShimHost(profile(), app->id())); +} + +#endif // defined(ARCH_CPU_64_BITS) + } // namespace apps diff --git a/apps/app_window.h b/apps/app_window.h index c8efcb571d..f2e0e98d81 100644 --- a/apps/app_window.h +++ b/apps/app_window.h @@ -7,7 +7,6 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "chrome/browser/extensions/extension_icon_image.h" #include "chrome/browser/sessions/session_id.h" #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" #include "content/public/browser/notification_observer.h" @@ -15,6 +14,7 @@ #include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/common/console_message_level.h" +#include "extensions/browser/extension_icon_image.h" #include "ui/base/ui_base_types.h" // WindowShowState #include "ui/gfx/image/image.h" #include "ui/gfx/rect.h" diff --git a/apps/shell/browser/shell_desktop_controller.cc b/apps/shell/browser/shell_desktop_controller.cc index 2db85b792b..296ca865fb 100644 --- a/apps/shell/browser/shell_desktop_controller.cc +++ b/apps/shell/browser/shell_desktop_controller.cc @@ -224,15 +224,15 @@ void ShellDesktopController::OnHostCloseRequested( } void ShellDesktopController::CreateRootWindow() { - test_screen_.reset(aura::TestScreen::Create()); - // TODO(jamescook): Replace this with a real Screen implementation. - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); - // TODO(mukai): Set up input method. - // Set up basic pieces of ui::wm. gfx::Size size = GetPrimaryDisplaySize(); if (size.IsEmpty()) - size = gfx::Size(1366, 768); + size = gfx::Size(1280, 720); + + test_screen_.reset(aura::TestScreen::Create(size)); + // TODO(jamescook): Replace this with a real Screen implementation. + gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); + // TODO(mukai): Set up input method. host_.reset(aura::WindowTreeHost::Create(gfx::Rect(size))); host_->InitHost(); diff --git a/apps/shell/browser/shell_extensions_browser_client.cc b/apps/shell/browser/shell_extensions_browser_client.cc index 6e8f3efb29..76f4a83b66 100644 --- a/apps/shell/browser/shell_extensions_browser_client.cc +++ b/apps/shell/browser/shell_extensions_browser_client.cc @@ -237,4 +237,9 @@ ShellExtensionsBrowserClient::CreateRuntimeAPIDelegate( return scoped_ptr<RuntimeAPIDelegate>(new apps::ShellRuntimeAPIDelegate()); } +ComponentExtensionResourceManager* +ShellExtensionsBrowserClient::GetComponentExtensionResourceManager() { + return NULL; +} + } // namespace extensions diff --git a/apps/shell/browser/shell_extensions_browser_client.h b/apps/shell/browser/shell_extensions_browser_client.h index 67e937d708..2013c6d741 100644 --- a/apps/shell/browser/shell_extensions_browser_client.h +++ b/apps/shell/browser/shell_extensions_browser_client.h @@ -75,6 +75,8 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient { ExtensionFunctionRegistry* registry) const OVERRIDE; virtual scoped_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate( content::BrowserContext* context) const OVERRIDE; + virtual ComponentExtensionResourceManager* + GetComponentExtensionResourceManager() OVERRIDE; private: // The single BrowserContext for app_shell. Not owned. |