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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 319 |
320 return handled; | 320 return handled; |
321 } | 321 } |
322 | 322 |
323 void TabContents::RunFileChooser( | 323 void TabContents::RunFileChooser( |
324 RenderViewHost* render_view_host, | 324 RenderViewHost* render_view_host, |
325 const ViewHostMsg_RunFileChooser_Params& params) { | 325 const ViewHostMsg_RunFileChooser_Params& params) { |
326 delegate()->RunFileChooser(this, params); | 326 delegate()->RunFileChooser(this, params); |
327 } | 327 } |
328 | 328 |
329 RenderProcessHost* TabContents::GetRenderProcessHost() const { | 329 content::RenderProcessHost* TabContents::GetRenderProcessHost() const { |
330 if (render_manager_.current_host()) | 330 if (render_manager_.current_host()) |
331 return render_manager_.current_host()->process(); | 331 return render_manager_.current_host()->process(); |
332 else | 332 else |
333 return NULL; | 333 return NULL; |
334 } | 334 } |
335 | 335 |
336 const GURL& TabContents::GetURL() const { | 336 const GURL& TabContents::GetURL() const { |
337 // We may not have a navigation entry yet | 337 // We may not have a navigation entry yet |
338 NavigationEntry* entry = controller_.GetActiveEntry(); | 338 NavigationEntry* entry = controller_.GetActiveEntry(); |
339 return entry ? entry->virtual_url() : GURL::EmptyGURL(); | 339 return entry ? entry->virtual_url() : GURL::EmptyGURL(); |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 } | 839 } |
840 | 840 |
841 double TabContents::GetZoomLevel() const { | 841 double TabContents::GetZoomLevel() const { |
842 HostZoomMap* zoom_map = browser_context()->GetHostZoomMap(); | 842 HostZoomMap* zoom_map = browser_context()->GetHostZoomMap(); |
843 if (!zoom_map) | 843 if (!zoom_map) |
844 return 0; | 844 return 0; |
845 | 845 |
846 double zoom_level; | 846 double zoom_level; |
847 if (temporary_zoom_settings_) { | 847 if (temporary_zoom_settings_) { |
848 zoom_level = zoom_map->GetTemporaryZoomLevel( | 848 zoom_level = zoom_map->GetTemporaryZoomLevel( |
849 GetRenderProcessHost()->id(), render_view_host()->routing_id()); | 849 GetRenderProcessHost()->GetID(), render_view_host()->routing_id()); |
850 } else { | 850 } else { |
851 GURL url; | 851 GURL url; |
852 NavigationEntry* active_entry = controller().GetActiveEntry(); | 852 NavigationEntry* active_entry = controller().GetActiveEntry(); |
853 // Since zoom map is updated using rewritten URL, use rewritten URL | 853 // Since zoom map is updated using rewritten URL, use rewritten URL |
854 // to get the zoom level. | 854 // to get the zoom level. |
855 url = active_entry ? active_entry->url() : GURL::EmptyGURL(); | 855 url = active_entry ? active_entry->url() : GURL::EmptyGURL(); |
856 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); | 856 zoom_level = zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(url)); |
857 } | 857 } |
858 return zoom_level; | 858 return zoom_level; |
859 } | 859 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 delegate()->WebIntentDispatch(this, message.routing_id(), intent, intent_id); | 907 delegate()->WebIntentDispatch(this, message.routing_id(), intent, intent_id); |
908 } | 908 } |
909 | 909 |
910 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, | 910 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, |
911 bool is_main_frame, | 911 bool is_main_frame, |
912 const GURL& opener_url, | 912 const GURL& opener_url, |
913 const GURL& url) { | 913 const GURL& url) { |
914 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); | 914 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); |
915 GURL validated_url(url); | 915 GURL validated_url(url); |
916 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), | 916 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
917 GetRenderProcessHost()->id(), &validated_url); | 917 GetRenderProcessHost()->GetID(), &validated_url); |
918 | 918 |
919 RenderViewHost* rvh = | 919 RenderViewHost* rvh = |
920 render_manager_.pending_render_view_host() ? | 920 render_manager_.pending_render_view_host() ? |
921 render_manager_.pending_render_view_host() : render_view_host(); | 921 render_manager_.pending_render_view_host() : render_view_host(); |
922 // Notify observers about the start of the provisional load. | 922 // Notify observers about the start of the provisional load. |
923 FOR_EACH_OBSERVER(TabContentsObserver, observers_, | 923 FOR_EACH_OBSERVER(TabContentsObserver, observers_, |
924 DidStartProvisionalLoadForFrame(frame_id, is_main_frame, | 924 DidStartProvisionalLoadForFrame(frame_id, is_main_frame, |
925 validated_url, is_error_page, rvh)); | 925 validated_url, is_error_page, rvh)); |
926 | 926 |
927 if (is_main_frame) { | 927 if (is_main_frame) { |
(...skipping 28 matching lines...) Expand all Loading... |
956 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { | 956 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { |
957 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() | 957 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() |
958 << ", error_code: " << params.error_code | 958 << ", error_code: " << params.error_code |
959 << ", error_description: " << params.error_description | 959 << ", error_description: " << params.error_description |
960 << ", is_main_frame: " << params.is_main_frame | 960 << ", is_main_frame: " << params.is_main_frame |
961 << ", showing_repost_interstitial: " << | 961 << ", showing_repost_interstitial: " << |
962 params.showing_repost_interstitial | 962 params.showing_repost_interstitial |
963 << ", frame_id: " << params.frame_id; | 963 << ", frame_id: " << params.frame_id; |
964 GURL validated_url(params.url); | 964 GURL validated_url(params.url); |
965 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), | 965 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
966 GetRenderProcessHost()->id(), &validated_url); | 966 GetRenderProcessHost()->GetID(), &validated_url); |
967 | 967 |
968 if (net::ERR_ABORTED == params.error_code) { | 968 if (net::ERR_ABORTED == params.error_code) { |
969 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. | 969 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. |
970 // This means that the interstitial won't be torn down properly, which is | 970 // This means that the interstitial won't be torn down properly, which is |
971 // bad. But if we have an interstitial, go back to another tab type, and | 971 // bad. But if we have an interstitial, go back to another tab type, and |
972 // then load the same interstitial again, we could end up getting the first | 972 // then load the same interstitial again, we could end up getting the first |
973 // interstitial's "failed" message (as a result of the cancel) when we're on | 973 // interstitial's "failed" message (as a result of the cancel) when we're on |
974 // the second one. | 974 // the second one. |
975 // | 975 // |
976 // We can't tell this apart, so we think we're tearing down the current page | 976 // 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... |
1038 | 1038 |
1039 // Send out a notification that we loaded a resource from our memory cache. | 1039 // Send out a notification that we loaded a resource from our memory cache. |
1040 int cert_id = 0; | 1040 int cert_id = 0; |
1041 net::CertStatus cert_status = 0; | 1041 net::CertStatus cert_status = 0; |
1042 int security_bits = -1; | 1042 int security_bits = -1; |
1043 int connection_status = 0; | 1043 int connection_status = 0; |
1044 SSLManager::DeserializeSecurityInfo(security_info, | 1044 SSLManager::DeserializeSecurityInfo(security_info, |
1045 &cert_id, &cert_status, | 1045 &cert_id, &cert_status, |
1046 &security_bits, | 1046 &security_bits, |
1047 &connection_status); | 1047 &connection_status); |
1048 LoadFromMemoryCacheDetails details(url, GetRenderProcessHost()->id(), | 1048 LoadFromMemoryCacheDetails details(url, GetRenderProcessHost()->GetID(), |
1049 cert_id, cert_status); | 1049 cert_id, cert_status); |
1050 | 1050 |
1051 content::NotificationService::current()->Notify( | 1051 content::NotificationService::current()->Notify( |
1052 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, | 1052 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, |
1053 content::Source<NavigationController>(&controller_), | 1053 content::Source<NavigationController>(&controller_), |
1054 content::Details<LoadFromMemoryCacheDetails>(&details)); | 1054 content::Details<LoadFromMemoryCacheDetails>(&details)); |
1055 } | 1055 } |
1056 | 1056 |
1057 void TabContents::OnDidDisplayInsecureContent() { | 1057 void TabContents::OnDidDisplayInsecureContent() { |
1058 UserMetrics::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); | 1058 UserMetrics::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 | 2027 |
2028 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2028 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2029 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2029 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
2030 rwh_view->SetSize(view()->GetContainerSize()); | 2030 rwh_view->SetSize(view()->GetContainerSize()); |
2031 } | 2031 } |
2032 | 2032 |
2033 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 2033 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
2034 return render_view_host() ? | 2034 return render_view_host() ? |
2035 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; | 2035 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; |
2036 } | 2036 } |
OLD | NEW |