| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 9 #include "chrome/browser/extensions/browser_action_test_util.h" | 9 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| 11 #include "chrome/browser/extensions/extension_event_router.h" | 11 #include "chrome/browser/extensions/extension_event_router.h" |
| 12 #include "chrome/browser/extensions/extension_host.h" | 12 #include "chrome/browser/extensions/extension_host.h" |
| 13 #include "chrome/browser/extensions/extension_test_message_listener.h" | 13 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
| 18 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 19 #include "chrome/browser/ui/omnibox/location_bar.h" | 19 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
| 23 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
| 24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "googleurl/src/gurl.h" | 26 #include "googleurl/src/gurl.h" |
| 27 #include "net/base/mock_host_resolver.h" | 27 #include "net/base/mock_host_resolver.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // Lazy Background Page has been shut down. | 268 // Lazy Background Page has been shut down. |
| 269 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); | 269 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); |
| 270 } | 270 } |
| 271 | 271 |
| 272 // Tests that an incognito split mode extension gets 2 lazy background pages, | 272 // Tests that an incognito split mode extension gets 2 lazy background pages, |
| 273 // and they each load and unload at the proper times. | 273 // and they each load and unload at the proper times. |
| 274 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, IncognitoSplitMode) { | 274 IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, IncognitoSplitMode) { |
| 275 // Open incognito window. | 275 // Open incognito window. |
| 276 ui_test_utils::OpenURLOffTheRecord( | 276 ui_test_utils::OpenURLOffTheRecord( |
| 277 browser()->profile(), GURL("about:blank")); | 277 browser()->profile(), GURL("about:blank")); |
| 278 Browser* incognito_browser = BrowserList::FindTabbedBrowser( | 278 Browser* incognito_browser = browser::FindTabbedBrowser( |
| 279 browser()->profile()->GetOffTheRecordProfile(), false); | 279 browser()->profile()->GetOffTheRecordProfile(), false); |
| 280 ASSERT_TRUE(incognito_browser); | 280 ASSERT_TRUE(incognito_browser); |
| 281 | 281 |
| 282 // Load the extension with incognito enabled. | 282 // Load the extension with incognito enabled. |
| 283 { | 283 { |
| 284 LoadedIncognitoObserver loaded(browser()->profile()); | 284 LoadedIncognitoObserver loaded(browser()->profile()); |
| 285 FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page"). | 285 FilePath extdir = test_data_dir_.AppendASCII("lazy_background_page"). |
| 286 AppendASCII("incognito_split"); | 286 AppendASCII("incognito_split"); |
| 287 ASSERT_TRUE(LoadExtensionIncognito(extdir)); | 287 ASSERT_TRUE(LoadExtensionIncognito(extdir)); |
| 288 loaded.Wait(); | 288 loaded.Wait(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 382 |
| 383 // The browser action has a new title. | 383 // The browser action has a new title. |
| 384 BrowserActionTestUtil browser_action(browser()); | 384 BrowserActionTestUtil browser_action(browser()); |
| 385 ASSERT_EQ(1, browser_action.NumberOfBrowserActions()); | 385 ASSERT_EQ(1, browser_action.NumberOfBrowserActions()); |
| 386 EXPECT_EQ("Success", browser_action.GetTooltip(0)); | 386 EXPECT_EQ("Success", browser_action.GetTooltip(0)); |
| 387 } | 387 } |
| 388 | 388 |
| 389 // TODO: background page with timer. | 389 // TODO: background page with timer. |
| 390 // TODO: background page that interacts with popup. | 390 // TODO: background page that interacts with popup. |
| 391 // TODO: background page with menu. | 391 // TODO: background page with menu. |
| OLD | NEW |