| 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 #include "content/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 4455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4466 observers_.AddObserver(observer); | 4466 observers_.AddObserver(observer); |
| 4467 } | 4467 } |
| 4468 | 4468 |
| 4469 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) { | 4469 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) { |
| 4470 observer->RenderFrameGone(); | 4470 observer->RenderFrameGone(); |
| 4471 observers_.RemoveObserver(observer); | 4471 observers_.RemoveObserver(observer); |
| 4472 } | 4472 } |
| 4473 | 4473 |
| 4474 void RenderFrameImpl::OnStop() { | 4474 void RenderFrameImpl::OnStop() { |
| 4475 DCHECK(frame_); | 4475 DCHECK(frame_); |
| 4476 |
| 4477 // The stopLoading call may run script, which may cause this frame to be |
| 4478 // detached/deleted. If that happens, return immediately. |
| 4479 base::WeakPtr<RenderFrameImpl> weak_this = weak_factory_.GetWeakPtr(); |
| 4476 frame_->stopLoading(); | 4480 frame_->stopLoading(); |
| 4481 if (!weak_this) |
| 4482 return; |
| 4483 |
| 4477 if (frame_ && !frame_->parent()) | 4484 if (frame_ && !frame_->parent()) |
| 4478 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, OnStop()); | 4485 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, OnStop()); |
| 4479 | 4486 |
| 4480 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); | 4487 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); |
| 4481 } | 4488 } |
| 4482 | 4489 |
| 4483 void RenderFrameImpl::WasHidden() { | 4490 void RenderFrameImpl::WasHidden() { |
| 4484 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); | 4491 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); |
| 4485 | 4492 |
| 4486 #if defined(ENABLE_PLUGINS) | 4493 #if defined(ENABLE_PLUGINS) |
| (...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5531 // Similarly, if the history item just says to stay on about:blank, | 5538 // Similarly, if the history item just says to stay on about:blank, |
| 5532 // don't load it again, which might clobber injected content. | 5539 // don't load it again, which might clobber injected content. |
| 5533 bool interrupted_by_client_redirect = | 5540 bool interrupted_by_client_redirect = |
| 5534 frame_->isNavigationScheduledWithin(0) || | 5541 frame_->isNavigationScheduledWithin(0) || |
| 5535 frame_->provisionalDataSource() || | 5542 frame_->provisionalDataSource() || |
| 5536 !current_history_item_.isNull(); | 5543 !current_history_item_.isNull(); |
| 5537 bool staying_at_about_blank = | 5544 bool staying_at_about_blank = |
| 5538 current_history_item_.isNull() && | 5545 current_history_item_.isNull() && |
| 5539 item_for_history_navigation.urlString() == url::kAboutBlankURL; | 5546 item_for_history_navigation.urlString() == url::kAboutBlankURL; |
| 5540 if (staying_at_about_blank) { | 5547 if (staying_at_about_blank) { |
| 5541 // TODO(creis): We need to generate a commit for the initial empty | 5548 // TODO(creis): We should avoid the need to go to the browser and back |
| 5542 // document, rather than just faking a DidStopLoading. See | 5549 // when loading about:blank as a history item, which we can do by |
| 5543 // https://crbug.com/626416. | 5550 // sending a subtree of same-process history items when navigating a |
| 5551 // frame back/forward (see https://crbug.com/639842). |
| 5552 // |
| 5553 // Until then, we need to fake a DidStopLoading, since there's no easy |
| 5554 // way to generate a commit for the initial empty document at this |
| 5555 // point in time. |
| 5556 // |
| 5557 // Note that the stopLoading call may run script which might delete |
| 5558 // this frame, so return immediately if this frame is no longer valid. |
| 5559 base::WeakPtr<RenderFrameImpl> weak_this = weak_factory_.GetWeakPtr(); |
| 5544 frame_->stopLoading(); | 5560 frame_->stopLoading(); |
| 5561 if (!weak_this) |
| 5562 return; |
| 5545 } | 5563 } |
| 5546 if (request_params.is_history_navigation_in_new_child && | 5564 if (request_params.is_history_navigation_in_new_child && |
| 5547 (interrupted_by_client_redirect || staying_at_about_blank)) { | 5565 (interrupted_by_client_redirect || staying_at_about_blank)) { |
| 5548 should_load_request = false; | 5566 should_load_request = false; |
| 5549 has_history_navigation_in_frame = false; | 5567 has_history_navigation_in_frame = false; |
| 5550 } | 5568 } |
| 5551 | 5569 |
| 5552 // Generate the request for the load from the HistoryItem. | 5570 // Generate the request for the load from the HistoryItem. |
| 5553 // PlzNavigate: use the data sent by the browser for the url and the | 5571 // PlzNavigate: use the data sent by the browser for the url and the |
| 5554 // HTTP state. The restoration of user state such as scroll position | 5572 // HTTP state. The restoration of user state such as scroll position |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6319 // event target. Potentially a Pepper plugin will receive the event. | 6337 // event target. Potentially a Pepper plugin will receive the event. |
| 6320 // In order to tell whether a plugin gets the last mouse event and which it | 6338 // In order to tell whether a plugin gets the last mouse event and which it |
| 6321 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6339 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6322 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6340 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6323 // |pepper_last_mouse_event_target_|. | 6341 // |pepper_last_mouse_event_target_|. |
| 6324 pepper_last_mouse_event_target_ = nullptr; | 6342 pepper_last_mouse_event_target_ = nullptr; |
| 6325 #endif | 6343 #endif |
| 6326 } | 6344 } |
| 6327 | 6345 |
| 6328 } // namespace content | 6346 } // namespace content |
| OLD | NEW |