summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbenwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-04 05:18:58 +0000
committerbenwells@chromium.org <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-04 05:18:58 +0000
commitd9d0276599ea5a23f2e5c5aa8fc3040ee18bd579 (patch)
tree6ed88f5b4b2fdb32df749f5c2676f9613c51a092
parente93b70ccbb53c6fec20427019b421a05a371114e (diff)
downloadchromium_src-d9d0276599ea5a23f2e5c5aa8fc3040ee18bd579.zip
chromium_src-d9d0276599ea5a23f2e5c5aa8fc3040ee18bd579.tar.gz
chromium_src-d9d0276599ea5a23f2e5c5aa8fc3040ee18bd579.tar.bz2
Revert 170660
This change causes shutdown crashes when chrome menu is used to exit. > Keep browser process alive while there are platform apps with background pages running. This does not happen on Android or ChromeOS builds: Android does not support browser process keep alive, and ChromeOS does not need or like it. > > This change prevents platform apps getting killed unceremoniously while they have background pages active. > > This also delays the process being shutdown after closing the last platform app window, as background pages are kept alive for 15 seconds after their last activity is completed. > > This change re-lands r165772 which caused problems on Google branded ChromeOS. This version does not add keep alives for ChromeOS and was tested on the ChromeOS try bots. > > TBR=davemoore@chromium.org for the ash launcher test change. > > BUG=155457 > TEST=Make sure platform apps can be used from the launcher without chrome windows open; make sure Chrome shuts down properly in all cases. > > > Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=165772 > > Review URL: https://chromiumcodereview.appspot.com/11117011 TBR=benwells@chromium.org Review URL: https://codereview.chromium.org/11299326 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170891 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/extensions/external_filesystem_apitest.cc1
-rw-r--r--chrome/browser/extensions/api/app_window/app_window_apitest.cc4
-rw-r--r--chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc14
-rw-r--r--chrome/browser/extensions/api/dns/dns_apitest.cc2
-rw-r--r--chrome/browser/extensions/api/identity/identity_apitest.cc13
-rw-r--r--chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc10
-rw-r--r--chrome/browser/extensions/api/media_galleries_private/media_galleries_private_apitest.cc74
-rw-r--r--chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc4
-rw-r--r--chrome/browser/extensions/api/serial/serial_apitest.cc4
-rw-r--r--chrome/browser/extensions/api/socket/socket_apitest.cc5
-rw-r--r--chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc10
-rw-r--r--chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc2
-rw-r--r--chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc2
-rw-r--r--chrome/browser/extensions/api/system_info_memory/system_info_memory_apitest.cc2
-rw-r--r--chrome/browser/extensions/api/usb/usb_apitest.cc8
-rw-r--r--chrome/browser/extensions/extension_apitest.cc7
-rw-r--r--chrome/browser/extensions/extension_apitest.h8
-rw-r--r--chrome/browser/extensions/extension_browsertest.cc39
-rw-r--r--chrome/browser/extensions/extension_browsertest.h8
-rw-r--r--chrome/browser/extensions/extension_host.cc17
-rw-r--r--chrome/browser/extensions/extension_host.h9
-rw-r--r--chrome/browser/extensions/platform_app_browsertest.cc83
-rw-r--r--chrome/browser/extensions/platform_app_browsertest_util.cc54
-rw-r--r--chrome/browser/extensions/platform_app_browsertest_util.h15
-rw-r--r--chrome/browser/extensions/platform_app_service.cc45
-rw-r--r--chrome/browser/extensions/platform_app_service.h35
-rw-r--r--chrome/browser/extensions/platform_app_service_factory.cc47
-rw-r--r--chrome/browser/extensions/platform_app_service_factory.h36
-rw-r--r--chrome/browser/extensions/web_view_browsertest.cc10
-rw-r--r--chrome/browser/profiles/profile_dependency_manager.cc2
-rw-r--r--chrome/browser/sync/test/integration/apps_helper.cc25
-rw-r--r--chrome/browser/sync/test/integration/apps_helper.h4
-rw-r--r--chrome/browser/sync/test/integration/single_client_apps_sync_test.cc17
-rw-r--r--chrome/browser/sync/test/integration/two_client_apps_sync_test.cc13
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc29
-rw-r--r--chrome/chrome_browser_extensions.gypi4
-rw-r--r--chrome/test/data/extensions/api_test/media_galleries_private/attachdetach/test.js2
-rw-r--r--chrome/test/data/extensions/platform_apps/geometry/test.js2
-rw-r--r--chrome/test/data/extensions/platform_apps/open_link/main.js2
-rw-r--r--chrome/test/data/extensions/platform_apps/windows_api_bounds/background.js1
40 files changed, 147 insertions, 522 deletions
diff --git a/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc b/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc
index 927955b..0efa08e 100644
--- a/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc
+++ b/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc
@@ -344,7 +344,6 @@ IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserWebIntentTest) {
// The webintent_handler sends chrome.test.succeed() on successful receipt
// of the incoming Web Intent.
ASSERT_TRUE(catcher.GetNextResult()) << message_;
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserTestWrite) {
diff --git a/chrome/browser/extensions/api/app_window/app_window_apitest.cc b/chrome/browser/extensions/api/app_window/app_window_apitest.cc
index 0b8c28c..dadffbd 100644
--- a/chrome/browser/extensions/api/app_window/app_window_apitest.cc
+++ b/chrome/browser/extensions/api/app_window/app_window_apitest.cc
@@ -35,8 +35,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiBounds) {
ready_listener.Reply(base::IntToString(slop));
ASSERT_TRUE(success_listener.WaitUntilSatisfied());
-
- CloseShellWindowsAndWaitForAppToExit();
}
// TODO(asargent) - Fix onMinimzed event on OSX (crbug.com/162793) and figure
@@ -46,7 +44,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiBounds) {
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiProperties) {
EXPECT_TRUE(
- RunPlatformAppTest("platform_apps/windows_api_properties")) << message_;
+ RunExtensionTest("platform_apps/windows_api_properties")) << message_;
}
#endif // defined(TOOLKIT_VIEWS)
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc
index d646d6d..15fa7c6 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc
@@ -330,7 +330,6 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DiscoveryCallback) {
discovery_stopped.Reply("go");
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DiscoveryInProgress) {
@@ -361,7 +360,6 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DiscoveryInProgress) {
discovery_stopped.Reply("go");
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Events) {
@@ -383,7 +381,6 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Events) {
listener.Reply("go");
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevices) {
@@ -417,7 +414,6 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevices) {
listener.Reply("go");
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesConcurrently) {
@@ -429,10 +425,9 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesConcurrently) {
// Save the callback to delay execution so that we can force the calls to
// happen concurrently. This will be called after the listener is satisfied.
- BluetoothDevice::ProvidesServiceCallback* callback =
- new BluetoothDevice::ProvidesServiceCallback;
+ BluetoothDevice::ProvidesServiceCallback callback;
EXPECT_CALL(*device1_, ProvidesServiceWithName(testing::_, testing::_))
- .WillOnce(testing::SaveArg<1>(callback));
+ .WillOnce(testing::SaveArg<1>(&callback));
EXPECT_CALL(*mock_adapter_, GetDevices())
.WillOnce(testing::Return(devices));
@@ -443,12 +438,10 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesConcurrently) {
test_data_dir_.AppendASCII("bluetooth/get_devices_concurrently")));
EXPECT_TRUE(listener.WaitUntilSatisfied());
- callback->Run(false);
- delete callback;
+ callback.Run(false);
listener.Reply("go");
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesError) {
@@ -464,5 +457,4 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesError) {
listener.Reply("go");
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
- CloseShellWindowsAndWaitForAppToExit();
}
diff --git a/chrome/browser/extensions/api/dns/dns_apitest.cc b/chrome/browser/extensions/api/dns/dns_apitest.cc
index b792127..a4c5ad0 100644
--- a/chrome/browser/extensions/api/dns/dns_apitest.cc
+++ b/chrome/browser/extensions/api/dns/dns_apitest.cc
@@ -101,5 +101,5 @@ IN_PROC_BROWSER_TEST_F(DnsApiTest, DnsResolveHostname) {
}
IN_PROC_BROWSER_TEST_F(DnsApiTest, DnsExtension) {
- ASSERT_TRUE(RunPlatformAppTest("dns/api")) << message_;
+ ASSERT_TRUE(RunExtensionTest("dns/api")) << message_;
}
diff --git a/chrome/browser/extensions/api/identity/identity_apitest.cc b/chrome/browser/extensions/api/identity/identity_apitest.cc
index 7f49ae4..e5d05bb 100644
--- a/chrome/browser/extensions/api/identity/identity_apitest.cc
+++ b/chrome/browser/extensions/api/identity/identity_apitest.cc
@@ -177,7 +177,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_EQ(std::string(errors::kInvalidClientId), error);
EXPECT_FALSE(func->login_ui_shown());
EXPECT_FALSE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -189,7 +188,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_EQ(std::string(errors::kInvalidScopes), error);
EXPECT_FALSE(func->login_ui_shown());
EXPECT_FALSE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -202,7 +200,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_EQ(std::string(errors::kUserNotSignedIn), error);
EXPECT_FALSE(func->login_ui_shown());
EXPECT_FALSE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -220,7 +217,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_TRUE(StartsWithASCII(error, errors::kAuthFailure, false));
EXPECT_FALSE(func->login_ui_shown());
EXPECT_FALSE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -240,7 +236,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_EQ(std::string(kAccessToken), access_token);
EXPECT_FALSE(func->login_ui_shown());
EXPECT_FALSE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -253,7 +248,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_EQ(std::string(errors::kUserNotSignedIn), error);
EXPECT_TRUE(func->login_ui_shown());
EXPECT_FALSE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -271,7 +265,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_TRUE(StartsWithASCII(error, errors::kAuthFailure, false));
EXPECT_TRUE(func->login_ui_shown());
EXPECT_FALSE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -291,7 +284,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_EQ(std::string(kAccessToken), access_token);
EXPECT_TRUE(func->login_ui_shown());
EXPECT_FALSE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -310,7 +302,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_EQ(std::string(errors::kUserRejected), error);
EXPECT_TRUE(func->login_ui_shown());
EXPECT_TRUE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -335,7 +326,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_TRUE(StartsWithASCII(error, errors::kAuthFailure, false));
EXPECT_TRUE(func->login_ui_shown());
EXPECT_TRUE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -362,7 +352,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_EQ(std::string(kAccessToken), access_token);
EXPECT_TRUE(func->login_ui_shown());
EXPECT_TRUE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -381,7 +370,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_EQ(std::string(errors::kUserRejected), error);
EXPECT_FALSE(func->login_ui_shown());
EXPECT_TRUE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
@@ -408,7 +396,6 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_EQ(std::string(kAccessToken), access_token);
EXPECT_FALSE(func->login_ui_shown());
EXPECT_TRUE(func->install_ui_shown());
- CloseShellWindowsAndWaitForAppToExit();
}
class LaunchWebAuthFlowFunctionTest : public ExtensionBrowserTest {
diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc b/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
index 3316e9d..d1a5e64 100644
--- a/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
+++ b/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
@@ -57,19 +57,17 @@ IN_PROC_BROWSER_TEST_F(PlatformAppMediaGalleriesBrowserTest, NoGalleries) {
IN_PROC_BROWSER_TEST_F(PlatformAppMediaGalleriesBrowserTest,
MediaGalleriesRead) {
chrome::EnsureMediaDirectoriesExists media_directories;
- ASSERT_TRUE(RunPlatformAppTestReturnImmediately(
- "api_test/media_galleries/read_access")) << message_;
+ ASSERT_TRUE(RunPlatformAppTest("api_test/media_galleries/read_access"))
+ << message_;
RunSecondTestPhase(media_directories.num_galleries());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(PlatformAppMediaGalleriesBrowserTest,
MediaGalleriesNoAccess) {
chrome::EnsureMediaDirectoriesExists media_directories;
- ASSERT_TRUE(RunPlatformAppTestReturnImmediately(
- "api_test/media_galleries/no_access")) << message_;
+ ASSERT_TRUE(RunPlatformAppTest("api_test/media_galleries/no_access"))
+ << message_;
RunSecondTestPhase(media_directories.num_galleries());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(ExperimentalMediaGalleriesApiTest,
diff --git a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_apitest.cc b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_apitest.cc
index 51ccbd2..05dffbe 100644
--- a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_apitest.cc
+++ b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_apitest.cc
@@ -80,27 +80,20 @@ class MediaGalleriesPrivateApiTest : public ExtensionApiTest {
EXPECT_TRUE(listener.WaitUntilSatisfied());
}
- void Attach(bool listening) {
- const std::string expect_attach_msg =
- base::StringPrintf("%s,%s", kAttachTestOk, kDeviceName);
- ExtensionTestMessageListener attach_finished_listener(
- expect_attach_msg,
- false /* no reply */);
+ void AttachDetach() {
+ Attach();
+ Detach();
+ }
+
+ void Attach() {
base::SystemMonitor::Get()->ProcessRemovableStorageAttached(
device_id_, ASCIIToUTF16(kDeviceName), kDevicePath);
WaitForDeviceEvents();
- if (listening)
- EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
}
- void Detach(bool listening) {
- ExtensionTestMessageListener detach_finished_listener(
- kDetachTestOk,
- false /* no reply */);
+ void Detach() {
base::SystemMonitor::Get()->ProcessRemovableStorageDetached(device_id_);
WaitForDeviceEvents();
- if (listening)
- EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied());
}
private:
@@ -126,41 +119,49 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateApiTest, DeviceAttachDetachEvents) {
ASSERT_TRUE(host);
// No listeners, attach and detach a couple times.
- Attach(false);
- Detach(false);
- Attach(false);
- Detach(false);
+ AttachDetach();
+ AttachDetach();
// Add attach listener.
ChangeListener(host, kAddAttachListenerCmd, kAddAttachListenerOk);
// Attach / detach
- Attach(true);
- Detach(false);
+ const std::string expect_attach_msg =
+ base::StringPrintf("%s,%s", kAttachTestOk, kDeviceName);
+ ExtensionTestMessageListener attach_finished_listener(expect_attach_msg,
+ false /* no reply */);
+ Attach();
+ EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
+ Detach();
// Attach / detach
- Attach(true);
- Detach(false);
+ Attach();
+ EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
+ // Detach
+ Detach();
// Remove attach listener.
ChangeListener(host, kRemoveAttachListenerCmd, kRemoveAttachListenerOk);
// No listeners, attach and detach a couple times.
- Attach(false);
- Detach(false);
- Attach(false);
- Detach(false);
+ AttachDetach();
+ AttachDetach();
// Add detach listener.
ChangeListener(host, kAddDummyDetachListenerCmd, kAddDummyDetachListenerOk);
// Attach / detach
- Attach(false);
- Detach(true);
+ Attach();
+
+ ExtensionTestMessageListener detach_finished_listener(kDetachTestOk,
+ false /* no reply */);
+ Detach();
+ EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied());
// Attach / detach
- Attach(false);
- Detach(true);
+ Attach();
+ Detach();
+ EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied());
// Switch ok dummy detach listener for the regular one.
ChangeListener(host, kRemoveDummyDetachListenerCmd,
@@ -170,10 +171,13 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesPrivateApiTest, DeviceAttachDetachEvents) {
// Add attach listener.
ChangeListener(host, kAddAttachListenerCmd, kAddAttachListenerOk);
- Attach(true);
- Detach(true);
+ Attach();
+ EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
+ Detach();
+ EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied());
- Attach(true);
- Detach(true);
- CloseShellWindowsAndWaitForAppToExit();
+ Attach();
+ EXPECT_TRUE(attach_finished_listener.WaitUntilSatisfied());
+ Detach();
+ EXPECT_TRUE(detach_finished_listener.WaitUntilSatisfied());
}
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc
index fe81014c..c881e88 100644
--- a/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc
@@ -52,7 +52,7 @@ class PushMessagingApiTest : public ExtensionApiTest {
IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, EventDispatch) {
ResultCatcher catcher;
catcher.RestrictToProfile(browser()->profile());
- ExtensionTestMessageListener ready("ready", false);
+ ExtensionTestMessageListener ready("ready", true);
const extensions::Extension* extension =
LoadExtension(test_data_dir_.AppendASCII("push_messaging"));
@@ -71,7 +71,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, EventDispatch) {
IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, ReceivesPush) {
ResultCatcher catcher;
catcher.RestrictToProfile(browser()->profile());
- ExtensionTestMessageListener ready("ready", false);
+ ExtensionTestMessageListener ready("ready", true);
const extensions::Extension* extension =
LoadExtension(test_data_dir_.AppendASCII("push_messaging"));
diff --git a/chrome/browser/extensions/api/serial/serial_apitest.cc b/chrome/browser/extensions/api/serial/serial_apitest.cc
index f37ae67..6495184 100644
--- a/chrome/browser/extensions/api/serial/serial_apitest.cc
+++ b/chrome/browser/extensions/api/serial/serial_apitest.cc
@@ -178,12 +178,12 @@ IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialFakeHardware) {
FakeSerialOpenFunctionFactory));
#endif
- ASSERT_TRUE(RunPlatformAppTest("serial/api")) << message_;
+ ASSERT_TRUE(RunExtensionTest("serial/api")) << message_;
}
IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialRealHardware) {
ResultCatcher catcher;
catcher.RestrictToProfile(browser()->profile());
- ASSERT_TRUE(RunPlatformAppTest("serial/real_hardware")) << message_;
+ ASSERT_TRUE(RunExtensionTest("serial/real_hardware")) << message_;
}
diff --git a/chrome/browser/extensions/api/socket/socket_apitest.cc b/chrome/browser/extensions/api/socket/socket_apitest.cc
index d279717..93bd3c8 100644
--- a/chrome/browser/extensions/api/socket/socket_apitest.cc
+++ b/chrome/browser/extensions/api/socket/socket_apitest.cc
@@ -145,7 +145,6 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPExtension) {
base::StringPrintf("udp:%s:%d", host_port_pair.host().c_str(), port));
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPExtension) {
@@ -173,7 +172,6 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPExtension) {
base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port));
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerExtension) {
@@ -186,12 +184,9 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerExtension) {
base::StringPrintf("tcp_server:%s:%d", kHostname.c_str(), kPort));
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerUnbindOnUnload) {
ASSERT_TRUE(RunExtensionTest("socket/unload")) << message_;
- CloseShellWindowsAndWaitForAppToExit();
ASSERT_TRUE(RunExtensionTest("socket/unload")) << message_;
- CloseShellWindowsAndWaitForAppToExit();
}
diff --git a/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc b/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc
index 35ee945..b5bc79c 100644
--- a/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc
+++ b/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc
@@ -58,18 +58,20 @@ class SyncFileSystemApiTest : public ExtensionApiTest {
} // namespace
// TODO(calvinlo): Add Chrome OS support for syncable file system
+#if !defined(OS_CHROMEOS)
+
+// TODO(calvinlo): Add Chrome OS support for syncable file system
// (http://crbug.com/160693)
#if !defined(OS_CHROMEOS)
-// TODO(calvinlo): Re-enable this test.
-// (http://crbug.com/162811)
+// TODO(benwells): Re-enable this test.
IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, DISABLED_DeleteFileSystem) {
ASSERT_TRUE(RunPlatformAppTest("sync_file_system/delete_file_system"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetUsageAndQuota) {
- ASSERT_TRUE(RunPlatformAppTest("sync_file_system/get_usage_and_quota"))
+ ASSERT_TRUE(RunExtensionTest("sync_file_system/get_usage_and_quota"))
<< message_;
}
@@ -87,5 +89,7 @@ IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, WriteFileThenGetUsage) {
#endif // !defined(OS_CHROMEOS)
+#endif // !defined(OS_CHROMEOS)
+
} // namespace chrome
diff --git a/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc b/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc
index 3fb2a00..446a576 100644
--- a/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc
+++ b/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc
@@ -5,5 +5,5 @@
#include "chrome/browser/extensions/extension_apitest.h"
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, SystemIndicator) {
- ASSERT_TRUE(RunPlatformAppTest("system_indicator/basics")) << message_;
+ ASSERT_TRUE(RunExtensionTest("system_indicator/basics")) << message_;
}
diff --git a/chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc b/chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc
index 3bc41d1..21f4e17 100644
--- a/chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc
+++ b/chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc
@@ -78,7 +78,7 @@ IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) {
CpuInfoProvider* provider = new MockCpuInfoProviderImpl();
// The provider is owned by the single CpuInfoProvider instance.
CpuInfoProvider::InitializeForTesting(provider);
- ASSERT_TRUE(RunPlatformAppTest("systeminfo/cpu")) << message_;
+ ASSERT_TRUE(RunExtensionTest("systeminfo/cpu")) << message_;
}
} // namespace extensions
diff --git a/chrome/browser/extensions/api/system_info_memory/system_info_memory_apitest.cc b/chrome/browser/extensions/api/system_info_memory/system_info_memory_apitest.cc
index dcf94ab..4ffb578 100644
--- a/chrome/browser/extensions/api/system_info_memory/system_info_memory_apitest.cc
+++ b/chrome/browser/extensions/api/system_info_memory/system_info_memory_apitest.cc
@@ -49,7 +49,7 @@ IN_PROC_BROWSER_TEST_F(SystemInfoMemoryApiTest, Memory) {
MemoryInfoProvider* provider = new MockMemoryInfoProviderImpl();
// The provider is owned by the single MemoryInfoProvider instance.
MemoryInfoProvider::InitializeForTesting(provider);
- ASSERT_TRUE(RunPlatformAppTest("systeminfo/memory")) << message_;
+ ASSERT_TRUE(RunExtensionTest("systeminfo/memory")) << message_;
}
} // namespace extensions
diff --git a/chrome/browser/extensions/api/usb/usb_apitest.cc b/chrome/browser/extensions/api/usb/usb_apitest.cc
index 3729efa..c7c382f 100644
--- a/chrome/browser/extensions/api/usb/usb_apitest.cc
+++ b/chrome/browser/extensions/api/usb/usb_apitest.cc
@@ -81,7 +81,7 @@ class UsbApiTest : public ExtensionApiTest {
IN_PROC_BROWSER_TEST_F(UsbApiTest, DeviceHandling) {
EXPECT_CALL(*mock_device_, Close(_)).Times(1);
- ASSERT_TRUE(RunPlatformAppTest("usb/device_handling"));
+ ASSERT_TRUE(RunExtensionTest("usb/device_handling"));
}
IN_PROC_BROWSER_TEST_F(UsbApiTest, TransferEvent) {
@@ -99,14 +99,14 @@ IN_PROC_BROWSER_TEST_F(UsbApiTest, TransferEvent) {
IsochronousTransfer(UsbDevice::OUTBOUND, 3, _, 1, 1, 1, _, _))
.WillOnce(InvokeUsbTransferCallback<7>(USB_TRANSFER_COMPLETED));
EXPECT_CALL(*mock_device_, Close(_)).Times(AnyNumber());
- ASSERT_TRUE(RunPlatformAppTest("usb/transfer_event"));
+ ASSERT_TRUE(RunExtensionTest("usb/transfer_event"));
}
IN_PROC_BROWSER_TEST_F(UsbApiTest, ZeroLengthTransfer) {
EXPECT_CALL(*mock_device_, BulkTransfer(_, _, _, 0, _, _))
.WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_COMPLETED));
EXPECT_CALL(*mock_device_, Close(_)).Times(AnyNumber());
- ASSERT_TRUE(RunPlatformAppTest("usb/zero_length_transfer"));
+ ASSERT_TRUE(RunExtensionTest("usb/zero_length_transfer"));
}
IN_PROC_BROWSER_TEST_F(UsbApiTest, TransferFailure) {
@@ -115,5 +115,5 @@ IN_PROC_BROWSER_TEST_F(UsbApiTest, TransferFailure) {
.WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_ERROR))
.WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_TIMEOUT));
EXPECT_CALL(*mock_device_, Close(_)).Times(AnyNumber());
- ASSERT_TRUE(RunPlatformAppTest("usb/transfer_failure"));
+ ASSERT_TRUE(RunExtensionTest("usb/transfer_failure"));
}
diff --git a/chrome/browser/extensions/extension_apitest.cc b/chrome/browser/extensions/extension_apitest.cc
index c09e185..9ab6a72 100644
--- a/chrome/browser/extensions/extension_apitest.cc
+++ b/chrome/browser/extensions/extension_apitest.cc
@@ -174,13 +174,6 @@ bool ExtensionApiTest::RunPageTest(const std::string& page_url,
}
bool ExtensionApiTest::RunPlatformAppTest(const char* extension_name) {
- bool res = RunPlatformAppTestReturnImmediately(extension_name);
- CloseShellWindowsAndWaitForAppToExit();
- return res;
-}
-
-bool ExtensionApiTest::RunPlatformAppTestReturnImmediately(
- const char* extension_name) {
return RunExtensionTestImpl(extension_name, "", kFlagLaunchPlatformApp);
}
diff --git a/chrome/browser/extensions/extension_apitest.h b/chrome/browser/extensions/extension_apitest.h
index 2c5343f..143f9fd 100644
--- a/chrome/browser/extensions/extension_apitest.h
+++ b/chrome/browser/extensions/extension_apitest.h
@@ -148,15 +148,9 @@ class ExtensionApiTest : public ExtensionBrowserTest {
bool RunPageTest(const std::string& page_url, int flags);
// Similar to RunExtensionTest, except used for running tests in platform app
- // shell windows. After running the test will close all shell windows and wait
- // for the background page to be unloaded.
+ // shell windows.
bool RunPlatformAppTest(const char* extension_name);
- // Similar to RunPlatformAppTest, except after running the test returns
- // without closing shell windows or waiting for the background page to be
- // unloaded.
- bool RunPlatformAppTestReturnImmediately(const char* extension_name);
-
// Start the test server, and store details of its state. Those details
// will be available to javascript tests using chrome.test.getConfig().
bool StartTestServer();
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc
index 68b3522..f53505a 100644
--- a/chrome/browser/extensions/extension_browsertest.cc
+++ b/chrome/browser/extensions/extension_browsertest.cc
@@ -23,7 +23,6 @@
#include "chrome/browser/extensions/extension_install_prompt.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@@ -48,7 +47,6 @@
using extensions::Extension;
using extensions::ExtensionCreator;
using extensions::FeatureSwitch;
-using extensions::ShellWindowRegistry;
ExtensionBrowserTest::ExtensionBrowserTest()
: loaded_(false),
@@ -79,10 +77,6 @@ void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) {
"TestUser@gmail.com");
command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
#endif
-
- // Make event pages get suspended quicker.
- command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1");
- command_line->AppendSwitchASCII(switches::kEventPageUnloadingTime, "1");
}
const Extension* ExtensionBrowserTest::LoadExtensionWithFlags(
@@ -551,39 +545,6 @@ bool ExtensionBrowserTest::WaitForCrxInstallerDone() {
return crx_installers_done_observed_ == (before + 1);
}
-void ExtensionBrowserTest::CloseShellWindow(ShellWindow* window) {
- content::WindowedNotificationObserver destroyed_observer(
- content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
- content::NotificationService::AllSources());
- window->GetBaseWindow()->Close();
- destroyed_observer.Wait();
-}
-
-void ExtensionBrowserTest::CloseShellWindowsAndWaitForAppToExit() {
- ExtensionProcessManager* manager =
- extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
- // If there are no background hosts active, the app must have already exited.
- // This can happen if no windows were opened.
- if (manager->background_hosts().empty())
- return;
-
- content::WindowedNotificationObserver destroyed_observer(
- chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
- content::NotificationService::AllSources());
-
- // Close all the windows.
- ShellWindowRegistry* app_registry =
- ShellWindowRegistry::Get(browser()->profile());
- ShellWindowRegistry::const_iterator iter;
- ShellWindowRegistry::ShellWindowSet shell_windows =
- app_registry->shell_windows();
- for (iter = shell_windows.begin(); iter != shell_windows.end(); ++iter)
- CloseShellWindow(*iter);
-
- // Now wait for the lazy background page of the platform app to be unloaded.
- destroyed_observer.Wait();
-}
-
void ExtensionBrowserTest::OpenWindow(content::WebContents* contents,
const GURL& url,
bool newtab_process_should_equal_opener,
diff --git a/chrome/browser/extensions/extension_browsertest.h b/chrome/browser/extensions/extension_browsertest.h
index 7affc49..b1e82a0 100644
--- a/chrome/browser/extensions/extension_browsertest.h
+++ b/chrome/browser/extensions/extension_browsertest.h
@@ -22,7 +22,6 @@
#include "content/public/browser/web_contents.h"
class ExtensionProcessManager;
-class ShellWindow;
// Base class for extension browser tests. Provides utilities for loading,
// unloading, and installing extensions.
@@ -170,13 +169,6 @@ class ExtensionBrowserTest : virtual public InProcessBrowserTest,
// Wait for the crx installer to be done. Returns true if it really is done.
bool WaitForCrxInstallerDone();
- // Closes |window| and waits until it's gone.
- void CloseShellWindow(ShellWindow* window);
-
- // Close any Shell Windows and wait for the app's background page to be
- // unloaded.
- void CloseShellWindowsAndWaitForAppToExit();
-
// Simulates a page calling window.open on an URL and waits for the
// navigation.
void OpenWindow(content::WebContents* contents,
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index aeddfff..ebc288d 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -22,7 +22,6 @@
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/file_select_helper.h"
#include "chrome/browser/intents/web_intents_util.h"
-#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h"
#include "chrome/browser/ui/browser.h"
@@ -138,7 +137,6 @@ ExtensionHost::ExtensionHost(const Extension* extension,
render_view_host_(NULL),
did_stop_loading_(false),
document_element_available_(false),
- keeping_browser_process_alive_(false),
initial_url_(url),
ALLOW_THIS_IN_INITIALIZER_LIST(
extension_function_dispatcher_(profile_, this)),
@@ -171,11 +169,6 @@ ExtensionHost::~ExtensionHost() {
content::Source<Profile>(profile_),
content::Details<ExtensionHost>(this));
ProcessCreationQueue::GetInstance()->Remove(this);
-
-#if !defined(OS_ANDROID)
- if (keeping_browser_process_alive_)
- browser::EndKeepAlive();
-#endif
}
void ExtensionHost::CreateView(Browser* browser) {
@@ -467,16 +460,6 @@ void ExtensionHost::DidCloseJavaScriptDialog() {
pm->DecrementLazyKeepaliveCount(extension());
}
-void ExtensionHost::SetKeepsBrowserProcessAlive() {
- if (keeping_browser_process_alive_)
- return;
-
-#if !defined(OS_ANDROID)
- keeping_browser_process_alive_ = true;
- browser::StartKeepAlive();
-#endif
-}
-
WebContents* ExtensionHost::OpenURLFromTab(WebContents* source,
const OpenURLParams& params) {
// Whitelist the dispositions we will allow to be opened.
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index 0e5bdbc..9c0e247 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -129,12 +129,6 @@ class ExtensionHost : public content::WebContentsDelegate,
void WillRunJavaScriptDialog();
void DidCloseJavaScriptDialog();
- // This is called on hosts which need to keep the browser process alive. This
- // function will add a browser process keep-alive, if it hasn't already been
- // added. Hosts which have had this called will remove the keep-alive when
- // they are destroyed.
- void SetKeepsBrowserProcessAlive();
-
// content::WebContentsObserver
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void RenderViewCreated(
@@ -251,9 +245,6 @@ class ExtensionHost : public content::WebContentsDelegate,
// True if the main frame has finished parsing.
bool document_element_available_;
- // If true, the browser process has had a keep-alive added for this host.
- bool keeping_browser_process_alive_;
-
// The original URL of the page being hosted.
GURL initial_url_;
diff --git a/chrome/browser/extensions/platform_app_browsertest.cc b/chrome/browser/extensions/platform_app_browsertest.cc
index 8a3c2ee..3aec39d 100644
--- a/chrome/browser/extensions/platform_app_browsertest.cc
+++ b/chrome/browser/extensions/platform_app_browsertest.cc
@@ -20,12 +20,10 @@
#include "chrome/browser/extensions/platform_app_browsertest_util.h"
#include "chrome/browser/extensions/platform_app_launcher.h"
#include "chrome/browser/extensions/shell_window_registry.h"
-#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/tab_contents/render_view_context_menu.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
-#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/constrained_window_tab_helper.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/extensions/native_app_window.h"
@@ -149,8 +147,6 @@ const char kTestFilePath[] = "platform_apps/launch_files/test.txt";
} // namespace
-// TODO(benwells): Break up this file into some sensible smaller files.
-
// Tests that CreateShellWindow doesn't crash if you close it straight away.
// LauncherPlatformAppBrowserTest relies on this behaviour, but is only run for
// ash, so we test that it works here.
@@ -158,7 +154,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, CreateAndCloseShellWindow) {
const Extension* extension = LoadAndLaunchPlatformApp("minimal");
ShellWindow* window = CreateShellWindow(extension);
CloseShellWindow(window);
- CloseShellWindowsAndWaitForAppToExit();
}
// Tests that platform apps can be launched in incognito mode without crashing.
@@ -183,16 +178,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_LaunchAppIncognito) {
NEW_WINDOW));
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
- CloseShellWindowsAndWaitForAppToExit();
-}
-
-// Tests that the browser process is kept alive by the platform app's background
-// page.
-IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppEventPageKeepsBrowserAlive) {
- LoadAndLaunchPlatformApp("minimal");
- browser()->window()->Close();
- ASSERT_TRUE(browser::WillKeepAlive());
- CloseShellWindowsAndWaitForAppToExit();
}
// Tests that platform apps received the "launch" event when launched.
@@ -227,7 +212,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchReply) {
web_contents);
ASSERT_TRUE(handler.WaitUntilReply());
- CloseShellWindowsAndWaitForAppToExit();
}
// Tests that platform apps cannot use certain disabled window properties, but
@@ -238,8 +222,11 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisabledWindowProperties) {
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) {
+ ExtensionTestMessageListener launched_listener("Launched", false);
LoadAndLaunchPlatformApp("minimal");
+ ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
+
// The empty app doesn't add any context menu items, so its menu should
// only include the developer tools.
WebContents* web_contents = GetFirstShellWindowWebContents();
@@ -255,12 +242,16 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) {
ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP));
ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) {
+ ExtensionTestMessageListener launched_listener("Launched", false);
LoadAndLaunchPlatformApp("context_menu");
+ // Wait for the extension to tell us it's initialized its context menus and
+ // launched a window.
+ ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
+
// The context_menu app has two context menu items. These, along with a
// separator and the developer tools, is all that should be in the menu.
WebContents* web_contents = GetFirstShellWindowWebContents();
@@ -279,12 +270,16 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) {
ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, InstalledAppWithContextMenu) {
+ ExtensionTestMessageListener launched_listener("Launched", false);
InstallAndLaunchPlatformApp("context_menu");
+ // Wait for the extension to tell us it's initialized its context menus and
+ // launched a window.
+ ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
+
// The context_menu app has two context menu items. For an installed app
// these are all that should be in the menu.
WebContents* web_contents = GetFirstShellWindowWebContents();
@@ -303,12 +298,16 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, InstalledAppWithContextMenu) {
ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
ASSERT_FALSE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_UNDO));
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuTextField) {
+ ExtensionTestMessageListener launched_listener("Launched", false);
LoadAndLaunchPlatformApp("context_menu");
+ // Wait for the extension to tell us it's initialized its context menus and
+ // launched a window.
+ ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
+
// The context_menu app has one context menu item. This, along with a
// separator and the developer tools, is all that should be in the menu.
WebContents* web_contents = GetFirstShellWindowWebContents();
@@ -328,12 +327,16 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuTextField) {
ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY));
ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuSelection) {
+ ExtensionTestMessageListener launched_listener("Launched", false);
LoadAndLaunchPlatformApp("context_menu");
+ // Wait for the extension to tell us it's initialized its context menus and
+ // launched a window.
+ ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
+
// The context_menu app has one context menu item. This, along with a
// separator and the developer tools, is all that should be in the menu.
WebContents* web_contents = GetFirstShellWindowWebContents();
@@ -353,12 +356,16 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuSelection) {
ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_COPY));
ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) {
+ ExtensionTestMessageListener launched_listener("Launched", false);
LoadAndLaunchPlatformApp("context_menu_click");
+ // Wait for the extension to tell us it's initialized its context menus and
+ // launched a window.
+ ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
+
// Test that the menu item shows up
WebContents* web_contents = GetFirstShellWindowWebContents();
ASSERT_TRUE(web_contents);
@@ -376,15 +383,13 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) {
menu->ExecuteCommand(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST);
ASSERT_TRUE(onclicked_listener.WaitUntilSatisfied());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) {
TabsAddedNotificationObserver observer(2);
ASSERT_TRUE(StartTestServer());
- ASSERT_TRUE(RunPlatformAppTestReturnImmediately("platform_apps/navigation"))
- << message_;
+ ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_;
observer.Wait();
ASSERT_EQ(2U, observer.tabs().size());
@@ -392,8 +397,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) {
observer.tabs()[0]->GetURL().spec());
EXPECT_EQ("http://chromium.org/",
observer.tabs()[1]->GetURL().spec());
- browser()->window()->Close();
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) {
@@ -463,7 +466,9 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ExtensionWindowingApis) {
ASSERT_EQ(0U, GetShellWindowCount());
// Launch a platform app that shows a window.
+ ExtensionTestMessageListener launched_listener("Launched", false);
LoadAndLaunchPlatformApp("minimal");
+ ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
ASSERT_EQ(1U, GetShellWindowCount());
ShellWindowRegistry::ShellWindowSet shell_windows =
ShellWindowRegistry::Get(browser()->profile())->shell_windows();
@@ -480,12 +485,13 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ExtensionWindowingApis) {
// to get a list of all the shell windows, so we can test this.
// Launch another platform app that also shows a window.
+ ExtensionTestMessageListener launched_listener2("Launched", false);
LoadAndLaunchPlatformApp("context_menu");
+ ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
// There are two total shell windows, but each app can only see its own.
ASSERT_EQ(2U, GetShellWindowCount());
// TODO(jeremya): as above, this requires more extension functions.
- CloseShellWindowsAndWaitForAppToExit();
}
// ChromeOS does not support passing arguments on the command line, so the tests
@@ -530,7 +536,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithRelativeFile) {
message_ = catcher.message();
ASSERT_TRUE(0);
}
- CloseShellWindowsAndWaitForAppToExit();
}
// Tests that no launch data is sent through if the file is of the wrong MIME
@@ -597,8 +602,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) {
LoadAndLaunchPlatformApp("open_link");
observer.Wait();
ASSERT_EQ(2, browser()->tab_count());
- browser()->window()->Close();
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MutationEventsDisabled) {
@@ -670,8 +673,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
// Wait for javascript to verify that the second window got the updated
// coordinates, ignoring the default coordinates passed to the create method.
ASSERT_TRUE(done2_listener.WaitUntilSatisfied());
-
- CloseShellWindowsAndWaitForAppToExit();
}
// Tests that a running app is recorded in the preferences as such.
@@ -703,7 +704,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) {
AppRestoreServiceFactory::GetForProfile(browser()->profile())->
HandleStartup(true);
restart_listener.WaitUntilSatisfied();
- CloseShellWindowsAndWaitForAppToExit();
}
namespace {
@@ -721,8 +721,10 @@ class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest {
void PlatformAppDevToolsBrowserTest::RunTestWithDevTools(
const char* name, int test_flags) {
using content::DevToolsAgentHostRegistry;
+ ExtensionTestMessageListener launched_listener("Launched", false);
const Extension* extension = LoadAndLaunchPlatformApp(name);
ASSERT_TRUE(extension);
+ ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
ShellWindow* window = GetFirstShellWindow();
ASSERT_TRUE(window);
ASSERT_EQ(window->window_key().empty(), (test_flags & HAS_ID) == 0);
@@ -760,7 +762,6 @@ void PlatformAppDevToolsBrowserTest::RunTestWithDevTools(
ASSERT_TRUE(rvh);
ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh));
}
- CloseShellWindowsAndWaitForAppToExit();
}
} // namespace
@@ -802,19 +803,14 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_ConstrainedWindowRequest) {
ExtensionTestMessageListener listener("PermissionRequestDone", false);
constrained_window_tab_helper->CloseConstrainedWindows();
ASSERT_TRUE(listener.WaitUntilSatisfied());
-
- CloseShellWindowsAndWaitForAppToExit();
}
// Tests that an app calling chrome.runtime.reload will reload the app and
// relaunch it if it was running.
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) {
ExtensionTestMessageListener launched_listener("Launched", true);
- const Extension* extension = LoadPlatformApp("reload");
+ const Extension* extension = LoadAndLaunchPlatformApp("reload");
ASSERT_TRUE(extension);
- application_launch::OpenApplication(application_launch::LaunchParams(
- browser()->profile(), extension, extension_misc::LAUNCH_NONE,
- NEW_WINDOW));
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
ASSERT_TRUE(GetFirstShellWindow());
@@ -823,7 +819,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) {
launched_listener.Reply("reload");
ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
ASSERT_TRUE(GetFirstShellWindow());
- CloseShellWindowsAndWaitForAppToExit();
}
namespace {
@@ -885,8 +880,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
NEW_WINDOW));
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
-
- CloseShellWindowsAndWaitForAppToExit();
}
// Component App Test 2 of 3: ensure an installed component app can be launched
@@ -929,8 +922,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
extension_prefs->pref_service()->RegisterStringPref(
pref_path.c_str(), std::string(), PrefServiceBase::UNSYNCABLE_PREF);
extension_prefs->pref_service()->Set(pref_path.c_str(), old_version);
-
- CloseShellWindowsAndWaitForAppToExit();
}
// Component App Test 3 of 3: simulate a component extension upgrade that
@@ -954,8 +945,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ComponentAppBackgroundPage) {
NEW_WINDOW));
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
-
- CloseShellWindowsAndWaitForAppToExit();
}
} // namespace extensions
diff --git a/chrome/browser/extensions/platform_app_browsertest_util.cc b/chrome/browser/extensions/platform_app_browsertest_util.cc
index 721778f..9883088 100644
--- a/chrome/browser/extensions/platform_app_browsertest_util.cc
+++ b/chrome/browser/extensions/platform_app_browsertest_util.cc
@@ -8,13 +8,11 @@
#include "base/stringprintf.h"
#include "chrome/browser/extensions/api/tabs/tabs.h"
#include "chrome/browser/extensions/extension_function_test_utils.h"
-#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/extensions/native_app_window.h"
#include "chrome/browser/ui/extensions/shell_window.h"
-#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"
@@ -28,49 +26,46 @@ namespace extensions {
void PlatformAppBrowserTest::SetUpCommandLine(CommandLine* command_line) {
// Skips ExtensionApiTest::SetUpCommandLine.
ExtensionBrowserTest::SetUpCommandLine(command_line);
-}
-
-const Extension* PlatformAppBrowserTest::LoadPlatformApp(const char* name) {
- const Extension* extension = LoadExtension(
- test_data_dir_.AppendASCII("platform_apps").AppendASCII(name));
- EXPECT_TRUE(extension);
-
- return extension;
-}
-
-const Extension* PlatformAppBrowserTest::InstallPlatformApp(
- const char* name) {
- const Extension* extension = InstallExtension(
- test_data_dir_.AppendASCII("platform_apps").AppendASCII(name), 1);
- EXPECT_TRUE(extension);
- return extension;
+ // Make event pages get suspended quicker.
+ command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1");
+ command_line->AppendSwitchASCII(switches::kEventPageUnloadingTime, "1");
}
const Extension* PlatformAppBrowserTest::LoadAndLaunchPlatformApp(
const char* name) {
- ExtensionTestMessageListener launched_listener("Launched", false);
+ content::WindowedNotificationObserver app_loaded_observer(
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
+ content::NotificationService::AllSources());
+
+ const Extension* extension = LoadExtension(
+ test_data_dir_.AppendASCII("platform_apps").AppendASCII(name));
+ EXPECT_TRUE(extension);
- const Extension* extension = LoadPlatformApp(name);
application_launch::OpenApplication(application_launch::LaunchParams(
browser()->profile(), extension, extension_misc::LAUNCH_NONE,
NEW_WINDOW));
- launched_listener.WaitUntilSatisfied();
+ app_loaded_observer.Wait();
return extension;
}
const Extension* PlatformAppBrowserTest::InstallAndLaunchPlatformApp(
const char* name) {
- ExtensionTestMessageListener launched_listener("Launched", false);
+ content::WindowedNotificationObserver app_loaded_observer(
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
+ content::NotificationService::AllSources());
+
+ const Extension* extension = InstallExtension(
+ test_data_dir_.AppendASCII("platform_apps").AppendASCII(name), 1);
+ EXPECT_TRUE(extension);
- const Extension* extension = InstallPlatformApp(name);
application_launch::OpenApplication(application_launch::LaunchParams(
browser()->profile(), extension, extension_misc::LAUNCH_NONE,
NEW_WINDOW));
- launched_listener.WaitUntilSatisfied();
+ app_loaded_observer.Wait();
return extension;
}
@@ -89,8 +84,9 @@ ShellWindow* PlatformAppBrowserTest::GetFirstShellWindow() {
ShellWindowRegistry::const_iterator iter;
ShellWindowRegistry::ShellWindowSet shell_windows =
app_registry->shell_windows();
- for (iter = shell_windows.begin(); iter != shell_windows.end(); ++iter)
+ for (iter = shell_windows.begin(); iter != shell_windows.end(); ++iter) {
return *iter;
+ }
return NULL;
}
@@ -148,4 +144,12 @@ ShellWindow* PlatformAppBrowserTest::CreateShellWindow(
browser()->profile(), extension, GURL(""), params);
}
+void PlatformAppBrowserTest::CloseShellWindow(ShellWindow* window) {
+ content::WindowedNotificationObserver destroyed_observer(
+ content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
+ content::NotificationService::AllSources());
+ window->GetBaseWindow()->Close();
+ destroyed_observer.Wait();
+}
+
} // namespace extensions
diff --git a/chrome/browser/extensions/platform_app_browsertest_util.h b/chrome/browser/extensions/platform_app_browsertest_util.h
index 88c9258..3d3a2a7 100644
--- a/chrome/browser/extensions/platform_app_browsertest_util.h
+++ b/chrome/browser/extensions/platform_app_browsertest_util.h
@@ -19,23 +19,11 @@ class ShellWindow;
namespace extensions {
class Extension;
-// TODO(benwells): Clean up this test hierarchy.
-// - rename this to PlatformAppApiTest
-// - remove the existing PlatformAppApiTest
-// - Move the CloseWindow* functions from ExtensionBrowserTest to here
-// - Move the RunPlatformAppTest functions from ExtensionApiTest to here
-// - Make all platform app tests use this class.
class PlatformAppBrowserTest : public ExtensionApiTest {
public:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
protected:
- // Loads the app named |name| out of the platform_apps subdirectory.
- const Extension* LoadPlatformApp(const char* name);
-
- // Installs the app named |name| out of the platform_apps subdirectory.
- const Extension* InstallPlatformApp(const char* name);
-
// Runs the app named |name| out of the platform_apps subdirectory. Waits
// until it is launched.
const Extension* LoadAndLaunchPlatformApp(const char* name);
@@ -75,6 +63,9 @@ class PlatformAppBrowserTest : public ExtensionApiTest {
// Creates an empty shell window for |extension|.
ShellWindow* CreateShellWindow(const Extension* extension);
+
+ // Closes |window| and waits until it's gone.
+ void CloseShellWindow(ShellWindow* window);
};
}
diff --git a/chrome/browser/extensions/platform_app_service.cc b/chrome/browser/extensions/platform_app_service.cc
deleted file mode 100644
index 8874ed0..0000000
--- a/chrome/browser/extensions/platform_app_service.cc
+++ /dev/null
@@ -1,45 +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 file.
-
-#include "chrome/browser/extensions/platform_app_service.h"
-
-#include "chrome/browser/extensions/extension_host.h"
-#include "chrome/common/chrome_notification_types.h"
-#include "chrome/common/extensions/extension.h"
-#include "content/public/browser/browser_context.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_types.h"
-
-namespace extensions {
-
-PlatformAppService::PlatformAppService(Profile* profile) {
-#if !defined(OS_CHROMEOS)
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_CREATED,
- content::Source<content::BrowserContext>(profile));
-#endif
-}
-
-PlatformAppService::~PlatformAppService() {}
-
-void PlatformAppService::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- switch (type) {
- case chrome::NOTIFICATION_EXTENSION_HOST_CREATED: {
-// This code causes problems at logout for ChromeOS, and is not necessary anyway
-// as the browser process lifetime is defined by the session.
-#if !defined(OS_CHROMEOS)
- ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
- if (host->extension()->is_platform_app())
- host->SetKeepsBrowserProcessAlive();
-#endif
- break;
- }
- default:
- NOTREACHED();
- }
-}
-
-} // namespace extensions
diff --git a/chrome/browser/extensions/platform_app_service.h b/chrome/browser/extensions/platform_app_service.h
deleted file mode 100644
index 28a578d..0000000
--- a/chrome/browser/extensions/platform_app_service.h
+++ /dev/null
@@ -1,35 +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 file.
-
-#ifndef CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_SERVICE_H_
-#define CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_SERVICE_H_
-
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_keyed_service.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
-
-namespace extensions {
-
-// The PlatformAppService provides services for platform apps, such as
-// keeping the browser process alive while they are running.
-// TODO(benwells): Merge functionality of ShellWindowRegistry into this class.
-class PlatformAppService : public ProfileKeyedService,
- public content::NotificationObserver {
- public:
- explicit PlatformAppService(Profile* profile);
- virtual ~PlatformAppService();
-
- private:
- // content::NotificationObserver:
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
-
- content::NotificationRegistrar registrar_;
-};
-
-} // namespace extensions
-
-#endif // CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_SERVICE_H_
diff --git a/chrome/browser/extensions/platform_app_service_factory.cc b/chrome/browser/extensions/platform_app_service_factory.cc
deleted file mode 100644
index c4fa6d1..0000000
--- a/chrome/browser/extensions/platform_app_service_factory.cc
+++ /dev/null
@@ -1,47 +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 file.
-
-#include "chrome/browser/extensions/platform_app_service_factory.h"
-
-#include "chrome/browser/profiles/profile_dependency_manager.h"
-
-namespace extensions {
-
-// static
-PlatformAppService* PlatformAppServiceFactory::GetForProfile(
- Profile* profile) {
- return static_cast<PlatformAppService*>(
- GetInstance()->GetServiceForProfile(profile, true));
-}
-
-PlatformAppServiceFactory* PlatformAppServiceFactory::GetInstance() {
- return Singleton<PlatformAppServiceFactory>::get();
-}
-
-PlatformAppServiceFactory::PlatformAppServiceFactory()
- : ProfileKeyedServiceFactory("PlatformAppService",
- ProfileDependencyManager::GetInstance()) {
-}
-
-PlatformAppServiceFactory::~PlatformAppServiceFactory() {
-}
-
-ProfileKeyedService* PlatformAppServiceFactory::BuildServiceInstanceFor(
- Profile* profile) const {
- return new PlatformAppService(profile);
-}
-
-bool PlatformAppServiceFactory::ServiceHasOwnInstanceInIncognito() const {
- return true;
-}
-
-bool PlatformAppServiceFactory::ServiceIsCreatedWithProfile() const {
- return true;
-}
-
-bool PlatformAppServiceFactory::ServiceIsNULLWhileTesting() const {
- return false;
-}
-
-} // namespace extensions
diff --git a/chrome/browser/extensions/platform_app_service_factory.h b/chrome/browser/extensions/platform_app_service_factory.h
deleted file mode 100644
index 82412e9..0000000
--- a/chrome/browser/extensions/platform_app_service_factory.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 file.
-
-#ifndef CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_SERVICE_FACTORY_H_
-#define CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_SERVICE_FACTORY_H_
-
-#include "base/memory/singleton.h"
-#include "chrome/browser/extensions/platform_app_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_keyed_service_factory.h"
-
-namespace extensions {
-
-class PlatformAppServiceFactory : public ProfileKeyedServiceFactory {
- public:
- static PlatformAppService* GetForProfile(Profile* profile);
-
- static PlatformAppServiceFactory* GetInstance();
- private:
- friend struct DefaultSingletonTraits<PlatformAppServiceFactory>;
-
- PlatformAppServiceFactory();
- virtual ~PlatformAppServiceFactory();
-
- // ProfileKeyedServiceFactory
- virtual ProfileKeyedService* BuildServiceInstanceFor(
- Profile* profile) const OVERRIDE;
- virtual bool ServiceHasOwnInstanceInIncognito() const OVERRIDE;
- virtual bool ServiceIsCreatedWithProfile() const OVERRIDE;
- virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
-};
-
-} // namespace extensions
-
-#endif // CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_SERVICE_FACTORY_H_
diff --git a/chrome/browser/extensions/web_view_browsertest.cc b/chrome/browser/extensions/web_view_browsertest.cc
index 5c90088..158fc3e 100644
--- a/chrome/browser/extensions/web_view_browsertest.cc
+++ b/chrome/browser/extensions/web_view_browsertest.cc
@@ -282,8 +282,6 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, CookieIsolation) {
named_partition_contents1,
&cookie_size, &cookie_value);
EXPECT_EQ("", cookie_value);
-
- CloseShellWindowsAndWaitForAppToExit();
}
// This tests that in-memory storage partitions are reset on browser restart,
@@ -374,8 +372,6 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, PRE_StoragePersistence) {
persistent_partition_contents3,
&cookie_size, &cookie_value);
EXPECT_EQ("persist2=true", cookie_value);
-
- CloseShellWindowsAndWaitForAppToExit();
}
// This is the post-reset portion of the StoragePersistence test. See
@@ -437,8 +433,6 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, StoragePersistence) {
persistent_partition_contents3,
&cookie_size, &cookie_value);
EXPECT_EQ("persist2=true", cookie_value);
-
- CloseShellWindowsAndWaitForAppToExit();
}
// This tests DOM storage isolation for packaged apps with webview tags. It
@@ -527,8 +521,6 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, DOMStorageIsolation) {
default_tag_contents1->GetRenderViewHost(), std::wstring(),
get_session_storage.c_str(), &output));
EXPECT_STREQ("badval", output.c_str());
-
- CloseShellWindowsAndWaitForAppToExit();
}
// This tests IndexedDB isolation for packaged apps with webview tags. It loads
@@ -615,6 +607,4 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, IndexedDBIsolation) {
ExecuteScriptWaitForTitle(chrome::GetWebContentsAt(browser(), 0),
script, "db not found");
ExecuteScriptWaitForTitle(default_tag_contents1, script, "db not found");
-
- CloseShellWindowsAndWaitForAppToExit();
}
diff --git a/chrome/browser/profiles/profile_dependency_manager.cc b/chrome/browser/profiles/profile_dependency_manager.cc
index 9488ff6..282d5a8 100644
--- a/chrome/browser/profiles/profile_dependency_manager.cc
+++ b/chrome/browser/profiles/profile_dependency_manager.cc
@@ -23,7 +23,6 @@
#include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory.h"
#include "chrome/browser/extensions/app_restore_service_factory.h"
#include "chrome/browser/extensions/extension_system_factory.h"
-#include "chrome/browser/extensions/platform_app_service_factory.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/google/google_url_tracker_factory.h"
#include "chrome/browser/history/history_service_factory.h"
@@ -226,7 +225,6 @@ void ProfileDependencyManager::AssertFactoriesBuilt() {
extensions::CommandServiceFactory::GetInstance();
extensions::ExtensionSystemFactory::GetInstance();
extensions::IdleManagerFactory::GetInstance();
- extensions::PlatformAppServiceFactory::GetInstance();
extensions::ProcessesAPIFactory::GetInstance();
extensions::SuggestedLinksRegistryFactory::GetInstance();
extensions::TabCaptureRegistryFactory::GetInstance();
diff --git a/chrome/browser/sync/test/integration/apps_helper.cc b/chrome/browser/sync/test/integration/apps_helper.cc
index 77c83c9..fe9a379 100644
--- a/chrome/browser/sync/test/integration/apps_helper.cc
+++ b/chrome/browser/sync/test/integration/apps_helper.cc
@@ -6,14 +6,11 @@
#include "base/logging.h"
#include "base/string_number_conversions.h"
-#include "chrome/browser/extensions/extension_process_manager.h"
-#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/test/integration/sync_app_helper.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "chrome/browser/sync/test/integration/sync_extension_helper.h"
#include "chrome/common/extensions/extension.h"
-#include "content/public/test/test_utils.h"
using sync_datatype_helper::test;
@@ -23,19 +20,6 @@ std::string CreateFakeAppName(int index) {
return "fakeapp" + base::IntToString(index);
}
-void WaitForPlatformAppsToUnloadForProfile(Profile* profile) {
- // Note this will hang if there are extensions with persistent background
- // pages loaded.
- ExtensionProcessManager* pm =
- extensions::ExtensionSystem::Get(profile)->process_manager();
- while (!pm->background_hosts().empty()) {
- content::WindowedNotificationObserver destroyed_observer(
- chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
- content::NotificationService::AllSources());
- destroyed_observer.Wait();
- }
-}
-
} // namespace
namespace apps_helper {
@@ -142,13 +126,4 @@ void FixNTPOrdinalCollisions(Profile* profile) {
SyncAppHelper::GetInstance()->FixNTPOrdinalCollisions(profile);
}
-void WaitForPlatformAppsToUnload() {
- // First run any pending tasks to allow any about to load background
- // pages to load.
- MessageLoop::current()->RunUntilIdle();
- for (int i = 0; i < test()->num_clients(); ++i)
- WaitForPlatformAppsToUnloadForProfile(test()->GetProfile(i));
- WaitForPlatformAppsToUnloadForProfile(test()->verifier());
-}
-
} // namespace apps_helper
diff --git a/chrome/browser/sync/test/integration/apps_helper.h b/chrome/browser/sync/test/integration/apps_helper.h
index e54a430..70d3ec4 100644
--- a/chrome/browser/sync/test/integration/apps_helper.h
+++ b/chrome/browser/sync/test/integration/apps_helper.h
@@ -84,10 +84,6 @@ void CopyNTPOrdinals(Profile* source, Profile* destination, int index);
// Fix any NTP icon collisions that are currently in |profile|.
void FixNTPOrdinalCollisions(Profile* profile);
-// Wait until there are no lazy background pages loaded.
-// This needs to be done before exiting tests which installed platform apps.
-void WaitForPlatformAppsToUnload();
-
} // namespace apps_helper
#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_APPS_HELPER_H_
diff --git a/chrome/browser/sync/test/integration/single_client_apps_sync_test.cc b/chrome/browser/sync/test/integration/single_client_apps_sync_test.cc
index d3139ca..320b4a2 100644
--- a/chrome/browser/sync/test/integration/single_client_apps_sync_test.cc
+++ b/chrome/browser/sync/test/integration/single_client_apps_sync_test.cc
@@ -3,16 +3,13 @@
// found in the LICENSE file.
#include "base/basictypes.h"
-#include "base/command_line.h"
#include "chrome/browser/sync/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/apps_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
-#include "chrome/common/chrome_switches.h"
using apps_helper::AllProfilesHaveSameAppsAsVerifier;
using apps_helper::InstallApp;
using apps_helper::InstallPlatformApp;
-using apps_helper::WaitForPlatformAppsToUnload;
class SingleClientAppsSyncTest : public SyncTest {
public:
@@ -20,14 +17,6 @@ class SingleClientAppsSyncTest : public SyncTest {
virtual ~SingleClientAppsSyncTest() {}
- protected:
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- SyncTest::SetUpCommandLine(command_line);
- // Make event pages get suspended quicker.
- command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1");
- command_line->AppendSwitchASCII(switches::kEventPageUnloadingTime, "1");
- }
-
private:
DISALLOW_COPY_AND_ASSIGN(SingleClientAppsSyncTest);
};
@@ -64,8 +53,6 @@ IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, StartWithSomePlatformApps) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
-
- WaitForPlatformAppsToUnload();
}
IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomeLegacyApps) {
@@ -96,8 +83,6 @@ IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomePlatformApps) {
"Waiting for app changes."));
ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
-
- WaitForPlatformAppsToUnload();
}
IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomeApps) {
@@ -121,6 +106,4 @@ IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomeApps) {
"Waiting for app changes."));
ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
-
- WaitForPlatformAppsToUnload();
}
diff --git a/chrome/browser/sync/test/integration/two_client_apps_sync_test.cc b/chrome/browser/sync/test/integration/two_client_apps_sync_test.cc
index 83b72ac..475759a 100644
--- a/chrome/browser/sync/test/integration/two_client_apps_sync_test.cc
+++ b/chrome/browser/sync/test/integration/two_client_apps_sync_test.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/basictypes.h"
-#include "base/command_line.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_sorting.h"
#include "chrome/browser/profiles/profile.h"
@@ -11,7 +10,6 @@
#include "chrome/browser/sync/test/integration/apps_helper.h"
#include "chrome/browser/sync/test/integration/sync_app_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
#include "sync/api/string_ordinal.h"
@@ -30,7 +28,6 @@ using apps_helper::InstallPlatformApp;
using apps_helper::SetAppLaunchOrdinalForApp;
using apps_helper::SetPageOrdinalForApp;
using apps_helper::UninstallApp;
-using apps_helper::WaitForPlatformAppsToUnload;
class TwoClientAppsSyncTest : public SyncTest {
public:
@@ -38,14 +35,6 @@ class TwoClientAppsSyncTest : public SyncTest {
virtual ~TwoClientAppsSyncTest() {}
- protected:
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- SyncTest::SetUpCommandLine(command_line);
- // Make event pages get suspended quicker.
- command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1");
- command_line->AppendSwitchASCII(switches::kEventPageUnloadingTime, "1");
- }
-
private:
DISALLOW_COPY_AND_ASSIGN(TwoClientAppsSyncTest);
};
@@ -119,8 +108,6 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, StartWithDifferentApps) {
InstallAppsPendingForSync(GetProfile(1));
ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
-
- WaitForPlatformAppsToUnload();
}
// Install some apps on both clients, then sync. Then install some apps on only
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
index c6c2a91..a9b8d26 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
@@ -127,7 +127,7 @@ class LauncherAppBrowserTest : public ExtensionBrowserTest {
IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) {
ash::Launcher* launcher = ash::Launcher::ForPrimaryDisplay();
int item_count = launcher->model()->item_count();
- const Extension* extension = LoadPlatformApp("launch");
+ const Extension* extension = LoadAndLaunchPlatformApp("launch");
ShellWindow* window = CreateShellWindow(extension);
++item_count;
ASSERT_EQ(item_count, launcher->model()->item_count());
@@ -138,7 +138,6 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) {
CloseShellWindow(window);
--item_count;
EXPECT_EQ(item_count, launcher->model()->item_count());
- CloseShellWindowsAndWaitForAppToExit();
}
// Test that we can launch a platform app that already has a shortcut.
@@ -146,7 +145,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) {
int item_count = launcher_->model()->item_count();
// First get app_id.
- const Extension* extension = LoadPlatformApp("launch");
+ const Extension* extension = LoadAndLaunchPlatformApp("launch");
const std::string app_id = extension->id();
// Then create a shortcut.
@@ -171,13 +170,12 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPinned) {
item = *launcher_->model()->ItemByID(shortcut_id);
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
EXPECT_EQ(ash::STATUS_CLOSED, item.status);
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) {
// Run.
int item_count = launcher_->model()->item_count();
- const Extension* extension = LoadPlatformApp("launch");
+ const Extension* extension = LoadAndLaunchPlatformApp("launch");
ShellWindow* window = CreateShellWindow(extension);
++item_count;
ASSERT_EQ(item_count, launcher_->model()->item_count());
@@ -211,14 +209,13 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, PinRunning) {
// Then close it, make sure the item remains.
CloseShellWindow(window);
ASSERT_EQ(item_count, launcher_->model()->item_count());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) {
int item_count = launcher_->model()->item_count();
// First get app_id.
- const Extension* extension = LoadPlatformApp("launch");
+ const Extension* extension = LoadAndLaunchPlatformApp("launch");
const std::string app_id = extension->id();
// Then create a shortcut.
@@ -259,7 +256,6 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, UnpinRunning) {
CloseShellWindow(window);
--item_count;
ASSERT_EQ(item_count, launcher_->model()->item_count());
- CloseShellWindowsAndWaitForAppToExit();
}
// Test that we can launch a platform app with more than one window.
@@ -267,7 +263,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) {
int item_count = launcher_->model()->item_count();
// First run app.
- const Extension* extension = LoadPlatformApp("launch");
+ const Extension* extension = LoadAndLaunchPlatformApp("launch");
ShellWindow* window1 = CreateShellWindow(extension);
++item_count;
ASSERT_EQ(item_count, launcher_->model()->item_count());
@@ -296,7 +292,6 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) {
// Confirm item is removed.
--item_count;
ASSERT_EQ(item_count, launcher_->model()->item_count());
- CloseShellWindowsAndWaitForAppToExit();
}
// Times out on ChromeOS: http://crbug.com/159394
@@ -309,7 +304,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_MultipleApps) {
int item_count = launcher_->model()->item_count();
// First run app.
- const Extension* extension1 = LoadPlatformApp("launch");
+ const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
ShellWindow* window1 = CreateShellWindow(extension1);
++item_count;
ASSERT_EQ(item_count, launcher_->model()->item_count());
@@ -320,7 +315,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_MultipleApps) {
EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
// Then run second app.
- const Extension* extension2 = LoadPlatformApp("launch_2");
+ const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2");
ShellWindow* window2 = CreateShellWindow(extension2);
++item_count;
ASSERT_EQ(item_count, launcher_->model()->item_count());
@@ -346,7 +341,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_MultipleApps) {
CloseShellWindow(window1);
--item_count;
ASSERT_EQ(item_count, launcher_->model()->item_count());
- CloseShellWindowsAndWaitForAppToExit();
+
}
// Confirm that app windows can be reactivated by clicking their icons and that
@@ -361,7 +356,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) {
int item_count = launcher_->model()->item_count();
// First run app.
- const Extension* extension1 = LoadPlatformApp("launch");
+ const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
ShellWindow* window1 = CreateShellWindow(extension1);
++item_count;
ASSERT_EQ(item_count, launcher_->model()->item_count());
@@ -372,7 +367,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) {
EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
// Then run second app.
- const Extension* extension2 = LoadPlatformApp("launch_2");
+ const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2");
ShellWindow* window2 = CreateShellWindow(extension2);
++item_count;
ASSERT_EQ(item_count, launcher_->model()->item_count());
@@ -441,14 +436,13 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) {
CloseShellWindow(window1);
--item_count;
EXPECT_EQ(item_count, launcher_->model()->item_count());
- CloseShellWindowsAndWaitForAppToExit();
}
IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) {
int item_count = launcher_->model()->item_count();
// First run app.
- const Extension* extension1 = LoadPlatformApp("launch");
+ const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
CreateShellWindow(extension1);
++item_count;
ASSERT_EQ(item_count, launcher_->model()->item_count());
@@ -461,7 +455,6 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) {
ash::wm::ActivateWindow(browser()->window()->GetNativeWindow());
EXPECT_EQ(ash::STATUS_RUNNING,
launcher_->model()->ItemByID(item_id1)->status);
- CloseShellWindowsAndWaitForAppToExit();
}
// Test that we can launch an app with a shortcut.
diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi
index 4a62728..2fc5943 100644
--- a/chrome/chrome_browser_extensions.gypi
+++ b/chrome/chrome_browser_extensions.gypi
@@ -581,10 +581,6 @@
'browser/extensions/permissions_updater.h',
'browser/extensions/platform_app_launcher.cc',
'browser/extensions/platform_app_launcher.h',
- 'browser/extensions/platform_app_service.cc',
- 'browser/extensions/platform_app_service.h',
- 'browser/extensions/platform_app_service_factory.cc',
- 'browser/extensions/platform_app_service_factory.h',
'browser/extensions/process_map.cc',
'browser/extensions/process_map.h',
'browser/extensions/requirements_checker.cc',
diff --git a/chrome/test/data/extensions/api_test/media_galleries_private/attachdetach/test.js b/chrome/test/data/extensions/api_test/media_galleries_private/attachdetach/test.js
index 232a081..76d6a55 100644
--- a/chrome/test/data/extensions/api_test/media_galleries_private/attachdetach/test.js
+++ b/chrome/test/data/extensions/api_test/media_galleries_private/attachdetach/test.js
@@ -48,6 +48,6 @@ function removeAttachListener() {
}
function removeDummyDetachListener() {
- chrome.mediaGalleriesPrivate.onDeviceDetached.removeListener(testDummyDetach);
+ chrome.mediaGalleriesPrivate.onDeviceAttached.removeListener(testDummyDetach);
chrome.test.sendMessage('remove_dummy_detach_ok');
}
diff --git a/chrome/test/data/extensions/platform_apps/geometry/test.js b/chrome/test/data/extensions/platform_apps/geometry/test.js
index d74c9fa..f2a24fa 100644
--- a/chrome/test/data/extensions/platform_apps/geometry/test.js
+++ b/chrome/test/data/extensions/platform_apps/geometry/test.js
@@ -3,8 +3,6 @@
// found in the LICENSE file.
chrome.app.runtime.onLaunched.addListener(function() {
- chrome.test.sendMessage('Launched');
-
var win1;
chrome.app.window.create('empty.html',
{ id: 'test',
diff --git a/chrome/test/data/extensions/platform_apps/open_link/main.js b/chrome/test/data/extensions/platform_apps/open_link/main.js
index adb7f0e..ddd0c8a 100644
--- a/chrome/test/data/extensions/platform_apps/open_link/main.js
+++ b/chrome/test/data/extensions/platform_apps/open_link/main.js
@@ -17,5 +17,3 @@ chrome.test.getConfig(function(config) {
onmessage = function() {
chrome.test.sendMessage('Link opened');
};
-
-chrome.test.sendMessage('Launched');
diff --git a/chrome/test/data/extensions/platform_apps/windows_api_bounds/background.js b/chrome/test/data/extensions/platform_apps/windows_api_bounds/background.js
index aa37b96..2bac58b 100644
--- a/chrome/test/data/extensions/platform_apps/windows_api_bounds/background.js
+++ b/chrome/test/data/extensions/platform_apps/windows_api_bounds/background.js
@@ -3,7 +3,6 @@
// found in the LICENSE file.
chrome.app.runtime.onLaunched.addListener(function() {
- chrome.test.sendMessage("Launched");
chrome.app.window.create("main.html", function(win){
// Make sure we get back a bounds and that it isn't all 0's.
var bounds = win.getBounds();