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" |
11 #include "chrome/browser/extensions/extension_test_message_listener.h" | 11 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 12 #include "chrome/browser/extensions/launch_util.h" |
12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
15 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
16 #include "chrome/browser/ui/browser_iterator.h" | 17 #include "chrome/browser/ui/browser_iterator.h" |
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
19 #include "content/public/test/test_utils.h" | 20 #include "content/public/test/test_utils.h" |
20 #include "extensions/browser/test_management_policy.h" | 21 #include "extensions/browser/test_management_policy.h" |
21 #include "extensions/common/manifest.h" | 22 #include "extensions/common/manifest.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 signal.Wait(); | 212 signal.Wait(); |
212 | 213 |
213 // Unload the extension. | 214 // Unload the extension. |
214 UninstallExtension(app_id); | 215 UninstallExtension(app_id); |
215 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | 216 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), |
216 browser()->host_desktop_type())); | 217 browser()->host_desktop_type())); |
217 ASSERT_FALSE(service->GetExtensionById(app_id, true)); | 218 ASSERT_FALSE(service->GetExtensionById(app_id, true)); |
218 | 219 |
219 // Set a pref indicating that the user wants to launch in a regular tab. | 220 // Set a pref indicating that the user wants to launch in a regular tab. |
220 // This should be ignored, because panel apps always load in a popup. | 221 // This should be ignored, because panel apps always load in a popup. |
221 service->extension_prefs()->SetLaunchType( | 222 extensions::SetLaunchType(service->extension_prefs(), |
222 app_id, extensions::ExtensionPrefs::LAUNCH_TYPE_REGULAR); | 223 app_id, extensions::LAUNCH_TYPE_REGULAR); |
223 | 224 |
224 // Load the extension again. | 225 // Load the extension again. |
225 std::string app_id_new; | 226 std::string app_id_new; |
226 LoadAndWaitForLaunch("management/launch_app_panel", &app_id_new); | 227 LoadAndWaitForLaunch("management/launch_app_panel", &app_id_new); |
227 ASSERT_FALSE(HasFatalFailure()); | 228 ASSERT_FALSE(HasFatalFailure()); |
228 | 229 |
229 // 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. |
230 ASSERT_EQ(app_id, app_id_new); | 231 ASSERT_EQ(app_id, app_id_new); |
231 | 232 |
232 // 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... |
271 browser()->host_desktop_type())); | 272 browser()->host_desktop_type())); |
272 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 273 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
273 | 274 |
274 // Unload the extension. | 275 // Unload the extension. |
275 UninstallExtension(app_id); | 276 UninstallExtension(app_id); |
276 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | 277 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), |
277 browser()->host_desktop_type())); | 278 browser()->host_desktop_type())); |
278 ASSERT_FALSE(service->GetExtensionById(app_id, true)); | 279 ASSERT_FALSE(service->GetExtensionById(app_id, true)); |
279 | 280 |
280 // 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. |
281 service->extension_prefs()->SetLaunchType( | 282 extensions::SetLaunchType(service->extension_prefs(), |
282 app_id, extensions::ExtensionPrefs::LAUNCH_TYPE_WINDOW); | 283 app_id, extensions::LAUNCH_TYPE_WINDOW); |
283 | 284 |
284 std::string app_id_new; | 285 std::string app_id_new; |
285 LoadAndWaitForLaunch("management/launch_app_tab", &app_id_new); | 286 LoadAndWaitForLaunch("management/launch_app_tab", &app_id_new); |
286 ASSERT_FALSE(HasFatalFailure()); | 287 ASSERT_FALSE(HasFatalFailure()); |
287 | 288 |
288 // If the ID changed, then the pref will not apply to the app. | 289 // If the ID changed, then the pref will not apply to the app. |
289 ASSERT_EQ(app_id, app_id_new); | 290 ASSERT_EQ(app_id, app_id_new); |
290 | 291 |
291 #if defined(OS_MACOSX) | 292 #if defined(OS_MACOSX) |
292 // App windows are not yet implemented on mac os. We should fall back | 293 // App windows are not yet implemented on mac os. We should fall back |
293 // to a normal tab. | 294 // to a normal tab. |
294 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | 295 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), |
295 browser()->host_desktop_type())); | 296 browser()->host_desktop_type())); |
296 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 297 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
297 #else | 298 #else |
298 // Find the app's browser. Opening in a new window will create | 299 // Find the app's browser. Opening in a new window will create |
299 // a new browser. | 300 // a new browser. |
300 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), | 301 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), |
301 browser()->host_desktop_type())); | 302 browser()->host_desktop_type())); |
302 Browser* app_browser = FindOtherBrowser(browser()); | 303 Browser* app_browser = FindOtherBrowser(browser()); |
303 ASSERT_TRUE(app_browser->is_app()); | 304 ASSERT_TRUE(app_browser->is_app()); |
304 #endif | 305 #endif |
305 } | 306 } |
OLD | NEW |