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

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

Issue 6319001: Support window.opener after a process swap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better message filtering approach. Created 9 years, 7 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) 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // RenderViewHost. This is called when a pending RenderViewHost is created 153 // RenderViewHost. This is called when a pending RenderViewHost is created
154 // for a cross-site navigation, because we must suspend any navigations until 154 // for a cross-site navigation, because we must suspend any navigations until
155 // we hear back from the old renderer's onbeforeunload handler. Note that it 155 // we hear back from the old renderer's onbeforeunload handler. Note that it
156 // is important that only one navigation event happen after calling this 156 // is important that only one navigation event happen after calling this
157 // method with |suspend| equal to true. If |suspend| is false and there is 157 // method with |suspend| equal to true. If |suspend| is false and there is
158 // a suspended_nav_message_, this will send the message. This function 158 // a suspended_nav_message_, this will send the message. This function
159 // should only be called to toggle the state; callers should check 159 // should only be called to toggle the state; callers should check
160 // are_navigations_suspended() first. 160 // are_navigations_suspended() first.
161 void SetNavigationsSuspended(bool suspend); 161 void SetNavigationsSuspended(bool suspend);
162 162
163 // Clears any suspended navigation state after a cross-site navigation is
164 // canceled or suspended. This is important if we later return to this
165 // RenderViewHost.
166 void CancelSuspendedNavigations();
167
168 // Whether this RenderViewHost has been swapped out to be displayed by a
169 // different process.
170 bool is_swapped_out() const { return is_swapped_out_; }
171
163 // Causes the renderer to invoke the onbeforeunload event handler. The 172 // Causes the renderer to invoke the onbeforeunload event handler. The
164 // result will be returned via ViewMsg_ShouldClose. See also ClosePage which 173 // result will be returned via ViewMsg_ShouldClose. See also ClosePage and
165 // will fire the PageUnload event. 174 // SwapOut, which fire the PageUnload event.
166 // 175 //
167 // Set bool for_cross_site_transition when this close is just for the current 176 // Set bool for_cross_site_transition when this close is just for the current
168 // RenderView in the case of a cross-site transition. False means we're 177 // RenderView in the case of a cross-site transition. False means we're
169 // closing the entire tab. 178 // closing the entire tab.
170 void FirePageBeforeUnload(bool for_cross_site_transition); 179 void FirePageBeforeUnload(bool for_cross_site_transition);
171 180
181 // Tells the renderer that this RenderView is being swapped out for one in a
182 // different renderer process. The renderer should preserve the Frame object
183 // until it exits (when it has no more active RenderViews).
184 //
185 // Please see ViewMsg_SwapOut_Params in view_messages.h for a description
186 // of the parameters.
187 void SwapOut(int new_render_process_host_id, int new_request_id);
188
189 // Called by ResourceDispatcherHost after the SwapOutACK is received.
190 void OnSwapOutACK();
191
192 // Called to notify the RenderWidget that it has been visibly swapped out,
Matt Perry 2011/04/29 19:25:18 RenderView
Charlie Reis 2011/05/05 15:17:59 Done.
193 // such that it is safe for the process to exit if not otherwise in use.
194 void WasSwappedOut();
Matt Perry 2011/04/29 19:25:18 I'm a little confused on the difference between Sw
Charlie Reis 2011/05/05 15:17:59 Done.
195
172 // Causes the renderer to close the current page, including running its 196 // Causes the renderer to close the current page, including running its
173 // onunload event handler. A ClosePage_ACK message will be sent to the 197 // onunload event handler. A ClosePage_ACK message will be sent to the
174 // ResourceDispatcherHost when it is finished. 198 // ResourceDispatcherHost when it is finished.
175 // 199 void ClosePage();
176 // Please see ViewMsg_ClosePage in resource_messages_internal.h for a
177 // description of the parameters.
178 void ClosePage(bool for_cross_site_transition,
179 int new_render_process_host_id,
180 int new_request_id);
181
182 // Called by ResourceDispatcherHost after the ClosePageACK is received.
183 void OnClosePageACK(bool for_cross_site_transition);
184 200
185 // Close the page ignoring whether it has unload events registers. 201 // Close the page ignoring whether it has unload events registers.
186 // This is called after the beforeunload and unload events have fired 202 // This is called after the beforeunload and unload events have fired
187 // and the user has agreed to continue with closing the page. 203 // and the user has agreed to continue with closing the page.
188 void ClosePageIgnoringUnloadEvents(); 204 void ClosePageIgnoringUnloadEvents();
189 205
190 // Sets whether this RenderViewHost has an outstanding cross-site request, 206 // Sets whether this RenderViewHost has an outstanding cross-site request,
191 // for which another renderer will need to run an onunload event handler. 207 // for which another renderer will need to run an onunload event handler.
192 // This is called before the first navigation event for this RenderViewHost, 208 // This is called before the first navigation event for this RenderViewHost,
193 // and again after the corresponding OnCrossSiteResponse. 209 // and again after the corresponding OnCrossSiteResponse.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 GURL* url); 462 GURL* url);
447 463
448 protected: 464 protected:
449 friend class RenderViewHostObserver; 465 friend class RenderViewHostObserver;
450 466
451 // Add and remove observers for filtering IPC messages. Clients must be sure 467 // Add and remove observers for filtering IPC messages. Clients must be sure
452 // to remove the observer before they go away. 468 // to remove the observer before they go away.
453 void AddObserver(RenderViewHostObserver* observer); 469 void AddObserver(RenderViewHostObserver* observer);
454 void RemoveObserver(RenderViewHostObserver* observer); 470 void RemoveObserver(RenderViewHostObserver* observer);
455 471
472 // Filter out most IPC messages while swapped out, except for messages needed
473 // to preserve consistent browser and renderer state.
474 bool CanHandleWhileSwappedOut(const IPC::Message& msg);
475
456 // RenderWidgetHost protected overrides. 476 // RenderWidgetHost protected overrides.
457 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 477 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
458 bool* is_keyboard_shortcut); 478 bool* is_keyboard_shortcut);
459 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event); 479 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event);
460 virtual void OnUserGesture(); 480 virtual void OnUserGesture();
461 virtual void NotifyRendererUnresponsive(); 481 virtual void NotifyRendererUnresponsive();
462 virtual void NotifyRendererResponsive(); 482 virtual void NotifyRendererResponsive();
463 virtual void OnMsgFocusedNodeChanged(bool is_editable_node); 483 virtual void OnMsgFocusedNodeChanged(bool is_editable_node);
464 virtual void OnMsgFocus(); 484 virtual void OnMsgFocus();
465 virtual void OnMsgBlur(); 485 virtual void OnMsgBlur();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 const gfx::Point& image_offset); 532 const gfx::Point& image_offset);
513 void OnUpdateDragCursor(WebKit::WebDragOperation drag_operation); 533 void OnUpdateDragCursor(WebKit::WebDragOperation drag_operation);
514 void OnTakeFocus(bool reverse); 534 void OnTakeFocus(bool reverse);
515 void OnAddMessageToConsole(int32 level, 535 void OnAddMessageToConsole(int32 level,
516 const std::wstring& message, 536 const std::wstring& message,
517 int32 line_no, 537 int32 line_no,
518 const std::wstring& source_id); 538 const std::wstring& source_id);
519 void OnUpdateInspectorSetting(const std::string& key, 539 void OnUpdateInspectorSetting(const std::string& key,
520 const std::string& value); 540 const std::string& value);
521 void OnMsgShouldCloseACK(bool proceed); 541 void OnMsgShouldCloseACK(bool proceed);
542 void OnMsgClosePageACK();
522 543
523 void OnAccessibilityNotifications( 544 void OnAccessibilityNotifications(
524 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params); 545 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params);
525 void OnCSSInserted(); 546 void OnCSSInserted();
526 void OnContentBlocked(ContentSettingsType type, 547 void OnContentBlocked(ContentSettingsType type,
527 const std::string& resource_identifier); 548 const std::string& resource_identifier);
528 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy); 549 void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy);
529 void OnWebDatabaseAccessed(const GURL& url, 550 void OnWebDatabaseAccessed(const GURL& url,
530 const string16& name, 551 const string16& name,
531 const string16& display_name, 552 const string16& display_name,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 // request, until we hear back from the onbeforeunload handler of the old 595 // request, until we hear back from the onbeforeunload handler of the old
575 // RenderViewHost. 596 // RenderViewHost.
576 bool navigations_suspended_; 597 bool navigations_suspended_;
577 598
578 // We only buffer a suspended navigation message while we a pending RVH for a 599 // We only buffer a suspended navigation message while we a pending RVH for a
579 // TabContents. There will only ever be one suspended navigation, because 600 // TabContents. There will only ever be one suspended navigation, because
580 // TabContents will destroy the pending RVH and create a new one if a second 601 // TabContents will destroy the pending RVH and create a new one if a second
581 // navigation occurs. 602 // navigation occurs.
582 scoped_ptr<ViewMsg_Navigate> suspended_nav_message_; 603 scoped_ptr<ViewMsg_Navigate> suspended_nav_message_;
583 604
605 // Whether this RenderViewHost is currently swapped out, such that the view is
606 // being rendered by another process.
607 bool is_swapped_out_;
608
584 // If we were asked to RunModal, then this will hold the reply_msg that we 609 // If we were asked to RunModal, then this will hold the reply_msg that we
585 // must return to the renderer to unblock it. 610 // must return to the renderer to unblock it.
586 IPC::Message* run_modal_reply_msg_; 611 IPC::Message* run_modal_reply_msg_;
587 612
588 // Set to true when there is a pending ViewMsg_ShouldClose message. This 613 // Set to true when there is a pending ViewMsg_ShouldClose message. This
589 // ensures we don't spam the renderer with multiple beforeunload requests. 614 // ensures we don't spam the renderer with multiple beforeunload requests.
590 // When either this value or is_waiting_for_unload_ack_ is true, the value of 615 // When either this value or is_waiting_for_unload_ack_ is true, the value of
591 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a 616 // unload_ack_is_for_cross_site_transition_ indicates whether this is for a
592 // cross-site transition or a tab close attempt. 617 // cross-site transition or a tab close attempt.
593 bool is_waiting_for_beforeunload_ack_; 618 bool is_waiting_for_beforeunload_ack_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // The enabled/disabled states of various commands. 651 // The enabled/disabled states of various commands.
627 std::map<RenderViewCommand, CommandState> command_states_; 652 std::map<RenderViewCommand, CommandState> command_states_;
628 653
629 // A list of observers that filter messages. Weak references. 654 // A list of observers that filter messages. Weak references.
630 ObserverList<RenderViewHostObserver> observers_; 655 ObserverList<RenderViewHostObserver> observers_;
631 656
632 DISALLOW_COPY_AND_ASSIGN(RenderViewHost); 657 DISALLOW_COPY_AND_ASSIGN(RenderViewHost);
633 }; 658 };
634 659
635 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_ 660 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698