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