forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_background_page_first_load_observer.h
58 lines (45 loc) · 1.97 KB
/
test_background_page_first_load_observer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2019 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 EXTENSIONS_TEST_TEST_BACKGROUND_PAGE_FIRST_LOAD_OBSERVER_H_
#define EXTENSIONS_TEST_TEST_BACKGROUND_PAGE_FIRST_LOAD_OBSERVER_H_
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/scoped_observer.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_host_observer.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_manager_observer.h"
#include "extensions/common/extension_id.h"
namespace content {
class BrowserContext;
}
namespace extensions {
// Allows to wait until the WebContents of an extension's ExtensionHost sees its
// first DidStopLoading().
class TestBackgroundPageFirstLoadObserver : public ProcessManagerObserver,
public ExtensionHostObserver {
public:
TestBackgroundPageFirstLoadObserver(content::BrowserContext* browser_context,
const ExtensionId& extension_id);
~TestBackgroundPageFirstLoadObserver() override;
void Wait();
private:
// ProcessManagerObserver:
void OnBackgroundHostCreated(ExtensionHost* host) override;
// ExtensionHostObserver:
void OnExtensionHostDestroyed(ExtensionHost* host) override;
void OnExtensionHostDidStopFirstLoad(const ExtensionHost* host) override;
void OnObtainedExtensionHost();
const ExtensionId extension_id_;
ProcessManager* const process_manager_ = nullptr;
ExtensionHost* extension_host_ = nullptr;
base::RunLoop run_loop_;
ScopedObserver<ProcessManager, ProcessManagerObserver>
process_manager_observer_{this};
ScopedObserver<ExtensionHost, ExtensionHostObserver> extension_host_observer_{
this};
DISALLOW_COPY_AND_ASSIGN(TestBackgroundPageFirstLoadObserver);
};
} // namespace extensions
#endif // EXTENSIONS_TEST_TEST_BACKGROUND_PAGE_FIRST_LOAD_OBSERVER_H_