| 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 "chrome/browser/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "chrome/browser/extensions/app_shortcut_manager.h" | 15 #include "chrome/browser/extensions/app_shortcut_manager.h" |
| 16 #include "chrome/browser/extensions/component_loader.h" | 16 #include "chrome/browser/extensions/component_loader.h" |
| 17 #include "chrome/browser/extensions/crx_installer.h" | 17 #include "chrome/browser/extensions/crx_installer.h" |
| 18 #include "chrome/browser/extensions/extension_creator.h" | 18 #include "chrome/browser/extensions/extension_creator.h" |
| 19 #include "chrome/browser/extensions/extension_error_reporter.h" | 19 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 20 #include "chrome/browser/extensions/extension_host.h" | |
| 21 #include "chrome/browser/extensions/extension_install_ui.h" | 20 #include "chrome/browser/extensions/extension_install_ui.h" |
| 22 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 23 #include "chrome/browser/extensions/unpacked_installer.h" | 22 #include "chrome/browser/extensions/unpacked_installer.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/browser/ui/browser_window.h" | 25 #include "chrome/browser/ui/browser_window.h" |
| 27 #include "chrome/browser/ui/omnibox/location_bar.h" | 26 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 28 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 29 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 30 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/test/base/ui_test_utils.h" | 30 #include "chrome/test/base/ui_test_utils.h" |
| 32 #include "content/public/browser/notification_registrar.h" | 31 #include "content/public/browser/notification_registrar.h" |
| 33 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| 33 #include "content/public/browser/render_view_host.h" |
| 34 | 34 |
| 35 ExtensionBrowserTest::ExtensionBrowserTest() | 35 ExtensionBrowserTest::ExtensionBrowserTest() |
| 36 : loaded_(false), | 36 : loaded_(false), |
| 37 installed_(false), | 37 installed_(false), |
| 38 extension_installs_observed_(0), | 38 extension_installs_observed_(0), |
| 39 extension_load_errors_observed_(0), | 39 extension_load_errors_observed_(0), |
| 40 target_page_action_count_(-1), | 40 target_page_action_count_(-1), |
| 41 target_visible_page_action_count_(-1) { | 41 target_visible_page_action_count_(-1) { |
| 42 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); | 42 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 43 AppShortcutManager::SetShortcutCreationDisabledForTesting(true); | 43 AppShortcutManager::SetShortcutCreationDisabledForTesting(true); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 388 } |
| 389 | 389 |
| 390 bool ExtensionBrowserTest::WaitForExtensionHostsToLoad() { | 390 bool ExtensionBrowserTest::WaitForExtensionHostsToLoad() { |
| 391 // Wait for all the extension hosts that exist to finish loading. | 391 // Wait for all the extension hosts that exist to finish loading. |
| 392 content::NotificationRegistrar registrar; | 392 content::NotificationRegistrar registrar; |
| 393 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 393 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
| 394 content::NotificationService::AllSources()); | 394 content::NotificationService::AllSources()); |
| 395 | 395 |
| 396 ExtensionProcessManager* manager = | 396 ExtensionProcessManager* manager = |
| 397 browser()->profile()->GetExtensionProcessManager(); | 397 browser()->profile()->GetExtensionProcessManager(); |
| 398 for (ExtensionProcessManager::const_iterator iter = manager->begin(); | 398 ExtensionProcessManager::ViewSet all_views = manager->GetAllViews(); |
| 399 iter != manager->end();) { | 399 for (ExtensionProcessManager::ViewSet::const_iterator iter = |
| 400 if ((*iter)->did_stop_loading()) { | 400 all_views.begin(); |
| 401 iter != all_views.end();) { |
| 402 if (!(*iter)->IsLoading()) { |
| 401 ++iter; | 403 ++iter; |
| 402 } else { | 404 } else { |
| 403 ui_test_utils::RunMessageLoop(); | 405 ui_test_utils::RunMessageLoop(); |
| 404 | 406 |
| 405 // Test activity may have modified the set of extension processes during | 407 // Test activity may have modified the set of extension processes during |
| 406 // message processing, so re-start the iteration to catch added/removed | 408 // message processing, so re-start the iteration to catch added/removed |
| 407 // processes. | 409 // processes. |
| 408 iter = manager->begin(); | 410 iter = all_views.begin(); |
| 409 } | 411 } |
| 410 } | 412 } |
| 411 return true; | 413 return true; |
| 412 } | 414 } |
| 413 | 415 |
| 414 bool ExtensionBrowserTest::WaitForExtensionInstall() { | 416 bool ExtensionBrowserTest::WaitForExtensionInstall() { |
| 415 int before = extension_installs_observed_; | 417 int before = extension_installs_observed_; |
| 416 ui_test_utils::RegisterAndWait(this, | 418 ui_test_utils::RegisterAndWait(this, |
| 417 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 419 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 418 content::NotificationService::AllSources()); | 420 content::NotificationService::AllSources()); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 MessageLoopForUI::current()->Quit(); | 534 MessageLoopForUI::current()->Quit(); |
| 533 } | 535 } |
| 534 break; | 536 break; |
| 535 } | 537 } |
| 536 | 538 |
| 537 default: | 539 default: |
| 538 NOTREACHED(); | 540 NOTREACHED(); |
| 539 break; | 541 break; |
| 540 } | 542 } |
| 541 } | 543 } |
| OLD | NEW |