| 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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 delegate_->ViewSourceForFrame(this, url, content_state); | 1008 delegate_->ViewSourceForFrame(this, url, content_state); |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 void TabContents::SetContentRestrictions(int restrictions) { | 1011 void TabContents::SetContentRestrictions(int restrictions) { |
| 1012 content_restrictions_ = restrictions; | 1012 content_restrictions_ = restrictions; |
| 1013 delegate()->ContentRestrictionsChanged(this); | 1013 delegate()->ContentRestrictionsChanged(this); |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, | 1016 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, |
| 1017 bool is_main_frame, | 1017 bool is_main_frame, |
| 1018 bool has_opener_set, |
| 1018 const GURL& url) { | 1019 const GURL& url) { |
| 1019 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); | 1020 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); |
| 1020 GURL validated_url(url); | 1021 GURL validated_url(url); |
| 1021 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), | 1022 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
| 1022 GetRenderProcessHost()->id(), &validated_url); | 1023 GetRenderProcessHost()->id(), &validated_url); |
| 1023 | 1024 |
| 1024 RenderViewHost* rvh = | 1025 RenderViewHost* rvh = |
| 1025 render_manager_.pending_render_view_host() ? | 1026 render_manager_.pending_render_view_host() ? |
| 1026 render_manager_.pending_render_view_host() : render_view_host(); | 1027 render_manager_.pending_render_view_host() : render_view_host(); |
| 1027 // Notify observers about the start of the provisional load. | 1028 // Notify observers about the start of the provisional load. |
| 1028 FOR_EACH_OBSERVER(TabContentsObserver, observers_, | 1029 FOR_EACH_OBSERVER(TabContentsObserver, observers_, |
| 1029 DidStartProvisionalLoadForFrame(frame_id, is_main_frame, | 1030 DidStartProvisionalLoadForFrame(frame_id, is_main_frame, |
| 1030 validated_url, is_error_page, rvh)); | 1031 validated_url, is_error_page, rvh)); |
| 1031 | 1032 |
| 1032 if (is_main_frame) { | 1033 if (is_main_frame) { |
| 1033 // Notify observers about the provisional change in the main frame URL. | 1034 // Notify observers about the provisional change in the main frame URL. |
| 1034 FOR_EACH_OBSERVER(TabContentsObserver, observers_, | 1035 FOR_EACH_OBSERVER(TabContentsObserver, observers_, |
| 1035 ProvisionalChangeToMainFrameUrl(url)); | 1036 ProvisionalChangeToMainFrameUrl(url, has_opener_set)); |
| 1036 } | 1037 } |
| 1037 } | 1038 } |
| 1038 | 1039 |
| 1039 void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, | 1040 void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, |
| 1041 bool has_opener_set, |
| 1040 const GURL& source_url, | 1042 const GURL& source_url, |
| 1041 const GURL& target_url) { | 1043 const GURL& target_url) { |
| 1042 // TODO(creis): Remove this method and have the pre-rendering code listen to | 1044 // TODO(creis): Remove this method and have the pre-rendering code listen to |
| 1043 // the ResourceDispatcherHost's RESOURCE_RECEIVED_REDIRECT notification | 1045 // the ResourceDispatcherHost's RESOURCE_RECEIVED_REDIRECT notification |
| 1044 // instead. See http://crbug.com/78512. | 1046 // instead. See http://crbug.com/78512. |
| 1045 NavigationEntry* entry; | 1047 NavigationEntry* entry; |
| 1046 if (page_id == -1) | 1048 if (page_id == -1) |
| 1047 entry = controller_.pending_entry(); | 1049 entry = controller_.pending_entry(); |
| 1048 else | 1050 else |
| 1049 entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); | 1051 entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); |
| 1050 if (!entry || entry->url() != source_url) | 1052 if (!entry || entry->url() != source_url) |
| 1051 return; | 1053 return; |
| 1052 | 1054 |
| 1053 // Notify observers about the provisional change in the main frame URL. | 1055 // Notify observers about the provisional change in the main frame URL. |
| 1054 FOR_EACH_OBSERVER(TabContentsObserver, observers_, | 1056 FOR_EACH_OBSERVER(TabContentsObserver, observers_, |
| 1055 ProvisionalChangeToMainFrameUrl(target_url)); | 1057 ProvisionalChangeToMainFrameUrl(target_url, |
| 1058 has_opener_set)); |
| 1056 } | 1059 } |
| 1057 | 1060 |
| 1058 void TabContents::OnDidFailProvisionalLoadWithError( | 1061 void TabContents::OnDidFailProvisionalLoadWithError( |
| 1059 int64 frame_id, | 1062 int64 frame_id, |
| 1060 bool is_main_frame, | 1063 bool is_main_frame, |
| 1061 int error_code, | 1064 int error_code, |
| 1062 const GURL& url, | 1065 const GURL& url, |
| 1063 bool showing_repost_interstitial) { | 1066 bool showing_repost_interstitial) { |
| 1064 VLOG(1) << "Failed Provisional Load: " << url.possibly_invalid_spec() | 1067 VLOG(1) << "Failed Provisional Load: " << url.possibly_invalid_spec() |
| 1065 << ", error_code: " << error_code | 1068 << ", error_code: " << error_code |
| (...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2226 | 2229 |
| 2227 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2230 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 2228 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2231 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 2229 rwh_view->SetSize(view()->GetContainerSize()); | 2232 rwh_view->SetSize(view()->GetContainerSize()); |
| 2230 } | 2233 } |
| 2231 | 2234 |
| 2232 void TabContents::OnOnlineStateChanged(bool online) { | 2235 void TabContents::OnOnlineStateChanged(bool online) { |
| 2233 render_view_host()->Send(new ViewMsg_NetworkStateChanged( | 2236 render_view_host()->Send(new ViewMsg_NetworkStateChanged( |
| 2234 render_view_host()->routing_id(), online)); | 2237 render_view_host()->routing_id(), online)); |
| 2235 } | 2238 } |
| OLD | NEW |