OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chrome_extension_test_notification_observer.
h> | 5 #include <chrome/browser/extensions/chrome_extension_test_notification_observer.
h> |
6 #include "base/scoped_observer.h" | 6 #include "base/scoped_observer.h" |
7 #include "chrome/browser/extensions/extension_action_test_util.h" | 7 #include "chrome/browser/extensions/extension_action_test_util.h" |
8 #include "chrome/browser/extensions/extension_util.h" | 8 #include "chrome/browser/extensions/extension_util.h" |
9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 #include "content/public/test/test_utils.h" | |
15 #include "extensions/browser/notification_types.h" | 14 #include "extensions/browser/notification_types.h" |
16 #include "extensions/browser/process_manager.h" | 15 #include "extensions/browser/process_manager.h" |
17 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
18 | 17 |
19 namespace extensions { | 18 namespace extensions { |
20 | 19 |
21 namespace { | 20 namespace { |
22 | 21 |
23 // A callback that returns true if the condition has been met and takes no | 22 // A callback that returns true if the condition has been met and takes no |
24 // arguments. | 23 // arguments. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 DCHECK(browser_); | 73 DCHECK(browser_); |
75 ScopedObserver<ExtensionActionAPI, ExtensionActionAPI::Observer> observer( | 74 ScopedObserver<ExtensionActionAPI, ExtensionActionAPI::Observer> observer( |
76 this); | 75 this); |
77 observer.Add(ExtensionActionAPI::Get(GetBrowserContext())); | 76 observer.Add(ExtensionActionAPI::Get(GetBrowserContext())); |
78 WaitForCondition( | 77 WaitForCondition( |
79 base::Bind(&HasPageActionVisibilityReachedTarget, browser_, count), NULL); | 78 base::Bind(&HasPageActionVisibilityReachedTarget, browser_, count), NULL); |
80 return true; | 79 return true; |
81 } | 80 } |
82 | 81 |
83 bool ChromeExtensionTestNotificationObserver::WaitForExtensionViewsToLoad() { | 82 bool ChromeExtensionTestNotificationObserver::WaitForExtensionViewsToLoad() { |
84 // Some views might be not created yet. This call may become insufficient if | |
85 // e.g. implementation of ExtensionHostQueue changes. | |
86 content::RunAllPendingInMessageLoop(); | |
87 | |
88 ProcessManager* manager = ProcessManager::Get(GetBrowserContext()); | 83 ProcessManager* manager = ProcessManager::Get(GetBrowserContext()); |
89 NotificationSet notification_set; | 84 NotificationSet notification_set; |
90 notification_set.Add(content::NOTIFICATION_WEB_CONTENTS_DESTROYED); | 85 notification_set.Add(content::NOTIFICATION_WEB_CONTENTS_DESTROYED); |
91 notification_set.Add(content::NOTIFICATION_LOAD_STOP); | 86 notification_set.Add(content::NOTIFICATION_LOAD_STOP); |
92 notification_set.AddExtensionFrameUnregistration(manager); | 87 notification_set.AddExtensionFrameUnregistration(manager); |
93 WaitForCondition( | 88 WaitForCondition( |
94 base::Bind(&HaveAllExtensionRenderFrameHostsFinishedLoading, manager), | 89 base::Bind(&HaveAllExtensionRenderFrameHostsFinishedLoading, manager), |
95 ¬ification_set); | 90 ¬ification_set); |
96 return true; | 91 return true; |
97 } | 92 } |
(...skipping 21 matching lines...) Expand all Loading... |
119 ¬ification_set); | 114 ¬ification_set); |
120 return true; | 115 return true; |
121 } | 116 } |
122 | 117 |
123 void ChromeExtensionTestNotificationObserver::OnPageActionsUpdated( | 118 void ChromeExtensionTestNotificationObserver::OnPageActionsUpdated( |
124 content::WebContents* web_contents) { | 119 content::WebContents* web_contents) { |
125 MaybeQuit(); | 120 MaybeQuit(); |
126 } | 121 } |
127 | 122 |
128 } // namespace extensions | 123 } // namespace extensions |
OLD | NEW |