| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_system.h" | 10 #include "chrome/browser/extensions/extension_system.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 signal.Wait(); | 213 signal.Wait(); |
| 214 | 214 |
| 215 // Unload the extension. | 215 // Unload the extension. |
| 216 UninstallExtension(app_id); | 216 UninstallExtension(app_id); |
| 217 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | 217 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), |
| 218 browser()->host_desktop_type())); | 218 browser()->host_desktop_type())); |
| 219 ASSERT_FALSE(service->GetExtensionById(app_id, true)); | 219 ASSERT_FALSE(service->GetExtensionById(app_id, true)); |
| 220 | 220 |
| 221 // Set a pref indicating that the user wants to launch in a regular tab. | 221 // Set a pref indicating that the user wants to launch in a regular tab. |
| 222 // This should be ignored, because panel apps always load in a popup. | 222 // This should be ignored, because panel apps always load in a popup. |
| 223 extensions::SetLaunchType(service->extension_prefs(), | 223 extensions::SetLaunchType(service, app_id, extensions::LAUNCH_TYPE_REGULAR); |
| 224 app_id, extensions::LAUNCH_TYPE_REGULAR); | |
| 225 | 224 |
| 226 // Load the extension again. | 225 // Load the extension again. |
| 227 std::string app_id_new; | 226 std::string app_id_new; |
| 228 LoadAndWaitForLaunch("management/launch_app_panel", &app_id_new); | 227 LoadAndWaitForLaunch("management/launch_app_panel", &app_id_new); |
| 229 ASSERT_FALSE(HasFatalFailure()); | 228 ASSERT_FALSE(HasFatalFailure()); |
| 230 | 229 |
| 231 // If the ID changed, then the pref will not apply to the app. | 230 // If the ID changed, then the pref will not apply to the app. |
| 232 ASSERT_EQ(app_id, app_id_new); | 231 ASSERT_EQ(app_id, app_id_new); |
| 233 | 232 |
| 234 // Find the app's browser. Apps that should load in a panel ignore | 233 // Find the app's browser. Apps that should load in a panel ignore |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 browser()->host_desktop_type())); | 272 browser()->host_desktop_type())); |
| 274 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 273 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
| 275 | 274 |
| 276 // Unload the extension. | 275 // Unload the extension. |
| 277 UninstallExtension(app_id); | 276 UninstallExtension(app_id); |
| 278 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | 277 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), |
| 279 browser()->host_desktop_type())); | 278 browser()->host_desktop_type())); |
| 280 ASSERT_FALSE(service->GetExtensionById(app_id, true)); | 279 ASSERT_FALSE(service->GetExtensionById(app_id, true)); |
| 281 | 280 |
| 282 // Set a pref indicating that the user wants to launch in a window. | 281 // Set a pref indicating that the user wants to launch in a window. |
| 283 extensions::SetLaunchType(service->extension_prefs(), | 282 extensions::SetLaunchType(service, app_id, extensions::LAUNCH_TYPE_WINDOW); |
| 284 app_id, extensions::LAUNCH_TYPE_WINDOW); | |
| 285 | 283 |
| 286 std::string app_id_new; | 284 std::string app_id_new; |
| 287 LoadAndWaitForLaunch("management/launch_app_tab", &app_id_new); | 285 LoadAndWaitForLaunch("management/launch_app_tab", &app_id_new); |
| 288 ASSERT_FALSE(HasFatalFailure()); | 286 ASSERT_FALSE(HasFatalFailure()); |
| 289 | 287 |
| 290 // If the ID changed, then the pref will not apply to the app. | 288 // If the ID changed, then the pref will not apply to the app. |
| 291 ASSERT_EQ(app_id, app_id_new); | 289 ASSERT_EQ(app_id, app_id_new); |
| 292 | 290 |
| 293 #if defined(OS_MACOSX) | 291 #if defined(OS_MACOSX) |
| 294 // App windows are not yet implemented on mac os. We should fall back | 292 // App windows are not yet implemented on mac os. We should fall back |
| 295 // to a normal tab. | 293 // to a normal tab. |
| 296 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | 294 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), |
| 297 browser()->host_desktop_type())); | 295 browser()->host_desktop_type())); |
| 298 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 296 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
| 299 #else | 297 #else |
| 300 // Find the app's browser. Opening in a new window will create | 298 // Find the app's browser. Opening in a new window will create |
| 301 // a new browser. | 299 // a new browser. |
| 302 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), | 300 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), |
| 303 browser()->host_desktop_type())); | 301 browser()->host_desktop_type())); |
| 304 Browser* app_browser = FindOtherBrowser(browser()); | 302 Browser* app_browser = FindOtherBrowser(browser()); |
| 305 ASSERT_TRUE(app_browser->is_app()); | 303 ASSERT_TRUE(app_browser->is_app()); |
| 306 #endif | 304 #endif |
| 307 } | 305 } |
| OLD | NEW |