| 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 24 matching lines...) Expand all Loading... |
| 35 #include "content/browser/tab_contents/provisional_load_details.h" | 35 #include "content/browser/tab_contents/provisional_load_details.h" |
| 36 #include "content/browser/tab_contents/tab_contents_delegate.h" | 36 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 37 #include "content/browser/tab_contents/tab_contents_observer.h" | 37 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 38 #include "content/browser/tab_contents/tab_contents_view.h" | 38 #include "content/browser/tab_contents/tab_contents_view.h" |
| 39 #include "content/browser/tab_contents/title_updated_details.h" | 39 #include "content/browser/tab_contents/title_updated_details.h" |
| 40 #include "content/browser/user_metrics.h" | 40 #include "content/browser/user_metrics.h" |
| 41 #include "content/browser/webui/web_ui_factory.h" | 41 #include "content/browser/webui/web_ui_factory.h" |
| 42 #include "content/common/bindings_policy.h" | 42 #include "content/common/bindings_policy.h" |
| 43 #include "content/common/content_client.h" | 43 #include "content/common/content_client.h" |
| 44 #include "content/common/content_restriction.h" | 44 #include "content/common/content_restriction.h" |
| 45 #include "content/common/intents_messages.h" |
| 45 #include "content/common/navigation_types.h" | 46 #include "content/common/navigation_types.h" |
| 46 #include "content/common/notification_service.h" | 47 #include "content/common/notification_service.h" |
| 47 #include "content/common/url_constants.h" | 48 #include "content/common/url_constants.h" |
| 48 #include "content/common/view_messages.h" | 49 #include "content/common/view_messages.h" |
| 49 #include "net/base/net_util.h" | 50 #include "net/base/net_util.h" |
| 50 #include "net/base/registry_controlled_domain.h" | 51 #include "net/base/registry_controlled_domain.h" |
| 51 #include "net/url_request/url_request_context_getter.h" | 52 #include "net/url_request/url_request_context_getter.h" |
| 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 53 #include "ui/gfx/codec/png_codec.h" | 54 #include "ui/gfx/codec/png_codec.h" |
| 54 #include "webkit/glue/password_form.h" | 55 #include "webkit/glue/password_form.h" |
| 56 #include "webkit/glue/web_intent_data.h" |
| 55 #include "webkit/glue/webpreferences.h" | 57 #include "webkit/glue/webpreferences.h" |
| 56 | 58 |
| 57 #if defined(OS_MACOSX) | 59 #if defined(OS_MACOSX) |
| 58 #include "ui/gfx/surface/io_surface_support_mac.h" | 60 #include "ui/gfx/surface/io_surface_support_mac.h" |
| 59 #endif // defined(OS_MACOSX) | 61 #endif // defined(OS_MACOSX) |
| 60 | 62 |
| 61 // Cross-Site Navigations | 63 // Cross-Site Navigations |
| 62 // | 64 // |
| 63 // If a TabContents is told to navigate to a different web site (as determined | 65 // If a TabContents is told to navigate to a different web site (as determined |
| 64 // by SiteInstance), it will replace its current RenderViewHost with a new | 66 // by SiteInstance), it will replace its current RenderViewHost with a new |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 272 |
| 271 ObserverListBase<TabContentsObserver>::Iterator it(observers_); | 273 ObserverListBase<TabContentsObserver>::Iterator it(observers_); |
| 272 TabContentsObserver* observer; | 274 TabContentsObserver* observer; |
| 273 while ((observer = it.GetNext()) != NULL) | 275 while ((observer = it.GetNext()) != NULL) |
| 274 if (observer->OnMessageReceived(message)) | 276 if (observer->OnMessageReceived(message)) |
| 275 return true; | 277 return true; |
| 276 | 278 |
| 277 bool handled = true; | 279 bool handled = true; |
| 278 bool message_is_ok = true; | 280 bool message_is_ok = true; |
| 279 IPC_BEGIN_MESSAGE_MAP_EX(TabContents, message, message_is_ok) | 281 IPC_BEGIN_MESSAGE_MAP_EX(TabContents, message, message_is_ok) |
| 282 IPC_MESSAGE_HANDLER(IntentsHostMsg_WebIntentDispatch, |
| 283 OnWebIntentDispatch) |
| 280 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, | 284 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, |
| 281 OnDidStartProvisionalLoadForFrame) | 285 OnDidStartProvisionalLoadForFrame) |
| 282 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRedirectProvisionalLoad, | 286 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRedirectProvisionalLoad, |
| 283 OnDidRedirectProvisionalLoad) | 287 OnDidRedirectProvisionalLoad) |
| 284 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError, | 288 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError, |
| 285 OnDidFailProvisionalLoadWithError) | 289 OnDidFailProvisionalLoadWithError) |
| 286 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, | 290 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, |
| 287 OnDidLoadResourceFromMemoryCache) | 291 OnDidLoadResourceFromMemoryCache) |
| 288 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent, | 292 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent, |
| 289 OnDidDisplayInsecureContent) | 293 OnDidDisplayInsecureContent) |
| 290 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, | 294 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, |
| 291 OnDidRunInsecureContent) | 295 OnDidRunInsecureContent) |
| 292 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, | 296 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, |
| 293 OnDocumentLoadedInFrame) | 297 OnDocumentLoadedInFrame) |
| 294 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) | 298 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) |
| 295 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, | 299 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, |
| 296 OnUpdateContentRestrictions) | 300 OnUpdateContentRestrictions) |
| 297 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) | 301 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) |
| 298 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) | 302 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) |
| 299 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) | 303 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) |
| 300 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL) | 304 IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL) |
| 301 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) | 305 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) |
| 302 IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory) | 306 IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory) |
| 303 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, | 307 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterProtocolHandler, |
| 304 OnRegisterProtocolHandler) | 308 OnRegisterProtocolHandler) |
| 305 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterIntentHandler, | 309 IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterIntentHandler, |
| 306 OnRegisterIntentHandler) | 310 OnRegisterIntentHandler) |
| 307 IPC_MESSAGE_HANDLER(ViewHostMsg_WebIntentDispatch, | |
| 308 OnWebIntentDispatch) | |
| 309 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) | 311 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) |
| 310 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) | 312 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) |
| 311 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 313 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
| 312 IPC_MESSAGE_UNHANDLED(handled = false) | 314 IPC_MESSAGE_UNHANDLED(handled = false) |
| 313 IPC_END_MESSAGE_MAP_EX() | 315 IPC_END_MESSAGE_MAP_EX() |
| 314 | 316 |
| 315 if (!message_is_ok) { | 317 if (!message_is_ok) { |
| 316 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 318 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
| 317 GetRenderProcessHost()->ReceivedBadMessage(); | 319 GetRenderProcessHost()->ReceivedBadMessage(); |
| 318 } | 320 } |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 } | 1131 } |
| 1130 | 1132 |
| 1131 void TabContents::OnRegisterIntentHandler(const string16& action, | 1133 void TabContents::OnRegisterIntentHandler(const string16& action, |
| 1132 const string16& type, | 1134 const string16& type, |
| 1133 const string16& href, | 1135 const string16& href, |
| 1134 const string16& title) { | 1136 const string16& title) { |
| 1135 delegate()->RegisterIntentHandler(this, action, type, href, title); | 1137 delegate()->RegisterIntentHandler(this, action, type, href, title); |
| 1136 } | 1138 } |
| 1137 | 1139 |
| 1138 void TabContents::OnWebIntentDispatch(const IPC::Message& message, | 1140 void TabContents::OnWebIntentDispatch(const IPC::Message& message, |
| 1139 const string16& action, | 1141 const webkit_glue::WebIntentData& intent, |
| 1140 const string16& type, | |
| 1141 const string16& data, | |
| 1142 int intent_id) { | 1142 int intent_id) { |
| 1143 delegate()->WebIntentDispatch(this, message.routing_id(), action, type, | 1143 delegate()->WebIntentDispatch(this, message.routing_id(), intent, intent_id); |
| 1144 data, intent_id); | |
| 1145 } | 1144 } |
| 1146 | 1145 |
| 1147 void TabContents::OnFindReply(int request_id, | 1146 void TabContents::OnFindReply(int request_id, |
| 1148 int number_of_matches, | 1147 int number_of_matches, |
| 1149 const gfx::Rect& selection_rect, | 1148 const gfx::Rect& selection_rect, |
| 1150 int active_match_ordinal, | 1149 int active_match_ordinal, |
| 1151 bool final_update) { | 1150 bool final_update) { |
| 1152 delegate()->FindReply(this, request_id, number_of_matches, selection_rect, | 1151 delegate()->FindReply(this, request_id, number_of_matches, selection_rect, |
| 1153 active_match_ordinal, final_update); | 1152 active_match_ordinal, final_update); |
| 1154 } | 1153 } |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 } | 2015 } |
| 2017 | 2016 |
| 2018 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { | 2017 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { |
| 2019 render_manager_.SwapInRenderViewHost(rvh); | 2018 render_manager_.SwapInRenderViewHost(rvh); |
| 2020 } | 2019 } |
| 2021 | 2020 |
| 2022 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2021 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 2023 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2022 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 2024 rwh_view->SetSize(view()->GetContainerSize()); | 2023 rwh_view->SetSize(view()->GetContainerSize()); |
| 2025 } | 2024 } |
| OLD | NEW |