forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
content_browser_sanity_checker.cc
40 lines (31 loc) · 1.25 KB
/
content_browser_sanity_checker.cc
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
// 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 "content/test/content_browser_sanity_checker.h"
#include "base/bind.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/test/web_contents_observer_sanity_checker.h"
namespace content {
namespace {
bool g_sanity_checks_already_enabled = false;
}
ContentBrowserSanityChecker::ContentBrowserSanityChecker() {
CHECK(!g_sanity_checks_already_enabled)
<< "Tried to enable ContentBrowserSanityChecker, but it's already been "
<< "enabled.";
g_sanity_checks_already_enabled = true;
creation_hook_ =
base::Bind(&ContentBrowserSanityChecker::OnWebContentsCreated,
base::Unretained(this));
WebContentsImpl::FriendWrapper::AddCreatedCallbackForTesting(creation_hook_);
}
ContentBrowserSanityChecker::~ContentBrowserSanityChecker() {
WebContentsImpl::FriendWrapper::RemoveCreatedCallbackForTesting(
creation_hook_);
g_sanity_checks_already_enabled = false;
}
void ContentBrowserSanityChecker::OnWebContentsCreated(
WebContents* web_contents) {
WebContentsObserverSanityChecker::Enable(web_contents);
}
} // namespace content