OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/public/test/test_navigation_observer.h" | 5 #include "content/public/test/test_navigation_observer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 STLDeleteContainerPointers(web_contents_observers_.begin(), | 86 STLDeleteContainerPointers(web_contents_observers_.begin(), |
87 web_contents_observers_.end()); | 87 web_contents_observers_.end()); |
88 } | 88 } |
89 | 89 |
90 void TestNavigationObserver::Wait() { | 90 void TestNavigationObserver::Wait() { |
91 message_loop_runner_->Run(); | 91 message_loop_runner_->Run(); |
92 } | 92 } |
93 | 93 |
94 void TestNavigationObserver::StartWatchingNewWebContents() { | 94 void TestNavigationObserver::StartWatchingNewWebContents() { |
95 WebContentsImpl::AddCreatedCallback(web_contents_created_callback_); | 95 WebContentsImpl::FriendZone::AddCreatedCallbackForTesting( |
| 96 web_contents_created_callback_); |
96 } | 97 } |
97 | 98 |
98 void TestNavigationObserver::StopWatchingNewWebContents() { | 99 void TestNavigationObserver::StopWatchingNewWebContents() { |
99 WebContentsImpl::RemoveCreatedCallback(web_contents_created_callback_); | 100 WebContentsImpl::FriendZone::RemoveCreatedCallbackForTesting( |
| 101 web_contents_created_callback_); |
100 } | 102 } |
101 | 103 |
102 void TestNavigationObserver::RegisterAsObserver(WebContents* web_contents) { | 104 void TestNavigationObserver::RegisterAsObserver(WebContents* web_contents) { |
103 web_contents_observers_.insert( | 105 web_contents_observers_.insert( |
104 new TestWebContentsObserver(this, web_contents)); | 106 new TestWebContentsObserver(this, web_contents)); |
105 } | 107 } |
106 | 108 |
107 void TestNavigationObserver::OnWebContentsCreated(WebContents* web_contents) { | 109 void TestNavigationObserver::OnWebContentsCreated(WebContents* web_contents) { |
108 RegisterAsObserver(web_contents); | 110 RegisterAsObserver(web_contents); |
109 } | 111 } |
(...skipping 28 matching lines...) Expand all Loading... |
138 return; | 140 return; |
139 | 141 |
140 ++navigations_completed_; | 142 ++navigations_completed_; |
141 if (navigations_completed_ == number_of_navigations_) { | 143 if (navigations_completed_ == number_of_navigations_) { |
142 navigation_started_ = false; | 144 navigation_started_ = false; |
143 message_loop_runner_->Quit(); | 145 message_loop_runner_->Quit(); |
144 } | 146 } |
145 } | 147 } |
146 | 148 |
147 } // namespace content | 149 } // namespace content |
OLD | NEW |