Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: content/browser/renderer_host/render_view_host.cc

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/renderer_host/render_view_host.h" 5 #include "content/browser/renderer_host/render_view_host.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 RenderViewHost* RenderViewHost::FromID(int render_process_id, 108 RenderViewHost* RenderViewHost::FromID(int render_process_id,
109 int render_view_id) { 109 int render_view_id) {
110 content::RenderProcessHost* process = 110 content::RenderProcessHost* process =
111 content::RenderProcessHost::FromID(render_process_id); 111 content::RenderProcessHost::FromID(render_process_id);
112 if (!process) 112 if (!process)
113 return NULL; 113 return NULL;
114 RenderWidgetHost* widget = RenderWidgetHost::FromIPCChannelListener( 114 RenderWidgetHost* widget = RenderWidgetHost::FromIPCChannelListener(
115 process->GetListenerByID(render_view_id)); 115 process->GetListenerByID(render_view_id));
116 if (!widget || !widget->IsRenderView()) 116 if (!widget || !widget->IsRenderView())
117 return NULL; 117 return NULL;
118 return static_cast<RenderViewHost*>(widget); 118 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(widget));
119 } 119 }
120 120
121 RenderViewHost::RenderViewHost(SiteInstance* instance, 121 ///////////////////////////////////////////////////////////////////////////////
122 RenderViewHostDelegate* delegate, 122 // RenderViewHostImpl, public:
123 int routing_id, 123
124 SessionStorageNamespace* session_storage) 124 // static
125 RenderViewHostImpl* RenderViewHostImpl::FromID(int render_process_id,
126 int render_view_id) {
127 return static_cast<RenderViewHostImpl*>(
128 RenderViewHost::FromID(render_process_id, render_view_id));
129 }
130
131 RenderViewHostImpl::RenderViewHostImpl(SiteInstance* instance,
132 RenderViewHostDelegate* delegate,
133 int routing_id,
134 SessionStorageNamespace* session_storage)
125 : RenderWidgetHostImpl(instance->GetProcess(), routing_id), 135 : RenderWidgetHostImpl(instance->GetProcess(), routing_id),
136 delegate_(delegate),
126 instance_(static_cast<SiteInstanceImpl*>(instance)), 137 instance_(static_cast<SiteInstanceImpl*>(instance)),
127 delegate_(delegate),
128 waiting_for_drag_context_response_(false), 138 waiting_for_drag_context_response_(false),
129 enabled_bindings_(0), 139 enabled_bindings_(0),
130 pending_request_id_(-1), 140 pending_request_id_(-1),
131 navigations_suspended_(false), 141 navigations_suspended_(false),
132 suspended_nav_message_(NULL), 142 suspended_nav_message_(NULL),
133 is_swapped_out_(false), 143 is_swapped_out_(false),
134 run_modal_reply_msg_(NULL), 144 run_modal_reply_msg_(NULL),
135 is_waiting_for_beforeunload_ack_(false), 145 is_waiting_for_beforeunload_ack_(false),
136 is_waiting_for_unload_ack_(false), 146 is_waiting_for_unload_ack_(false),
137 unload_ack_is_for_cross_site_transition_(false), 147 unload_ack_is_for_cross_site_transition_(false),
138 are_javascript_messages_suppressed_(false), 148 are_javascript_messages_suppressed_(false),
139 sudden_termination_allowed_(false), 149 sudden_termination_allowed_(false),
140 session_storage_namespace_( 150 session_storage_namespace_(
141 static_cast<SessionStorageNamespaceImpl*>(session_storage)), 151 static_cast<SessionStorageNamespaceImpl*>(session_storage)),
142 save_accessibility_tree_for_testing_(false), 152 save_accessibility_tree_for_testing_(false),
143 send_accessibility_updated_notifications_(false), 153 send_accessibility_updated_notifications_(false),
144 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING) { 154 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING) {
145 if (!session_storage_namespace_) { 155 if (!session_storage_namespace_) {
146 DOMStorageContext* dom_storage_context = 156 DOMStorageContext* dom_storage_context =
147 BrowserContext::GetDOMStorageContext(process()->GetBrowserContext()); 157 BrowserContext::GetDOMStorageContext(GetProcess()->GetBrowserContext());
148 session_storage_namespace_ = new SessionStorageNamespaceImpl( 158 session_storage_namespace_ = new SessionStorageNamespaceImpl(
149 static_cast<DOMStorageContextImpl*>(dom_storage_context)); 159 static_cast<DOMStorageContextImpl*>(dom_storage_context));
150 } 160 }
151 161
152 DCHECK(instance_); 162 DCHECK(instance_);
153 CHECK(delegate_); // http://crbug.com/82827 163 CHECK(delegate_); // http://crbug.com/82827
154 164
155 process()->EnableSendQueue(); 165 GetProcess()->EnableSendQueue();
156 166
157 content::GetContentClient()->browser()->RenderViewHostCreated(this); 167 content::GetContentClient()->browser()->RenderViewHostCreated(this);
158 168
159 content::NotificationService::current()->Notify( 169 content::NotificationService::current()->Notify(
160 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, 170 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED,
161 content::Source<RenderViewHost>(this), 171 content::Source<RenderViewHost>(this),
162 content::NotificationService::NoDetails()); 172 content::NotificationService::NoDetails());
163 } 173 }
164 174
165 RenderViewHost::~RenderViewHost() { 175 RenderViewHostImpl::~RenderViewHostImpl() {
166 FOR_EACH_OBSERVER( 176 FOR_EACH_OBSERVER(
167 content::RenderViewHostObserver, observers_, RenderViewHostDestruction()); 177 content::RenderViewHostObserver, observers_, RenderViewHostDestruction());
168 178
169 content::NotificationService::current()->Notify( 179 content::NotificationService::current()->Notify(
170 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, 180 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED,
171 content::Source<RenderViewHost>(this), 181 content::Source<RenderViewHost>(this),
172 content::NotificationService::NoDetails()); 182 content::NotificationService::NoDetails());
173 183
174 ClearPowerSaveBlockers(); 184 ClearPowerSaveBlockers();
175 185
176 delegate()->RenderViewDeleted(this); 186 GetDelegate()->RenderViewDeleted(this);
177 187
178 // Be sure to clean up any leftover state from cross-site requests. 188 // Be sure to clean up any leftover state from cross-site requests.
179 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( 189 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest(
180 process()->GetID(), routing_id(), false); 190 GetProcess()->GetID(), GetRoutingID(), false);
181 } 191 }
182 192
183 bool RenderViewHost::CreateRenderView(const string16& frame_name, 193 content::RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const {
184 int32 max_page_id) { 194 return delegate_;
195 }
196
197 content::SiteInstance* RenderViewHostImpl::GetSiteInstance() const {
198 return instance_;
199 }
200
201 bool RenderViewHostImpl::CreateRenderView(const string16& frame_name,
202 int32 max_page_id) {
185 DCHECK(!IsRenderViewLive()) << "Creating view twice"; 203 DCHECK(!IsRenderViewLive()) << "Creating view twice";
186 204
187 // The process may (if we're sharing a process with another host that already 205 // The process may (if we're sharing a process with another host that already
188 // initialized it) or may not (we have our own process or the old process 206 // initialized it) or may not (we have our own process or the old process
189 // crashed) have been initialized. Calling Init multiple times will be 207 // crashed) have been initialized. Calling Init multiple times will be
190 // ignored, so this is safe. 208 // ignored, so this is safe.
191 if (!process()->Init(renderer_accessible())) 209 if (!GetProcess()->Init(renderer_accessible()))
192 return false; 210 return false;
193 DCHECK(process()->HasConnection()); 211 DCHECK(GetProcess()->HasConnection());
194 DCHECK(process()->GetBrowserContext()); 212 DCHECK(GetProcess()->GetBrowserContext());
195 213
196 renderer_initialized_ = true; 214 renderer_initialized_ = true;
197 215
198 GpuSurfaceTracker::Get()->SetSurfaceHandle( 216 GpuSurfaceTracker::Get()->SetSurfaceHandle(
199 surface_id(), GetCompositingSurface()); 217 surface_id(), GetCompositingSurface());
200 218
201 // Ensure the RenderView starts with a next_page_id larger than any existing 219 // Ensure the RenderView starts with a next_page_id larger than any existing
202 // page ID it might be asked to render. 220 // page ID it might be asked to render.
203 int32 next_page_id = 1; 221 int32 next_page_id = 1;
204 if (max_page_id > -1) 222 if (max_page_id > -1)
205 next_page_id = max_page_id + 1; 223 next_page_id = max_page_id + 1;
206 224
207 ViewMsg_New_Params params; 225 ViewMsg_New_Params params;
208 params.parent_window = GetNativeViewId(); 226 params.parent_window = GetNativeViewId();
209 params.renderer_preferences = 227 params.renderer_preferences =
210 delegate_->GetRendererPrefs(process()->GetBrowserContext()); 228 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext());
211 params.web_preferences = delegate_->GetWebkitPrefs(); 229 params.web_preferences = delegate_->GetWebkitPrefs();
212 params.view_id = routing_id(); 230 params.view_id = GetRoutingID();
213 params.surface_id = surface_id(); 231 params.surface_id = surface_id();
214 params.session_storage_namespace_id = session_storage_namespace_->id(); 232 params.session_storage_namespace_id = session_storage_namespace_->id();
215 params.frame_name = frame_name; 233 params.frame_name = frame_name;
216 params.next_page_id = next_page_id; 234 params.next_page_id = next_page_id;
217 #if defined(OS_POSIX) || defined(USE_AURA) 235 #if defined(OS_POSIX) || defined(USE_AURA)
218 if (view()) { 236 if (GetView()) {
219 static_cast<content::RenderWidgetHostViewPort*>( 237 static_cast<content::RenderWidgetHostViewPort*>(
220 view())->GetScreenInfo(&params.screen_info); 238 GetView())->GetScreenInfo(&params.screen_info);
221 } else { 239 } else {
222 content::RenderWidgetHostViewPort::GetDefaultScreenInfo( 240 content::RenderWidgetHostViewPort::GetDefaultScreenInfo(
223 &params.screen_info); 241 &params.screen_info);
224 } 242 }
225 #else 243 #else
226 params.screen_info = 244 params.screen_info =
227 WebKit::WebScreenInfoFactory::screenInfo( 245 WebKit::WebScreenInfoFactory::screenInfo(
228 gfx::NativeViewFromId(GetNativeViewId())); 246 gfx::NativeViewFromId(GetNativeViewId()));
229 #endif 247 #endif
230 248
231 Send(new ViewMsg_New(params)); 249 Send(new ViewMsg_New(params));
232 250
233 // If it's enabled, tell the renderer to set up the Javascript bindings for 251 // If it's enabled, tell the renderer to set up the Javascript bindings for
234 // sending messages back to the browser. 252 // sending messages back to the browser.
235 Send(new ViewMsg_AllowBindings(routing_id(), enabled_bindings_)); 253 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_));
236 // Let our delegate know that we created a RenderView. 254 // Let our delegate know that we created a RenderView.
237 delegate_->RenderViewCreated(this); 255 delegate_->RenderViewCreated(this);
238 256
239 // Invert the color scheme if a flag was set. 257 // Invert the color scheme if a flag was set.
240 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInvertWebContent)) 258 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInvertWebContent))
241 Send(new ViewMsg_InvertWebContent(routing_id(), true)); 259 Send(new ViewMsg_InvertWebContent(GetRoutingID(), true));
242 260
243 FOR_EACH_OBSERVER( 261 FOR_EACH_OBSERVER(
244 content::RenderViewHostObserver, observers_, RenderViewHostInitialized()); 262 content::RenderViewHostObserver, observers_, RenderViewHostInitialized());
245 263
246 return true; 264 return true;
247 } 265 }
248 266
249 bool RenderViewHost::IsRenderViewLive() const { 267 bool RenderViewHostImpl::IsRenderViewLive() const {
250 return process()->HasConnection() && renderer_initialized_; 268 return GetProcess()->HasConnection() && renderer_initialized_;
251 } 269 }
252 270
253 void RenderViewHost::SyncRendererPrefs() { 271 void RenderViewHostImpl::SyncRendererPrefs() {
254 Send(new ViewMsg_SetRendererPrefs(routing_id(), 272 Send(new ViewMsg_SetRendererPrefs(GetRoutingID(),
255 delegate_->GetRendererPrefs( 273 delegate_->GetRendererPrefs(
256 process()->GetBrowserContext()))); 274 GetProcess()->GetBrowserContext())));
257 } 275 }
258 276
259 void RenderViewHost::Navigate(const ViewMsg_Navigate_Params& params) { 277 void RenderViewHostImpl::Navigate(const ViewMsg_Navigate_Params& params) {
260 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( 278 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL(
261 process()->GetID(), params.url); 279 GetProcess()->GetID(), params.url);
262 280
263 ViewMsg_Navigate* nav_message = new ViewMsg_Navigate(routing_id(), params); 281 ViewMsg_Navigate* nav_message = new ViewMsg_Navigate(GetRoutingID(), params);
264 282
265 // Only send the message if we aren't suspended at the start of a cross-site 283 // Only send the message if we aren't suspended at the start of a cross-site
266 // request. 284 // request.
267 if (navigations_suspended_) { 285 if (navigations_suspended_) {
268 // Shouldn't be possible to have a second navigation while suspended, since 286 // Shouldn't be possible to have a second navigation while suspended, since
269 // navigations will only be suspended during a cross-site request. If a 287 // navigations will only be suspended during a cross-site request. If a
270 // second navigation occurs, TabContents will cancel this pending RVH 288 // second navigation occurs, TabContents will cancel this pending RVH
271 // create a new pending RVH. 289 // create a new pending RVH.
272 DCHECK(!suspended_nav_message_.get()); 290 DCHECK(!suspended_nav_message_.get());
273 suspended_nav_message_.reset(nav_message); 291 suspended_nav_message_.reset(nav_message);
(...skipping 16 matching lines...) Expand all
290 // 308 //
291 // WebKit doesn't send throb notifications for JavaScript URLs, so we 309 // WebKit doesn't send throb notifications for JavaScript URLs, so we
292 // don't want to either. 310 // don't want to either.
293 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) 311 if (!params.url.SchemeIs(chrome::kJavaScriptScheme))
294 delegate_->DidStartLoading(); 312 delegate_->DidStartLoading();
295 313
296 FOR_EACH_OBSERVER(content::RenderViewHostObserver, 314 FOR_EACH_OBSERVER(content::RenderViewHostObserver,
297 observers_, Navigate(params.url)); 315 observers_, Navigate(params.url));
298 } 316 }
299 317
300 void RenderViewHost::NavigateToURL(const GURL& url) { 318 void RenderViewHostImpl::NavigateToURL(const GURL& url) {
301 ViewMsg_Navigate_Params params; 319 ViewMsg_Navigate_Params params;
302 params.page_id = -1; 320 params.page_id = -1;
303 params.pending_history_list_offset = -1; 321 params.pending_history_list_offset = -1;
304 params.current_history_list_offset = -1; 322 params.current_history_list_offset = -1;
305 params.current_history_list_length = 0; 323 params.current_history_list_length = 0;
306 params.url = url; 324 params.url = url;
307 params.transition = content::PAGE_TRANSITION_LINK; 325 params.transition = content::PAGE_TRANSITION_LINK;
308 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 326 params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
309 Navigate(params); 327 Navigate(params);
310 } 328 }
311 329
312 void RenderViewHost::SetNavigationsSuspended(bool suspend) { 330 void RenderViewHostImpl::SetNavigationsSuspended(bool suspend) {
313 // This should only be called to toggle the state. 331 // This should only be called to toggle the state.
314 DCHECK(navigations_suspended_ != suspend); 332 DCHECK(navigations_suspended_ != suspend);
315 333
316 navigations_suspended_ = suspend; 334 navigations_suspended_ = suspend;
317 if (!suspend && suspended_nav_message_.get()) { 335 if (!suspend && suspended_nav_message_.get()) {
318 // There's a navigation message waiting to be sent. Now that we're not 336 // There's a navigation message waiting to be sent. Now that we're not
319 // suspended anymore, resume navigation by sending it. If we were swapped 337 // suspended anymore, resume navigation by sending it. If we were swapped
320 // out, we should also stop filtering out the IPC messages now. 338 // out, we should also stop filtering out the IPC messages now.
321 SetSwappedOut(false); 339 SetSwappedOut(false);
322 340
323 Send(suspended_nav_message_.release()); 341 Send(suspended_nav_message_.release());
324 } 342 }
325 } 343 }
326 344
327 void RenderViewHost::CancelSuspendedNavigations() { 345 void RenderViewHostImpl::CancelSuspendedNavigations() {
328 // Clear any state if a pending navigation is canceled or pre-empted. 346 // Clear any state if a pending navigation is canceled or pre-empted.
329 if (suspended_nav_message_.get()) 347 if (suspended_nav_message_.get())
330 suspended_nav_message_.reset(); 348 suspended_nav_message_.reset();
331 navigations_suspended_ = false; 349 navigations_suspended_ = false;
332 } 350 }
333 351
334 void RenderViewHost::FirePageBeforeUnload(bool for_cross_site_transition) { 352 void RenderViewHostImpl::FirePageBeforeUnload(bool for_cross_site_transition) {
335 if (!IsRenderViewLive()) { 353 if (!IsRenderViewLive()) {
336 // This RenderViewHost doesn't have a live renderer, so just skip running 354 // This RenderViewHostImpl doesn't have a live renderer, so just
337 // the onbeforeunload handler. 355 // skip running the onbeforeunload handler.
338 is_waiting_for_beforeunload_ack_ = true; // Checked by OnMsgShouldCloseACK. 356 is_waiting_for_beforeunload_ack_ = true; // Checked by OnMsgShouldCloseACK.
339 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; 357 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition;
340 OnMsgShouldCloseACK(true); 358 OnMsgShouldCloseACK(true);
341 return; 359 return;
342 } 360 }
343 361
344 // This may be called more than once (if the user clicks the tab close button 362 // This may be called more than once (if the user clicks the tab close button
345 // several times, or if she clicks the tab close button then the browser close 363 // several times, or if she clicks the tab close button then the browser close
346 // button), and we only send the message once. 364 // button), and we only send the message once.
347 if (is_waiting_for_beforeunload_ack_) { 365 if (is_waiting_for_beforeunload_ack_) {
348 // Some of our close messages could be for the tab, others for cross-site 366 // Some of our close messages could be for the tab, others for cross-site
349 // transitions. We always want to think it's for closing the tab if any 367 // transitions. We always want to think it's for closing the tab if any
350 // of the messages were, since otherwise it might be impossible to close 368 // of the messages were, since otherwise it might be impossible to close
351 // (if there was a cross-site "close" request pending when the user clicked 369 // (if there was a cross-site "close" request pending when the user clicked
352 // the close button). We want to keep the "for cross site" flag only if 370 // the close button). We want to keep the "for cross site" flag only if
353 // both the old and the new ones are also for cross site. 371 // both the old and the new ones are also for cross site.
354 unload_ack_is_for_cross_site_transition_ = 372 unload_ack_is_for_cross_site_transition_ =
355 unload_ack_is_for_cross_site_transition_ && for_cross_site_transition; 373 unload_ack_is_for_cross_site_transition_ && for_cross_site_transition;
356 } else { 374 } else {
357 // Start the hang monitor in case the renderer hangs in the beforeunload 375 // Start the hang monitor in case the renderer hangs in the beforeunload
358 // handler. 376 // handler.
359 is_waiting_for_beforeunload_ack_ = true; 377 is_waiting_for_beforeunload_ack_ = true;
360 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; 378 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition;
361 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 379 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
362 Send(new ViewMsg_ShouldClose(routing_id())); 380 Send(new ViewMsg_ShouldClose(GetRoutingID()));
363 } 381 }
364 } 382 }
365 383
366 void RenderViewHost::SwapOut(int new_render_process_host_id, 384 void RenderViewHostImpl::SwapOut(int new_render_process_host_id,
367 int new_request_id) { 385 int new_request_id) {
368 // This will be set back to false in OnSwapOutACK, just before we replace 386 // This will be set back to false in OnSwapOutACK, just before we replace
369 // this RVH with the pending RVH. 387 // this RVH with the pending RVH.
370 is_waiting_for_unload_ack_ = true; 388 is_waiting_for_unload_ack_ = true;
371 // Start the hang monitor in case the renderer hangs in the unload handler. 389 // Start the hang monitor in case the renderer hangs in the unload handler.
372 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 390 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
373 391
374 ViewMsg_SwapOut_Params params; 392 ViewMsg_SwapOut_Params params;
375 params.closing_process_id = process()->GetID(); 393 params.closing_process_id = GetProcess()->GetID();
376 params.closing_route_id = routing_id(); 394 params.closing_route_id = GetRoutingID();
377 params.new_render_process_host_id = new_render_process_host_id; 395 params.new_render_process_host_id = new_render_process_host_id;
378 params.new_request_id = new_request_id; 396 params.new_request_id = new_request_id;
379 if (IsRenderViewLive()) { 397 if (IsRenderViewLive()) {
380 Send(new ViewMsg_SwapOut(routing_id(), params)); 398 Send(new ViewMsg_SwapOut(GetRoutingID(), params));
381 } else { 399 } else {
382 // This RenderViewHost doesn't have a live renderer, so just skip the unload 400 // This RenderViewHost doesn't have a live renderer, so just skip the unload
383 // event. We must notify the ResourceDispatcherHost on the IO thread, 401 // event. We must notify the ResourceDispatcherHost on the IO thread,
384 // which we will do through the RenderProcessHost's widget helper. 402 // which we will do through the RenderProcessHost's widget helper.
385 process()->CrossSiteSwapOutACK(params); 403 GetProcess()->CrossSiteSwapOutACK(params);
386 } 404 }
387 } 405 }
388 406
389 void RenderViewHost::OnSwapOutACK() { 407 void RenderViewHostImpl::OnSwapOutACK() {
390 // Stop the hang monitor now that the unload handler has finished. 408 // Stop the hang monitor now that the unload handler has finished.
391 StopHangMonitorTimeout(); 409 StopHangMonitorTimeout();
392 is_waiting_for_unload_ack_ = false; 410 is_waiting_for_unload_ack_ = false;
393 delegate_->SwappedOut(this); 411 delegate_->SwappedOut(this);
394 } 412 }
395 413
396 void RenderViewHost::WasSwappedOut() { 414 void RenderViewHostImpl::WasSwappedOut() {
397 // Don't bother reporting hung state anymore. 415 // Don't bother reporting hung state anymore.
398 StopHangMonitorTimeout(); 416 StopHangMonitorTimeout();
399 417
400 // Now that we're no longer the active RVH in the tab, start filtering out 418 // Now that we're no longer the active RVH in the tab, start filtering out
401 // most IPC messages. Usually the renderer will have stopped sending 419 // most IPC messages. Usually the renderer will have stopped sending
402 // messages as of OnSwapOutACK. However, we may have timed out waiting 420 // messages as of OnSwapOutACK. However, we may have timed out waiting
403 // for that message, and additional IPC messages may keep streaming in. 421 // for that message, and additional IPC messages may keep streaming in.
404 // We filter them out, as long as that won't cause problems (e.g., we 422 // We filter them out, as long as that won't cause problems (e.g., we
405 // still allow synchronous messages through). 423 // still allow synchronous messages through).
406 SetSwappedOut(true); 424 SetSwappedOut(true);
407 425
408 // Inform the renderer that it can exit if no one else is using it. 426 // Inform the renderer that it can exit if no one else is using it.
409 Send(new ViewMsg_WasSwappedOut(routing_id())); 427 Send(new ViewMsg_WasSwappedOut(GetRoutingID()));
410 } 428 }
411 429
412 void RenderViewHost::ClosePage() { 430 void RenderViewHostImpl::ClosePage() {
413 // Start the hang monitor in case the renderer hangs in the unload handler. 431 // Start the hang monitor in case the renderer hangs in the unload handler.
414 is_waiting_for_unload_ack_ = true; 432 is_waiting_for_unload_ack_ = true;
415 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 433 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
416 434
417 if (IsRenderViewLive()) { 435 if (IsRenderViewLive()) {
418 // TODO(creis): Should this be moved to Shutdown? It may not be called for 436 // TODO(creis): Should this be moved to Shutdown? It may not be called for
419 // RenderViewHosts that have been swapped out. 437 // RenderViewHosts that have been swapped out.
420 content::NotificationService::current()->Notify( 438 content::NotificationService::current()->Notify(
421 content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, 439 content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW,
422 content::Source<RenderViewHost>(this), 440 content::Source<RenderViewHost>(this),
423 content::NotificationService::NoDetails()); 441 content::NotificationService::NoDetails());
424 442
425 Send(new ViewMsg_ClosePage(routing_id())); 443 Send(new ViewMsg_ClosePage(GetRoutingID()));
426 } else { 444 } else {
427 // This RenderViewHost doesn't have a live renderer, so just skip the unload 445 // This RenderViewHost doesn't have a live renderer, so just skip the unload
428 // event and close the page. 446 // event and close the page.
429 ClosePageIgnoringUnloadEvents(); 447 ClosePageIgnoringUnloadEvents();
430 } 448 }
431 } 449 }
432 450
433 void RenderViewHost::ClosePageIgnoringUnloadEvents() { 451 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() {
434 StopHangMonitorTimeout(); 452 StopHangMonitorTimeout();
435 is_waiting_for_beforeunload_ack_ = false; 453 is_waiting_for_beforeunload_ack_ = false;
436 is_waiting_for_unload_ack_ = false; 454 is_waiting_for_unload_ack_ = false;
437 455
438 sudden_termination_allowed_ = true; 456 sudden_termination_allowed_ = true;
439 delegate_->Close(this); 457 delegate_->Close(this);
440 } 458 }
441 459
442 void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request, 460 void RenderViewHostImpl::SetHasPendingCrossSiteRequest(bool has_pending_request,
443 int request_id) { 461 int request_id) {
444 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( 462 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest(
445 process()->GetID(), routing_id(), has_pending_request); 463 GetProcess()->GetID(), GetRoutingID(), has_pending_request);
446 pending_request_id_ = request_id; 464 pending_request_id_ = request_id;
447 } 465 }
448 466
449 int RenderViewHost::GetPendingRequestId() { 467 int RenderViewHostImpl::GetPendingRequestId() {
450 return pending_request_id_; 468 return pending_request_id_;
451 } 469 }
452 470
453 void RenderViewHost::DragTargetDragEnter( 471 void RenderViewHostImpl::DragTargetDragEnter(
454 const WebDropData& drop_data, 472 const WebDropData& drop_data,
455 const gfx::Point& client_pt, 473 const gfx::Point& client_pt,
456 const gfx::Point& screen_pt, 474 const gfx::Point& screen_pt,
457 WebDragOperationsMask operations_allowed) { 475 WebDragOperationsMask operations_allowed) {
458 const int renderer_id = process()->GetID(); 476 const int renderer_id = GetProcess()->GetID();
459 ChildProcessSecurityPolicyImpl* policy = 477 ChildProcessSecurityPolicyImpl* policy =
460 ChildProcessSecurityPolicyImpl::GetInstance(); 478 ChildProcessSecurityPolicyImpl::GetInstance();
461 479
462 // The URL could have been cobbled together from any highlighted text string, 480 // The URL could have been cobbled together from any highlighted text string,
463 // and can't be interpreted as a capability. 481 // and can't be interpreted as a capability.
464 WebDropData filtered_data(drop_data); 482 WebDropData filtered_data(drop_data);
465 FilterURL(policy, renderer_id, &filtered_data.url); 483 FilterURL(policy, renderer_id, &filtered_data.url);
466 484
467 // The filenames vector, on the other hand, does represent a capability to 485 // The filenames vector, on the other hand, does represent a capability to
468 // access the given files. 486 // access the given files.
(...skipping 12 matching lines...) Expand all
481 } 499 }
482 500
483 fileapi::IsolatedContext* isolated_context = 501 fileapi::IsolatedContext* isolated_context =
484 fileapi::IsolatedContext::GetInstance(); 502 fileapi::IsolatedContext::GetInstance();
485 DCHECK(isolated_context); 503 DCHECK(isolated_context);
486 std::string filesystem_id = isolated_context->RegisterIsolatedFileSystem( 504 std::string filesystem_id = isolated_context->RegisterIsolatedFileSystem(
487 filesets); 505 filesets);
488 policy->GrantAccessFileSystem(renderer_id, filesystem_id); 506 policy->GrantAccessFileSystem(renderer_id, filesystem_id);
489 filtered_data.filesystem_id = UTF8ToUTF16(filesystem_id); 507 filtered_data.filesystem_id = UTF8ToUTF16(filesystem_id);
490 508
491 Send(new DragMsg_TargetDragEnter(routing_id(), filtered_data, client_pt, 509 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt,
492 screen_pt, operations_allowed)); 510 screen_pt, operations_allowed));
493 } 511 }
494 512
495 void RenderViewHost::DragTargetDragOver( 513 void RenderViewHostImpl::DragTargetDragOver(
496 const gfx::Point& client_pt, const gfx::Point& screen_pt, 514 const gfx::Point& client_pt, const gfx::Point& screen_pt,
497 WebDragOperationsMask operations_allowed) { 515 WebDragOperationsMask operations_allowed) {
498 Send(new DragMsg_TargetDragOver(routing_id(), client_pt, screen_pt, 516 Send(new DragMsg_TargetDragOver(GetRoutingID(), client_pt, screen_pt,
499 operations_allowed)); 517 operations_allowed));
500 } 518 }
501 519
502 void RenderViewHost::DragTargetDragLeave() { 520 void RenderViewHostImpl::DragTargetDragLeave() {
503 Send(new DragMsg_TargetDragLeave(routing_id())); 521 Send(new DragMsg_TargetDragLeave(GetRoutingID()));
504 } 522 }
505 523
506 void RenderViewHost::DragTargetDrop( 524 void RenderViewHostImpl::DragTargetDrop(
507 const gfx::Point& client_pt, const gfx::Point& screen_pt) { 525 const gfx::Point& client_pt, const gfx::Point& screen_pt) {
508 Send(new DragMsg_TargetDrop(routing_id(), client_pt, screen_pt)); 526 Send(new DragMsg_TargetDrop(GetRoutingID(), client_pt, screen_pt));
509 } 527 }
510 528
511 void RenderViewHost::DesktopNotificationPermissionRequestDone( 529 void RenderViewHostImpl::DesktopNotificationPermissionRequestDone(
512 int callback_context) { 530 int callback_context) {
513 Send(new DesktopNotificationMsg_PermissionRequestDone( 531 Send(new DesktopNotificationMsg_PermissionRequestDone(
514 routing_id(), callback_context)); 532 GetRoutingID(), callback_context));
515 } 533 }
516 534
517 void RenderViewHost::DesktopNotificationPostDisplay(int callback_context) { 535 void RenderViewHostImpl::DesktopNotificationPostDisplay(int callback_context) {
518 Send(new DesktopNotificationMsg_PostDisplay(routing_id(), callback_context)); 536 Send(new DesktopNotificationMsg_PostDisplay(GetRoutingID(),
537 callback_context));
519 } 538 }
520 539
521 void RenderViewHost::DesktopNotificationPostError(int notification_id, 540 void RenderViewHostImpl::DesktopNotificationPostError(int notification_id,
522 const string16& message) { 541 const string16& message) {
523 Send(new DesktopNotificationMsg_PostError( 542 Send(new DesktopNotificationMsg_PostError(
524 routing_id(), notification_id, message)); 543 GetRoutingID(), notification_id, message));
525 } 544 }
526 545
527 void RenderViewHost::DesktopNotificationPostClose(int notification_id, 546 void RenderViewHostImpl::DesktopNotificationPostClose(int notification_id,
528 bool by_user) { 547 bool by_user) {
529 Send(new DesktopNotificationMsg_PostClose( 548 Send(new DesktopNotificationMsg_PostClose(
530 routing_id(), notification_id, by_user)); 549 GetRoutingID(), notification_id, by_user));
531 } 550 }
532 551
533 void RenderViewHost::DesktopNotificationPostClick(int notification_id) { 552 void RenderViewHostImpl::DesktopNotificationPostClick(int notification_id) {
534 Send(new DesktopNotificationMsg_PostClick(routing_id(), notification_id)); 553 Send(new DesktopNotificationMsg_PostClick(GetRoutingID(), notification_id));
535 } 554 }
536 555
537 void RenderViewHost::ExecuteJavascriptInWebFrame( 556 void RenderViewHostImpl::ExecuteJavascriptInWebFrame(
538 const string16& frame_xpath, 557 const string16& frame_xpath,
539 const string16& jscript) { 558 const string16& jscript) {
540 Send(new ViewMsg_ScriptEvalRequest(routing_id(), frame_xpath, jscript, 559 Send(new ViewMsg_ScriptEvalRequest(GetRoutingID(), frame_xpath, jscript,
541 0, false)); 560 0, false));
542 } 561 }
543 562
544 int RenderViewHost::ExecuteJavascriptInWebFrameNotifyResult( 563 int RenderViewHostImpl::ExecuteJavascriptInWebFrameNotifyResult(
545 const string16& frame_xpath, 564 const string16& frame_xpath,
546 const string16& jscript) { 565 const string16& jscript) {
547 static int next_id = 1; 566 static int next_id = 1;
548 Send(new ViewMsg_ScriptEvalRequest(routing_id(), frame_xpath, jscript, 567 Send(new ViewMsg_ScriptEvalRequest(GetRoutingID(), frame_xpath, jscript,
549 next_id, true)); 568 next_id, true));
550 return next_id++; 569 return next_id++;
551 } 570 }
552 571
553 typedef std::pair<int, Value*> ExecuteDetailType; 572 typedef std::pair<int, Value*> ExecuteDetailType;
554 573
555 ExecuteNotificationObserver::ExecuteNotificationObserver(int id) 574 ExecuteNotificationObserver::ExecuteNotificationObserver(int id)
556 : id_(id) { 575 : id_(id) {
557 } 576 }
558 577
559 ExecuteNotificationObserver::~ExecuteNotificationObserver() { 578 ExecuteNotificationObserver::~ExecuteNotificationObserver() {
560 } 579 }
561 580
562 void ExecuteNotificationObserver::Observe(int type, 581 void ExecuteNotificationObserver::Observe(int type,
563 const content::NotificationSource& source, 582 const content::NotificationSource& source,
564 const content::NotificationDetails& details) { 583 const content::NotificationDetails& details) {
565 content::Details<ExecuteDetailType> execute_details = 584 content::Details<ExecuteDetailType> execute_details =
566 static_cast<content::Details<ExecuteDetailType> >(details); 585 static_cast<content::Details<ExecuteDetailType> >(details);
567 int id = execute_details->first; 586 int id = execute_details->first;
568 if (id != id_) 587 if (id != id_)
569 return; 588 return;
570 Value* value = execute_details->second; 589 Value* value = execute_details->second;
571 if (value) 590 if (value)
572 value_.reset(value->DeepCopy()); 591 value_.reset(value->DeepCopy());
573 MessageLoop::current()->Quit(); 592 MessageLoop::current()->Quit();
574 } 593 }
575 594
576 Value* RenderViewHost::ExecuteJavascriptAndGetValue(const string16& frame_xpath, 595 Value* RenderViewHostImpl::ExecuteJavascriptAndGetValue(
577 const string16& jscript) { 596 const string16& frame_xpath,
597 const string16& jscript) {
578 int id = ExecuteJavascriptInWebFrameNotifyResult(frame_xpath, jscript); 598 int id = ExecuteJavascriptInWebFrameNotifyResult(frame_xpath, jscript);
579 ExecuteNotificationObserver observer(id); 599 ExecuteNotificationObserver observer(id);
580 content::NotificationRegistrar notification_registrar; 600 content::NotificationRegistrar notification_registrar;
581 notification_registrar.Add( 601 notification_registrar.Add(
582 &observer, content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, 602 &observer, content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
583 content::Source<RenderViewHost>(this)); 603 content::Source<RenderViewHost>(this));
584 MessageLoop* loop = MessageLoop::current(); 604 MessageLoop* loop = MessageLoop::current();
585 loop->Run(); 605 loop->Run();
586 return observer.value()->DeepCopy(); 606 return observer.value()->DeepCopy();
587 } 607 }
588 608
589 void RenderViewHost::JavaScriptDialogClosed(IPC::Message* reply_msg, 609 void RenderViewHostImpl::JavaScriptDialogClosed(IPC::Message* reply_msg,
590 bool success, 610 bool success,
591 const string16& user_input) { 611 const string16& user_input) {
592 process()->SetIgnoreInputEvents(false); 612 GetProcess()->SetIgnoreInputEvents(false);
593 bool is_waiting = 613 bool is_waiting =
594 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; 614 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_;
595 if (is_waiting) 615 if (is_waiting)
596 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 616 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
597 617
598 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, 618 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg,
599 success, user_input); 619 success, user_input);
600 Send(reply_msg); 620 Send(reply_msg);
601 621
602 // If we are waiting for an unload or beforeunload ack and the user has 622 // If we are waiting for an unload or beforeunload ack and the user has
603 // suppressed messages, kill the tab immediately; a page that's spamming 623 // suppressed messages, kill the tab immediately; a page that's spamming
604 // alerts in onbeforeunload is presumably malicious, so there's no point in 624 // alerts in onbeforeunload is presumably malicious, so there's no point in
605 // continuing to run its script and dragging out the process. 625 // continuing to run its script and dragging out the process.
606 // This must be done after sending the reply since RenderView can't close 626 // This must be done after sending the reply since RenderView can't close
607 // correctly while waiting for a response. 627 // correctly while waiting for a response.
608 if (is_waiting && are_javascript_messages_suppressed_) 628 if (is_waiting && are_javascript_messages_suppressed_)
609 delegate_->RendererUnresponsive(this, is_waiting); 629 delegate_->RendererUnresponsive(this, is_waiting);
610 } 630 }
611 631
612 void RenderViewHost::DragSourceEndedAt( 632 void RenderViewHostImpl::DragSourceEndedAt(
613 int client_x, int client_y, int screen_x, int screen_y, 633 int client_x, int client_y, int screen_x, int screen_y,
614 WebDragOperation operation) { 634 WebDragOperation operation) {
615 Send(new DragMsg_SourceEndedOrMoved( 635 Send(new DragMsg_SourceEndedOrMoved(
616 routing_id(), 636 GetRoutingID(),
617 gfx::Point(client_x, client_y), 637 gfx::Point(client_x, client_y),
618 gfx::Point(screen_x, screen_y), 638 gfx::Point(screen_x, screen_y),
619 true, operation)); 639 true, operation));
620 } 640 }
621 641
622 void RenderViewHost::DragSourceMovedTo( 642 void RenderViewHostImpl::DragSourceMovedTo(
623 int client_x, int client_y, int screen_x, int screen_y) { 643 int client_x, int client_y, int screen_x, int screen_y) {
624 Send(new DragMsg_SourceEndedOrMoved( 644 Send(new DragMsg_SourceEndedOrMoved(
625 routing_id(), 645 GetRoutingID(),
626 gfx::Point(client_x, client_y), 646 gfx::Point(client_x, client_y),
627 gfx::Point(screen_x, screen_y), 647 gfx::Point(screen_x, screen_y),
628 false, WebDragOperationNone)); 648 false, WebDragOperationNone));
629 } 649 }
630 650
631 void RenderViewHost::DragSourceSystemDragEnded() { 651 void RenderViewHostImpl::DragSourceSystemDragEnded() {
632 Send(new DragMsg_SourceSystemDragEnded(routing_id())); 652 Send(new DragMsg_SourceSystemDragEnded(GetRoutingID()));
633 } 653 }
634 654
635 void RenderViewHost::AllowBindings(int bindings_flags) { 655 void RenderViewHostImpl::AllowBindings(int bindings_flags) {
636 if (bindings_flags & content::BINDINGS_POLICY_WEB_UI) { 656 if (bindings_flags & content::BINDINGS_POLICY_WEB_UI) {
637 ChildProcessSecurityPolicyImpl::GetInstance()->GrantWebUIBindings( 657 ChildProcessSecurityPolicyImpl::GetInstance()->GrantWebUIBindings(
638 process()->GetID()); 658 GetProcess()->GetID());
639 } 659 }
640 660
641 enabled_bindings_ |= bindings_flags; 661 enabled_bindings_ |= bindings_flags;
642 if (renderer_initialized_) 662 if (renderer_initialized_)
643 Send(new ViewMsg_AllowBindings(routing_id(), enabled_bindings_)); 663 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_));
644 } 664 }
645 665
646 void RenderViewHost::SetWebUIProperty(const std::string& name, 666 int RenderViewHostImpl::GetEnabledBindings() const {
647 const std::string& value) { 667 return enabled_bindings_;
648 DCHECK(enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI);
649 Send(new ViewMsg_SetWebUIProperty(routing_id(), name, value));
650 } 668 }
651 669
652 void RenderViewHost::GotFocus() { 670 void RenderViewHostImpl::SetWebUIProperty(const std::string& name,
671 const std::string& value) {
672 DCHECK(enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI);
673 Send(new ViewMsg_SetWebUIProperty(GetRoutingID(), name, value));
674 }
675
676 void RenderViewHostImpl::GotFocus() {
653 RenderWidgetHostImpl::GotFocus(); // Notifies the renderer it got focus. 677 RenderWidgetHostImpl::GotFocus(); // Notifies the renderer it got focus.
654 678
655 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 679 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
656 if (view) 680 if (view)
657 view->GotFocus(); 681 view->GotFocus();
658 } 682 }
659 683
660 void RenderViewHost::LostCapture() { 684 void RenderViewHostImpl::LostCapture() {
661 RenderWidgetHostImpl::LostCapture(); 685 RenderWidgetHostImpl::LostCapture();
662 delegate_->LostCapture(); 686 delegate_->LostCapture();
663 } 687 }
664 688
665 void RenderViewHost::LostMouseLock() { 689 void RenderViewHostImpl::LostMouseLock() {
666 RenderWidgetHostImpl::LostMouseLock(); 690 RenderWidgetHostImpl::LostMouseLock();
667 delegate_->LostMouseLock(); 691 delegate_->LostMouseLock();
668 } 692 }
669 693
670 void RenderViewHost::SetInitialFocus(bool reverse) { 694 void RenderViewHostImpl::SetInitialFocus(bool reverse) {
671 Send(new ViewMsg_SetInitialFocus(routing_id(), reverse)); 695 Send(new ViewMsg_SetInitialFocus(GetRoutingID(), reverse));
672 } 696 }
673 697
674 void RenderViewHost::FilesSelectedInChooser( 698 void RenderViewHostImpl::FilesSelectedInChooser(
675 const std::vector<FilePath>& files, 699 const std::vector<FilePath>& files,
676 int permissions) { 700 int permissions) {
677 // Grant the security access requested to the given files. 701 // Grant the security access requested to the given files.
678 for (std::vector<FilePath>::const_iterator file = files.begin(); 702 for (std::vector<FilePath>::const_iterator file = files.begin();
679 file != files.end(); ++file) { 703 file != files.end(); ++file) {
680 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( 704 ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile(
681 process()->GetID(), *file, permissions); 705 GetProcess()->GetID(), *file, permissions);
682 } 706 }
683 Send(new ViewMsg_RunFileChooserResponse(routing_id(), files)); 707 Send(new ViewMsg_RunFileChooserResponse(GetRoutingID(), files));
684 } 708 }
685 709
686 void RenderViewHost::DirectoryEnumerationFinished( 710 void RenderViewHostImpl::DirectoryEnumerationFinished(
687 int request_id, 711 int request_id,
688 const std::vector<FilePath>& files) { 712 const std::vector<FilePath>& files) {
689 // Grant the security access requested to the given files. 713 // Grant the security access requested to the given files.
690 for (std::vector<FilePath>::const_iterator file = files.begin(); 714 for (std::vector<FilePath>::const_iterator file = files.begin();
691 file != files.end(); ++file) { 715 file != files.end(); ++file) {
692 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( 716 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
693 process()->GetID(), *file); 717 GetProcess()->GetID(), *file);
694 } 718 }
695 Send(new ViewMsg_EnumerateDirectoryResponse(routing_id(), 719 Send(new ViewMsg_EnumerateDirectoryResponse(GetRoutingID(),
696 request_id, 720 request_id,
697 files)); 721 files));
698 } 722 }
699 723
700 void RenderViewHost::LoadStateChanged(const GURL& url, 724 void RenderViewHostImpl::LoadStateChanged(
701 const net::LoadStateWithParam& load_state, 725 const GURL& url,
702 uint64 upload_position, 726 const net::LoadStateWithParam& load_state,
703 uint64 upload_size) { 727 uint64 upload_position,
728 uint64 upload_size) {
704 delegate_->LoadStateChanged(url, load_state, upload_position, upload_size); 729 delegate_->LoadStateChanged(url, load_state, upload_position, upload_size);
705 } 730 }
706 731
707 bool RenderViewHost::SuddenTerminationAllowed() const { 732 bool RenderViewHostImpl::SuddenTerminationAllowed() const {
708 return sudden_termination_allowed_ || process()->SuddenTerminationAllowed(); 733 return sudden_termination_allowed_ ||
734 GetProcess()->SuddenTerminationAllowed();
709 } 735 }
710 736
711 /////////////////////////////////////////////////////////////////////////////// 737 ///////////////////////////////////////////////////////////////////////////////
712 // RenderViewHost, IPC message handlers: 738 // RenderViewHostImpl, IPC message handlers:
713 739
714 bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { 740 bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) {
715 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) 741 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this))
716 return true; 742 return true;
717 743
718 // Filter out most IPC messages if this renderer is swapped out. 744 // Filter out most IPC messages if this renderer is swapped out.
719 // We still want to handle certain ACKs to keep our state consistent. 745 // We still want to handle certain ACKs to keep our state consistent.
720 if (is_swapped_out_) { 746 if (is_swapped_out_) {
721 if (!content::SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { 747 if (!content::SwappedOutMessages::CanHandleWhileSwappedOut(msg)) {
722 // If this is a synchronous message and we decided not to handle it, 748 // If this is a synchronous message and we decided not to handle it,
723 // we must send an error reply, or else the renderer will be stuck 749 // we must send an error reply, or else the renderer will be stuck
724 // and won't respond to future requests. 750 // and won't respond to future requests.
(...skipping 12 matching lines...) Expand all
737 while ((observer = it.GetNext()) != NULL) { 763 while ((observer = it.GetNext()) != NULL) {
738 if (observer->OnMessageReceived(msg)) 764 if (observer->OnMessageReceived(msg))
739 return true; 765 return true;
740 } 766 }
741 767
742 if (delegate_->OnMessageReceived(msg)) 768 if (delegate_->OnMessageReceived(msg))
743 return true; 769 return true;
744 770
745 bool handled = true; 771 bool handled = true;
746 bool msg_is_ok = true; 772 bool msg_is_ok = true;
747 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewHost, msg, msg_is_ok) 773 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewHostImpl, msg, msg_is_ok)
748 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnMsgShowView) 774 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnMsgShowView)
749 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnMsgShowWidget) 775 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnMsgShowWidget)
750 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowFullscreenWidget, 776 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowFullscreenWidget,
751 OnMsgShowFullscreenWidget) 777 OnMsgShowFullscreenWidget)
752 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunModal, OnMsgRunModal) 778 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunModal, OnMsgRunModal)
753 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady) 779 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady)
754 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone) 780 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone)
755 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_FrameNavigate, OnMsgNavigate(msg)) 781 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_FrameNavigate, OnMsgNavigate(msg))
756 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateState, OnMsgUpdateState) 782 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateState, OnMsgUpdateState)
757 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTitle, OnMsgUpdateTitle) 783 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTitle, OnMsgUpdateTitle)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 OnAccessibilityNotifications) 842 OnAccessibilityNotifications)
817 // Have the super handle all other messages. 843 // Have the super handle all other messages.
818 IPC_MESSAGE_UNHANDLED( 844 IPC_MESSAGE_UNHANDLED(
819 handled = RenderWidgetHostImpl::OnMessageReceived(msg)) 845 handled = RenderWidgetHostImpl::OnMessageReceived(msg))
820 IPC_END_MESSAGE_MAP_EX() 846 IPC_END_MESSAGE_MAP_EX()
821 847
822 if (!msg_is_ok) { 848 if (!msg_is_ok) {
823 // The message had a handler, but its de-serialization failed. 849 // The message had a handler, but its de-serialization failed.
824 // Kill the renderer. 850 // Kill the renderer.
825 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); 851 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVH"));
826 process()->ReceivedBadMessage(); 852 GetProcess()->ReceivedBadMessage();
827 } 853 }
828 854
829 return handled; 855 return handled;
830 } 856 }
831 857
832 void RenderViewHost::Shutdown() { 858 void RenderViewHostImpl::Shutdown() {
833 // If we are being run modally (see RunModal), then we need to cleanup. 859 // If we are being run modally (see RunModal), then we need to cleanup.
834 if (run_modal_reply_msg_) { 860 if (run_modal_reply_msg_) {
835 Send(run_modal_reply_msg_); 861 Send(run_modal_reply_msg_);
836 run_modal_reply_msg_ = NULL; 862 run_modal_reply_msg_ = NULL;
837 } 863 }
838 864
839 RenderWidgetHostImpl::Shutdown(); 865 RenderWidgetHostImpl::Shutdown();
840 } 866 }
841 867
842 bool RenderViewHost::IsRenderView() const { 868 bool RenderViewHostImpl::IsRenderView() const {
843 return true; 869 return true;
844 } 870 }
845 871
846 void RenderViewHost::CreateNewWindow( 872 void RenderViewHostImpl::CreateNewWindow(
847 int route_id, 873 int route_id,
848 const ViewHostMsg_CreateWindow_Params& params) { 874 const ViewHostMsg_CreateWindow_Params& params) {
849 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 875 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
850 if (!view) 876 if (!view)
851 return; 877 return;
852 878
853 view->CreateNewWindow(route_id, params); 879 view->CreateNewWindow(route_id, params);
854 } 880 }
855 881
856 void RenderViewHost::CreateNewWidget(int route_id, 882 void RenderViewHostImpl::CreateNewWidget(int route_id,
857 WebKit::WebPopupType popup_type) { 883 WebKit::WebPopupType popup_type) {
858 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 884 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
859 if (view) 885 if (view)
860 view->CreateNewWidget(route_id, popup_type); 886 view->CreateNewWidget(route_id, popup_type);
861 } 887 }
862 888
863 void RenderViewHost::CreateNewFullscreenWidget(int route_id) { 889 void RenderViewHostImpl::CreateNewFullscreenWidget(int route_id) {
864 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 890 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
865 if (view) 891 if (view)
866 view->CreateNewFullscreenWidget(route_id); 892 view->CreateNewFullscreenWidget(route_id);
867 } 893 }
868 894
869 void RenderViewHost::OnMsgShowView(int route_id, 895 void RenderViewHostImpl::OnMsgShowView(int route_id,
870 WindowOpenDisposition disposition, 896 WindowOpenDisposition disposition,
871 const gfx::Rect& initial_pos, 897 const gfx::Rect& initial_pos,
872 bool user_gesture) { 898 bool user_gesture) {
873 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 899 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
874 if (view) { 900 if (view) {
875 if (!is_swapped_out_) 901 if (!is_swapped_out_)
876 view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture); 902 view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture);
877 Send(new ViewMsg_Move_ACK(route_id)); 903 Send(new ViewMsg_Move_ACK(route_id));
878 } 904 }
879 } 905 }
880 906
881 void RenderViewHost::OnMsgShowWidget(int route_id, 907 void RenderViewHostImpl::OnMsgShowWidget(int route_id,
882 const gfx::Rect& initial_pos) { 908 const gfx::Rect& initial_pos) {
883 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 909 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
884 if (view) { 910 if (view) {
885 if (!is_swapped_out_) 911 if (!is_swapped_out_)
886 view->ShowCreatedWidget(route_id, initial_pos); 912 view->ShowCreatedWidget(route_id, initial_pos);
887 Send(new ViewMsg_Move_ACK(route_id)); 913 Send(new ViewMsg_Move_ACK(route_id));
888 } 914 }
889 } 915 }
890 916
891 void RenderViewHost::OnMsgShowFullscreenWidget(int route_id) { 917 void RenderViewHostImpl::OnMsgShowFullscreenWidget(int route_id) {
892 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 918 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
893 if (view) { 919 if (view) {
894 if (!is_swapped_out_) 920 if (!is_swapped_out_)
895 view->ShowCreatedFullscreenWidget(route_id); 921 view->ShowCreatedFullscreenWidget(route_id);
896 Send(new ViewMsg_Move_ACK(route_id)); 922 Send(new ViewMsg_Move_ACK(route_id));
897 } 923 }
898 } 924 }
899 925
900 void RenderViewHost::OnMsgRunModal(IPC::Message* reply_msg) { 926 void RenderViewHostImpl::OnMsgRunModal(IPC::Message* reply_msg) {
901 DCHECK(!run_modal_reply_msg_); 927 DCHECK(!run_modal_reply_msg_);
902 run_modal_reply_msg_ = reply_msg; 928 run_modal_reply_msg_ = reply_msg;
903 929
904 content::RecordAction(UserMetricsAction("ShowModalDialog")); 930 content::RecordAction(UserMetricsAction("ShowModalDialog"));
905 931
906 // TODO(darin): Bug 1107929: Need to inform our delegate to show this view in 932 // TODO(darin): Bug 1107929: Need to inform our delegate to show this view in
907 // an app-modal fashion. 933 // an app-modal fashion.
908 } 934 }
909 935
910 void RenderViewHost::OnMsgRenderViewReady() { 936 void RenderViewHostImpl::OnMsgRenderViewReady() {
911 render_view_termination_status_ = base::TERMINATION_STATUS_STILL_RUNNING; 937 render_view_termination_status_ = base::TERMINATION_STATUS_STILL_RUNNING;
912 WasResized(); 938 WasResized();
913 delegate_->RenderViewReady(this); 939 delegate_->RenderViewReady(this);
914 } 940 }
915 941
916 void RenderViewHost::OnMsgRenderViewGone(int status, int exit_code) { 942 void RenderViewHostImpl::OnMsgRenderViewGone(int status, int exit_code) {
917 // Keep the termination status so we can get at it later when we 943 // Keep the termination status so we can get at it later when we
918 // need to know why it died. 944 // need to know why it died.
919 render_view_termination_status_ = 945 render_view_termination_status_ =
920 static_cast<base::TerminationStatus>(status); 946 static_cast<base::TerminationStatus>(status);
921 947
922 // Reset state. 948 // Reset state.
923 ClearPowerSaveBlockers(); 949 ClearPowerSaveBlockers();
924 950
925 // Our base class RenderWidgetHost needs to reset some stuff. 951 // Our base class RenderWidgetHost needs to reset some stuff.
926 RendererExited(render_view_termination_status_, exit_code); 952 RendererExited(render_view_termination_status_, exit_code);
927 953
928 delegate_->RenderViewGone(this, 954 delegate_->RenderViewGone(this,
929 static_cast<base::TerminationStatus>(status), 955 static_cast<base::TerminationStatus>(status),
930 exit_code); 956 exit_code);
931 } 957 }
932 958
933 // Called when the renderer navigates. For every frame loaded, we'll get this 959 // Called when the renderer navigates. For every frame loaded, we'll get this
934 // notification containing parameters identifying the navigation. 960 // notification containing parameters identifying the navigation.
935 // 961 //
936 // Subframes are identified by the page transition type. For subframes loaded 962 // Subframes are identified by the page transition type. For subframes loaded
937 // as part of a wider page load, the page_id will be the same as for the top 963 // as part of a wider page load, the page_id will be the same as for the top
938 // level frame. If the user explicitly requests a subframe navigation, we will 964 // level frame. If the user explicitly requests a subframe navigation, we will
939 // get a new page_id because we need to create a new navigation entry for that 965 // get a new page_id because we need to create a new navigation entry for that
940 // action. 966 // action.
941 void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) { 967 void RenderViewHostImpl::OnMsgNavigate(const IPC::Message& msg) {
942 // Read the parameters out of the IPC message directly to avoid making another 968 // Read the parameters out of the IPC message directly to avoid making another
943 // copy when we filter the URLs. 969 // copy when we filter the URLs.
944 void* iter = NULL; 970 void* iter = NULL;
945 ViewHostMsg_FrameNavigate_Params validated_params; 971 ViewHostMsg_FrameNavigate_Params validated_params;
946 if (!IPC::ParamTraits<ViewHostMsg_FrameNavigate_Params>:: 972 if (!IPC::ParamTraits<ViewHostMsg_FrameNavigate_Params>::
947 Read(&msg, &iter, &validated_params)) 973 Read(&msg, &iter, &validated_params))
948 return; 974 return;
949 975
950 // If we're waiting for a cross-site beforeunload ack from this renderer and 976 // If we're waiting for a cross-site beforeunload ack from this renderer and
951 // we receive a Navigate message from the main frame, then the renderer was 977 // we receive a Navigate message from the main frame, then the renderer was
952 // navigating already and sent it before hearing the ViewMsg_Stop message. 978 // navigating already and sent it before hearing the ViewMsg_Stop message.
953 // We do not want to cancel the pending navigation in this case, since the 979 // We do not want to cancel the pending navigation in this case, since the
954 // old page will soon be stopped. Instead, treat this as a beforeunload ack 980 // old page will soon be stopped. Instead, treat this as a beforeunload ack
955 // to allow the pending navigation to continue. 981 // to allow the pending navigation to continue.
956 if (is_waiting_for_beforeunload_ack_ && 982 if (is_waiting_for_beforeunload_ack_ &&
957 unload_ack_is_for_cross_site_transition_ && 983 unload_ack_is_for_cross_site_transition_ &&
958 content::PageTransitionIsMainFrame(validated_params.transition)) { 984 content::PageTransitionIsMainFrame(validated_params.transition)) {
959 OnMsgShouldCloseACK(true); 985 OnMsgShouldCloseACK(true);
960 return; 986 return;
961 } 987 }
962 988
963 // If we're waiting for an unload ack from this renderer and we receive a 989 // If we're waiting for an unload ack from this renderer and we receive a
964 // Navigate message, then the renderer was navigating before it received the 990 // Navigate message, then the renderer was navigating before it received the
965 // unload request. It will either respond to the unload request soon or our 991 // unload request. It will either respond to the unload request soon or our
966 // timer will expire. Either way, we should ignore this message, because we 992 // timer will expire. Either way, we should ignore this message, because we
967 // have already committed to closing this renderer. 993 // have already committed to closing this renderer.
968 if (is_waiting_for_unload_ack_) 994 if (is_waiting_for_unload_ack_)
969 return; 995 return;
970 996
971 const int renderer_id = process()->GetID(); 997 const int renderer_id = GetProcess()->GetID();
972 ChildProcessSecurityPolicyImpl* policy = 998 ChildProcessSecurityPolicyImpl* policy =
973 ChildProcessSecurityPolicyImpl::GetInstance(); 999 ChildProcessSecurityPolicyImpl::GetInstance();
974 // Without this check, an evil renderer can trick the browser into creating 1000 // Without this check, an evil renderer can trick the browser into creating
975 // a navigation entry for a banned URL. If the user clicks the back button 1001 // a navigation entry for a banned URL. If the user clicks the back button
976 // followed by the forward button (or clicks reload, or round-trips through 1002 // followed by the forward button (or clicks reload, or round-trips through
977 // session restore, etc), we'll think that the browser commanded the 1003 // session restore, etc), we'll think that the browser commanded the
978 // renderer to load the URL and grant the renderer the privileges to request 1004 // renderer to load the URL and grant the renderer the privileges to request
979 // the URL. To prevent this attack, we block the renderer from inserting 1005 // the URL. To prevent this attack, we block the renderer from inserting
980 // banned URLs into the navigation controller in the first place. 1006 // banned URLs into the navigation controller in the first place.
981 FilterURL(policy, renderer_id, &validated_params.url); 1007 FilterURL(policy, renderer_id, &validated_params.url);
982 FilterURL(policy, renderer_id, &validated_params.referrer.url); 1008 FilterURL(policy, renderer_id, &validated_params.referrer.url);
983 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); 1009 for (std::vector<GURL>::iterator it(validated_params.redirects.begin());
984 it != validated_params.redirects.end(); ++it) { 1010 it != validated_params.redirects.end(); ++it) {
985 FilterURL(policy, renderer_id, &(*it)); 1011 FilterURL(policy, renderer_id, &(*it));
986 } 1012 }
987 FilterURL(policy, renderer_id, &validated_params.searchable_form_url); 1013 FilterURL(policy, renderer_id, &validated_params.searchable_form_url);
988 FilterURL(policy, renderer_id, &validated_params.password_form.origin); 1014 FilterURL(policy, renderer_id, &validated_params.password_form.origin);
989 FilterURL(policy, renderer_id, &validated_params.password_form.action); 1015 FilterURL(policy, renderer_id, &validated_params.password_form.action);
990 1016
991 delegate_->DidNavigate(this, validated_params); 1017 delegate_->DidNavigate(this, validated_params);
992 } 1018 }
993 1019
994 void RenderViewHost::OnMsgUpdateState(int32 page_id, 1020 void RenderViewHostImpl::OnMsgUpdateState(int32 page_id,
995 const std::string& state) { 1021 const std::string& state) {
996 delegate_->UpdateState(this, page_id, state); 1022 delegate_->UpdateState(this, page_id, state);
997 } 1023 }
998 1024
999 void RenderViewHost::OnMsgUpdateTitle( 1025 void RenderViewHostImpl::OnMsgUpdateTitle(
1000 int32 page_id, 1026 int32 page_id,
1001 const string16& title, 1027 const string16& title,
1002 WebKit::WebTextDirection title_direction) { 1028 WebKit::WebTextDirection title_direction) {
1003 if (title.length() > content::kMaxTitleChars) { 1029 if (title.length() > content::kMaxTitleChars) {
1004 NOTREACHED() << "Renderer sent too many characters in title."; 1030 NOTREACHED() << "Renderer sent too many characters in title.";
1005 return; 1031 return;
1006 } 1032 }
1007 1033
1008 delegate_->UpdateTitle(this, page_id, title, 1034 delegate_->UpdateTitle(this, page_id, title,
1009 WebTextDirectionToChromeTextDirection( 1035 WebTextDirectionToChromeTextDirection(
1010 title_direction)); 1036 title_direction));
1011 } 1037 }
1012 1038
1013 void RenderViewHost::OnMsgUpdateEncoding(const std::string& encoding_name) { 1039 void RenderViewHostImpl::OnMsgUpdateEncoding(const std::string& encoding_name) {
1014 delegate_->UpdateEncoding(this, encoding_name); 1040 delegate_->UpdateEncoding(this, encoding_name);
1015 } 1041 }
1016 1042
1017 void RenderViewHost::OnMsgUpdateTargetURL(int32 page_id, 1043 void RenderViewHostImpl::OnMsgUpdateTargetURL(int32 page_id,
1018 const GURL& url) { 1044 const GURL& url) {
1019 if (!is_swapped_out_) 1045 if (!is_swapped_out_)
1020 delegate_->UpdateTargetURL(page_id, url); 1046 delegate_->UpdateTargetURL(page_id, url);
1021 1047
1022 // Send a notification back to the renderer that we are ready to 1048 // Send a notification back to the renderer that we are ready to
1023 // receive more target urls. 1049 // receive more target urls.
1024 Send(new ViewMsg_UpdateTargetURL_ACK(routing_id())); 1050 Send(new ViewMsg_UpdateTargetURL_ACK(GetRoutingID()));
1025 } 1051 }
1026 1052
1027 void RenderViewHost::OnUpdateInspectorSetting( 1053 void RenderViewHostImpl::OnUpdateInspectorSetting(
1028 const std::string& key, const std::string& value) { 1054 const std::string& key, const std::string& value) {
1029 content::GetContentClient()->browser()->UpdateInspectorSetting( 1055 content::GetContentClient()->browser()->UpdateInspectorSetting(
1030 this, key, value); 1056 this, key, value);
1031 } 1057 }
1032 1058
1033 void RenderViewHost::OnMsgClose() { 1059 void RenderViewHostImpl::OnMsgClose() {
1034 // If the renderer is telling us to close, it has already run the unload 1060 // If the renderer is telling us to close, it has already run the unload
1035 // events, and we can take the fast path. 1061 // events, and we can take the fast path.
1036 ClosePageIgnoringUnloadEvents(); 1062 ClosePageIgnoringUnloadEvents();
1037 } 1063 }
1038 1064
1039 void RenderViewHost::OnMsgRequestMove(const gfx::Rect& pos) { 1065 void RenderViewHostImpl::OnMsgRequestMove(const gfx::Rect& pos) {
1040 if (!is_swapped_out_) 1066 if (!is_swapped_out_)
1041 delegate_->RequestMove(pos); 1067 delegate_->RequestMove(pos);
1042 Send(new ViewMsg_Move_ACK(routing_id())); 1068 Send(new ViewMsg_Move_ACK(GetRoutingID()));
1043 } 1069 }
1044 1070
1045 void RenderViewHost::OnMsgDidStartLoading() { 1071 void RenderViewHostImpl::OnMsgDidStartLoading() {
1046 delegate_->DidStartLoading(); 1072 delegate_->DidStartLoading();
1047 } 1073 }
1048 1074
1049 void RenderViewHost::OnMsgDidStopLoading() { 1075 void RenderViewHostImpl::OnMsgDidStopLoading() {
1050 delegate_->DidStopLoading(); 1076 delegate_->DidStopLoading();
1051 } 1077 }
1052 1078
1053 void RenderViewHost::OnMsgDidChangeLoadProgress(double load_progress) { 1079 void RenderViewHostImpl::OnMsgDidChangeLoadProgress(double load_progress) {
1054 delegate_->DidChangeLoadProgress(load_progress); 1080 delegate_->DidChangeLoadProgress(load_progress);
1055 } 1081 }
1056 1082
1057 void RenderViewHost::OnMsgDocumentAvailableInMainFrame() { 1083 void RenderViewHostImpl::OnMsgDocumentAvailableInMainFrame() {
1058 delegate_->DocumentAvailableInMainFrame(this); 1084 delegate_->DocumentAvailableInMainFrame(this);
1059 } 1085 }
1060 1086
1061 void RenderViewHost::OnMsgDocumentOnLoadCompletedInMainFrame(int32 page_id) { 1087 void RenderViewHostImpl::OnMsgDocumentOnLoadCompletedInMainFrame(
1088 int32 page_id) {
1062 delegate_->DocumentOnLoadCompletedInMainFrame(this, page_id); 1089 delegate_->DocumentOnLoadCompletedInMainFrame(this, page_id);
1063 } 1090 }
1064 1091
1065 void RenderViewHost::OnMsgContextMenu( 1092 void RenderViewHostImpl::OnMsgContextMenu(
1066 const content::ContextMenuParams& params) { 1093 const content::ContextMenuParams& params) {
1067 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 1094 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
1068 if (!view) 1095 if (!view)
1069 return; 1096 return;
1070 1097
1071 // Validate the URLs in |params|. If the renderer can't request the URLs 1098 // Validate the URLs in |params|. If the renderer can't request the URLs
1072 // directly, don't show them in the context menu. 1099 // directly, don't show them in the context menu.
1073 content::ContextMenuParams validated_params(params); 1100 content::ContextMenuParams validated_params(params);
1074 int renderer_id = process()->GetID(); 1101 int renderer_id = GetProcess()->GetID();
1075 ChildProcessSecurityPolicyImpl* policy = 1102 ChildProcessSecurityPolicyImpl* policy =
1076 ChildProcessSecurityPolicyImpl::GetInstance(); 1103 ChildProcessSecurityPolicyImpl::GetInstance();
1077 1104
1078 // We don't validate |unfiltered_link_url| so that this field can be used 1105 // We don't validate |unfiltered_link_url| so that this field can be used
1079 // when users want to copy the original link URL. 1106 // when users want to copy the original link URL.
1080 FilterURL(policy, renderer_id, &validated_params.link_url); 1107 FilterURL(policy, renderer_id, &validated_params.link_url);
1081 FilterURL(policy, renderer_id, &validated_params.src_url); 1108 FilterURL(policy, renderer_id, &validated_params.src_url);
1082 FilterURL(policy, renderer_id, &validated_params.page_url); 1109 FilterURL(policy, renderer_id, &validated_params.page_url);
1083 FilterURL(policy, renderer_id, &validated_params.frame_url); 1110 FilterURL(policy, renderer_id, &validated_params.frame_url);
1084 1111
1085 view->ShowContextMenu(validated_params); 1112 view->ShowContextMenu(validated_params);
1086 } 1113 }
1087 1114
1088 void RenderViewHost::OnMsgToggleFullscreen(bool enter_fullscreen) { 1115 void RenderViewHostImpl::OnMsgToggleFullscreen(bool enter_fullscreen) {
1089 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1090 delegate_->ToggleFullscreenMode(enter_fullscreen); 1117 delegate_->ToggleFullscreenMode(enter_fullscreen);
1091 } 1118 }
1092 1119
1093 void RenderViewHost::OnMsgOpenURL(const GURL& url, 1120 void RenderViewHostImpl::OnMsgOpenURL(const GURL& url,
1094 const content::Referrer& referrer, 1121 const content::Referrer& referrer,
1095 WindowOpenDisposition disposition, 1122 WindowOpenDisposition disposition,
1096 int64 source_frame_id) { 1123 int64 source_frame_id) {
1097 GURL validated_url(url); 1124 GURL validated_url(url);
1098 FilterURL(ChildProcessSecurityPolicyImpl::GetInstance(), 1125 FilterURL(ChildProcessSecurityPolicyImpl::GetInstance(),
1099 process()->GetID(), &validated_url); 1126 GetProcess()->GetID(), &validated_url);
1100 1127
1101 delegate_->RequestOpenURL( 1128 delegate_->RequestOpenURL(
1102 validated_url, referrer, disposition, source_frame_id); 1129 validated_url, referrer, disposition, source_frame_id);
1103 } 1130 }
1104 1131
1105 void RenderViewHost::OnMsgDidContentsPreferredSizeChange( 1132 void RenderViewHostImpl::OnMsgDidContentsPreferredSizeChange(
1106 const gfx::Size& new_size) { 1133 const gfx::Size& new_size) {
1107 delegate_->UpdatePreferredSize(new_size); 1134 delegate_->UpdatePreferredSize(new_size);
1108 } 1135 }
1109 1136
1110 void RenderViewHost::OnRenderAutoResized(const gfx::Size& new_size) { 1137 void RenderViewHostImpl::OnRenderAutoResized(const gfx::Size& new_size) {
1111 delegate_->ResizeDueToAutoResize(new_size); 1138 delegate_->ResizeDueToAutoResize(new_size);
1112 } 1139 }
1113 1140
1114 void RenderViewHost::OnMsgDidChangeScrollbarsForMainFrame( 1141 void RenderViewHostImpl::OnMsgDidChangeScrollbarsForMainFrame(
1115 bool has_horizontal_scrollbar, bool has_vertical_scrollbar) { 1142 bool has_horizontal_scrollbar, bool has_vertical_scrollbar) {
1116 if (view_) 1143 if (view_)
1117 view_->SetHasHorizontalScrollbar(has_horizontal_scrollbar); 1144 view_->SetHasHorizontalScrollbar(has_horizontal_scrollbar);
1118 } 1145 }
1119 1146
1120 void RenderViewHost::OnMsgDidChangeScrollOffsetPinningForMainFrame( 1147 void RenderViewHostImpl::OnMsgDidChangeScrollOffsetPinningForMainFrame(
1121 bool is_pinned_to_left, bool is_pinned_to_right) { 1148 bool is_pinned_to_left, bool is_pinned_to_right) {
1122 if (view_) 1149 if (view_)
1123 view_->SetScrollOffsetPinning(is_pinned_to_left, is_pinned_to_right); 1150 view_->SetScrollOffsetPinning(is_pinned_to_left, is_pinned_to_right);
1124 } 1151 }
1125 1152
1126 void RenderViewHost::OnMsgDidChangeNumWheelEvents(int count) { 1153 void RenderViewHostImpl::OnMsgDidChangeNumWheelEvents(int count) {
1127 } 1154 }
1128 1155
1129 void RenderViewHost::OnMsgSelectionChanged(const string16& text, 1156 void RenderViewHostImpl::OnMsgSelectionChanged(const string16& text,
1130 size_t offset, 1157 size_t offset,
1131 const ui::Range& range) { 1158 const ui::Range& range) {
1132 if (view_) 1159 if (view_)
1133 view_->SelectionChanged(text, offset, range); 1160 view_->SelectionChanged(text, offset, range);
1134 } 1161 }
1135 1162
1136 void RenderViewHost::OnMsgSelectionBoundsChanged( 1163 void RenderViewHostImpl::OnMsgSelectionBoundsChanged(
1137 const gfx::Rect& start_rect, 1164 const gfx::Rect& start_rect,
1138 const gfx::Rect& end_rect) { 1165 const gfx::Rect& end_rect) {
1139 if (view_) 1166 if (view_)
1140 view_->SelectionBoundsChanged(start_rect, end_rect); 1167 view_->SelectionBoundsChanged(start_rect, end_rect);
1141 } 1168 }
1142 1169
1143 void RenderViewHost::OnMsgRunJavaScriptMessage( 1170 void RenderViewHostImpl::OnMsgRunJavaScriptMessage(
1144 const string16& message, 1171 const string16& message,
1145 const string16& default_prompt, 1172 const string16& default_prompt,
1146 const GURL& frame_url, 1173 const GURL& frame_url,
1147 ui::JavascriptMessageType type, 1174 ui::JavascriptMessageType type,
1148 IPC::Message* reply_msg) { 1175 IPC::Message* reply_msg) {
1149 // While a JS message dialog is showing, tabs in the same process shouldn't 1176 // While a JS message dialog is showing, tabs in the same process shouldn't
1150 // process input events. 1177 // process input events.
1151 process()->SetIgnoreInputEvents(true); 1178 GetProcess()->SetIgnoreInputEvents(true);
1152 StopHangMonitorTimeout(); 1179 StopHangMonitorTimeout();
1153 delegate_->RunJavaScriptMessage(this, message, default_prompt, frame_url, 1180 delegate_->RunJavaScriptMessage(this, message, default_prompt, frame_url,
1154 type, reply_msg, 1181 type, reply_msg,
1155 &are_javascript_messages_suppressed_); 1182 &are_javascript_messages_suppressed_);
1156 } 1183 }
1157 1184
1158 void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url, 1185 void RenderViewHostImpl::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url,
1159 const string16& message, 1186 const string16& message,
1160 bool is_reload, 1187 bool is_reload,
1161 IPC::Message* reply_msg) { 1188 IPC::Message* reply_msg) {
1162 // While a JS before unload dialog is showing, tabs in the same process 1189 // While a JS before unload dialog is showing, tabs in the same process
1163 // shouldn't process input events. 1190 // shouldn't process input events.
1164 process()->SetIgnoreInputEvents(true); 1191 GetProcess()->SetIgnoreInputEvents(true);
1165 StopHangMonitorTimeout(); 1192 StopHangMonitorTimeout();
1166 delegate_->RunBeforeUnloadConfirm(this, message, is_reload, reply_msg); 1193 delegate_->RunBeforeUnloadConfirm(this, message, is_reload, reply_msg);
1167 } 1194 }
1168 1195
1169 void RenderViewHost::OnMsgStartDragging( 1196 void RenderViewHostImpl::OnMsgStartDragging(
1170 const WebDropData& drop_data, 1197 const WebDropData& drop_data,
1171 WebDragOperationsMask drag_operations_mask, 1198 WebDragOperationsMask drag_operations_mask,
1172 const SkBitmap& image, 1199 const SkBitmap& image,
1173 const gfx::Point& image_offset) { 1200 const gfx::Point& image_offset) {
1174 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 1201 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
1175 if (!view) 1202 if (!view)
1176 return; 1203 return;
1177 1204
1178 WebDropData filtered_data(drop_data); 1205 WebDropData filtered_data(drop_data);
1179 ChildProcessSecurityPolicyImpl* policy = 1206 ChildProcessSecurityPolicyImpl* policy =
1180 ChildProcessSecurityPolicyImpl::GetInstance(); 1207 ChildProcessSecurityPolicyImpl::GetInstance();
1181 1208
1182 // Allow drag of Javascript URLs to enable bookmarklet drag to bookmark bar. 1209 // Allow drag of Javascript URLs to enable bookmarklet drag to bookmark bar.
1183 if (!filtered_data.url.SchemeIs(chrome::kJavaScriptScheme)) 1210 if (!filtered_data.url.SchemeIs(chrome::kJavaScriptScheme))
1184 FilterURL(policy, process()->GetID(), &filtered_data.url); 1211 FilterURL(policy, GetProcess()->GetID(), &filtered_data.url);
1185 FilterURL(policy, process()->GetID(), &filtered_data.html_base_url); 1212 FilterURL(policy, GetProcess()->GetID(), &filtered_data.html_base_url);
1186 view->StartDragging(filtered_data, drag_operations_mask, image, image_offset); 1213 view->StartDragging(filtered_data, drag_operations_mask, image, image_offset);
1187 } 1214 }
1188 1215
1189 void RenderViewHost::OnUpdateDragCursor(WebDragOperation current_op) { 1216 void RenderViewHostImpl::OnUpdateDragCursor(WebDragOperation current_op) {
1190 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 1217 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
1191 if (view) 1218 if (view)
1192 view->UpdateDragCursor(current_op); 1219 view->UpdateDragCursor(current_op);
1193 } 1220 }
1194 1221
1195 void RenderViewHost::OnTargetDropACK() { 1222 void RenderViewHostImpl::OnTargetDropACK() {
1196 content::NotificationService::current()->Notify( 1223 content::NotificationService::current()->Notify(
1197 content::NOTIFICATION_RENDER_VIEW_HOST_DID_RECEIVE_DRAG_TARGET_DROP_ACK, 1224 content::NOTIFICATION_RENDER_VIEW_HOST_DID_RECEIVE_DRAG_TARGET_DROP_ACK,
1198 content::Source<RenderViewHost>(this), 1225 content::Source<RenderViewHost>(this),
1199 content::NotificationService::NoDetails()); 1226 content::NotificationService::NoDetails());
1200 } 1227 }
1201 1228
1202 void RenderViewHost::OnTakeFocus(bool reverse) { 1229 void RenderViewHostImpl::OnTakeFocus(bool reverse) {
1203 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 1230 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
1204 if (view) 1231 if (view)
1205 view->TakeFocus(reverse); 1232 view->TakeFocus(reverse);
1206 } 1233 }
1207 1234
1208 void RenderViewHost::OnFocusedNodeChanged(bool is_editable_node) { 1235 void RenderViewHostImpl::OnFocusedNodeChanged(bool is_editable_node) {
1209 content::NotificationService::current()->Notify( 1236 content::NotificationService::current()->Notify(
1210 content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, 1237 content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
1211 content::Source<RenderViewHost>(this), 1238 content::Source<RenderViewHost>(this),
1212 content::Details<const bool>(&is_editable_node)); 1239 content::Details<const bool>(&is_editable_node));
1213 } 1240 }
1214 1241
1215 void RenderViewHost::OnAddMessageToConsole(int32 level, 1242 void RenderViewHostImpl::OnAddMessageToConsole(int32 level,
1216 const string16& message, 1243 const string16& message,
1217 int32 line_no, 1244 int32 line_no,
1218 const string16& source_id) { 1245 const string16& source_id) {
1219 // Pass through log level only on WebUI pages to limit console spew. 1246 // Pass through log level only on WebUI pages to limit console spew.
1220 int32 resolved_level = 1247 int32 resolved_level =
1221 (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) ? level : 0; 1248 (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) ? level : 0;
1222 1249
1223 logging::LogMessage("CONSOLE", line_no, resolved_level).stream() << "\"" << 1250 logging::LogMessage("CONSOLE", line_no, resolved_level).stream() << "\"" <<
1224 message << "\", source: " << source_id << " (" << line_no << ")"; 1251 message << "\", source: " << source_id << " (" << line_no << ")";
1225 } 1252 }
1226 1253
1227 void RenderViewHost::AddObserver(content::RenderViewHostObserver* observer) { 1254 void RenderViewHostImpl::AddObserver(
1255 content::RenderViewHostObserver* observer) {
1228 observers_.AddObserver(observer); 1256 observers_.AddObserver(observer);
1229 } 1257 }
1230 1258
1231 void RenderViewHost::RemoveObserver(content::RenderViewHostObserver* observer) { 1259 void RenderViewHostImpl::RemoveObserver(
1260 content::RenderViewHostObserver* observer) {
1232 observers_.RemoveObserver(observer); 1261 observers_.RemoveObserver(observer);
1233 } 1262 }
1234 1263
1235 bool RenderViewHost::PreHandleKeyboardEvent( 1264 bool RenderViewHostImpl::PreHandleKeyboardEvent(
1236 const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) { 1265 const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) {
1237 return delegate_->PreHandleKeyboardEvent(event, is_keyboard_shortcut); 1266 return delegate_->PreHandleKeyboardEvent(event, is_keyboard_shortcut);
1238 } 1267 }
1239 1268
1240 void RenderViewHost::UnhandledKeyboardEvent( 1269 void RenderViewHostImpl::UnhandledKeyboardEvent(
1241 const NativeWebKeyboardEvent& event) { 1270 const NativeWebKeyboardEvent& event) {
1242 delegate_->HandleKeyboardEvent(event); 1271 delegate_->HandleKeyboardEvent(event);
1243 } 1272 }
1244 1273
1245 void RenderViewHost::OnUserGesture() { 1274 void RenderViewHostImpl::OnUserGesture() {
1246 delegate_->OnUserGesture(); 1275 delegate_->OnUserGesture();
1247 } 1276 }
1248 1277
1249 void RenderViewHost::OnMsgShouldCloseACK(bool proceed) { 1278 void RenderViewHostImpl::OnMsgShouldCloseACK(bool proceed) {
1250 StopHangMonitorTimeout(); 1279 StopHangMonitorTimeout();
1251 // If this renderer navigated while the beforeunload request was in flight, we 1280 // If this renderer navigated while the beforeunload request was in flight, we
1252 // may have cleared this state in OnMsgNavigate, in which case we can ignore 1281 // may have cleared this state in OnMsgNavigate, in which case we can ignore
1253 // this message. 1282 // this message.
1254 if (!is_waiting_for_beforeunload_ack_ || is_swapped_out_) 1283 if (!is_waiting_for_beforeunload_ack_ || is_swapped_out_)
1255 return; 1284 return;
1256 1285
1257 is_waiting_for_beforeunload_ack_ = false; 1286 is_waiting_for_beforeunload_ack_ = false;
1258 1287
1259 RenderViewHostDelegate::RendererManagement* management_delegate = 1288 RenderViewHostDelegate::RendererManagement* management_delegate =
1260 delegate_->GetRendererManagementDelegate(); 1289 delegate_->GetRendererManagementDelegate();
1261 if (management_delegate) { 1290 if (management_delegate) {
1262 management_delegate->ShouldClosePage( 1291 management_delegate->ShouldClosePage(
1263 unload_ack_is_for_cross_site_transition_, proceed); 1292 unload_ack_is_for_cross_site_transition_, proceed);
1264 } 1293 }
1265 1294
1266 // If canceled, notify the delegate to cancel its pending navigation entry. 1295 // If canceled, notify the delegate to cancel its pending navigation entry.
1267 if (!proceed) 1296 if (!proceed)
1268 delegate_->DidCancelLoading(); 1297 delegate_->DidCancelLoading();
1269 } 1298 }
1270 1299
1271 void RenderViewHost::OnMsgClosePageACK() { 1300 void RenderViewHostImpl::OnMsgClosePageACK() {
1272 ClosePageIgnoringUnloadEvents(); 1301 ClosePageIgnoringUnloadEvents();
1273 } 1302 }
1274 1303
1275 void RenderViewHost::NotifyRendererUnresponsive() { 1304 void RenderViewHostImpl::NotifyRendererUnresponsive() {
1276 delegate_->RendererUnresponsive( 1305 delegate_->RendererUnresponsive(
1277 this, is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_); 1306 this, is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_);
1278 } 1307 }
1279 1308
1280 void RenderViewHost::NotifyRendererResponsive() { 1309 void RenderViewHostImpl::NotifyRendererResponsive() {
1281 delegate_->RendererResponsive(this); 1310 delegate_->RendererResponsive(this);
1282 } 1311 }
1283 1312
1284 void RenderViewHost::RequestToLockMouse() { 1313 void RenderViewHostImpl::RequestToLockMouse() {
1285 delegate_->RequestToLockMouse(); 1314 delegate_->RequestToLockMouse();
1286 } 1315 }
1287 1316
1288 bool RenderViewHost::IsFullscreen() const { 1317 bool RenderViewHostImpl::IsFullscreen() const {
1289 return delegate_->IsFullscreenForCurrentTab(); 1318 return delegate_->IsFullscreenForCurrentTab();
1290 } 1319 }
1291 1320
1292 void RenderViewHost::OnMsgFocus() { 1321 void RenderViewHostImpl::OnMsgFocus() {
1293 delegate_->Activate(); 1322 delegate_->Activate();
1294 } 1323 }
1295 1324
1296 void RenderViewHost::OnMsgBlur() { 1325 void RenderViewHostImpl::OnMsgBlur() {
1297 delegate_->Deactivate(); 1326 delegate_->Deactivate();
1298 } 1327 }
1299 1328
1300 gfx::Rect RenderViewHost::GetRootWindowResizerRect() const { 1329 gfx::Rect RenderViewHostImpl::GetRootWindowResizerRect() const {
1301 return delegate_->GetRootWindowResizerRect(); 1330 return delegate_->GetRootWindowResizerRect();
1302 } 1331 }
1303 1332
1304 void RenderViewHost::ForwardMouseEvent( 1333 void RenderViewHostImpl::ForwardMouseEvent(
1305 const WebKit::WebMouseEvent& mouse_event) { 1334 const WebKit::WebMouseEvent& mouse_event) {
1306 1335
1307 // We make a copy of the mouse event because 1336 // We make a copy of the mouse event because
1308 // RenderWidgetHost::ForwardMouseEvent will delete |mouse_event|. 1337 // RenderWidgetHost::ForwardMouseEvent will delete |mouse_event|.
1309 WebKit::WebMouseEvent event_copy(mouse_event); 1338 WebKit::WebMouseEvent event_copy(mouse_event);
1310 RenderWidgetHostImpl::ForwardMouseEvent(event_copy); 1339 RenderWidgetHostImpl::ForwardMouseEvent(event_copy);
1311 1340
1312 switch (event_copy.type) { 1341 switch (event_copy.type) {
1313 case WebInputEvent::MouseMove: 1342 case WebInputEvent::MouseMove:
1314 delegate_->HandleMouseMove(); 1343 delegate_->HandleMouseMove();
1315 break; 1344 break;
1316 case WebInputEvent::MouseLeave: 1345 case WebInputEvent::MouseLeave:
1317 delegate_->HandleMouseLeave(); 1346 delegate_->HandleMouseLeave();
1318 break; 1347 break;
1319 case WebInputEvent::MouseDown: 1348 case WebInputEvent::MouseDown:
1320 delegate_->HandleMouseDown(); 1349 delegate_->HandleMouseDown();
1321 break; 1350 break;
1322 case WebInputEvent::MouseWheel: 1351 case WebInputEvent::MouseWheel:
1323 if (ignore_input_events()) 1352 if (ignore_input_events())
1324 delegate_->OnIgnoredUIEvent(); 1353 delegate_->OnIgnoredUIEvent();
1325 break; 1354 break;
1326 case WebInputEvent::MouseUp: 1355 case WebInputEvent::MouseUp:
1327 delegate_->HandleMouseUp(); 1356 delegate_->HandleMouseUp();
1328 default: 1357 default:
1329 // For now, we don't care about the rest. 1358 // For now, we don't care about the rest.
1330 break; 1359 break;
1331 } 1360 }
1332 } 1361 }
1333 1362
1334 void RenderViewHost::OnMouseActivate() { 1363 void RenderViewHostImpl::OnMouseActivate() {
1335 delegate_->HandleMouseActivate(); 1364 delegate_->HandleMouseActivate();
1336 } 1365 }
1337 1366
1338 void RenderViewHost::ForwardKeyboardEvent( 1367 void RenderViewHostImpl::ForwardKeyboardEvent(
1339 const NativeWebKeyboardEvent& key_event) { 1368 const NativeWebKeyboardEvent& key_event) {
1340 if (ignore_input_events()) { 1369 if (ignore_input_events()) {
1341 if (key_event.type == WebInputEvent::RawKeyDown) 1370 if (key_event.type == WebInputEvent::RawKeyDown)
1342 delegate_->OnIgnoredUIEvent(); 1371 delegate_->OnIgnoredUIEvent();
1343 return; 1372 return;
1344 } 1373 }
1345 RenderWidgetHostImpl::ForwardKeyboardEvent(key_event); 1374 RenderWidgetHostImpl::ForwardKeyboardEvent(key_event);
1346 } 1375 }
1347 1376
1348 #if defined(OS_MACOSX) 1377 #if defined(OS_MACOSX)
1349 void RenderViewHost::DidSelectPopupMenuItem(int selected_index) { 1378 void RenderViewHostImpl::DidSelectPopupMenuItem(int selected_index) {
1350 Send(new ViewMsg_SelectPopupMenuItem(routing_id(), selected_index)); 1379 Send(new ViewMsg_SelectPopupMenuItem(GetRoutingID(), selected_index));
1351 } 1380 }
1352 1381
1353 void RenderViewHost::DidCancelPopupMenu() { 1382 void RenderViewHostImpl::DidCancelPopupMenu() {
1354 Send(new ViewMsg_SelectPopupMenuItem(routing_id(), -1)); 1383 Send(new ViewMsg_SelectPopupMenuItem(GetRoutingID(), -1));
1355 } 1384 }
1356 #endif 1385 #endif
1357 1386
1358 void RenderViewHost::ToggleSpeechInput() { 1387 void RenderViewHostImpl::ToggleSpeechInput() {
1359 Send(new SpeechInputMsg_ToggleSpeechInput(routing_id())); 1388 Send(new SpeechInputMsg_ToggleSpeechInput(GetRoutingID()));
1360 } 1389 }
1361 1390
1362 void RenderViewHost::FilterURL(ChildProcessSecurityPolicyImpl* policy, 1391 void RenderViewHostImpl::FilterURL(ChildProcessSecurityPolicyImpl* policy,
1363 int renderer_id, 1392 int renderer_id,
1364 GURL* url) { 1393 GURL* url) {
1365 if (!url->is_valid()) 1394 if (!url->is_valid())
1366 return; // We don't need to block invalid URLs. 1395 return; // We don't need to block invalid URLs.
1367 1396
1368 if (url->SchemeIs(chrome::kAboutScheme)) { 1397 if (url->SchemeIs(chrome::kAboutScheme)) {
1369 // The renderer treats all URLs in the about: scheme as being about:blank. 1398 // The renderer treats all URLs in the about: scheme as being about:blank.
1370 // Canonicalize about: URLs to about:blank. 1399 // Canonicalize about: URLs to about:blank.
1371 *url = GURL(chrome::kAboutBlankURL); 1400 *url = GURL(chrome::kAboutBlankURL);
1372 } 1401 }
1373 1402
1374 if (!policy->CanRequestURL(renderer_id, *url)) { 1403 if (!policy->CanRequestURL(renderer_id, *url)) {
1375 // If this renderer is not permitted to request this URL, we invalidate the 1404 // If this renderer is not permitted to request this URL, we invalidate the
1376 // URL. This prevents us from storing the blocked URL and becoming confused 1405 // URL. This prevents us from storing the blocked URL and becoming confused
1377 // later. 1406 // later.
1378 VLOG(1) << "Blocked URL " << url->spec(); 1407 VLOG(1) << "Blocked URL " << url->spec();
1379 *url = GURL(); 1408 *url = GURL();
1380 } 1409 }
1381 } 1410 }
1382 1411
1383 void RenderViewHost::SetAltErrorPageURL(const GURL& url) { 1412 void RenderViewHostImpl::SetAltErrorPageURL(const GURL& url) {
1384 Send(new ViewMsg_SetAltErrorPageURL(routing_id(), url)); 1413 Send(new ViewMsg_SetAltErrorPageURL(GetRoutingID(), url));
1385 } 1414 }
1386 1415
1387 void RenderViewHost::ExitFullscreen() { 1416 void RenderViewHostImpl::ExitFullscreen() {
1388 RejectMouseLockOrUnlockIfNecessary(); 1417 RejectMouseLockOrUnlockIfNecessary();
1389 } 1418 }
1390 1419
1391 void RenderViewHost::UpdateWebkitPreferences(const WebPreferences& prefs) { 1420 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) {
1392 Send(new ViewMsg_UpdateWebPreferences(routing_id(), prefs)); 1421 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs));
1393 } 1422 }
1394 1423
1395 void RenderViewHost::ClearFocusedNode() { 1424 void RenderViewHostImpl::ClearFocusedNode() {
1396 Send(new ViewMsg_ClearFocusedNode(routing_id())); 1425 Send(new ViewMsg_ClearFocusedNode(GetRoutingID()));
1397 } 1426 }
1398 1427
1399 void RenderViewHost::SetZoomLevel(double level) { 1428 void RenderViewHostImpl::SetZoomLevel(double level) {
1400 Send(new ViewMsg_SetZoomLevel(routing_id(), level)); 1429 Send(new ViewMsg_SetZoomLevel(GetRoutingID(), level));
1401 } 1430 }
1402 1431
1403 void RenderViewHost::Zoom(content::PageZoom zoom) { 1432 void RenderViewHostImpl::Zoom(content::PageZoom zoom) {
1404 Send(new ViewMsg_Zoom(routing_id(), zoom)); 1433 Send(new ViewMsg_Zoom(GetRoutingID(), zoom));
1405 } 1434 }
1406 1435
1407 void RenderViewHost::ReloadFrame() { 1436 void RenderViewHostImpl::ReloadFrame() {
1408 Send(new ViewMsg_ReloadFrame(routing_id())); 1437 Send(new ViewMsg_ReloadFrame(GetRoutingID()));
1409 } 1438 }
1410 1439
1411 void RenderViewHost::Find(int request_id, const string16& search_text, 1440 void RenderViewHostImpl::Find(int request_id,
1412 const WebKit::WebFindOptions& options) { 1441 const string16& search_text,
1413 Send(new ViewMsg_Find(routing_id(), request_id, search_text, options)); 1442 const WebKit::WebFindOptions& options) {
1443 Send(new ViewMsg_Find(GetRoutingID(), request_id, search_text, options));
1414 } 1444 }
1415 1445
1416 void RenderViewHost::InsertCSS(const string16& frame_xpath, 1446 void RenderViewHostImpl::InsertCSS(const string16& frame_xpath,
1417 const std::string& css) { 1447 const std::string& css) {
1418 Send(new ViewMsg_CSSInsertRequest(routing_id(), frame_xpath, css)); 1448 Send(new ViewMsg_CSSInsertRequest(GetRoutingID(), frame_xpath, css));
1419 } 1449 }
1420 1450
1421 void RenderViewHost::DisableScrollbarsForThreshold(const gfx::Size& size) { 1451 void RenderViewHostImpl::DisableScrollbarsForThreshold(const gfx::Size& size) {
1422 Send(new ViewMsg_DisableScrollbarsForSmallWindows(routing_id(), size)); 1452 Send(new ViewMsg_DisableScrollbarsForSmallWindows(GetRoutingID(), size));
1423 } 1453 }
1424 1454
1425 void RenderViewHost::EnablePreferredSizeMode() { 1455 void RenderViewHostImpl::EnablePreferredSizeMode() {
1426 Send(new ViewMsg_EnablePreferredSizeChangedMode(routing_id())); 1456 Send(new ViewMsg_EnablePreferredSizeChangedMode(GetRoutingID()));
1427 } 1457 }
1428 1458
1429 void RenderViewHost::EnableAutoResize(const gfx::Size& min_size, 1459 void RenderViewHostImpl::EnableAutoResize(const gfx::Size& min_size,
1430 const gfx::Size& max_size) { 1460 const gfx::Size& max_size) {
1431 SetShouldAutoResize(true); 1461 SetShouldAutoResize(true);
1432 Send(new ViewMsg_EnableAutoResize(routing_id(), min_size, max_size)); 1462 Send(new ViewMsg_EnableAutoResize(GetRoutingID(), min_size, max_size));
1433 } 1463 }
1434 1464
1435 void RenderViewHost::DisableAutoResize(const gfx::Size& new_size) { 1465 void RenderViewHostImpl::DisableAutoResize(const gfx::Size& new_size) {
1436 SetShouldAutoResize(false); 1466 SetShouldAutoResize(false);
1437 Send(new ViewMsg_DisableAutoResize(routing_id(), new_size)); 1467 Send(new ViewMsg_DisableAutoResize(GetRoutingID(), new_size));
1438 } 1468 }
1439 1469
1440 void RenderViewHost::ExecuteCustomContextMenuCommand( 1470 void RenderViewHostImpl::ExecuteCustomContextMenuCommand(
1441 int action, const content::CustomContextMenuContext& context) { 1471 int action, const content::CustomContextMenuContext& context) {
1442 Send(new ViewMsg_CustomContextMenuAction(routing_id(), context, action)); 1472 Send(new ViewMsg_CustomContextMenuAction(GetRoutingID(), context, action));
1443 } 1473 }
1444 1474
1445 void RenderViewHost::NotifyContextMenuClosed( 1475 void RenderViewHostImpl::NotifyContextMenuClosed(
1446 const content::CustomContextMenuContext& context) { 1476 const content::CustomContextMenuContext& context) {
1447 Send(new ViewMsg_ContextMenuClosed(routing_id(), context)); 1477 Send(new ViewMsg_ContextMenuClosed(GetRoutingID(), context));
1448 } 1478 }
1449 1479
1450 void RenderViewHost::CopyImageAt(int x, int y) { 1480 void RenderViewHostImpl::CopyImageAt(int x, int y) {
1451 Send(new ViewMsg_CopyImageAt(routing_id(), x, y)); 1481 Send(new ViewMsg_CopyImageAt(GetRoutingID(), x, y));
1452 } 1482 }
1453 1483
1454 void RenderViewHost::ExecuteMediaPlayerActionAtLocation( 1484 void RenderViewHostImpl::ExecuteMediaPlayerActionAtLocation(
1455 const gfx::Point& location, const WebKit::WebMediaPlayerAction& action) { 1485 const gfx::Point& location, const WebKit::WebMediaPlayerAction& action) {
1456 Send(new ViewMsg_MediaPlayerActionAt(routing_id(), location, action)); 1486 Send(new ViewMsg_MediaPlayerActionAt(GetRoutingID(), location, action));
1457 } 1487 }
1458 1488
1459 void RenderViewHost::ExecutePluginActionAtLocation( 1489 void RenderViewHostImpl::ExecutePluginActionAtLocation(
1460 const gfx::Point& location, const WebKit::WebPluginAction& action) { 1490 const gfx::Point& location, const WebKit::WebPluginAction& action) {
1461 Send(new ViewMsg_PluginActionAt(routing_id(), location, action)); 1491 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action));
1462 } 1492 }
1463 1493
1464 void RenderViewHost::DisassociateFromPopupCount() { 1494 void RenderViewHostImpl::DisassociateFromPopupCount() {
1465 Send(new ViewMsg_DisassociateFromPopupCount(routing_id())); 1495 Send(new ViewMsg_DisassociateFromPopupCount(GetRoutingID()));
1466 } 1496 }
1467 1497
1468 void RenderViewHost::NotifyMoveOrResizeStarted() { 1498 void RenderViewHostImpl::NotifyMoveOrResizeStarted() {
1469 Send(new ViewMsg_MoveOrResizeStarted(routing_id())); 1499 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID()));
1470 } 1500 }
1471 1501
1472 void RenderViewHost::StopFinding(content::StopFindAction action) { 1502 void RenderViewHostImpl::StopFinding(content::StopFindAction action) {
1473 Send(new ViewMsg_StopFinding(routing_id(), action)); 1503 Send(new ViewMsg_StopFinding(GetRoutingID(), action));
1474 } 1504 }
1475 1505
1476 void RenderViewHost::OnAccessibilityNotifications( 1506 content::SessionStorageNamespace*
1507 RenderViewHostImpl::GetSessionStorageNamespace() {
1508 return session_storage_namespace_.get();
1509 }
1510
1511 void RenderViewHostImpl::OnAccessibilityNotifications(
1477 const std::vector<AccessibilityHostMsg_NotificationParams>& params) { 1512 const std::vector<AccessibilityHostMsg_NotificationParams>& params) {
1478 if (view_ && !is_swapped_out_) 1513 if (view_ && !is_swapped_out_)
1479 view_->OnAccessibilityNotifications(params); 1514 view_->OnAccessibilityNotifications(params);
1480 1515
1481 if (!params.empty()) { 1516 if (!params.empty()) {
1482 for (unsigned i = 0; i < params.size(); i++) { 1517 for (unsigned i = 0; i < params.size(); i++) {
1483 const AccessibilityHostMsg_NotificationParams& param = params[i]; 1518 const AccessibilityHostMsg_NotificationParams& param = params[i];
1484 1519
1485 if ((param.notification_type == AccessibilityNotificationLayoutComplete || 1520 if ((param.notification_type == AccessibilityNotificationLayoutComplete ||
1486 param.notification_type == AccessibilityNotificationLoadComplete) && 1521 param.notification_type == AccessibilityNotificationLoadComplete) &&
(...skipping 10 matching lines...) Expand all
1497 } 1532 }
1498 } 1533 }
1499 1534
1500 if (send_accessibility_updated_notifications_) { 1535 if (send_accessibility_updated_notifications_) {
1501 content::NotificationService::current()->Notify( 1536 content::NotificationService::current()->Notify(
1502 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, 1537 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
1503 content::Source<RenderViewHost>(this), 1538 content::Source<RenderViewHost>(this),
1504 content::NotificationService::NoDetails()); 1539 content::NotificationService::NoDetails());
1505 } 1540 }
1506 1541
1507 Send(new AccessibilityMsg_Notifications_ACK(routing_id())); 1542 Send(new AccessibilityMsg_Notifications_ACK(GetRoutingID()));
1508 } 1543 }
1509 1544
1510 void RenderViewHost::OnScriptEvalResponse(int id, const ListValue& result) { 1545 void RenderViewHostImpl::OnScriptEvalResponse(int id, const ListValue& result) {
1511 Value* result_value; 1546 Value* result_value;
1512 if (!result.Get(0, &result_value)) { 1547 if (!result.Get(0, &result_value)) {
1513 // Programming error or rogue renderer. 1548 // Programming error or rogue renderer.
1514 NOTREACHED() << "Got bad arguments for OnScriptEvalResponse"; 1549 NOTREACHED() << "Got bad arguments for OnScriptEvalResponse";
1515 return; 1550 return;
1516 } 1551 }
1517 std::pair<int, Value*> details(id, result_value); 1552 std::pair<int, Value*> details(id, result_value);
1518 content::NotificationService::current()->Notify( 1553 content::NotificationService::current()->Notify(
1519 content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, 1554 content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
1520 content::Source<RenderViewHost>(this), 1555 content::Source<RenderViewHost>(this),
1521 content::Details<std::pair<int, Value*> >(&details)); 1556 content::Details<std::pair<int, Value*> >(&details));
1522 } 1557 }
1523 1558
1524 void RenderViewHost::OnDidZoomURL(double zoom_level, 1559 void RenderViewHostImpl::OnDidZoomURL(double zoom_level,
1525 bool remember, 1560 bool remember,
1526 const GURL& url) { 1561 const GURL& url) {
1527 HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>( 1562 HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>(
1528 HostZoomMap::GetForBrowserContext(process()->GetBrowserContext())); 1563 HostZoomMap::GetForBrowserContext(GetProcess()->GetBrowserContext()));
1529 if (remember) { 1564 if (remember) {
1530 host_zoom_map->SetZoomLevel(net::GetHostOrSpecFromURL(url), zoom_level); 1565 host_zoom_map->SetZoomLevel(net::GetHostOrSpecFromURL(url), zoom_level);
1531 } else { 1566 } else {
1532 host_zoom_map->SetTemporaryZoomLevel( 1567 host_zoom_map->SetTemporaryZoomLevel(
1533 process()->GetID(), routing_id(), zoom_level); 1568 GetProcess()->GetID(), GetRoutingID(), zoom_level);
1534 } 1569 }
1535 } 1570 }
1536 1571
1537 void RenderViewHost::OnMediaNotification(int64 player_cookie, 1572 void RenderViewHostImpl::OnMediaNotification(int64 player_cookie,
1538 bool has_video, 1573 bool has_video,
1539 bool has_audio, 1574 bool has_audio,
1540 bool is_playing) { 1575 bool is_playing) {
1541 if (is_playing) { 1576 if (is_playing) {
1542 PowerSaveBlocker* blocker = NULL; 1577 PowerSaveBlocker* blocker = NULL;
1543 if (has_video) { 1578 if (has_video) {
1544 blocker = new PowerSaveBlocker( 1579 blocker = new PowerSaveBlocker(
1545 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep); 1580 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep);
1546 } else if (has_audio) { 1581 } else if (has_audio) {
1547 blocker = new PowerSaveBlocker( 1582 blocker = new PowerSaveBlocker(
1548 PowerSaveBlocker::kPowerSaveBlockPreventSystemSleep); 1583 PowerSaveBlocker::kPowerSaveBlockPreventSystemSleep);
1549 } 1584 }
1550 1585
1551 if (blocker) 1586 if (blocker)
1552 power_save_blockers_[player_cookie] = blocker; 1587 power_save_blockers_[player_cookie] = blocker;
1553 } else { 1588 } else {
1554 delete power_save_blockers_[player_cookie]; 1589 delete power_save_blockers_[player_cookie];
1555 power_save_blockers_.erase(player_cookie); 1590 power_save_blockers_.erase(player_cookie);
1556 } 1591 }
1557 } 1592 }
1558 1593
1559 void RenderViewHost::OnRequestDesktopNotificationPermission( 1594 void RenderViewHostImpl::OnRequestDesktopNotificationPermission(
1560 const GURL& source_origin, int callback_context) { 1595 const GURL& source_origin, int callback_context) {
1561 content::GetContentClient()->browser()->RequestDesktopNotificationPermission( 1596 content::GetContentClient()->browser()->RequestDesktopNotificationPermission(
1562 source_origin, callback_context, process()->GetID(), routing_id()); 1597 source_origin, callback_context, GetProcess()->GetID(), GetRoutingID());
1563 } 1598 }
1564 1599
1565 void RenderViewHost::OnShowDesktopNotification( 1600 void RenderViewHostImpl::OnShowDesktopNotification(
1566 const content::ShowDesktopNotificationHostMsgParams& params) { 1601 const content::ShowDesktopNotificationHostMsgParams& params) {
1567 // Disallow HTML notifications from javascript: and file: schemes as this 1602 // Disallow HTML notifications from javascript: and file: schemes as this
1568 // allows unwanted cross-domain access. 1603 // allows unwanted cross-domain access.
1569 GURL url = params.contents_url; 1604 GURL url = params.contents_url;
1570 if (params.is_html && 1605 if (params.is_html &&
1571 (url.SchemeIs(chrome::kJavaScriptScheme) || 1606 (url.SchemeIs(chrome::kJavaScriptScheme) ||
1572 url.SchemeIs(chrome::kFileScheme))) { 1607 url.SchemeIs(chrome::kFileScheme))) {
1573 return; 1608 return;
1574 } 1609 }
1575 1610
1576 content::GetContentClient()->browser()->ShowDesktopNotification( 1611 content::GetContentClient()->browser()->ShowDesktopNotification(
1577 params, process()->GetID(), routing_id(), false); 1612 params, GetProcess()->GetID(), GetRoutingID(), false);
1578 } 1613 }
1579 1614
1580 void RenderViewHost::OnCancelDesktopNotification(int notification_id) { 1615 void RenderViewHostImpl::OnCancelDesktopNotification(int notification_id) {
1581 content::GetContentClient()->browser()->CancelDesktopNotification( 1616 content::GetContentClient()->browser()->CancelDesktopNotification(
1582 process()->GetID(), routing_id(), notification_id); 1617 GetProcess()->GetID(), GetRoutingID(), notification_id);
1583 } 1618 }
1584 1619
1585 #if defined(OS_MACOSX) 1620 #if defined(OS_MACOSX)
1586 void RenderViewHost::OnMsgShowPopup( 1621 void RenderViewHostImpl::OnMsgShowPopup(
1587 const ViewHostMsg_ShowPopup_Params& params) { 1622 const ViewHostMsg_ShowPopup_Params& params) {
1588 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 1623 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
1589 if (view) { 1624 if (view) {
1590 view->ShowPopupMenu(params.bounds, 1625 view->ShowPopupMenu(params.bounds,
1591 params.item_height, 1626 params.item_height,
1592 params.item_font_size, 1627 params.item_font_size,
1593 params.selected_item, 1628 params.selected_item,
1594 params.popup_items, 1629 params.popup_items,
1595 params.right_aligned); 1630 params.right_aligned);
1596 } 1631 }
1597 } 1632 }
1598 #endif 1633 #endif
1599 1634
1600 void RenderViewHost::OnRunFileChooser( 1635 void RenderViewHostImpl::OnRunFileChooser(
1601 const content::FileChooserParams& params) { 1636 const content::FileChooserParams& params) {
1602 delegate_->RunFileChooser(this, params); 1637 delegate_->RunFileChooser(this, params);
1603 } 1638 }
1604 1639
1605 void RenderViewHost::OnWebUISend(const GURL& source_url, 1640 void RenderViewHostImpl::OnWebUISend(const GURL& source_url,
1606 const std::string& name, 1641 const std::string& name,
1607 const base::ListValue& args) { 1642 const base::ListValue& args) {
1608 delegate_->WebUISend(this, source_url, name, args); 1643 delegate_->WebUISend(this, source_url, name, args);
1609 } 1644 }
1610 1645
1611 void RenderViewHost::OnDomOperationResponse( 1646 void RenderViewHostImpl::OnDomOperationResponse(
1612 const std::string& json_string, int automation_id) { 1647 const std::string& json_string, int automation_id) {
1613 DomOperationNotificationDetails details(json_string, automation_id); 1648 DomOperationNotificationDetails details(json_string, automation_id);
1614 content::NotificationService::current()->Notify( 1649 content::NotificationService::current()->Notify(
1615 content::NOTIFICATION_DOM_OPERATION_RESPONSE, 1650 content::NOTIFICATION_DOM_OPERATION_RESPONSE,
1616 content::Source<RenderViewHost>(this), 1651 content::Source<RenderViewHost>(this),
1617 content::Details<DomOperationNotificationDetails>(&details)); 1652 content::Details<DomOperationNotificationDetails>(&details));
1618 } 1653 }
1619 1654
1620 void RenderViewHost::SetSwappedOut(bool is_swapped_out) { 1655 void RenderViewHostImpl::SetSwappedOut(bool is_swapped_out) {
1621 is_swapped_out_ = is_swapped_out; 1656 is_swapped_out_ = is_swapped_out;
1622 1657
1623 // Whenever we change swap out state, we should not be waiting for 1658 // Whenever we change swap out state, we should not be waiting for
1624 // beforeunload or unload acks. We clear them here to be safe, since they 1659 // beforeunload or unload acks. We clear them here to be safe, since they
1625 // can cause navigations to be ignored in OnMsgNavigate. 1660 // can cause navigations to be ignored in OnMsgNavigate.
1626 is_waiting_for_beforeunload_ack_ = false; 1661 is_waiting_for_beforeunload_ack_ = false;
1627 is_waiting_for_unload_ack_ = false; 1662 is_waiting_for_unload_ack_ = false;
1628 } 1663 }
1629 1664
1630 void RenderViewHost::ClearPowerSaveBlockers() { 1665 void RenderViewHostImpl::ClearPowerSaveBlockers() {
1631 STLDeleteValues(&power_save_blockers_); 1666 STLDeleteValues(&power_save_blockers_);
1632 } 1667 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host.h ('k') | content/browser/renderer_host/render_view_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698