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 "content/browser/renderer_host/render_widget_host.h" | 5 #include "content/browser/renderer_host/render_widget_host.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // tell the process host that we're alive. | 89 // tell the process host that we're alive. |
90 process_->WidgetRestored(); | 90 process_->WidgetRestored(); |
91 | 91 |
92 if (CommandLine::ForCurrentProcess()->HasSwitch( | 92 if (CommandLine::ForCurrentProcess()->HasSwitch( |
93 switches::kForceRendererAccessibility)) { | 93 switches::kForceRendererAccessibility)) { |
94 EnableRendererAccessibility(); | 94 EnableRendererAccessibility(); |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 RenderWidgetHost::~RenderWidgetHost() { | 98 RenderWidgetHost::~RenderWidgetHost() { |
| 99 SetView(NULL); |
| 100 |
99 // Clear our current or cached backing store if either remains. | 101 // Clear our current or cached backing store if either remains. |
100 BackingStoreManager::RemoveBackingStore(this); | 102 BackingStoreManager::RemoveBackingStore(this); |
101 | 103 |
102 process_->Release(routing_id_); | 104 process_->Release(routing_id_); |
103 } | 105 } |
104 | 106 |
| 107 void RenderWidgetHost::SetView(RenderWidgetHostView* view) { |
| 108 view_ = view; |
| 109 |
| 110 if (!view_) |
| 111 process_->SetCompositingSurface(routing_id_, gfx::kNullPluginWindow); |
| 112 } |
| 113 |
105 gfx::NativeViewId RenderWidgetHost::GetNativeViewId() { | 114 gfx::NativeViewId RenderWidgetHost::GetNativeViewId() { |
106 if (view_) | 115 if (view_) |
107 return gfx::IdFromNativeView(view_->GetNativeView()); | 116 return gfx::IdFromNativeView(view_->GetNativeView()); |
108 return 0; | 117 return 0; |
109 } | 118 } |
110 | 119 |
111 gfx::PluginWindowHandle RenderWidgetHost::GetCompositingSurface() { | 120 gfx::PluginWindowHandle RenderWidgetHost::GetCompositingSurface() { |
112 if (view_) | 121 if (view_) |
113 return view_->GetCompositingSurface(); | 122 return view_->GetCompositingSurface(); |
114 return gfx::kNullPluginWindow; | 123 return gfx::kNullPluginWindow; |
115 } | 124 } |
116 | 125 |
117 bool RenderWidgetHost::PreHandleKeyboardEvent( | 126 bool RenderWidgetHost::PreHandleKeyboardEvent( |
118 const NativeWebKeyboardEvent& event, | 127 const NativeWebKeyboardEvent& event, |
119 bool* is_keyboard_shortcut) { | 128 bool* is_keyboard_shortcut) { |
120 return false; | 129 return false; |
121 } | 130 } |
122 | 131 |
123 void RenderWidgetHost::Init() { | 132 void RenderWidgetHost::Init() { |
124 DCHECK(process_->HasConnection()); | 133 DCHECK(process_->HasConnection()); |
125 | 134 |
126 renderer_initialized_ = true; | 135 renderer_initialized_ = true; |
127 | 136 |
| 137 process_->SetCompositingSurface(routing_id_, |
| 138 GetCompositingSurface()); |
| 139 |
128 // Send the ack along with the information on placement. | 140 // Send the ack along with the information on placement. |
129 Send(new ViewMsg_CreatingNew_ACK( | 141 Send(new ViewMsg_CreatingNew_ACK(routing_id_, GetNativeViewId())); |
130 routing_id_, GetNativeViewId(), GetCompositingSurface())); | |
131 WasResized(); | 142 WasResized(); |
132 } | 143 } |
133 | 144 |
134 void RenderWidgetHost::Shutdown() { | 145 void RenderWidgetHost::Shutdown() { |
135 if (process_->HasConnection()) { | 146 if (process_->HasConnection()) { |
136 // Tell the renderer object to close. | 147 // Tell the renderer object to close. |
137 process_->ReportExpectingClose(routing_id_); | 148 process_->ReportExpectingClose(routing_id_); |
138 bool rv = Send(new ViewMsg_Close(routing_id_)); | 149 bool rv = Send(new ViewMsg_Close(routing_id_)); |
139 DCHECK(rv); | 150 DCHECK(rv); |
140 } | 151 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 Send(new ViewMsg_SetFocus(routing_id_, false)); | 365 Send(new ViewMsg_SetFocus(routing_id_, false)); |
355 } | 366 } |
356 | 367 |
357 void RenderWidgetHost::LostCapture() { | 368 void RenderWidgetHost::LostCapture() { |
358 Send(new ViewMsg_MouseCaptureLost(routing_id_)); | 369 Send(new ViewMsg_MouseCaptureLost(routing_id_)); |
359 } | 370 } |
360 | 371 |
361 void RenderWidgetHost::ViewDestroyed() { | 372 void RenderWidgetHost::ViewDestroyed() { |
362 // TODO(evanm): tracking this may no longer be necessary; | 373 // TODO(evanm): tracking this may no longer be necessary; |
363 // eliminate this function if so. | 374 // eliminate this function if so. |
364 view_ = NULL; | 375 SetView(NULL); |
365 } | 376 } |
366 | 377 |
367 void RenderWidgetHost::SetIsLoading(bool is_loading) { | 378 void RenderWidgetHost::SetIsLoading(bool is_loading) { |
368 is_loading_ = is_loading; | 379 is_loading_ = is_loading; |
369 if (!view_) | 380 if (!view_) |
370 return; | 381 return; |
371 view_->SetIsLoading(is_loading); | 382 view_->SetIsLoading(is_loading); |
372 } | 383 } |
373 | 384 |
374 void RenderWidgetHost::PaintAtSize(TransportDIB::Handle dib_handle, | 385 void RenderWidgetHost::PaintAtSize(TransportDIB::Handle dib_handle, |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 view_->CreatePluginContainer(deferred_plugin_handles_[i]); | 1205 view_->CreatePluginContainer(deferred_plugin_handles_[i]); |
1195 #endif | 1206 #endif |
1196 } | 1207 } |
1197 | 1208 |
1198 deferred_plugin_handles_.clear(); | 1209 deferred_plugin_handles_.clear(); |
1199 } | 1210 } |
1200 | 1211 |
1201 void RenderWidgetHost::StartUserGesture() { | 1212 void RenderWidgetHost::StartUserGesture() { |
1202 OnUserGesture(); | 1213 OnUserGesture(); |
1203 } | 1214 } |
OLD | NEW |