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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2514323003: Fix UaF in RenderFrameImpl::OnBeforeUnload. (Closed)
Patch Set: add comments Created 4 years 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
« no previous file with comments | « no previous file | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 } 1705 }
1706 1706
1707 void RenderFrameImpl::OnBeforeUnload(bool is_reload) { 1707 void RenderFrameImpl::OnBeforeUnload(bool is_reload) {
1708 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::OnBeforeUnload", 1708 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::OnBeforeUnload",
1709 "id", routing_id_); 1709 "id", routing_id_);
1710 // TODO(creis): Right now, this is only called on the main frame. Make the 1710 // TODO(creis): Right now, this is only called on the main frame. Make the
1711 // browser process send dispatchBeforeUnloadEvent to every frame that needs 1711 // browser process send dispatchBeforeUnloadEvent to every frame that needs
1712 // it. 1712 // it.
1713 CHECK(!frame_->parent()); 1713 CHECK(!frame_->parent());
1714 1714
1715 // Save the routing_id, as the RenderFrameImpl can be deleted in
1716 // dispatchBeforeUnloadEvent. See https://crbug.com/666714 for details.
1717 int routing_id = routing_id_;
1718
1715 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); 1719 base::TimeTicks before_unload_start_time = base::TimeTicks::Now();
1716 bool proceed = frame_->dispatchBeforeUnloadEvent(is_reload); 1720 bool proceed = frame_->dispatchBeforeUnloadEvent(is_reload);
1717 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); 1721 base::TimeTicks before_unload_end_time = base::TimeTicks::Now();
1718 Send(new FrameHostMsg_BeforeUnload_ACK( 1722 RenderThread::Get()->Send(new FrameHostMsg_BeforeUnload_ACK(
1719 routing_id_, proceed, before_unload_start_time, before_unload_end_time)); 1723 routing_id, proceed, before_unload_start_time, before_unload_end_time));
1720 } 1724 }
1721 1725
1722 void RenderFrameImpl::OnSwapOut( 1726 void RenderFrameImpl::OnSwapOut(
1723 int proxy_routing_id, 1727 int proxy_routing_id,
1724 bool is_loading, 1728 bool is_loading,
1725 const FrameReplicationState& replicated_frame_state) { 1729 const FrameReplicationState& replicated_frame_state) {
1726 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::OnSwapOut", 1730 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::OnSwapOut",
1727 "id", routing_id_); 1731 "id", routing_id_);
1728 RenderFrameProxy* proxy = NULL; 1732 RenderFrameProxy* proxy = NULL;
1729 1733
(...skipping 4901 matching lines...) Expand 10 before | Expand all | Expand 10 after
6631 // event target. Potentially a Pepper plugin will receive the event. 6635 // event target. Potentially a Pepper plugin will receive the event.
6632 // In order to tell whether a plugin gets the last mouse event and which it 6636 // In order to tell whether a plugin gets the last mouse event and which it
6633 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6637 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6634 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6638 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6635 // |pepper_last_mouse_event_target_|. 6639 // |pepper_last_mouse_event_target_|.
6636 pepper_last_mouse_event_target_ = nullptr; 6640 pepper_last_mouse_event_target_ = nullptr;
6637 #endif 6641 #endif
6638 } 6642 }
6639 6643
6640 } // namespace content 6644 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698