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

Side by Side Diff: content/public/test/test_utils.cc

Issue 24261010: Allow explicitly whitelisted apps/extensions in public sessions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix handing of guest user ID. Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « content/public/test/test_utils.h ('k') | net/base/url_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/public/test/test_utils.h" 5 #include "content/public/test/test_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 DISALLOW_COPY_AND_ASSIGN(ScriptCallback); 61 DISALLOW_COPY_AND_ASSIGN(ScriptCallback);
62 }; 62 };
63 63
64 void ScriptCallback::ResultCallback(const base::Value* result) { 64 void ScriptCallback::ResultCallback(const base::Value* result) {
65 if (result) 65 if (result)
66 result_.reset(result->DeepCopy()); 66 result_.reset(result->DeepCopy());
67 base::MessageLoop::current()->Quit(); 67 base::MessageLoop::current()->Quit();
68 } 68 }
69 69
70 // Adapter that makes a WindowedNotificationObserver::ConditionTestCallback from
71 // a WindowedNotificationObserver::ConditionTestCallbackWithoutSourceAndDetails
72 // by ignoring the notification source and details.
73 bool IgnoreSourceAndDetails(
74 const WindowedNotificationObserver::
75 ConditionTestCallbackWithoutSourceAndDetails& callback,
76 const NotificationSource& source,
77 const NotificationDetails& details) {
78 return callback.Run();
79 }
80
70 } // namespace 81 } // namespace
71 82
72 void RunMessageLoop() { 83 void RunMessageLoop() {
73 base::RunLoop run_loop; 84 base::RunLoop run_loop;
74 RunThisRunLoop(&run_loop); 85 RunThisRunLoop(&run_loop);
75 } 86 }
76 87
77 void RunThisRunLoop(base::RunLoop* run_loop) { 88 void RunThisRunLoop(base::RunLoop* run_loop) {
78 base::MessageLoop::ScopedNestableTaskAllower allow( 89 base::MessageLoop::ScopedNestableTaskAllower allow(
79 base::MessageLoop::current()); 90 base::MessageLoop::current());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 WindowedNotificationObserver::WindowedNotificationObserver( 190 WindowedNotificationObserver::WindowedNotificationObserver(
180 int notification_type, 191 int notification_type,
181 const ConditionTestCallback& callback) 192 const ConditionTestCallback& callback)
182 : seen_(false), 193 : seen_(false),
183 running_(false), 194 running_(false),
184 callback_(callback), 195 callback_(callback),
185 source_(NotificationService::AllSources()) { 196 source_(NotificationService::AllSources()) {
186 AddNotificationType(notification_type, source_); 197 AddNotificationType(notification_type, source_);
187 } 198 }
188 199
200 WindowedNotificationObserver::WindowedNotificationObserver(
201 int notification_type,
202 const ConditionTestCallbackWithoutSourceAndDetails& callback)
203 : seen_(false),
204 running_(false),
205 callback_(base::Bind(&IgnoreSourceAndDetails, callback)),
206 source_(NotificationService::AllSources()) {
207 registrar_.Add(this, notification_type, source_);
208 }
209
189 WindowedNotificationObserver::~WindowedNotificationObserver() {} 210 WindowedNotificationObserver::~WindowedNotificationObserver() {}
190 211
191 void WindowedNotificationObserver::AddNotificationType( 212 void WindowedNotificationObserver::AddNotificationType(
192 int notification_type, 213 int notification_type,
193 const NotificationSource& source) { 214 const NotificationSource& source) {
194 registrar_.Add(this, notification_type, source); 215 registrar_.Add(this, notification_type, source);
195 } 216 }
196 217
197 void WindowedNotificationObserver::Wait() { 218 void WindowedNotificationObserver::Wait() {
198 if (seen_) 219 if (seen_)
199 return; 220 return;
200 221
201 running_ = true; 222 running_ = true;
202 message_loop_runner_ = new MessageLoopRunner; 223 message_loop_runner_ = new MessageLoopRunner;
203 message_loop_runner_->Run(); 224 message_loop_runner_->Run();
204 EXPECT_TRUE(seen_); 225 EXPECT_TRUE(seen_);
205 } 226 }
206 227
207 void WindowedNotificationObserver::Observe( 228 void WindowedNotificationObserver::Observe(
208 int type, 229 int type,
209 const NotificationSource& source, 230 const NotificationSource& source,
210 const NotificationDetails& details) { 231 const NotificationDetails& details) {
211 source_ = source; 232 source_ = source;
212 details_ = details; 233 details_ = details;
213 if (!callback_.is_null() && !callback_.Run()) 234 if (!callback_.is_null() && !callback_.Run(source, details))
214 return; 235 return;
215 236
216 seen_ = true; 237 seen_ = true;
217 if (!running_) 238 if (!running_)
218 return; 239 return;
219 240
220 message_loop_runner_->Quit(); 241 message_loop_runner_->Quit();
221 running_ = false; 242 running_ = false;
222 } 243 }
223 244
224 } // namespace content 245 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_utils.h ('k') | net/base/url_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698