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

Unified Diff: content/public/browser/notification_watcher.cc

Issue 12218078: Implement a policy to autologin a public account. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: split an assert Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/public/browser/notification_watcher.cc
diff --git a/content/public/browser/notification_watcher.cc b/content/public/browser/notification_watcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..da3f69302ef7a14145ff05ac08c250b51722727d
--- /dev/null
+++ b/content/public/browser/notification_watcher.cc
@@ -0,0 +1,37 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/public/browser/notification_watcher.h"
+
+#include "content/public/browser/notification_details.h"
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_source.h"
+
+namespace content {
+
+NotificationWatcher::NotificationWatcher(int notification_type,
+ const ConditionTestCallback& callback)
+ : type_(notification_type),
+ callback_(callback) {
+}
+
+void NotificationWatcher::Run() {
+ if (callback_.Run())
+ return;
+
+ content::NotificationRegistrar registrar;
+ registrar.Add(this, type_, content::NotificationService::AllSources());
+ run_loop_.Run();
+}
+
+void NotificationWatcher::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ if (callback_.Run())
+ run_loop_.Quit();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698