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

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

Powered by Google App Engine
This is Rietveld 408576698