| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/test/content_browser_sanity_checker.h" | 5 #include "content/test/content_browser_sanity_checker.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
| 9 #include "content/test/web_contents_observer_sanity_checker.h" | 9 #include "content/test/web_contents_observer_sanity_checker.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 bool g_sanity_checks_already_enabled = false; | 14 bool g_sanity_checks_already_enabled = false; |
| 15 } | 15 } |
| 16 | 16 |
| 17 ContentBrowserSanityChecker::ContentBrowserSanityChecker() { | 17 ContentBrowserSanityChecker::ContentBrowserSanityChecker() { |
| 18 CHECK(!g_sanity_checks_already_enabled) | 18 // Tried to enable ContentBrowserSanityChecker, but it's already been enabled. |
| 19 << "Tried to enable ContentBrowserSanityChecker, but it's already been " | 19 CHECK(!g_sanity_checks_already_enabled); |
| 20 << "enabled."; | |
| 21 g_sanity_checks_already_enabled = true; | 20 g_sanity_checks_already_enabled = true; |
| 22 | 21 |
| 23 creation_hook_ = | 22 creation_hook_ = |
| 24 base::Bind(&ContentBrowserSanityChecker::OnWebContentsCreated, | 23 base::Bind(&ContentBrowserSanityChecker::OnWebContentsCreated, |
| 25 base::Unretained(this)); | 24 base::Unretained(this)); |
| 26 WebContentsImpl::FriendZone::AddCreatedCallbackForTesting(creation_hook_); | 25 WebContentsImpl::FriendZone::AddCreatedCallbackForTesting(creation_hook_); |
| 27 } | 26 } |
| 28 | 27 |
| 29 ContentBrowserSanityChecker::~ContentBrowserSanityChecker() { | 28 ContentBrowserSanityChecker::~ContentBrowserSanityChecker() { |
| 30 WebContentsImpl::FriendZone::RemoveCreatedCallbackForTesting(creation_hook_); | 29 WebContentsImpl::FriendZone::RemoveCreatedCallbackForTesting(creation_hook_); |
| 31 g_sanity_checks_already_enabled = false; | 30 g_sanity_checks_already_enabled = false; |
| 32 } | 31 } |
| 33 | 32 |
| 34 void ContentBrowserSanityChecker::OnWebContentsCreated( | 33 void ContentBrowserSanityChecker::OnWebContentsCreated( |
| 35 WebContents* web_contents) { | 34 WebContents* web_contents) { |
| 36 WebContentsObserverSanityChecker::Enable(web_contents); | 35 WebContentsObserverSanityChecker::Enable(web_contents); |
| 37 } | 36 } |
| 38 | 37 |
| 39 } // namespace content | 38 } // namespace content |
| OLD | NEW |