| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/test/base/test_html_dialog_observer.h" | 5 #include "chrome/test/base/test_html_dialog_observer.h" |
| 6 | 6 |
| 7 #include "chrome/common/chrome_notification_types.h" | 7 #include "chrome/common/chrome_notification_types.h" |
| 8 #include "content/test/js_injection_ready_observer.h" | 8 #include "content/test/js_injection_ready_observer.h" |
| 9 #include "chrome/test/base/ui_test_utils.h" | 9 #include "chrome/test/base/ui_test_utils.h" |
| 10 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 void TestHtmlDialogObserver::Observe( | 31 void TestHtmlDialogObserver::Observe( |
| 32 int type, | 32 int type, |
| 33 const content::NotificationSource& source, | 33 const content::NotificationSource& source, |
| 34 const content::NotificationDetails& details) { | 34 const content::NotificationDetails& details) { |
| 35 switch (type) { | 35 switch (type) { |
| 36 case chrome::NOTIFICATION_HTML_DIALOG_SHOWN: | 36 case chrome::NOTIFICATION_HTML_DIALOG_SHOWN: |
| 37 if (js_injection_ready_observer_) { | 37 if (js_injection_ready_observer_) { |
| 38 js_injection_ready_observer_->OnJsInjectionReady( | 38 js_injection_ready_observer_->OnJsInjectionReady( |
| 39 content::Details<RenderViewHost>(details).ptr()); | 39 content::Details<content::RenderViewHost>(details).ptr()); |
| 40 } | 40 } |
| 41 web_ui_ = content::Source<content::WebUI>(source).ptr(); | 41 web_ui_ = content::Source<content::WebUI>(source).ptr(); |
| 42 registrar_.Remove(this, chrome::NOTIFICATION_HTML_DIALOG_SHOWN, | 42 registrar_.Remove(this, chrome::NOTIFICATION_HTML_DIALOG_SHOWN, |
| 43 content::NotificationService::AllSources()); | 43 content::NotificationService::AllSources()); |
| 44 // Wait for navigation on the new WebUI instance to complete. This depends | 44 // Wait for navigation on the new WebUI instance to complete. This depends |
| 45 // on receiving the notification of the HtmlDialog being shown before the | 45 // on receiving the notification of the HtmlDialog being shown before the |
| 46 // NavigationController finishes loading. The HtmlDialog notification is | 46 // NavigationController finishes loading. The HtmlDialog notification is |
| 47 // issued from html_dialog_ui.cc on RenderView creation which results from | 47 // issued from html_dialog_ui.cc on RenderView creation which results from |
| 48 // the call to render_manager_.Navigate in the method | 48 // the call to render_manager_.Navigate in the method |
| 49 // TabContents::NavigateToEntry. The new RenderView is later told to | 49 // TabContents::NavigateToEntry. The new RenderView is later told to |
| (...skipping 20 matching lines...) Expand all Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 content::WebUI* TestHtmlDialogObserver::GetWebUI() { | 72 content::WebUI* TestHtmlDialogObserver::GetWebUI() { |
| 73 if (!done_) { | 73 if (!done_) { |
| 74 EXPECT_FALSE(running_); | 74 EXPECT_FALSE(running_); |
| 75 running_ = true; | 75 running_ = true; |
| 76 ui_test_utils::RunMessageLoop(); | 76 ui_test_utils::RunMessageLoop(); |
| 77 } | 77 } |
| 78 return web_ui_; | 78 return web_ui_; |
| 79 } | 79 } |
| OLD | NEW |