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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 if (!entry || entry->url() != source_url) | 897 if (!entry || entry->url() != source_url) |
898 return; | 898 return; |
899 | 899 |
900 // Notify observers about the provisional change in the main frame URL. | 900 // Notify observers about the provisional change in the main frame URL. |
901 FOR_EACH_OBSERVER(TabContentsObserver, observers_, | 901 FOR_EACH_OBSERVER(TabContentsObserver, observers_, |
902 ProvisionalChangeToMainFrameUrl(target_url, | 902 ProvisionalChangeToMainFrameUrl(target_url, |
903 opener_url)); | 903 opener_url)); |
904 } | 904 } |
905 | 905 |
906 void TabContents::OnDidFailProvisionalLoadWithError( | 906 void TabContents::OnDidFailProvisionalLoadWithError( |
907 int64 frame_id, | 907 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { |
908 bool is_main_frame, | 908 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() |
909 int error_code, | 909 << ", error_code: " << params.error_code |
910 const GURL& url, | 910 << ", error_description: " << params.error_description |
911 bool showing_repost_interstitial) { | 911 << ", is_main_frame: " << params.is_main_frame |
912 VLOG(1) << "Failed Provisional Load: " << url.possibly_invalid_spec() | 912 << ", showing_repost_interstitial: " << |
913 << ", error_code: " << error_code | 913 params.showing_repost_interstitial |
914 << " is_main_frame: " << is_main_frame | 914 << ", frame_id: " << params.frame_id; |
915 << " showing_repost_interstitial: " << showing_repost_interstitial | 915 GURL validated_url(params.url); |
916 << " frame_id: " << frame_id; | |
917 GURL validated_url(url); | |
918 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), | 916 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
919 GetRenderProcessHost()->id(), &validated_url); | 917 GetRenderProcessHost()->id(), &validated_url); |
920 | 918 |
921 if (net::ERR_ABORTED == error_code) { | 919 if (net::ERR_ABORTED == params.error_code) { |
922 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. | 920 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. |
923 // This means that the interstitial won't be torn down properly, which is | 921 // This means that the interstitial won't be torn down properly, which is |
924 // bad. But if we have an interstitial, go back to another tab type, and | 922 // bad. But if we have an interstitial, go back to another tab type, and |
925 // then load the same interstitial again, we could end up getting the first | 923 // then load the same interstitial again, we could end up getting the first |
926 // interstitial's "failed" message (as a result of the cancel) when we're on | 924 // interstitial's "failed" message (as a result of the cancel) when we're on |
927 // the second one. | 925 // the second one. |
928 // | 926 // |
929 // We can't tell this apart, so we think we're tearing down the current page | 927 // We can't tell this apart, so we think we're tearing down the current page |
930 // which will cause a crash later one. There is also some code in | 928 // which will cause a crash later one. There is also some code in |
931 // RenderViewHostManager::RendererAbortedProvisionalLoad that is commented | 929 // RenderViewHostManager::RendererAbortedProvisionalLoad that is commented |
(...skipping 20 matching lines...) Expand all Loading... |
952 // navigation will still commit even if there is no pending entry. | 950 // navigation will still commit even if there is no pending entry. |
953 NavigationEntry* pending_entry = controller_.pending_entry(); | 951 NavigationEntry* pending_entry = controller_.pending_entry(); |
954 if (pending_entry) | 952 if (pending_entry) |
955 DidCancelLoading(); | 953 DidCancelLoading(); |
956 | 954 |
957 render_manager_.RendererAbortedProvisionalLoad(render_view_host()); | 955 render_manager_.RendererAbortedProvisionalLoad(render_view_host()); |
958 } | 956 } |
959 | 957 |
960 // Send out a notification that we failed a provisional load with an error. | 958 // Send out a notification that we failed a provisional load with an error. |
961 ProvisionalLoadDetails details( | 959 ProvisionalLoadDetails details( |
962 is_main_frame, controller_.IsURLInPageNavigation(validated_url), | 960 params.is_main_frame, |
963 validated_url, std::string(), false, frame_id); | 961 controller_.IsURLInPageNavigation(validated_url), |
964 details.set_error_code(error_code); | 962 validated_url, |
| 963 std::string(), |
| 964 false, |
| 965 params.frame_id); |
| 966 details.set_error_code(params.error_code); |
965 | 967 |
966 NotificationService::current()->Notify( | 968 NotificationService::current()->Notify( |
967 content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, | 969 content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, |
968 Source<NavigationController>(&controller_), | 970 Source<NavigationController>(&controller_), |
969 Details<ProvisionalLoadDetails>(&details)); | 971 Details<ProvisionalLoadDetails>(&details)); |
970 | 972 |
971 FOR_EACH_OBSERVER(TabContentsObserver, observers_, | 973 FOR_EACH_OBSERVER(TabContentsObserver, |
972 DidFailProvisionalLoad(frame_id, is_main_frame, | 974 observers_, |
973 validated_url, error_code)); | 975 DidFailProvisionalLoad(params.frame_id, |
| 976 params.is_main_frame, |
| 977 validated_url, |
| 978 params.error_code, |
| 979 params.error_description)); |
974 } | 980 } |
975 | 981 |
976 void TabContents::OnDidLoadResourceFromMemoryCache( | 982 void TabContents::OnDidLoadResourceFromMemoryCache( |
977 const GURL& url, | 983 const GURL& url, |
978 const std::string& security_info, | 984 const std::string& security_info, |
979 const std::string& http_method, | 985 const std::string& http_method, |
980 ResourceType::Type resource_type) { | 986 ResourceType::Type resource_type) { |
981 base::StatsCounter cache("WebKit.CacheHit"); | 987 base::StatsCounter cache("WebKit.CacheHit"); |
982 cache.Increment(); | 988 cache.Increment(); |
983 | 989 |
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1959 | 1965 |
1960 void TabContents::set_encoding(const std::string& encoding) { | 1966 void TabContents::set_encoding(const std::string& encoding) { |
1961 encoding_ = content::GetContentClient()->browser()-> | 1967 encoding_ = content::GetContentClient()->browser()-> |
1962 GetCanonicalEncodingNameByAliasName(encoding); | 1968 GetCanonicalEncodingNameByAliasName(encoding); |
1963 } | 1969 } |
1964 | 1970 |
1965 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 1971 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
1966 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 1972 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
1967 rwh_view->SetSize(view()->GetContainerSize()); | 1973 rwh_view->SetSize(view()->GetContainerSize()); |
1968 } | 1974 } |
OLD | NEW |