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