| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 ObserverListBase<TabContentsObserver>::Iterator it(observers_); | 272 ObserverListBase<TabContentsObserver>::Iterator it(observers_); |
| 273 TabContentsObserver* observer; | 273 TabContentsObserver* observer; |
| 274 while ((observer = it.GetNext()) != NULL) | 274 while ((observer = it.GetNext()) != NULL) |
| 275 if (observer->OnMessageReceived(message)) | 275 if (observer->OnMessageReceived(message)) |
| 276 return true; | 276 return true; |
| 277 | 277 |
| 278 bool handled = true; | 278 bool handled = true; |
| 279 bool message_is_ok = true; | 279 bool message_is_ok = true; |
| 280 IPC_BEGIN_MESSAGE_MAP_EX(TabContents, message, message_is_ok) | 280 IPC_BEGIN_MESSAGE_MAP_EX(TabContents, message, message_is_ok) |
| 281 IPC_MESSAGE_HANDLER(IntentsHostMsg_RegisterIntentHandler, |
| 282 OnRegisterIntentHandler) |
| 281 IPC_MESSAGE_HANDLER(IntentsHostMsg_WebIntentDispatch, | 283 IPC_MESSAGE_HANDLER(IntentsHostMsg_WebIntentDispatch, |
| 282 OnWebIntentDispatch) | 284 OnWebIntentDispatch) |
| 283 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, | 285 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, |
| 284 OnDidStartProvisionalLoadForFrame) | 286 OnDidStartProvisionalLoadForFrame) |
| 285 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRedirectProvisionalLoad, | 287 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRedirectProvisionalLoad, |
| 286 OnDidRedirectProvisionalLoad) | 288 OnDidRedirectProvisionalLoad) |
| 287 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError, | 289 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError, |
| 288 OnDidFailProvisionalLoadWithError) | 290 OnDidFailProvisionalLoadWithError) |
| 289 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, | 291 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, |
| 290 OnDidLoadResourceFromMemoryCache) | 292 OnDidLoadResourceFromMemoryCache) |
| 291 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent, | 293 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent, |
| 292 OnDidDisplayInsecureContent) | 294 OnDidDisplayInsecureContent) |
| 293 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, | 295 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, |
| 294 OnDidRunInsecureContent) | 296 OnDidRunInsecureContent) |
| 295 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, | 297 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, |
| 296 OnDocumentLoadedInFrame) | 298 OnDocumentLoadedInFrame) |
| 297 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) | 299 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) |
| 298 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, | 300 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, |
| 299 OnUpdateContentRestrictions) | 301 OnUpdateContentRestrictions) |
| 300 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) | 302 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) |
| 301 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) | 303 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) |
| 302 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) | 304 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) |
| 303 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL) | 305 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL) |
| 304 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) | 306 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) |
| 305 IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory) | 307 IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory) |
| 306 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, | 308 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, |
| 307 OnRegisterProtocolHandler) | 309 OnRegisterProtocolHandler) |
| 308 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterIntentHandler, | |
| 309 OnRegisterIntentHandler) | |
| 310 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) | 310 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) |
| 311 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) | 311 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) |
| 312 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 312 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
| 313 IPC_MESSAGE_UNHANDLED(handled = false) | 313 IPC_MESSAGE_UNHANDLED(handled = false) |
| 314 IPC_END_MESSAGE_MAP_EX() | 314 IPC_END_MESSAGE_MAP_EX() |
| 315 | 315 |
| 316 if (!message_is_ok) { | 316 if (!message_is_ok) { |
| 317 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 317 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
| 318 GetRenderProcessHost()->ReceivedBadMessage(); | 318 GetRenderProcessHost()->ReceivedBadMessage(); |
| 319 } | 319 } |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 return; | 874 return; |
| 875 | 875 |
| 876 delegate_->ViewSourceForFrame(this, url, content_state); | 876 delegate_->ViewSourceForFrame(this, url, content_state); |
| 877 } | 877 } |
| 878 | 878 |
| 879 void TabContents::SetContentRestrictions(int restrictions) { | 879 void TabContents::SetContentRestrictions(int restrictions) { |
| 880 content_restrictions_ = restrictions; | 880 content_restrictions_ = restrictions; |
| 881 delegate()->ContentRestrictionsChanged(this); | 881 delegate()->ContentRestrictionsChanged(this); |
| 882 } | 882 } |
| 883 | 883 |
| 884 void TabContents::OnRegisterIntentHandler(const string16& action, |
| 885 const string16& type, |
| 886 const string16& href, |
| 887 const string16& title, |
| 888 const string16& disposition) { |
| 889 delegate()->RegisterIntentHandler( |
| 890 this, action, type, href, title, disposition); |
| 891 } |
| 892 |
| 893 void TabContents::OnWebIntentDispatch(const IPC::Message& message, |
| 894 const webkit_glue::WebIntentData& intent, |
| 895 int intent_id) { |
| 896 delegate()->WebIntentDispatch(this, message.routing_id(), intent, intent_id); |
| 897 } |
| 898 |
| 884 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, | 899 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, |
| 885 bool is_main_frame, | 900 bool is_main_frame, |
| 886 const GURL& opener_url, | 901 const GURL& opener_url, |
| 887 const GURL& url) { | 902 const GURL& url) { |
| 888 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); | 903 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); |
| 889 GURL validated_url(url); | 904 GURL validated_url(url); |
| 890 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), | 905 render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), |
| 891 GetRenderProcessHost()->id(), &validated_url); | 906 GetRenderProcessHost()->id(), &validated_url); |
| 892 | 907 |
| 893 RenderViewHost* rvh = | 908 RenderViewHost* rvh = |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 void TabContents::OnJSOutOfMemory() { | 1124 void TabContents::OnJSOutOfMemory() { |
| 1110 delegate()->JSOutOfMemory(this); | 1125 delegate()->JSOutOfMemory(this); |
| 1111 } | 1126 } |
| 1112 | 1127 |
| 1113 void TabContents::OnRegisterProtocolHandler(const std::string& protocol, | 1128 void TabContents::OnRegisterProtocolHandler(const std::string& protocol, |
| 1114 const GURL& url, | 1129 const GURL& url, |
| 1115 const string16& title) { | 1130 const string16& title) { |
| 1116 delegate()->RegisterProtocolHandler(this, protocol, url, title); | 1131 delegate()->RegisterProtocolHandler(this, protocol, url, title); |
| 1117 } | 1132 } |
| 1118 | 1133 |
| 1119 void TabContents::OnRegisterIntentHandler(const string16& action, | |
| 1120 const string16& type, | |
| 1121 const string16& href, | |
| 1122 const string16& title) { | |
| 1123 delegate()->RegisterIntentHandler(this, action, type, href, title); | |
| 1124 } | |
| 1125 | |
| 1126 void TabContents::OnWebIntentDispatch(const IPC::Message& message, | |
| 1127 const webkit_glue::WebIntentData& intent, | |
| 1128 int intent_id) { | |
| 1129 delegate()->WebIntentDispatch(this, message.routing_id(), intent, intent_id); | |
| 1130 } | |
| 1131 | |
| 1132 void TabContents::OnFindReply(int request_id, | 1134 void TabContents::OnFindReply(int request_id, |
| 1133 int number_of_matches, | 1135 int number_of_matches, |
| 1134 const gfx::Rect& selection_rect, | 1136 const gfx::Rect& selection_rect, |
| 1135 int active_match_ordinal, | 1137 int active_match_ordinal, |
| 1136 bool final_update) { | 1138 bool final_update) { |
| 1137 delegate()->FindReply(this, request_id, number_of_matches, selection_rect, | 1139 delegate()->FindReply(this, request_id, number_of_matches, selection_rect, |
| 1138 active_match_ordinal, final_update); | 1140 active_match_ordinal, final_update); |
| 1139 // Send a notification to the renderer that we are ready to receive more | 1141 // Send a notification to the renderer that we are ready to receive more |
| 1140 // results from the scoping effort of the Find operation. The FindInPage | 1142 // results from the scoping effort of the Find operation. The FindInPage |
| 1141 // scoping is asynchronous and periodically sends results back up to the | 1143 // scoping is asynchronous and periodically sends results back up to the |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1999 | 2001 |
| 2000 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2002 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 2001 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2003 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 2002 rwh_view->SetSize(view()->GetContainerSize()); | 2004 rwh_view->SetSize(view()->GetContainerSize()); |
| 2003 } | 2005 } |
| 2004 | 2006 |
| 2005 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { | 2007 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { |
| 2006 return render_view_host() ? | 2008 return render_view_host() ? |
| 2007 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; | 2009 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; |
| 2008 } | 2010 } |
| OLD | NEW |