blob: 802deec1357193212610329ba168a64eea2ec138 [file] [log] [blame]
// 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.
#include "base/callback_forward.h"
#include "base/macros.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 wait for an extension to load. Callers provide a load
// callback and can block until the extension loads.
class ExtensionLoadWaiterOneShot : public content::NotificationObserver {
~ExtensionLoadWaiterOneShot() override;
// Waits for extension with |extension_id| to load. The id should be a pointer
// to a static char array.
void WaitForExtension(const char* extension_id, const base::Closure& load_cb);
// content::NotificationObserver overrides.
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
// Get the browser context associated with the loaded extension. Returns
// NULL if |WaitForExtension| was not previously called.
content::BrowserContext* browser_context() { return browser_context_; }
// Get the id of the loaded extension.
const char* extension_id() { return extension_id_; }
content::NotificationRegistrar registrar_;
scoped_refptr<content::MessageLoopRunner> load_looper_;
const char* extension_id_;
content::BrowserContext* browser_context_;