Chromium Code Reviews| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL) | 300 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL) |
| 301 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) | 301 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) |
| 302 IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory) | 302 IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory) |
| 303 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, | 303 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, |
| 304 OnRegisterProtocolHandler) | 304 OnRegisterProtocolHandler) |
| 305 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterIntentHandler, | 305 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterIntentHandler, |
| 306 OnRegisterIntentHandler) | 306 OnRegisterIntentHandler) |
| 307 IPC_MESSAGE_HANDLER(ViewHostMsg_WebIntentDispatch, | 307 IPC_MESSAGE_HANDLER(ViewHostMsg_WebIntentDispatch, |
| 308 OnWebIntentDispatch) | 308 OnWebIntentDispatch) |
| 309 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) | 309 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) |
| 310 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) | |
| 310 IPC_MESSAGE_UNHANDLED(handled = false) | 311 IPC_MESSAGE_UNHANDLED(handled = false) |
| 311 IPC_END_MESSAGE_MAP_EX() | 312 IPC_END_MESSAGE_MAP_EX() |
| 312 | 313 |
| 313 if (!message_is_ok) { | 314 if (!message_is_ok) { |
| 314 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 315 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
| 315 GetRenderProcessHost()->ReceivedBadMessage(); | 316 GetRenderProcessHost()->ReceivedBadMessage(); |
| 316 } | 317 } |
| 317 | 318 |
| 318 return handled; | 319 return handled; |
| 319 } | 320 } |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 894 | 895 |
| 895 void TabContents::SetContentRestrictions(int restrictions) { | 896 void TabContents::SetContentRestrictions(int restrictions) { |
| 896 content_restrictions_ = restrictions; | 897 content_restrictions_ = restrictions; |
| 897 delegate()->ContentRestrictionsChanged(this); | 898 delegate()->ContentRestrictionsChanged(this); |
| 898 } | 899 } |
| 899 | 900 |
| 900 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, | 901 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, |
| 901 bool is_main_frame, | 902 bool is_main_frame, |
| 902 bool has_opener_set, | 903 bool has_opener_set, |
| 903 const GURL& url) { | 904 const GURL& url) { |
| 905 delegate()->DidStartProvisionalLoadForFrame(this, frame_id, is_main_frame, | |
|
jam
2011/09/03 00:10:47
is this new delegate method really necessary? the
ananta
2011/09/03 00:43:23
Thanks for pointing that out. Done.
| |
| 906 has_opener_set, url); | |
| 907 | |
| 904 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); | 908 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); |
| 905 GURL validated_url(url); | 909 GURL validated_url(url); |
| 906 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), | 910 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
| 907 GetRenderProcessHost()->id(), &validated_url); | 911 GetRenderProcessHost()->id(), &validated_url); |
| 908 | 912 |
| 909 RenderViewHost* rvh = | 913 RenderViewHost* rvh = |
| 910 render_manager_.pending_render_view_host() ? | 914 render_manager_.pending_render_view_host() ? |
| 911 render_manager_.pending_render_view_host() : render_view_host(); | 915 render_manager_.pending_render_view_host() : render_view_host(); |
| 912 // Notify observers about the start of the provisional load. | 916 // Notify observers about the start of the provisional load. |
| 913 FOR_EACH_OBSERVER(TabContentsObserver, observers_, | 917 FOR_EACH_OBSERVER(TabContentsObserver, observers_, |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1139 | 1143 |
| 1140 void TabContents::OnFindReply(int request_id, | 1144 void TabContents::OnFindReply(int request_id, |
| 1141 int number_of_matches, | 1145 int number_of_matches, |
| 1142 const gfx::Rect& selection_rect, | 1146 const gfx::Rect& selection_rect, |
| 1143 int active_match_ordinal, | 1147 int active_match_ordinal, |
| 1144 bool final_update) { | 1148 bool final_update) { |
| 1145 delegate()->FindReply(this, request_id, number_of_matches, selection_rect, | 1149 delegate()->FindReply(this, request_id, number_of_matches, selection_rect, |
| 1146 active_match_ordinal, final_update); | 1150 active_match_ordinal, final_update); |
| 1147 } | 1151 } |
| 1148 | 1152 |
| 1153 void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { | |
| 1154 delegate()->CrashedPlugin(this, plugin_path); | |
| 1155 } | |
| 1156 | |
| 1149 // Notifies the RenderWidgetHost instance about the fact that the page is | 1157 // Notifies the RenderWidgetHost instance about the fact that the page is |
| 1150 // loading, or done loading and calls the base implementation. | 1158 // loading, or done loading and calls the base implementation. |
| 1151 void TabContents::SetIsLoading(bool is_loading, | 1159 void TabContents::SetIsLoading(bool is_loading, |
| 1152 LoadNotificationDetails* details) { | 1160 LoadNotificationDetails* details) { |
| 1153 if (is_loading == is_loading_) | 1161 if (is_loading == is_loading_) |
| 1154 return; | 1162 return; |
| 1155 | 1163 |
| 1156 if (!is_loading) { | 1164 if (!is_loading) { |
| 1157 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); | 1165 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); |
| 1158 load_state_host_.clear(); | 1166 load_state_host_.clear(); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1599 NotifyNavigationStateChanged(INVALIDATE_TITLE); | 1607 NotifyNavigationStateChanged(INVALIDATE_TITLE); |
| 1600 } | 1608 } |
| 1601 | 1609 |
| 1602 void TabContents::UpdateEncoding(RenderViewHost* render_view_host, | 1610 void TabContents::UpdateEncoding(RenderViewHost* render_view_host, |
| 1603 const std::string& encoding) { | 1611 const std::string& encoding) { |
| 1604 set_encoding(encoding); | 1612 set_encoding(encoding); |
| 1605 } | 1613 } |
| 1606 | 1614 |
| 1607 void TabContents::UpdateTargetURL(int32 page_id, const GURL& url) { | 1615 void TabContents::UpdateTargetURL(int32 page_id, const GURL& url) { |
| 1608 if (delegate()) | 1616 if (delegate()) |
| 1609 delegate()->UpdateTargetURL(this, url); | 1617 delegate()->UpdateTargetURL(this, page_id, url); |
| 1610 } | 1618 } |
| 1611 | 1619 |
| 1612 void TabContents::Close(RenderViewHost* rvh) { | 1620 void TabContents::Close(RenderViewHost* rvh) { |
| 1613 // The UI may be in an event-tracking loop, such as between the | 1621 // The UI may be in an event-tracking loop, such as between the |
| 1614 // mouse-down and mouse-up in text selection or a button click. | 1622 // mouse-down and mouse-up in text selection or a button click. |
| 1615 // Defer the close until after tracking is complete, so that we | 1623 // Defer the close until after tracking is complete, so that we |
| 1616 // don't free objects out from under the UI. | 1624 // don't free objects out from under the UI. |
| 1617 // TODO(shess): This could probably be integrated with the | 1625 // TODO(shess): This could probably be integrated with the |
| 1618 // IsDoingDrag() test below. Punting for now because I need more | 1626 // IsDoingDrag() test below. Punting for now because I need more |
| 1619 // research to understand how this impacts platforms other than Mac. | 1627 // research to understand how this impacts platforms other than Mac. |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1994 } | 2002 } |
| 1995 | 2003 |
| 1996 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { | 2004 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { |
| 1997 render_manager_.SwapInRenderViewHost(rvh); | 2005 render_manager_.SwapInRenderViewHost(rvh); |
| 1998 } | 2006 } |
| 1999 | 2007 |
| 2000 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2008 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 2001 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2009 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 2002 rwh_view->SetSize(view()->GetContainerSize()); | 2010 rwh_view->SetSize(view()->GetContainerSize()); |
| 2003 } | 2011 } |
| OLD | NEW |