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

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

Issue 174277: override chrome:// URLs via extensions. (Closed)
Patch Set: fix linux errors Created 11 years, 3 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 MessageLoop::current()->PostDelayedTask(FROM_HERE, 130 MessageLoop::current()->PostDelayedTask(FROM_HERE,
131 new MessageLoop::QuitTask, 200); 131 new MessageLoop::QuitTask, 200);
132 ui_test_utils::RunMessageLoop(); 132 ui_test_utils::RunMessageLoop();
133 } 133 }
134 } 134 }
135 135
136 bool ExtensionBrowserTest::WaitForExtensionHostsToLoad() { 136 bool ExtensionBrowserTest::WaitForExtensionHostsToLoad() {
137 // Wait for all the extension hosts that exist to finish loading. 137 // Wait for all the extension hosts that exist to finish loading.
138 // NOTE: This assumes that the extension host list is not changing while 138 // NOTE: This assumes that the extension host list is not changing while
139 // this method is running. 139 // this method is running.
140
141 NotificationRegistrar registrar;
142 registrar.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING,
143 NotificationService::AllSources());
144
140 ExtensionProcessManager* manager = 145 ExtensionProcessManager* manager =
141 browser()->profile()->GetExtensionProcessManager(); 146 browser()->profile()->GetExtensionProcessManager();
142 base::Time start_time = base::Time::Now(); 147 base::Time start_time = base::Time::Now();
148 MessageLoop::current()->PostDelayedTask(FROM_HERE,
149 new MessageLoop::QuitTask, kTimeoutMs);
143 for (ExtensionProcessManager::const_iterator iter = manager->begin(); 150 for (ExtensionProcessManager::const_iterator iter = manager->begin();
144 iter != manager->end(); ++iter) { 151 iter != manager->end(); ++iter) {
145 while (!(*iter)->did_stop_loading()) { 152 if (!(*iter)->did_stop_loading())
146 if ((base::Time::Now() - start_time).InMilliseconds() > kTimeoutMs) {
147 std::cout << "Extension host did not load for URL: "
148 << (*iter)->GetURL().spec();
149 return false;
150 }
151
152 MessageLoop::current()->PostDelayedTask(FROM_HERE,
153 new MessageLoop::QuitTask, 200);
154 ui_test_utils::RunMessageLoop(); 153 ui_test_utils::RunMessageLoop();
155 }
156 } 154 }
157 155
158 return true; 156 return true;
159 } 157 }
160 158
161 void ExtensionBrowserTest::Observe(NotificationType type, 159 void ExtensionBrowserTest::Observe(NotificationType type,
162 const NotificationSource& source, 160 const NotificationSource& source,
163 const NotificationDetails& details) { 161 const NotificationDetails& details) {
164 switch (type.value) { 162 switch (type.value) {
165 case NotificationType::EXTENSION_LOADED: 163 case NotificationType::EXTENSION_LOADED:
166 std::cout << "Got EXTENSION_LOADED notification.\n"; 164 std::cout << "Got EXTENSION_LOADED notification.\n";
167 MessageLoopForUI::current()->Quit(); 165 MessageLoopForUI::current()->Quit();
168 break; 166 break;
169 167
170 case NotificationType::EXTENSION_UPDATE_DISABLED: 168 case NotificationType::EXTENSION_UPDATE_DISABLED:
171 std::cout << "Got EXTENSION_UPDATE_DISABLED notification.\n"; 169 std::cout << "Got EXTENSION_UPDATE_DISABLED notification.\n";
172 MessageLoopForUI::current()->Quit(); 170 MessageLoopForUI::current()->Quit();
173 break; 171 break;
174 172
173 case NotificationType::EXTENSION_HOST_DID_STOP_LOADING:
174 std::cout << "Got EXTENSION_HOST_DID_STOP_LOADING notification.\n";
175 MessageLoopForUI::current()->Quit();
176 break;
177
175 default: 178 default:
176 NOTREACHED(); 179 NOTREACHED();
177 break; 180 break;
178 } 181 }
179 } 182 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_apitest.cc ('k') | chrome/browser/extensions/extension_dom_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698