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/browser/chromeos/tab_first_render_watcher.h" | 5 #include "chrome/browser/chromeos/tab_first_render_watcher.h" |
6 | 6 |
7 #include "content/browser/renderer_host/render_widget_host.h" | 7 #include "content/browser/renderer_host/render_widget_host.h" |
| 8 #include "content/browser/renderer_host/render_view_host.h" |
8 #include "content/common/content_notification_types.h" | 9 #include "content/common/content_notification_types.h" |
9 #include "content/common/notification_details.h" | 10 #include "content/common/notification_details.h" |
10 #include "content/common/notification_source.h" | 11 #include "content/common/notification_source.h" |
11 | 12 |
12 namespace chromeos { | 13 namespace chromeos { |
13 | 14 |
14 TabFirstRenderWatcher::TabFirstRenderWatcher(TabContents* tab, | 15 TabFirstRenderWatcher::TabFirstRenderWatcher(TabContents* tab, |
15 Delegate* delegate) | 16 Delegate* delegate) |
16 : state_(NONE), | 17 : state_(NONE), |
17 tab_contents_(tab), | 18 tab_contents_(tab), |
18 delegate_(delegate) { | 19 delegate_(delegate) { |
19 registrar_.Add(this, | 20 registrar_.Add(this, |
20 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, | 21 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, |
21 Source<TabContents>(tab_contents_)); | 22 Source<TabContents>(tab_contents_)); |
22 registrar_.Add(this, | 23 registrar_.Add(this, |
23 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 24 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
24 Source<TabContents>(tab_contents_)); | 25 Source<TabContents>(tab_contents_)); |
25 } | 26 } |
26 | 27 |
27 void TabFirstRenderWatcher::Observe(int type, | 28 void TabFirstRenderWatcher::Observe(int type, |
28 const NotificationSource& source, const NotificationDetails& details) { | 29 const NotificationSource& source, const NotificationDetails& details) { |
29 switch (type) { | 30 switch (type) { |
30 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { | 31 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { |
31 RenderWidgetHost* rwh = Details<RenderWidgetHost>(details).ptr(); | 32 RenderWidgetHost* rwh = Details<RenderWidgetHost>(details).ptr(); |
32 registrar_.Add(this, | 33 registrar_.Add(this, |
33 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, | 34 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, |
34 Source<RenderWidgetHost>(rwh)); | 35 Source<RenderWidgetHost>(rwh)); |
| 36 delegate_->OnRenderHostCreated(Details<RenderViewHost>(details).ptr()); |
35 break; | 37 break; |
36 } | 38 } |
37 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: | 39 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: |
38 if (state_ == NONE) { | 40 if (state_ == NONE) { |
39 state_ = LOADED; | 41 state_ = LOADED; |
40 delegate_->OnTabMainFrameLoaded(); | 42 delegate_->OnTabMainFrameLoaded(); |
41 } | 43 } |
42 break; | 44 break; |
43 case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT: | 45 case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT: |
44 if (state_ == LOADED) { | 46 if (state_ == LOADED) { |
45 state_ = FIRST_PAINT; | 47 state_ = FIRST_PAINT; |
46 delegate_->OnTabMainFrameFirstRender(); | 48 delegate_->OnTabMainFrameFirstRender(); |
47 } | 49 } |
48 break; | 50 break; |
49 default: | 51 default: |
50 NOTREACHED() << "unknown type" << type; | 52 NOTREACHED() << "unknown type" << type; |
51 } | 53 } |
52 } | 54 } |
53 | 55 |
54 } // namespace chromeos | 56 } // namespace chromeos |
OLD | NEW |