OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // function takes ownership of the provided message pointer. | 182 // function takes ownership of the provided message pointer. |
183 // | 183 // |
184 // If a cross-site request is in progress, we may be suspended while waiting | 184 // If a cross-site request is in progress, we may be suspended while waiting |
185 // for the onbeforeunload handler, so this function might buffer the message | 185 // for the onbeforeunload handler, so this function might buffer the message |
186 // rather than sending it. | 186 // rather than sending it. |
187 void Navigate(const FrameMsg_Navigate_Params& params); | 187 void Navigate(const FrameMsg_Navigate_Params& params); |
188 | 188 |
189 // Load the specified URL; this is a shortcut for Navigate(). | 189 // Load the specified URL; this is a shortcut for Navigate(). |
190 void NavigateToURL(const GURL& url); | 190 void NavigateToURL(const GURL& url); |
191 | 191 |
| 192 // Returns whether navigation messages are currently suspended for this |
| 193 // RenderFrameHost. Only true during a cross-site navigation, while waiting |
| 194 // for the onbeforeunload handler. |
| 195 bool are_navigations_suspended() const { return navigations_suspended_; } |
| 196 |
| 197 // Suspends (or unsuspends) any navigation messages from being sent from this |
| 198 // RenderFrameHost. This is called when a pending RenderFrameHost is created |
| 199 // for a cross-site navigation, because we must suspend any navigations until |
| 200 // we hear back from the old renderer's onbeforeunload handler. Note that it |
| 201 // is important that only one navigation event happen after calling this |
| 202 // method with |suspend| equal to true. If |suspend| is false and there is a |
| 203 // suspended_nav_message_, this will send the message. This function should |
| 204 // only be called to toggle the state; callers should check |
| 205 // are_navigations_suspended() first. If |suspend| is false, the time that the |
| 206 // user decided the navigation should proceed should be passed as |
| 207 // |proceed_time|. |
| 208 void SetNavigationsSuspended(bool suspend, |
| 209 const base::TimeTicks& proceed_time); |
| 210 |
| 211 // Clears any suspended navigation state after a cross-site navigation is |
| 212 // canceled or suspended. This is important if we later return to this |
| 213 // RenderFrameHost. |
| 214 void CancelSuspendedNavigations(); |
| 215 |
192 // Runs the beforeunload handler for this frame. |for_cross_site_transition| | 216 // Runs the beforeunload handler for this frame. |for_cross_site_transition| |
193 // indicates whether this call is for the current frame during a cross-process | 217 // indicates whether this call is for the current frame during a cross-process |
194 // navigation. False means we're closing the entire tab. | 218 // navigation. False means we're closing the entire tab. |
195 void DispatchBeforeUnload(bool for_cross_site_transition); | 219 void DispatchBeforeUnload(bool for_cross_site_transition); |
196 | 220 |
197 // Deletes the current selection plus the specified number of characters | 221 // Deletes the current selection plus the specified number of characters |
198 // before and after the selection or caret. | 222 // before and after the selection or caret. |
199 void ExtendSelectionAndDelete(size_t before, size_t after); | 223 void ExtendSelectionAndDelete(size_t before, size_t after); |
200 | 224 |
201 // Notifies the RenderFrame that the JavaScript message that was shown was | 225 // Notifies the RenderFrame that the JavaScript message that was shown was |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // this frame, or create one if it doesn't exist yet, otherwise return | 260 // this frame, or create one if it doesn't exist yet, otherwise return |
237 // NULL. | 261 // NULL. |
238 BrowserAccessibilityManager* GetOrCreateBrowserAccessibilityManager(); | 262 BrowserAccessibilityManager* GetOrCreateBrowserAccessibilityManager(); |
239 | 263 |
240 #if defined(OS_WIN) | 264 #if defined(OS_WIN) |
241 void SetParentNativeViewAccessible( | 265 void SetParentNativeViewAccessible( |
242 gfx::NativeViewAccessible accessible_parent); | 266 gfx::NativeViewAccessible accessible_parent); |
243 gfx::NativeViewAccessible GetParentNativeViewAccessible() const; | 267 gfx::NativeViewAccessible GetParentNativeViewAccessible() const; |
244 #endif | 268 #endif |
245 | 269 |
| 270 // Returns whether this RenderFrameHost has an outstanding cross-site request. |
| 271 // Cleared when we hear the response and start to swap out the old |
| 272 // RenderFrameHost, or if we hear a commit here without a network request. |
| 273 bool HasPendingCrossSiteRequest(); |
| 274 |
| 275 // Sets whether this RenderFrameHost has an outstanding cross-site request, |
| 276 // for which another renderer will need to run an onunload event handler. |
| 277 // This is called before the first navigation event for this RenderFrameHost, |
| 278 // and cleared when we hear the response or commit. |
| 279 void SetHasPendingCrossSiteRequest(bool has_pending_request); |
| 280 |
246 protected: | 281 protected: |
247 friend class RenderFrameHostFactory; | 282 friend class RenderFrameHostFactory; |
248 | 283 |
249 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 284 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
250 // should be the abstraction needed here, but we need RenderViewHost to pass | 285 // should be the abstraction needed here, but we need RenderViewHost to pass |
251 // into WebContentsObserver::FrameDetached for now. | 286 // into WebContentsObserver::FrameDetached for now. |
252 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, | 287 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, |
253 RenderFrameHostDelegate* delegate, | 288 RenderFrameHostDelegate* delegate, |
254 FrameTree* frame_tree, | 289 FrameTree* frame_tree, |
255 FrameTreeNode* frame_tree_node, | 290 FrameTreeNode* frame_tree_node, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 // ExecuteJavaScript and their corresponding callbacks. | 402 // ExecuteJavaScript and their corresponding callbacks. |
368 std::map<int, JavaScriptResultCallback> javascript_callbacks_; | 403 std::map<int, JavaScriptResultCallback> javascript_callbacks_; |
369 | 404 |
370 // Map from notification_id to a callback to cancel them. | 405 // Map from notification_id to a callback to cancel them. |
371 std::map<int, base::Closure> cancel_notification_callbacks_; | 406 std::map<int, base::Closure> cancel_notification_callbacks_; |
372 | 407 |
373 int routing_id_; | 408 int routing_id_; |
374 bool is_swapped_out_; | 409 bool is_swapped_out_; |
375 bool renderer_initialized_; | 410 bool renderer_initialized_; |
376 | 411 |
| 412 // Whether we should buffer outgoing Navigate messages rather than sending |
| 413 // them. This will be true when a RenderFrameHost is created for a cross-site |
| 414 // request, until we hear back from the onbeforeunload handler of the old |
| 415 // RenderFrameHost. |
| 416 bool navigations_suspended_; |
| 417 |
| 418 // We only buffer the params for a suspended navigation while this RFH is the |
| 419 // pending RenderFrameHost of a RenderFrameHostManager. There will only ever |
| 420 // be one suspended navigation, because RenderFrameHostManager will destroy |
| 421 // the pending RenderFrameHost and create a new one if a second navigation |
| 422 // occurs. |
| 423 scoped_ptr<FrameMsg_Navigate_Params> suspended_nav_params_; |
| 424 |
377 // When the last BeforeUnload message was sent. | 425 // When the last BeforeUnload message was sent. |
378 base::TimeTicks send_before_unload_start_time_; | 426 base::TimeTicks send_before_unload_start_time_; |
379 | 427 |
380 ServiceRegistryImpl service_registry_; | 428 ServiceRegistryImpl service_registry_; |
381 | 429 |
382 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 430 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
383 | 431 |
384 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; | 432 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; |
385 | 433 |
386 // Callback when an event is received, for testing. | 434 // Callback when an event is received, for testing. |
387 base::Callback<void(ui::AXEvent, int)> accessibility_testing_callback_; | 435 base::Callback<void(ui::AXEvent, int)> accessibility_testing_callback_; |
388 // The most recently received accessibility tree - for testing only. | 436 // The most recently received accessibility tree - for testing only. |
389 scoped_ptr<ui::AXTree> ax_tree_for_testing_; | 437 scoped_ptr<ui::AXTree> ax_tree_for_testing_; |
390 | 438 |
391 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 439 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
392 }; | 440 }; |
393 | 441 |
394 } // namespace content | 442 } // namespace content |
395 | 443 |
396 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 444 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
OLD | NEW |