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/content_browser_test_utils.h" | 5 #include "content/public/test/content_browser_test_utils.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/strings/pattern.h" | |
12 #include "base/strings/utf_string_conversions.h" | |
13 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
14 #include "content/public/browser/navigation_controller.h" | 12 #include "content/public/browser/navigation_controller.h" |
15 #include "content/public/browser/notification_source.h" | 13 #include "content/public/browser/notification_source.h" |
16 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
17 #include "content/public/common/content_paths.h" | 15 #include "content/public/common/content_paths.h" |
18 #include "content/public/test/browser_test_utils.h" | 16 #include "content/public/test/browser_test_utils.h" |
19 #include "content/public/test/test_navigation_observer.h" | 17 #include "content/public/test/test_navigation_observer.h" |
20 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
21 #include "content/shell/browser/shell.h" | 19 #include "content/shell/browser/shell.h" |
22 #include "content/shell/browser/shell_javascript_dialog_manager.h" | 20 #include "content/shell/browser/shell_javascript_dialog_manager.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 return shell_; | 127 return shell_; |
130 } | 128 } |
131 | 129 |
132 void ShellAddedObserver::ShellCreated(Shell* shell) { | 130 void ShellAddedObserver::ShellCreated(Shell* shell) { |
133 DCHECK(!shell_); | 131 DCHECK(!shell_); |
134 shell_ = shell; | 132 shell_ = shell; |
135 if (runner_.get()) | 133 if (runner_.get()) |
136 runner_->QuitClosure().Run(); | 134 runner_->QuitClosure().Run(); |
137 } | 135 } |
138 | 136 |
139 ConsoleObserverDelegate::ConsoleObserverDelegate(WebContents* web_contents, | |
140 const std::string& filter) | |
141 : web_contents_(web_contents), | |
142 filter_(filter), | |
143 message_loop_runner_(new MessageLoopRunner) {} | |
144 | |
145 ConsoleObserverDelegate::~ConsoleObserverDelegate() {} | |
146 | |
147 void ConsoleObserverDelegate::Wait() { | |
148 message_loop_runner_->Run(); | |
149 } | |
150 | |
151 bool ConsoleObserverDelegate::AddMessageToConsole( | |
152 WebContents* source, | |
153 int32_t level, | |
154 const base::string16& message, | |
155 int32_t line_no, | |
156 const base::string16& source_id) { | |
157 DCHECK(source == web_contents_); | |
158 | |
159 std::string ascii_message = base::UTF16ToASCII(message); | |
160 if (base::MatchPattern(ascii_message, filter_)) { | |
161 message_ = ascii_message; | |
162 message_loop_runner_->Quit(); | |
163 } | |
164 return false; | |
165 } | |
166 | |
167 } // namespace content | 137 } // namespace content |
OLD | NEW |