Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/tab_contents/tab_contents.h" | 5 #include "content/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 905 if (!entry || entry->url() != source_url) | 905 if (!entry || entry->url() != source_url) |
| 906 return; | 906 return; |
| 907 | 907 |
| 908 // Notify observers about the provisional change in the main frame URL. | 908 // Notify observers about the provisional change in the main frame URL. |
| 909 FOR_EACH_OBSERVER(TabContentsObserver, observers_, | 909 FOR_EACH_OBSERVER(TabContentsObserver, observers_, |
| 910 ProvisionalChangeToMainFrameUrl(target_url, | 910 ProvisionalChangeToMainFrameUrl(target_url, |
| 911 has_opener_set)); | 911 has_opener_set)); |
| 912 } | 912 } |
| 913 | 913 |
| 914 void TabContents::OnDidFailProvisionalLoadWithError( | 914 void TabContents::OnDidFailProvisionalLoadWithError( |
| 915 int64 frame_id, | 915 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& ipc_params) { |
|
jam
2011/10/05 17:12:06
nit: here and elsewhere, we usually just call this
mkosiba (inactive)
2011/10/05 17:53:18
Done.
| |
| 916 bool is_main_frame, | 916 VLOG(1) << "Failed Provisional Load: " << |
| 917 int error_code, | 917 ipc_params.url.possibly_invalid_spec() |
| 918 const GURL& url, | 918 << ", error_code: " << ipc_params.error_code |
| 919 bool showing_repost_interstitial) { | 919 << ", error_description: " << ipc_params.error_description |
| 920 VLOG(1) << "Failed Provisional Load: " << url.possibly_invalid_spec() | 920 << ", is_main_frame: " << ipc_params.is_main_frame |
| 921 << ", error_code: " << error_code | 921 << ", showing_repost_interstitial: " << |
| 922 << " is_main_frame: " << is_main_frame | 922 ipc_params.showing_repost_interstitial |
| 923 << " showing_repost_interstitial: " << showing_repost_interstitial | 923 << ", frame_id: " << ipc_params.frame_id; |
| 924 << " frame_id: " << frame_id; | 924 GURL validated_url(ipc_params.url); |
| 925 GURL validated_url(url); | |
| 926 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), | 925 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
| 927 GetRenderProcessHost()->id(), &validated_url); | 926 GetRenderProcessHost()->id(), &validated_url); |
| 928 | 927 |
| 929 if (net::ERR_ABORTED == error_code) { | 928 if (net::ERR_ABORTED == ipc_params.error_code) { |
| 930 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. | 929 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. |
| 931 // This means that the interstitial won't be torn down properly, which is | 930 // This means that the interstitial won't be torn down properly, which is |
| 932 // bad. But if we have an interstitial, go back to another tab type, and | 931 // bad. But if we have an interstitial, go back to another tab type, and |
| 933 // then load the same interstitial again, we could end up getting the first | 932 // then load the same interstitial again, we could end up getting the first |
| 934 // interstitial's "failed" message (as a result of the cancel) when we're on | 933 // interstitial's "failed" message (as a result of the cancel) when we're on |
| 935 // the second one. | 934 // the second one. |
| 936 // | 935 // |
| 937 // We can't tell this apart, so we think we're tearing down the current page | 936 // We can't tell this apart, so we think we're tearing down the current page |
| 938 // which will cause a crash later one. There is also some code in | 937 // which will cause a crash later one. There is also some code in |
| 939 // RenderViewHostManager::RendererAbortedProvisionalLoad that is commented | 938 // RenderViewHostManager::RendererAbortedProvisionalLoad that is commented |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 960 // navigation will still commit even if there is no pending entry. | 959 // navigation will still commit even if there is no pending entry. |
| 961 NavigationEntry* pending_entry = controller_.pending_entry(); | 960 NavigationEntry* pending_entry = controller_.pending_entry(); |
| 962 if (pending_entry) | 961 if (pending_entry) |
| 963 DidCancelLoading(); | 962 DidCancelLoading(); |
| 964 | 963 |
| 965 render_manager_.RendererAbortedProvisionalLoad(render_view_host()); | 964 render_manager_.RendererAbortedProvisionalLoad(render_view_host()); |
| 966 } | 965 } |
| 967 | 966 |
| 968 // Send out a notification that we failed a provisional load with an error. | 967 // Send out a notification that we failed a provisional load with an error. |
| 969 ProvisionalLoadDetails details( | 968 ProvisionalLoadDetails details( |
| 970 is_main_frame, controller_.IsURLInPageNavigation(validated_url), | 969 ipc_params.is_main_frame, |
| 971 validated_url, std::string(), false, frame_id); | 970 controller_.IsURLInPageNavigation(validated_url), |
| 972 details.set_error_code(error_code); | 971 validated_url, |
| 972 std::string(), | |
| 973 false, | |
| 974 ipc_params.frame_id); | |
| 975 details.set_error_code(ipc_params.error_code); | |
| 973 | 976 |
| 974 NotificationService::current()->Notify( | 977 NotificationService::current()->Notify( |
| 975 content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, | 978 content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, |
| 976 Source<NavigationController>(&controller_), | 979 Source<NavigationController>(&controller_), |
| 977 Details<ProvisionalLoadDetails>(&details)); | 980 Details<ProvisionalLoadDetails>(&details)); |
| 978 | 981 |
| 979 FOR_EACH_OBSERVER(TabContentsObserver, observers_, | 982 FOR_EACH_OBSERVER(TabContentsObserver, |
| 980 DidFailProvisionalLoad(frame_id, is_main_frame, | 983 observers_, |
| 981 validated_url, error_code)); | 984 DidFailProvisionalLoad(ipc_params.frame_id, |
| 985 ipc_params.is_main_frame, | |
| 986 validated_url, | |
| 987 ipc_params.error_code, | |
| 988 ipc_params.error_description)); | |
| 982 } | 989 } |
| 983 | 990 |
| 984 void TabContents::OnDidLoadResourceFromMemoryCache( | 991 void TabContents::OnDidLoadResourceFromMemoryCache( |
| 985 const GURL& url, | 992 const GURL& url, |
| 986 const std::string& security_info, | 993 const std::string& security_info, |
| 987 const std::string& http_method, | 994 const std::string& http_method, |
| 988 ResourceType::Type resource_type) { | 995 ResourceType::Type resource_type) { |
| 989 base::StatsCounter cache("WebKit.CacheHit"); | 996 base::StatsCounter cache("WebKit.CacheHit"); |
| 990 cache.Increment(); | 997 cache.Increment(); |
| 991 | 998 |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1956 } | 1963 } |
| 1957 | 1964 |
| 1958 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { | 1965 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { |
| 1959 render_manager_.SwapInRenderViewHost(rvh); | 1966 render_manager_.SwapInRenderViewHost(rvh); |
| 1960 } | 1967 } |
| 1961 | 1968 |
| 1962 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 1969 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 1963 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 1970 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 1964 rwh_view->SetSize(view()->GetContainerSize()); | 1971 rwh_view->SetSize(view()->GetContainerSize()); |
| 1965 } | 1972 } |
| OLD | NEW |