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

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: New patch, still not quite done 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/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/time.h" 17 #include "base/time.h"
18 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "content/browser/browser_context.h" 20 #include "content/browser/browser_context.h"
21 #include "content/browser/browser_message_filter.h" 21 #include "content/browser/browser_message_filter.h"
22 #include "content/browser/browsing_instance_frame_id.h"
22 #include "content/browser/child_process_security_policy.h" 23 #include "content/browser/child_process_security_policy.h"
23 #include "content/browser/cross_site_request_manager.h" 24 #include "content/browser/cross_site_request_manager.h"
25 #include "content/browser/frame_map.h"
24 #include "content/browser/host_zoom_map.h" 26 #include "content/browser/host_zoom_map.h"
25 #include "content/browser/in_process_webkit/session_storage_namespace.h" 27 #include "content/browser/in_process_webkit/session_storage_namespace.h"
26 #include "content/browser/power_save_blocker.h" 28 #include "content/browser/power_save_blocker.h"
27 #include "content/browser/renderer_host/render_process_host_impl.h" 29 #include "content/browser/renderer_host/render_process_host_impl.h"
28 #include "content/browser/renderer_host/render_view_host_delegate.h" 30 #include "content/browser/renderer_host/render_view_host_delegate.h"
29 #include "content/browser/renderer_host/render_widget_host.h" 31 #include "content/browser/renderer_host/render_widget_host.h"
30 #include "content/browser/renderer_host/render_widget_host_view.h" 32 #include "content/browser/renderer_host/render_widget_host_view.h"
31 #include "content/browser/site_instance.h" 33 #include "content/browser/site_instance.h"
32 #include "content/browser/user_metrics.h" 34 #include "content/browser/user_metrics.h"
33 #include "content/common/desktop_notification_messages.h" 35 #include "content/common/desktop_notification_messages.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 256
255 void RenderViewHost::NavigateToURL(const GURL& url) { 257 void RenderViewHost::NavigateToURL(const GURL& url) {
256 ViewMsg_Navigate_Params params; 258 ViewMsg_Navigate_Params params;
257 params.page_id = -1; 259 params.page_id = -1;
258 params.pending_history_list_offset = -1; 260 params.pending_history_list_offset = -1;
259 params.current_history_list_offset = -1; 261 params.current_history_list_offset = -1;
260 params.current_history_list_length = 0; 262 params.current_history_list_length = 0;
261 params.url = url; 263 params.url = url;
262 params.transition = content::PAGE_TRANSITION_LINK; 264 params.transition = content::PAGE_TRANSITION_LINK;
263 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; 265 params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
266 params.opener_browsing_instance_frame_id = -1;
264 Navigate(params); 267 Navigate(params);
265 } 268 }
266 269
267 void RenderViewHost::SetNavigationsSuspended(bool suspend) { 270 void RenderViewHost::SetNavigationsSuspended(bool suspend) {
268 // This should only be called to toggle the state. 271 // This should only be called to toggle the state.
269 DCHECK(navigations_suspended_ != suspend); 272 DCHECK(navigations_suspended_ != suspend);
270 273
271 navigations_suspended_ = suspend; 274 navigations_suspended_ = suspend;
272 if (!suspend && suspended_nav_message_.get()) { 275 if (!suspend && suspended_nav_message_.get()) {
273 // There's a navigation message waiting to be sent. Now that we're not 276 // There's a navigation message waiting to be sent. Now that we're not
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // already decided to silence them in crbug.com/68780. We will set it back 327 // already decided to silence them in crbug.com/68780. We will set it back
325 // to false in SetNavigationsSuspended if we swap back in. 328 // to false in SetNavigationsSuspended if we swap back in.
326 is_swapped_out_ = true; 329 is_swapped_out_ = true;
327 330
328 // This will be set back to false in OnSwapOutACK, just before we replace 331 // This will be set back to false in OnSwapOutACK, just before we replace
329 // this RVH with the pending RVH. 332 // this RVH with the pending RVH.
330 is_waiting_for_unload_ack_ = true; 333 is_waiting_for_unload_ack_ = true;
331 // Start the hang monitor in case the renderer hangs in the unload handler. 334 // Start the hang monitor in case the renderer hangs in the unload handler.
332 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 335 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
333 336
337 content::FrameMap& frame_mapper =
338 process()->GetBrowserContext()->frame_mapper();
339 content::BrowsingInstanceFrame* topLevelFrame =
340 frame_mapper.FindTopLevelFrameByProcessAndRoute(process()->GetID(),
341 routing_id());
342 DCHECK(topLevelFrame);
343
334 ViewMsg_SwapOut_Params params; 344 ViewMsg_SwapOut_Params params;
335 params.closing_process_id = process()->GetID(); 345 params.closing_process_id = process()->GetID();
336 params.closing_route_id = routing_id(); 346 params.closing_route_id = routing_id();
337 params.new_render_process_host_id = new_render_process_host_id; 347 params.new_render_process_host_id = new_render_process_host_id;
338 params.new_request_id = new_request_id; 348 params.new_request_id = new_request_id;
349 params.browsing_instance_frame_id = topLevelFrame->id();
350
339 if (IsRenderViewLive()) { 351 if (IsRenderViewLive()) {
340 Send(new ViewMsg_SwapOut(routing_id(), params)); 352 Send(new ViewMsg_SwapOut(routing_id(), params));
341 } else { 353 } else {
342 // This RenderViewHost doesn't have a live renderer, so just skip the unload 354 // This RenderViewHost doesn't have a live renderer, so just skip the unload
343 // event. We must notify the ResourceDispatcherHost on the IO thread, 355 // event. We must notify the ResourceDispatcherHost on the IO thread,
344 // which we will do through the RenderProcessHost's widget helper. 356 // which we will do through the RenderProcessHost's widget helper.
345 process()->CrossSiteSwapOutACK(params); 357 process()->CrossSiteSwapOutACK(params);
346 } 358 }
347 } 359 }
348 360
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 FilterURL(policy, renderer_id, &validated_params.frame_url); 1012 FilterURL(policy, renderer_id, &validated_params.frame_url);
1001 1013
1002 view->ShowContextMenu(validated_params); 1014 view->ShowContextMenu(validated_params);
1003 } 1015 }
1004 1016
1005 void RenderViewHost::OnMsgToggleFullscreen(bool enter_fullscreen) { 1017 void RenderViewHost::OnMsgToggleFullscreen(bool enter_fullscreen) {
1006 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1018 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1007 delegate_->ToggleFullscreenMode(enter_fullscreen); 1019 delegate_->ToggleFullscreenMode(enter_fullscreen);
1008 } 1020 }
1009 1021
1010 void RenderViewHost::OnMsgOpenURL(const GURL& url, 1022 void RenderViewHost::OnMsgOpenURL(const ViewHostMsg_OpenURL_Params& params) {
1011 const content::Referrer& referrer, 1023 GURL validated_url(params.url);
1012 WindowOpenDisposition disposition,
1013 int64 source_frame_id) {
1014 GURL validated_url(url);
1015 FilterURL(ChildProcessSecurityPolicy::GetInstance(), 1024 FilterURL(ChildProcessSecurityPolicy::GetInstance(),
1016 process()->GetID(), &validated_url); 1025 process()->GetID(), &validated_url);
1017 1026
1018 delegate_->RequestOpenURL( 1027 // Translate the RenderView's opener_frame_id to browsing instance frame id
1019 validated_url, referrer, disposition, source_frame_id); 1028 int64 opener_browsing_instance_frame_id = -1;
1029 DLOG(WARNING) << "OnMsgOpenURL, opener_frame_id = " << params.opener_frame_id;
1030 if (params.opener_frame_id) {
1031 DLOG(WARNING) << "Mapping opener_frame_id " << params.opener_frame_id;
1032 DLOG(WARNING) << "Process = " << process()->GetID();
1033 content::FrameMap& frame_mapper =
1034 process()->GetBrowserContext()->frame_mapper();
1035 content::BrowsingInstanceFrame* opener = frame_mapper.FindByWebKitId(
1036 process()->GetID(), params.opener_frame_id);
1037 if (opener) {
1038 DLOG(WARNING) << "Opener is " << opener->id();
1039 opener_browsing_instance_frame_id = opener->id();
1040 } else {
1041 DLOG(WARNING) << "Opener not found";
1042 }
1043 }
1044 delegate_->RequestOpenURL(validated_url, params.referrer,
1045 params.disposition, params.source_frame_id,
1046 opener_browsing_instance_frame_id);
1020 } 1047 }
1021 1048
1022 void RenderViewHost::OnMsgDidContentsPreferredSizeChange( 1049 void RenderViewHost::OnMsgDidContentsPreferredSizeChange(
1023 const gfx::Size& new_size) { 1050 const gfx::Size& new_size) {
1024 delegate_->UpdatePreferredSize(new_size); 1051 delegate_->UpdatePreferredSize(new_size);
1025 } 1052 }
1026 1053
1027 void RenderViewHost::OnRenderAutoResized(const gfx::Size& new_size) { 1054 void RenderViewHost::OnRenderAutoResized(const gfx::Size& new_size) {
1028 delegate_->UpdatePreferredSize(new_size); 1055 delegate_->UpdatePreferredSize(new_size);
1029 } 1056 }
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 1547
1521 void RenderViewHost::OnWebUISend(const GURL& source_url, 1548 void RenderViewHost::OnWebUISend(const GURL& source_url,
1522 const std::string& name, 1549 const std::string& name,
1523 const base::ListValue& args) { 1550 const base::ListValue& args) {
1524 delegate_->WebUISend(this, source_url, name, args); 1551 delegate_->WebUISend(this, source_url, name, args);
1525 } 1552 }
1526 1553
1527 void RenderViewHost::ClearPowerSaveBlockers() { 1554 void RenderViewHost::ClearPowerSaveBlockers() {
1528 STLDeleteValues(&power_save_blockers_); 1555 STLDeleteValues(&power_save_blockers_);
1529 } 1556 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698