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/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "chrome/browser/translate/page_translated_details.h" | 51 #include "chrome/browser/translate/page_translated_details.h" |
52 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" | 52 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" |
53 #include "chrome/browser/ui/browser_dialogs.h" | 53 #include "chrome/browser/ui/browser_dialogs.h" |
54 #include "chrome/common/bindings_policy.h" | 54 #include "chrome/common/bindings_policy.h" |
55 #include "chrome/common/chrome_constants.h" | 55 #include "chrome/common/chrome_constants.h" |
56 #include "chrome/common/chrome_switches.h" | 56 #include "chrome/common/chrome_switches.h" |
57 #include "chrome/common/content_restriction.h" | 57 #include "chrome/common/content_restriction.h" |
58 #include "chrome/common/extensions/extension.h" | 58 #include "chrome/common/extensions/extension.h" |
59 #include "chrome/common/extensions/extension_action.h" | 59 #include "chrome/common/extensions/extension_action.h" |
60 #include "chrome/common/extensions/extension_icon_set.h" | 60 #include "chrome/common/extensions/extension_icon_set.h" |
| 61 #include "chrome/common/extensions/extension_messages.h" |
61 #include "chrome/common/extensions/extension_resource.h" | 62 #include "chrome/common/extensions/extension_resource.h" |
62 #include "chrome/common/extensions/url_pattern.h" | 63 #include "chrome/common/extensions/url_pattern.h" |
63 #include "chrome/common/net/url_request_context_getter.h" | 64 #include "chrome/common/net/url_request_context_getter.h" |
64 #include "chrome/common/pref_names.h" | 65 #include "chrome/common/pref_names.h" |
65 #include "chrome/common/render_messages.h" | 66 #include "chrome/common/render_messages.h" |
66 #include "chrome/common/render_messages_params.h" | |
67 #include "chrome/common/url_constants.h" | 67 #include "chrome/common/url_constants.h" |
68 #include "content/browser/child_process_security_policy.h" | 68 #include "content/browser/child_process_security_policy.h" |
69 #include "content/browser/host_zoom_map.h" | 69 #include "content/browser/host_zoom_map.h" |
70 #include "content/browser/in_process_webkit/session_storage_namespace.h" | 70 #include "content/browser/in_process_webkit/session_storage_namespace.h" |
71 #include "content/browser/renderer_host/render_process_host.h" | 71 #include "content/browser/renderer_host/render_process_host.h" |
72 #include "content/browser/renderer_host/render_view_host.h" | 72 #include "content/browser/renderer_host/render_view_host.h" |
73 #include "content/browser/renderer_host/render_widget_host_view.h" | 73 #include "content/browser/renderer_host/render_widget_host_view.h" |
74 #include "content/browser/renderer_host/resource_request_details.h" | 74 #include "content/browser/renderer_host/resource_request_details.h" |
75 #include "content/browser/site_instance.h" | 75 #include "content/browser/site_instance.h" |
76 #include "content/browser/tab_contents/interstitial_page.h" | 76 #include "content/browser/tab_contents/interstitial_page.h" |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, | 410 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, |
411 OnDidRunInsecureContent) | 411 OnDidRunInsecureContent) |
412 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, | 412 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, |
413 OnDocumentLoadedInFrame) | 413 OnDocumentLoadedInFrame) |
414 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) | 414 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) |
415 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, | 415 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, |
416 OnUpdateContentRestrictions) | 416 OnUpdateContentRestrictions) |
417 IPC_MESSAGE_HANDLER(ViewHostMsg_PDFHasUnsupportedFeature, | 417 IPC_MESSAGE_HANDLER(ViewHostMsg_PDFHasUnsupportedFeature, |
418 OnPDFHasUnsupportedFeature) | 418 OnPDFHasUnsupportedFeature) |
419 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) | 419 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) |
420 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetApplicationInfo, | 420 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DidGetApplicationInfo, |
421 OnDidGetApplicationInfo) | 421 OnDidGetApplicationInfo) |
422 IPC_MESSAGE_HANDLER(ViewHostMsg_InstallApplication, | 422 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InstallApplication, |
423 OnInstallApplication) | 423 OnInstallApplication) |
424 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) | 424 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) |
425 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) | 425 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) |
426 IPC_MESSAGE_UNHANDLED(handled = false) | 426 IPC_MESSAGE_UNHANDLED(handled = false) |
427 IPC_END_MESSAGE_MAP_EX() | 427 IPC_END_MESSAGE_MAP_EX() |
428 | 428 |
429 if (!message_is_ok) { | 429 if (!message_is_ok) { |
430 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 430 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
431 GetRenderProcessHost()->ReceivedBadMessage(); | 431 GetRenderProcessHost()->ReceivedBadMessage(); |
432 } | 432 } |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 PopupNotificationVisibilityChanged(blocked_contents_ != NULL); | 885 PopupNotificationVisibilityChanged(blocked_contents_ != NULL); |
886 } | 886 } |
887 | 887 |
888 bool TabContents::ExecuteCode(int request_id, const std::string& extension_id, | 888 bool TabContents::ExecuteCode(int request_id, const std::string& extension_id, |
889 bool is_js_code, const std::string& code_string, | 889 bool is_js_code, const std::string& code_string, |
890 bool all_frames) { | 890 bool all_frames) { |
891 RenderViewHost* host = render_view_host(); | 891 RenderViewHost* host = render_view_host(); |
892 if (!host) | 892 if (!host) |
893 return false; | 893 return false; |
894 | 894 |
895 return host->Send(new ViewMsg_ExecuteCode(host->routing_id(), | 895 ExtensionMsg_ExecuteCode_Params params; |
896 ViewMsg_ExecuteCode_Params(request_id, extension_id, | 896 params.request_id = request_id; |
897 is_js_code, code_string, all_frames))); | 897 params.extension_id = extension_id; |
| 898 params.is_javascript = is_js_code; |
| 899 params.code = code_string; |
| 900 params.all_frames = all_frames; |
| 901 return host->Send(new ExtensionMsg_ExecuteCode(host->routing_id(), params)); |
898 } | 902 } |
899 | 903 |
900 void TabContents::PopupNotificationVisibilityChanged(bool visible) { | 904 void TabContents::PopupNotificationVisibilityChanged(bool visible) { |
901 if (is_being_destroyed_) | 905 if (is_being_destroyed_) |
902 return; | 906 return; |
903 content_settings_delegate_->SetPopupsBlocked(visible); | 907 content_settings_delegate_->SetPopupsBlocked(visible); |
904 if (!dont_notify_render_view_) | 908 if (!dont_notify_render_view_) |
905 render_view_host()->AllowScriptToClose(!visible); | 909 render_view_host()->AllowScriptToClose(!visible); |
906 } | 910 } |
907 | 911 |
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2307 } else { | 2311 } else { |
2308 OpenURL(url, referrer, disposition, PageTransition::LINK); | 2312 OpenURL(url, referrer, disposition, PageTransition::LINK); |
2309 } | 2313 } |
2310 } | 2314 } |
2311 | 2315 |
2312 void TabContents::DomOperationResponse(const std::string& json_string, | 2316 void TabContents::DomOperationResponse(const std::string& json_string, |
2313 int automation_id) { | 2317 int automation_id) { |
2314 } | 2318 } |
2315 | 2319 |
2316 void TabContents::ProcessWebUIMessage( | 2320 void TabContents::ProcessWebUIMessage( |
2317 const ViewHostMsg_DomMessage_Params& params) { | 2321 const ExtensionHostMsg_DomMessage_Params& params) { |
2318 if (!render_manager_.web_ui()) { | 2322 if (!render_manager_.web_ui()) { |
2319 // This can happen if someone uses window.open() to open an extension URL | 2323 // This can happen if someone uses window.open() to open an extension URL |
2320 // from a non-extension context. | 2324 // from a non-extension context. |
2321 render_view_host()->BlockExtensionRequest(params.request_id); | 2325 render_view_host()->BlockExtensionRequest(params.request_id); |
2322 return; | 2326 return; |
2323 } | 2327 } |
2324 render_manager_.web_ui()->ProcessWebUIMessage(params); | 2328 render_manager_.web_ui()->ProcessWebUIMessage(params); |
2325 } | 2329 } |
2326 | 2330 |
2327 void TabContents::ProcessExternalHostMessage(const std::string& message, | 2331 void TabContents::ProcessExternalHostMessage(const std::string& message, |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2747 | 2751 |
2748 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2752 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2749 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2753 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
2750 rwh_view->SetSize(view()->GetContainerSize()); | 2754 rwh_view->SetSize(view()->GetContainerSize()); |
2751 } | 2755 } |
2752 | 2756 |
2753 void TabContents::OnOnlineStateChanged(bool online) { | 2757 void TabContents::OnOnlineStateChanged(bool online) { |
2754 render_view_host()->Send(new ViewMsg_NetworkStateChanged( | 2758 render_view_host()->Send(new ViewMsg_NetworkStateChanged( |
2755 render_view_host()->routing_id(), online)); | 2759 render_view_host()->routing_id(), online)); |
2756 } | 2760 } |
OLD | NEW |