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" |
11 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "content/browser/browser_context.h" | 16 #include "content/browser/browser_context.h" |
17 #include "content/browser/child_process_security_policy.h" | 17 #include "content/browser/child_process_security_policy.h" |
18 #include "content/browser/debugger/devtools_manager.h" | 18 #include "content/browser/debugger/devtools_manager.h" |
19 #include "content/browser/download/download_manager.h" | 19 #include "content/browser/download/download_manager.h" |
20 #include "content/browser/download/download_stats.h" | 20 #include "content/browser/download/download_stats.h" |
21 #include "content/browser/host_zoom_map.h" | 21 #include "content/browser/host_zoom_map.h" |
22 #include "content/browser/in_process_webkit/session_storage_namespace.h" | 22 #include "content/browser/in_process_webkit/session_storage_namespace.h" |
23 #include "content/browser/load_from_memory_cache_details.h" | 23 #include "content/browser/load_from_memory_cache_details.h" |
24 #include "content/browser/load_notification_details.h" | 24 #include "content/browser/load_notification_details.h" |
25 #include "content/browser/renderer_host/render_process_host.h" | 25 #include "content/browser/renderer_host/render_process_host_impl.h" |
26 #include "content/browser/renderer_host/render_view_host.h" | 26 #include "content/browser/renderer_host/render_view_host.h" |
27 #include "content/browser/renderer_host/render_widget_host_view.h" | 27 #include "content/browser/renderer_host/render_widget_host_view.h" |
28 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 28 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
29 #include "content/browser/renderer_host/resource_request_details.h" | 29 #include "content/browser/renderer_host/resource_request_details.h" |
30 #include "content/browser/site_instance.h" | 30 #include "content/browser/site_instance.h" |
31 #include "content/browser/tab_contents/interstitial_page.h" | 31 #include "content/browser/tab_contents/interstitial_page.h" |
32 #include "content/browser/tab_contents/navigation_details.h" | 32 #include "content/browser/tab_contents/navigation_details.h" |
33 #include "content/browser/tab_contents/navigation_entry.h" | 33 #include "content/browser/tab_contents/navigation_entry.h" |
34 #include "content/browser/tab_contents/provisional_load_details.h" | 34 #include "content/browser/tab_contents/provisional_load_details.h" |
35 #include "content/browser/tab_contents/tab_contents_delegate.h" | 35 #include "content/browser/tab_contents/tab_contents_delegate.h" |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 } | 840 } |
841 | 841 |
842 double TabContents::GetZoomLevel() const { | 842 double TabContents::GetZoomLevel() const { |
843 HostZoomMap* zoom_map = browser_context()->GetHostZoomMap(); | 843 HostZoomMap* zoom_map = browser_context()->GetHostZoomMap(); |
844 if (!zoom_map) | 844 if (!zoom_map) |
845 return 0; | 845 return 0; |
846 | 846 |
847 double zoom_level; | 847 double zoom_level; |
848 if (temporary_zoom_settings_) { | 848 if (temporary_zoom_settings_) { |
849 zoom_level = zoom_map->GetTemporaryZoomLevel( | 849 zoom_level = zoom_map->GetTemporaryZoomLevel( |
850 GetRenderProcessHost()->id(), render_view_host()->routing_id()); | 850 GetRenderProcessHost()->GetID(), render_view_host()->routing_id()); |
851 } else { | 851 } else { |
852 GURL url; | 852 GURL url; |
853 NavigationEntry* active_entry = controller().GetActiveEntry(); | 853 NavigationEntry* active_entry = controller().GetActiveEntry(); |
854 // Since zoom map is updated using rewritten URL, use rewritten URL | 854 // Since zoom map is updated using rewritten URL, use rewritten URL |
855 // to get the zoom level. | 855 // to get the zoom level. |
856 url = active_entry ? active_entry->url() : GURL::EmptyGURL(); | 856 url = active_entry ? active_entry->url() : GURL::EmptyGURL(); |
857 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); | 857 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); |
858 } | 858 } |
859 return zoom_level; | 859 return zoom_level; |
860 } | 860 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 delegate()->WebIntentDispatch(this, message.routing_id(), intent, intent_id); | 908 delegate()->WebIntentDispatch(this, message.routing_id(), intent, intent_id); |
909 } | 909 } |
910 | 910 |
911 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, | 911 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, |
912 bool is_main_frame, | 912 bool is_main_frame, |
913 const GURL& opener_url, | 913 const GURL& opener_url, |
914 const GURL& url) { | 914 const GURL& url) { |
915 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); | 915 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); |
916 GURL validated_url(url); | 916 GURL validated_url(url); |
917 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), | 917 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
918 GetRenderProcessHost()->id(), &validated_url); | 918 GetRenderProcessHost()->GetID(), &validated_url); |
919 | 919 |
920 RenderViewHost* rvh = | 920 RenderViewHost* rvh = |
921 render_manager_.pending_render_view_host() ? | 921 render_manager_.pending_render_view_host() ? |
922 render_manager_.pending_render_view_host() : render_view_host(); | 922 render_manager_.pending_render_view_host() : render_view_host(); |
923 // Notify observers about the start of the provisional load. | 923 // Notify observers about the start of the provisional load. |
924 FOR_EACH_OBSERVER(TabContentsObserver, observers_, | 924 FOR_EACH_OBSERVER(TabContentsObserver, observers_, |
925 DidStartProvisionalLoadForFrame(frame_id, is_main_frame, | 925 DidStartProvisionalLoadForFrame(frame_id, is_main_frame, |
926 validated_url, is_error_page, rvh)); | 926 validated_url, is_error_page, rvh)); |
927 | 927 |
928 if (is_main_frame) { | 928 if (is_main_frame) { |
(...skipping 28 matching lines...) Expand all Loading... |
957 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { | 957 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { |
958 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() | 958 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() |
959 << ", error_code: " << params.error_code | 959 << ", error_code: " << params.error_code |
960 << ", error_description: " << params.error_description | 960 << ", error_description: " << params.error_description |
961 << ", is_main_frame: " << params.is_main_frame | 961 << ", is_main_frame: " << params.is_main_frame |
962 << ", showing_repost_interstitial: " << | 962 << ", showing_repost_interstitial: " << |
963 params.showing_repost_interstitial | 963 params.showing_repost_interstitial |
964 << ", frame_id: " << params.frame_id; | 964 << ", frame_id: " << params.frame_id; |
965 GURL validated_url(params.url); | 965 GURL validated_url(params.url); |
966 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), | 966 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
967 GetRenderProcessHost()->id(), &validated_url); | 967 GetRenderProcessHost()->GetID(), &validated_url); |
968 | 968 |
969 if (net::ERR_ABORTED == params.error_code) { | 969 if (net::ERR_ABORTED == params.error_code) { |
970 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. | 970 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. |
971 // This means that the interstitial won't be torn down properly, which is | 971 // This means that the interstitial won't be torn down properly, which is |
972 // bad. But if we have an interstitial, go back to another tab type, and | 972 // bad. But if we have an interstitial, go back to another tab type, and |
973 // then load the same interstitial again, we could end up getting the first | 973 // then load the same interstitial again, we could end up getting the first |
974 // interstitial's "failed" message (as a result of the cancel) when we're on | 974 // interstitial's "failed" message (as a result of the cancel) when we're on |
975 // the second one. | 975 // the second one. |
976 // | 976 // |
977 // We can't tell this apart, so we think we're tearing down the current page | 977 // We can't tell this apart, so we think we're tearing down the current page |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 | 1039 |
1040 // Send out a notification that we loaded a resource from our memory cache. | 1040 // Send out a notification that we loaded a resource from our memory cache. |
1041 int cert_id = 0; | 1041 int cert_id = 0; |
1042 net::CertStatus cert_status = 0; | 1042 net::CertStatus cert_status = 0; |
1043 int security_bits = -1; | 1043 int security_bits = -1; |
1044 int connection_status = 0; | 1044 int connection_status = 0; |
1045 SSLManager::DeserializeSecurityInfo(security_info, | 1045 SSLManager::DeserializeSecurityInfo(security_info, |
1046 &cert_id, &cert_status, | 1046 &cert_id, &cert_status, |
1047 &security_bits, | 1047 &security_bits, |
1048 &connection_status); | 1048 &connection_status); |
1049 LoadFromMemoryCacheDetails details(url, GetRenderProcessHost()->id(), | 1049 LoadFromMemoryCacheDetails details(url, GetRenderProcessHost()->GetID(), |
1050 cert_id, cert_status); | 1050 cert_id, cert_status); |
1051 | 1051 |
1052 content::NotificationService::current()->Notify( | 1052 content::NotificationService::current()->Notify( |
1053 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, | 1053 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, |
1054 content::Source<NavigationController>(&controller_), | 1054 content::Source<NavigationController>(&controller_), |
1055 content::Details<LoadFromMemoryCacheDetails>(&details)); | 1055 content::Details<LoadFromMemoryCacheDetails>(&details)); |
1056 } | 1056 } |
1057 | 1057 |
1058 void TabContents::OnDidDisplayInsecureContent() { | 1058 void TabContents::OnDidDisplayInsecureContent() { |
1059 UserMetrics::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); | 1059 UserMetrics::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 | 2022 |
2023 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2023 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2024 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2024 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
2025 rwh_view->SetSize(view()->GetContainerSize()); | 2025 rwh_view->SetSize(view()->GetContainerSize()); |
2026 } | 2026 } |
2027 | 2027 |
2028 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 2028 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
2029 return render_view_host() ? | 2029 return render_view_host() ? |
2030 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; | 2030 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; |
2031 } | 2031 } |
OLD | NEW |