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

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

Issue 8760024: Cross-process postMessage (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_view_host.h" 5 #include "content/browser/renderer_host/render_view_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "content/browser/browser_context.h" 19 #include "content/browser/browser_context.h"
20 #include "content/browser/browser_message_filter.h" 20 #include "content/browser/browser_message_filter.h"
21 #include "content/browser/browsing_instance_frame_id.h"
21 #include "content/browser/child_process_security_policy.h" 22 #include "content/browser/child_process_security_policy.h"
22 #include "content/browser/cross_site_request_manager.h" 23 #include "content/browser/cross_site_request_manager.h"
24 #include "content/browser/frame_mapper.h"
23 #include "content/browser/host_zoom_map.h" 25 #include "content/browser/host_zoom_map.h"
24 #include "content/browser/in_process_webkit/session_storage_namespace.h" 26 #include "content/browser/in_process_webkit/session_storage_namespace.h"
25 #include "content/browser/power_save_blocker.h" 27 #include "content/browser/power_save_blocker.h"
26 #include "content/browser/renderer_host/render_process_host_impl.h" 28 #include "content/browser/renderer_host/render_process_host_impl.h"
27 #include "content/browser/renderer_host/render_view_host_delegate.h" 29 #include "content/browser/renderer_host/render_view_host_delegate.h"
28 #include "content/browser/renderer_host/render_widget_host.h" 30 #include "content/browser/renderer_host/render_widget_host.h"
29 #include "content/browser/renderer_host/render_widget_host_view.h" 31 #include "content/browser/renderer_host/render_widget_host_view.h"
30 #include "content/browser/site_instance.h" 32 #include "content/browser/site_instance.h"
31 #include "content/browser/user_metrics.h" 33 #include "content/browser/user_metrics.h"
32 #include "content/common/desktop_notification_messages.h" 34 #include "content/common/desktop_notification_messages.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // already decided to silence them in crbug.com/68780. We will set it back 325 // already decided to silence them in crbug.com/68780. We will set it back
324 // to false in SetNavigationsSuspended if we swap back in. 326 // to false in SetNavigationsSuspended if we swap back in.
325 is_swapped_out_ = true; 327 is_swapped_out_ = true;
326 328
327 // This will be set back to false in OnSwapOutACK, just before we replace 329 // This will be set back to false in OnSwapOutACK, just before we replace
328 // this RVH with the pending RVH. 330 // this RVH with the pending RVH.
329 is_waiting_for_unload_ack_ = true; 331 is_waiting_for_unload_ack_ = true;
330 // Start the hang monitor in case the renderer hangs in the unload handler. 332 // Start the hang monitor in case the renderer hangs in the unload handler.
331 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 333 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
332 334
335 content::FrameMapper& frame_mapper =
336 process()->GetBrowserContext()->frame_mapper();
337 content::BrowsingInstanceFrame* topLevelFrame =
338 frame_mapper.FindTopLevelFrameByProcessAndRoute(process()->GetID(),
339 routing_id());
340 DCHECK(topLevelFrame);
341
333 ViewMsg_SwapOut_Params params; 342 ViewMsg_SwapOut_Params params;
334 params.closing_process_id = process()->GetID(); 343 params.closing_process_id = process()->GetID();
335 params.closing_route_id = routing_id(); 344 params.closing_route_id = routing_id();
336 params.new_render_process_host_id = new_render_process_host_id; 345 params.new_render_process_host_id = new_render_process_host_id;
337 params.new_request_id = new_request_id; 346 params.new_request_id = new_request_id;
347 params.browsing_instance_frame_id = topLevelFrame->id();
348
338 if (IsRenderViewLive()) { 349 if (IsRenderViewLive()) {
339 Send(new ViewMsg_SwapOut(routing_id(), params)); 350 Send(new ViewMsg_SwapOut(routing_id(), params));
340 } else { 351 } else {
341 // This RenderViewHost doesn't have a live renderer, so just skip the unload 352 // This RenderViewHost doesn't have a live renderer, so just skip the unload
342 // event. We must notify the ResourceDispatcherHost on the IO thread, 353 // event. We must notify the ResourceDispatcherHost on the IO thread,
343 // which we will do through the RenderProcessHost's widget helper. 354 // which we will do through the RenderProcessHost's widget helper.
344 process()->CrossSiteSwapOutACK(params); 355 process()->CrossSiteSwapOutACK(params);
345 } 356 }
346 } 357 }
347 358
(...skipping 24 matching lines...) Expand all
372 content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, 383 content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW,
373 content::Source<RenderViewHost>(this), 384 content::Source<RenderViewHost>(this),
374 content::NotificationService::NoDetails()); 385 content::NotificationService::NoDetails());
375 386
376 Send(new ViewMsg_ClosePage(routing_id())); 387 Send(new ViewMsg_ClosePage(routing_id()));
377 } else { 388 } else {
378 // This RenderViewHost doesn't have a live renderer, so just skip the unload 389 // This RenderViewHost doesn't have a live renderer, so just skip the unload
379 // event and close the page. 390 // event and close the page.
380 ClosePageIgnoringUnloadEvents(); 391 ClosePageIgnoringUnloadEvents();
381 } 392 }
393
394 // Remove the top-level frame from the frame mapper
395 content::FrameMapper& frame_mapper =
396 process()->GetBrowserContext()->frame_mapper();
397 content::BrowsingInstanceFrame* topLevelFrame =
398 frame_mapper.FindTopLevelFrameByProcessAndRoute(process()->GetID(),
399 routing_id());
400 frame_mapper.RemoveFrame(topLevelFrame);
401 // TODO(supersat): This should probably remove the proxy on the other side
382 } 402 }
383 403
384 void RenderViewHost::ClosePageIgnoringUnloadEvents() { 404 void RenderViewHost::ClosePageIgnoringUnloadEvents() {
385 StopHangMonitorTimeout(); 405 StopHangMonitorTimeout();
386 is_waiting_for_beforeunload_ack_ = false; 406 is_waiting_for_beforeunload_ack_ = false;
387 is_waiting_for_unload_ack_ = false; 407 is_waiting_for_unload_ack_ = false;
388 408
389 sudden_termination_allowed_ = true; 409 sudden_termination_allowed_ = true;
390 delegate_->Close(this); 410 delegate_->Close(this);
391 } 411 }
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 FilterURL(policy, renderer_id, &validated_params.frame_url); 1018 FilterURL(policy, renderer_id, &validated_params.frame_url);
999 1019
1000 view->ShowContextMenu(validated_params); 1020 view->ShowContextMenu(validated_params);
1001 } 1021 }
1002 1022
1003 void RenderViewHost::OnMsgToggleFullscreen(bool enter_fullscreen) { 1023 void RenderViewHost::OnMsgToggleFullscreen(bool enter_fullscreen) {
1004 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1024 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1005 delegate_->ToggleFullscreenMode(enter_fullscreen); 1025 delegate_->ToggleFullscreenMode(enter_fullscreen);
1006 } 1026 }
1007 1027
1008 void RenderViewHost::OnMsgOpenURL(const GURL& url, 1028 void RenderViewHost::OnMsgOpenURL(const ViewHostMsg_OpenURL_Params& params) {
1009 const GURL& referrer, 1029 GURL validated_url(params.url);
1010 WindowOpenDisposition disposition,
1011 int64 source_frame_id) {
1012 GURL validated_url(url);
1013 FilterURL(ChildProcessSecurityPolicy::GetInstance(), 1030 FilterURL(ChildProcessSecurityPolicy::GetInstance(),
1014 process()->GetID(), &validated_url); 1031 process()->GetID(), &validated_url);
1015 1032
1016 delegate_->RequestOpenURL( 1033 // Translate the RenderView's opener_frame_id to browsing instance frame id
1017 validated_url, referrer, disposition, source_frame_id); 1034 int64 opener_browsing_instance_frame_id = -1;
1035 DLOG(WARNING) << "OnMsgOpenURL, opener_frame_id = " << params.opener_frame_id;
1036 if (params.opener_frame_id) {
1037 DLOG(WARNING) << "Mapping opener_frame_id " << params.opener_frame_id;
1038 DLOG(WARNING) << "Process = " << process()->GetID();
1039 content::FrameMapper& frame_mapper =
1040 process()->GetBrowserContext()->frame_mapper();
1041 content::BrowsingInstanceFrame* opener = frame_mapper.FindByWebKitId(
1042 process()->GetID(), params.opener_frame_id);
1043 if (opener) {
1044 DLOG(WARNING) << "Opener is " << opener->id();
1045 opener_browsing_instance_frame_id = opener->id();
1046 } else {
1047 DLOG(WARNING) << "Opener not found";
1048 }
1049 }
1050 delegate_->RequestOpenURL(validated_url, params.referrer,
1051 params.disposition, params.source_frame_id,
1052 opener_browsing_instance_frame_id);
1018 } 1053 }
1019 1054
1020 void RenderViewHost::OnMsgDidContentsPreferredSizeChange( 1055 void RenderViewHost::OnMsgDidContentsPreferredSizeChange(
1021 const gfx::Size& new_size) { 1056 const gfx::Size& new_size) {
1022 delegate_->UpdatePreferredSize(new_size); 1057 delegate_->UpdatePreferredSize(new_size);
1023 } 1058 }
1024 1059
1025 void RenderViewHost::OnMsgDidChangeScrollbarsForMainFrame( 1060 void RenderViewHost::OnMsgDidChangeScrollbarsForMainFrame(
1026 bool has_horizontal_scrollbar, bool has_vertical_scrollbar) { 1061 bool has_horizontal_scrollbar, bool has_vertical_scrollbar) {
1027 if (view()) 1062 if (view())
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 1537
1503 void RenderViewHost::OnWebUISend(const GURL& source_url, 1538 void RenderViewHost::OnWebUISend(const GURL& source_url,
1504 const std::string& name, 1539 const std::string& name,
1505 const base::ListValue& args) { 1540 const base::ListValue& args) {
1506 delegate_->WebUISend(this, source_url, name, args); 1541 delegate_->WebUISend(this, source_url, name, args);
1507 } 1542 }
1508 1543
1509 void RenderViewHost::ClearPowerSaveBlockers() { 1544 void RenderViewHost::ClearPowerSaveBlockers() {
1510 STLDeleteValues(&power_save_blockers_); 1545 STLDeleteValues(&power_save_blockers_);
1511 } 1546 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698