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 | |
216 // Runs the beforeunload handler for this frame. |for_cross_site_transition| | 192 // Runs the beforeunload handler for this frame. |for_cross_site_transition| |
217 // indicates whether this call is for the current frame during a cross-process | 193 // indicates whether this call is for the current frame during a cross-process |
218 // navigation. False means we're closing the entire tab. | 194 // navigation. False means we're closing the entire tab. |
219 void DispatchBeforeUnload(bool for_cross_site_transition); | 195 void DispatchBeforeUnload(bool for_cross_site_transition); |
220 | 196 |
221 // Deletes the current selection plus the specified number of characters | 197 // Deletes the current selection plus the specified number of characters |
222 // before and after the selection or caret. | 198 // before and after the selection or caret. |
223 void ExtendSelectionAndDelete(size_t before, size_t after); | 199 void ExtendSelectionAndDelete(size_t before, size_t after); |
224 | 200 |
225 // Notifies the RenderFrame that the JavaScript message that was shown was | 201 // Notifies the RenderFrame that the JavaScript message that was shown was |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 // this frame, or create one if it doesn't exist yet, otherwise return | 236 // this frame, or create one if it doesn't exist yet, otherwise return |
261 // NULL. | 237 // NULL. |
262 BrowserAccessibilityManager* GetOrCreateBrowserAccessibilityManager(); | 238 BrowserAccessibilityManager* GetOrCreateBrowserAccessibilityManager(); |
263 | 239 |
264 #if defined(OS_WIN) | 240 #if defined(OS_WIN) |
265 void SetParentNativeViewAccessible( | 241 void SetParentNativeViewAccessible( |
266 gfx::NativeViewAccessible accessible_parent); | 242 gfx::NativeViewAccessible accessible_parent); |
267 gfx::NativeViewAccessible GetParentNativeViewAccessible() const; | 243 gfx::NativeViewAccessible GetParentNativeViewAccessible() const; |
268 #endif | 244 #endif |
269 | 245 |
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 | |
281 protected: | 246 protected: |
282 friend class RenderFrameHostFactory; | 247 friend class RenderFrameHostFactory; |
283 | 248 |
284 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 249 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
285 // should be the abstraction needed here, but we need RenderViewHost to pass | 250 // should be the abstraction needed here, but we need RenderViewHost to pass |
286 // into WebContentsObserver::FrameDetached for now. | 251 // into WebContentsObserver::FrameDetached for now. |
287 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, | 252 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, |
288 RenderFrameHostDelegate* delegate, | 253 RenderFrameHostDelegate* delegate, |
289 FrameTree* frame_tree, | 254 FrameTree* frame_tree, |
290 FrameTreeNode* frame_tree_node, | 255 FrameTreeNode* frame_tree_node, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 // ExecuteJavaScript and their corresponding callbacks. | 367 // ExecuteJavaScript and their corresponding callbacks. |
403 std::map<int, JavaScriptResultCallback> javascript_callbacks_; | 368 std::map<int, JavaScriptResultCallback> javascript_callbacks_; |
404 | 369 |
405 // Map from notification_id to a callback to cancel them. | 370 // Map from notification_id to a callback to cancel them. |
406 std::map<int, base::Closure> cancel_notification_callbacks_; | 371 std::map<int, base::Closure> cancel_notification_callbacks_; |
407 | 372 |
408 int routing_id_; | 373 int routing_id_; |
409 bool is_swapped_out_; | 374 bool is_swapped_out_; |
410 bool renderer_initialized_; | 375 bool renderer_initialized_; |
411 | 376 |
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 | |
425 // When the last BeforeUnload message was sent. | 377 // When the last BeforeUnload message was sent. |
426 base::TimeTicks send_before_unload_start_time_; | 378 base::TimeTicks send_before_unload_start_time_; |
427 | 379 |
428 ServiceRegistryImpl service_registry_; | 380 ServiceRegistryImpl service_registry_; |
429 | 381 |
430 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 382 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
431 | 383 |
432 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; | 384 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; |
433 | 385 |
434 // Callback when an event is received, for testing. | 386 // Callback when an event is received, for testing. |
435 base::Callback<void(ui::AXEvent, int)> accessibility_testing_callback_; | 387 base::Callback<void(ui::AXEvent, int)> accessibility_testing_callback_; |
436 // The most recently received accessibility tree - for testing only. | 388 // The most recently received accessibility tree - for testing only. |
437 scoped_ptr<ui::AXTree> ax_tree_for_testing_; | 389 scoped_ptr<ui::AXTree> ax_tree_for_testing_; |
438 | 390 |
439 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 391 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
440 }; | 392 }; |
441 | 393 |
442 } // namespace content | 394 } // namespace content |
443 | 395 |
444 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 396 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
OLD | NEW |