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/test/content_browser_test_utils.h" | 5 #include "content/test/content_browser_test_utils.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_path.h" | 8 #include "base/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" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 void WaitForAppModalDialog(Shell* window) { | 57 void WaitForAppModalDialog(Shell* window) { |
58 ShellJavaScriptDialogCreator* dialog_creator = | 58 ShellJavaScriptDialogCreator* dialog_creator = |
59 static_cast<ShellJavaScriptDialogCreator*>( | 59 static_cast<ShellJavaScriptDialogCreator*>( |
60 window->GetJavaScriptDialogCreator()); | 60 window->GetJavaScriptDialogCreator()); |
61 | 61 |
62 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner(); | 62 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner(); |
63 dialog_creator->set_dialog_request_callback(runner->QuitClosure()); | 63 dialog_creator->set_dialog_request_callback(runner->QuitClosure()); |
64 runner->Run(); | 64 runner->Run(); |
65 } | 65 } |
66 | 66 |
| 67 ShellAddedObserver::ShellAddedObserver() |
| 68 : shell_(NULL) { |
| 69 Shell::SetShellCreatedCallback( |
| 70 base::Bind(&ShellAddedObserver::ShellCreated, base::Unretained(this))); |
| 71 } |
| 72 |
| 73 ShellAddedObserver::~ShellAddedObserver() { |
| 74 } |
| 75 |
| 76 Shell* ShellAddedObserver::GetShell() { |
| 77 if (shell_) |
| 78 return shell_; |
| 79 |
| 80 runner_ = new MessageLoopRunner(); |
| 81 runner_->Run(); |
| 82 return shell_; |
| 83 } |
| 84 |
| 85 void ShellAddedObserver::ShellCreated(Shell* shell) { |
| 86 DCHECK(!shell_); |
| 87 shell_ = shell; |
| 88 if (runner_) |
| 89 runner_->QuitClosure().Run(); |
| 90 } |
| 91 |
67 } // namespace content | 92 } // namespace content |
OLD | NEW |