| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_test_notification_observer.h" | 5 #include "chrome/browser/extensions/extension_test_notification_observer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_process_manager.h" | |
| 8 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 8 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 11 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
| 17 #include "content/public/test/test_utils.h" | 16 #include "content/public/test/test_utils.h" |
| 17 #include "extensions/browser/process_manager.h" |
| 18 | 18 |
| 19 using extensions::Extension; | 19 using extensions::Extension; |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 bool HasExtensionPageActionCountReachedTarget(LocationBarTesting* location_bar, | 23 bool HasExtensionPageActionCountReachedTarget(LocationBarTesting* location_bar, |
| 24 int target_page_action_count) { | 24 int target_page_action_count) { |
| 25 VLOG(1) << "Number of page actions: " << location_bar->PageActionCount(); | 25 VLOG(1) << "Number of page actions: " << location_bar->PageActionCount(); |
| 26 return location_bar->PageActionCount() == target_page_action_count; | 26 return location_bar->PageActionCount() == target_page_action_count; |
| 27 } | 27 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 content::WindowedNotificationObserver( | 92 content::WindowedNotificationObserver( |
| 93 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 93 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, |
| 94 base::Bind(&HasExtensionPageActionVisibilityReachedTarget, | 94 base::Bind(&HasExtensionPageActionVisibilityReachedTarget, |
| 95 location_bar, | 95 location_bar, |
| 96 count)).Wait(); | 96 count)).Wait(); |
| 97 } | 97 } |
| 98 return HasExtensionPageActionVisibilityReachedTarget(location_bar, count); | 98 return HasExtensionPageActionVisibilityReachedTarget(location_bar, count); |
| 99 } | 99 } |
| 100 | 100 |
| 101 bool ExtensionTestNotificationObserver::WaitForExtensionViewsToLoad() { | 101 bool ExtensionTestNotificationObserver::WaitForExtensionViewsToLoad() { |
| 102 ExtensionProcessManager* manager = | 102 extensions::ProcessManager* manager = |
| 103 extensions::ExtensionSystem::Get(GetProfile())->process_manager(); | 103 extensions::ExtensionSystem::Get(GetProfile())->process_manager(); |
| 104 ExtensionProcessManager::ViewSet all_views = manager->GetAllViews(); | 104 extensions::ProcessManager::ViewSet all_views = manager->GetAllViews(); |
| 105 for (ExtensionProcessManager::ViewSet::const_iterator iter = | 105 for (extensions::ProcessManager::ViewSet::const_iterator iter = |
| 106 all_views.begin(); | 106 all_views.begin(); |
| 107 iter != all_views.end();) { | 107 iter != all_views.end();) { |
| 108 if (!(*iter)->IsLoading()) { | 108 if (!(*iter)->IsLoading()) { |
| 109 ++iter; | 109 ++iter; |
| 110 } else { | 110 } else { |
| 111 // Wait for all the extension render view hosts that exist to finish | 111 // Wait for all the extension render view hosts that exist to finish |
| 112 // loading. | 112 // loading. |
| 113 content::WindowedNotificationObserver observer( | 113 content::WindowedNotificationObserver observer( |
| 114 content::NOTIFICATION_LOAD_STOP, | 114 content::NOTIFICATION_LOAD_STOP, |
| 115 content::NotificationService::AllSources()); | 115 content::NotificationService::AllSources()); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: | 225 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: |
| 226 VLOG(1) << "Got EXTENSION_LOAD_ERROR notification."; | 226 VLOG(1) << "Got EXTENSION_LOAD_ERROR notification."; |
| 227 ++extension_load_errors_observed_; | 227 ++extension_load_errors_observed_; |
| 228 break; | 228 break; |
| 229 | 229 |
| 230 default: | 230 default: |
| 231 NOTREACHED(); | 231 NOTREACHED(); |
| 232 break; | 232 break; |
| 233 } | 233 } |
| 234 } | 234 } |
| OLD | NEW |