Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: chrome/browser/extensions/chrome_extension_test_notification_observer.cc

Issue 2740783003: Revert "Revert of Reland: Switch WindowedNotificationObserver to use base::RunLoop. (patchset #3 id… (Closed)
Patch Set: Fix comment. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
14 #include "extensions/browser/notification_types.h" 15 #include "extensions/browser/notification_types.h"
15 #include "extensions/browser/process_manager.h" 16 #include "extensions/browser/process_manager.h"
16 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
17 18
18 namespace extensions { 19 namespace extensions {
19 20
20 namespace { 21 namespace {
21 22
22 // A callback that returns true if the condition has been met and takes no 23 // A callback that returns true if the condition has been met and takes no
23 // arguments. 24 // arguments.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 DCHECK(browser_); 74 DCHECK(browser_);
74 ScopedObserver<ExtensionActionAPI, ExtensionActionAPI::Observer> observer( 75 ScopedObserver<ExtensionActionAPI, ExtensionActionAPI::Observer> observer(
75 this); 76 this);
76 observer.Add(ExtensionActionAPI::Get(GetBrowserContext())); 77 observer.Add(ExtensionActionAPI::Get(GetBrowserContext()));
77 WaitForCondition( 78 WaitForCondition(
78 base::Bind(&HasPageActionVisibilityReachedTarget, browser_, count), NULL); 79 base::Bind(&HasPageActionVisibilityReachedTarget, browser_, count), NULL);
79 return true; 80 return true;
80 } 81 }
81 82
82 bool ChromeExtensionTestNotificationObserver::WaitForExtensionViewsToLoad() { 83 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
83 ProcessManager* manager = ProcessManager::Get(GetBrowserContext()); 88 ProcessManager* manager = ProcessManager::Get(GetBrowserContext());
84 NotificationSet notification_set; 89 NotificationSet notification_set;
85 notification_set.Add(content::NOTIFICATION_WEB_CONTENTS_DESTROYED); 90 notification_set.Add(content::NOTIFICATION_WEB_CONTENTS_DESTROYED);
86 notification_set.Add(content::NOTIFICATION_LOAD_STOP); 91 notification_set.Add(content::NOTIFICATION_LOAD_STOP);
87 notification_set.AddExtensionFrameUnregistration(manager); 92 notification_set.AddExtensionFrameUnregistration(manager);
88 WaitForCondition( 93 WaitForCondition(
89 base::Bind(&HaveAllExtensionRenderFrameHostsFinishedLoading, manager), 94 base::Bind(&HaveAllExtensionRenderFrameHostsFinishedLoading, manager),
90 &notification_set); 95 &notification_set);
91 return true; 96 return true;
92 } 97 }
(...skipping 21 matching lines...) Expand all
114 &notification_set); 119 &notification_set);
115 return true; 120 return true;
116 } 121 }
117 122
118 void ChromeExtensionTestNotificationObserver::OnPageActionsUpdated( 123 void ChromeExtensionTestNotificationObserver::OnPageActionsUpdated(
119 content::WebContents* web_contents) { 124 content::WebContents* web_contents) {
120 MaybeQuit(); 125 MaybeQuit();
121 } 126 }
122 127
123 } // namespace extensions 128 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698