OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 5606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5617 | 5617 |
5618 void RenderViewImpl::OnShouldClose() { | 5618 void RenderViewImpl::OnShouldClose() { |
5619 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); | 5619 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); |
5620 bool should_close = webview()->dispatchBeforeUnloadEvent(); | 5620 bool should_close = webview()->dispatchBeforeUnloadEvent(); |
5621 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); | 5621 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); |
5622 Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close, | 5622 Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close, |
5623 before_unload_start_time, | 5623 before_unload_start_time, |
5624 before_unload_end_time)); | 5624 before_unload_end_time)); |
5625 } | 5625 } |
5626 | 5626 |
5627 void RenderViewImpl::OnSwapOut(const ViewMsg_SwapOut_Params& params) { | 5627 void RenderViewImpl::OnSwapOut() { |
5628 // Only run unload if we're not swapped out yet, but send the ack either way. | 5628 // Only run unload if we're not swapped out yet, but send the ack either way. |
5629 if (!is_swapped_out_) { | 5629 if (!is_swapped_out_) { |
5630 // Swap this RenderView out so the tab can navigate to a page rendered by a | 5630 // Swap this RenderView out so the tab can navigate to a page rendered by a |
5631 // different process. This involves running the unload handler and clearing | 5631 // different process. This involves running the unload handler and clearing |
5632 // the page. Once WasSwappedOut is called, we also allow this process to | 5632 // the page. Once WasSwappedOut is called, we also allow this process to |
5633 // exit if there are no other active RenderViews in it. | 5633 // exit if there are no other active RenderViews in it. |
5634 | 5634 |
5635 // Send an UpdateState message before we get swapped out. | 5635 // Send an UpdateState message before we get swapped out. |
5636 SyncNavigationState(); | 5636 SyncNavigationState(); |
5637 | 5637 |
(...skipping 12 matching lines...) Expand all Loading... |
5650 // run a second time, thanks to a check in FrameLoader::stopLoading. | 5650 // run a second time, thanks to a check in FrameLoader::stopLoading. |
5651 // TODO(creis): Need to add a better way to do this that avoids running the | 5651 // TODO(creis): Need to add a better way to do this that avoids running the |
5652 // beforeunload handler. For now, we just run it a second time silently. | 5652 // beforeunload handler. For now, we just run it a second time silently. |
5653 NavigateToSwappedOutURL(webview()->mainFrame()); | 5653 NavigateToSwappedOutURL(webview()->mainFrame()); |
5654 | 5654 |
5655 // Let WebKit know that this view is hidden so it can drop resources and | 5655 // Let WebKit know that this view is hidden so it can drop resources and |
5656 // stop compositing. | 5656 // stop compositing. |
5657 webview()->setVisibilityState(WebKit::WebPageVisibilityStateHidden, false); | 5657 webview()->setVisibilityState(WebKit::WebPageVisibilityStateHidden, false); |
5658 } | 5658 } |
5659 | 5659 |
5660 // Just echo back the params in the ACK. | 5660 Send(new ViewHostMsg_SwapOut_ACK(routing_id_)); |
5661 Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); | |
5662 } | 5661 } |
5663 | 5662 |
5664 void RenderViewImpl::NavigateToSwappedOutURL(WebKit::WebFrame* frame) { | 5663 void RenderViewImpl::NavigateToSwappedOutURL(WebKit::WebFrame* frame) { |
5665 // We use loadRequest instead of loadHTMLString because the former commits | 5664 // We use loadRequest instead of loadHTMLString because the former commits |
5666 // synchronously. Otherwise a new navigation can interrupt the navigation | 5665 // synchronously. Otherwise a new navigation can interrupt the navigation |
5667 // to kSwappedOutURL. If that happens to be to the page we had been | 5666 // to kSwappedOutURL. If that happens to be to the page we had been |
5668 // showing, then WebKit will never send a commit and we'll be left spinning. | 5667 // showing, then WebKit will never send a commit and we'll be left spinning. |
5669 CHECK(is_swapped_out_); | 5668 CHECK(is_swapped_out_); |
5670 GURL swappedOutURL(kSwappedOutURL); | 5669 GURL swappedOutURL(kSwappedOutURL); |
5671 WebURLRequest request(swappedOutURL); | 5670 WebURLRequest request(swappedOutURL); |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6729 WebURL url = icon_urls[i].iconURL(); | 6728 WebURL url = icon_urls[i].iconURL(); |
6730 if (!url.isEmpty()) | 6729 if (!url.isEmpty()) |
6731 urls.push_back(FaviconURL(url, | 6730 urls.push_back(FaviconURL(url, |
6732 ToFaviconType(icon_urls[i].iconType()))); | 6731 ToFaviconType(icon_urls[i].iconType()))); |
6733 } | 6732 } |
6734 SendUpdateFaviconURL(urls); | 6733 SendUpdateFaviconURL(urls); |
6735 } | 6734 } |
6736 | 6735 |
6737 | 6736 |
6738 } // namespace content | 6737 } // namespace content |
OLD | NEW |