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

Unified Diff: chrome/test/base/extension_load_waiter.h

Issue 320753002: Support javascript gtests in an extension background page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixup comment Created 6 years, 6 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: chrome/test/base/extension_load_waiter.h
diff --git a/chrome/test/base/extension_load_waiter.h b/chrome/test/base/extension_load_waiter.h
new file mode 100644
index 0000000000000000000000000000000000000000..c9dfe2e6fae4eec891663670ff212cabfd4bb2a5
--- /dev/null
+++ b/chrome/test/base/extension_load_waiter.h
@@ -0,0 +1,47 @@
+// Copyright 2014 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.
+
+#ifndef CHROME_TEST_BASE_EXTENSION_LOAD_WAITER_H_
+#define CHROME_TEST_BASE_EXTENSION_LOAD_WAITER_H_
+
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/test/test_utils.h"
+
+namespace content {
+class BrowserContext;
+} // namespace content
+
+// A class used to load and wait for the ChromeVox component extension.
dmazzoni 2014/06/10 16:06:16 Update this comment, this waits for any extension
Peter Lundblad 2014/06/11 16:45:06 Remove chromevox here.
Peter Lundblad 2014/06/11 16:45:06 Remove chromevox here.
Peter Lundblad 2014/06/11 16:45:07 Remove chromevox here.
David Tseng 2014/06/11 17:52:55 Already done.
+class ExtensionLoadWaiter : public content::NotificationObserver {
+ public:
+ ExtensionLoadWaiter();
+ virtual ~ExtensionLoadWaiter();
+
+ // Waits for extension with |extension_id| to load.
Peter Lundblad 2014/06/11 16:45:06 ^ nit: Do you need a particle here?
Peter Lundblad 2014/06/11 16:45:07 ^ nit: Do you need a particle here?
Peter Lundblad 2014/06/11 16:45:07 ^ nit: Do you need a particle here?
David Tseng 2014/06/11 17:52:55 Particle? Don't follow....it looks fine I think.
+ void WaitFor(const char* extension_id);
Peter Lundblad 2014/06/11 16:45:06 Note in the docs that the extension id should be a
Peter Lundblad 2014/06/11 16:45:06 Note in the docs that the extension id should be a
Peter Lundblad 2014/06/11 16:45:06 Note in the docs that the extension id should be a
David Tseng 2014/06/11 17:52:54 You mean a pointer to a static char array? Ok sure
+
+ // content::NotificationObserver overrides.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ // Get the browser context associated with the loaded extension.
Peter Lundblad 2014/06/11 16:45:06 Note that this can only be called after waiting fo
Peter Lundblad 2014/06/11 16:45:06 Note that this can only be called after waiting fo
Peter Lundblad 2014/06/11 16:45:07 Note that this can only be called after waiting fo
David Tseng 2014/06/11 17:52:54 You actually can call it; it will just be NULL. Cl
+ content::BrowserContext* browser_context() { return browser_context_; }
+
+ // Get the id of the loaded extension.
Peter Lundblad 2014/06/11 16:45:06 Either make this class a one-shot only or change d
Peter Lundblad 2014/06/11 16:45:06 Either make this class a one-shot only or change d
Peter Lundblad 2014/06/11 16:45:07 Either make this class a one-shot only or change d
David Tseng 2014/06/11 17:52:54 Made one shot.
+ const char* extension_id() { return extension_id_; }
+
+ private:
+ void Reset();
+
+ content::NotificationRegistrar registrar_;
+ scoped_refptr<content::MessageLoopRunner> load_looper_;
+ const char* extension_id_;
+ content::BrowserContext* browser_context_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionLoadWaiter);
+};
+
+#endif // CHROME_TEST_BASE_EXTENSION_LOAD_WAITER_H_

Powered by Google App Engine
This is Rietveld 408576698