| 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 4481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4492 observers_.AddObserver(observer); | 4492 observers_.AddObserver(observer); |
| 4493 } | 4493 } |
| 4494 | 4494 |
| 4495 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) { | 4495 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) { |
| 4496 observer->RenderFrameGone(); | 4496 observer->RenderFrameGone(); |
| 4497 observers_.RemoveObserver(observer); | 4497 observers_.RemoveObserver(observer); |
| 4498 } | 4498 } |
| 4499 | 4499 |
| 4500 void RenderFrameImpl::OnStop() { | 4500 void RenderFrameImpl::OnStop() { |
| 4501 DCHECK(frame_); | 4501 DCHECK(frame_); |
| 4502 |
| 4503 // The stopLoading call may run script, which may cause this frame to be |
| 4504 // detached/deleted. If that happens, return immediately. |
| 4505 base::WeakPtr<RenderFrameImpl> weak_this = weak_factory_.GetWeakPtr(); |
| 4502 frame_->stopLoading(); | 4506 frame_->stopLoading(); |
| 4507 if (!weak_this) |
| 4508 return; |
| 4509 |
| 4503 if (frame_ && !frame_->parent()) | 4510 if (frame_ && !frame_->parent()) |
| 4504 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, OnStop()); | 4511 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, OnStop()); |
| 4505 | 4512 |
| 4506 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); | 4513 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); |
| 4507 } | 4514 } |
| 4508 | 4515 |
| 4509 void RenderFrameImpl::WasHidden() { | 4516 void RenderFrameImpl::WasHidden() { |
| 4510 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); | 4517 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); |
| 4511 | 4518 |
| 4512 #if defined(ENABLE_PLUGINS) | 4519 #if defined(ENABLE_PLUGINS) |
| (...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5550 // Similarly, if the history item just says to stay on about:blank, | 5557 // Similarly, if the history item just says to stay on about:blank, |
| 5551 // don't load it again, which might clobber injected content. | 5558 // don't load it again, which might clobber injected content. |
| 5552 bool interrupted_by_client_redirect = | 5559 bool interrupted_by_client_redirect = |
| 5553 frame_->isNavigationScheduledWithin(0) || | 5560 frame_->isNavigationScheduledWithin(0) || |
| 5554 frame_->provisionalDataSource() || | 5561 frame_->provisionalDataSource() || |
| 5555 !current_history_item_.isNull(); | 5562 !current_history_item_.isNull(); |
| 5556 bool staying_at_about_blank = | 5563 bool staying_at_about_blank = |
| 5557 current_history_item_.isNull() && | 5564 current_history_item_.isNull() && |
| 5558 item_for_history_navigation.urlString() == url::kAboutBlankURL; | 5565 item_for_history_navigation.urlString() == url::kAboutBlankURL; |
| 5559 if (staying_at_about_blank) { | 5566 if (staying_at_about_blank) { |
| 5560 // TODO(creis): We need to generate a commit for the initial empty | 5567 // TODO(creis): We should avoid the need to go to the browser and back |
| 5561 // document, rather than just faking a DidStopLoading. See | 5568 // when loading about:blank as a history item, which we can do by |
| 5562 // https://crbug.com/626416. | 5569 // sending a subtree of same-process history items when navigating a |
| 5570 // frame back/forward (see https://crbug.com/639842). |
| 5571 // |
| 5572 // Until then, we need to fake a DidStopLoading, since there's no easy |
| 5573 // way to generate a commit for the initial empty document at this |
| 5574 // point in time. |
| 5575 // |
| 5576 // Note that the stopLoading call may run script which might delete |
| 5577 // this frame, so return immediately if this frame is no longer valid. |
| 5578 base::WeakPtr<RenderFrameImpl> weak_this = weak_factory_.GetWeakPtr(); |
| 5563 frame_->stopLoading(); | 5579 frame_->stopLoading(); |
| 5580 if (!weak_this) |
| 5581 return; |
| 5564 } | 5582 } |
| 5565 if (request_params.is_history_navigation_in_new_child && | 5583 if (request_params.is_history_navigation_in_new_child && |
| 5566 (interrupted_by_client_redirect || staying_at_about_blank)) { | 5584 (interrupted_by_client_redirect || staying_at_about_blank)) { |
| 5567 should_load_request = false; | 5585 should_load_request = false; |
| 5568 has_history_navigation_in_frame = false; | 5586 has_history_navigation_in_frame = false; |
| 5569 } | 5587 } |
| 5570 | 5588 |
| 5571 // Generate the request for the load from the HistoryItem. | 5589 // Generate the request for the load from the HistoryItem. |
| 5572 // PlzNavigate: use the data sent by the browser for the url and the | 5590 // PlzNavigate: use the data sent by the browser for the url and the |
| 5573 // HTTP state. The restoration of user state such as scroll position | 5591 // HTTP state. The restoration of user state such as scroll position |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6348 // event target. Potentially a Pepper plugin will receive the event. | 6366 // event target. Potentially a Pepper plugin will receive the event. |
| 6349 // In order to tell whether a plugin gets the last mouse event and which it | 6367 // In order to tell whether a plugin gets the last mouse event and which it |
| 6350 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6368 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6351 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6369 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6352 // |pepper_last_mouse_event_target_|. | 6370 // |pepper_last_mouse_event_target_|. |
| 6353 pepper_last_mouse_event_target_ = nullptr; | 6371 pepper_last_mouse_event_target_ = nullptr; |
| 6354 #endif | 6372 #endif |
| 6355 } | 6373 } |
| 6356 | 6374 |
| 6357 } // namespace content | 6375 } // namespace content |
| OLD | NEW |