| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, | 409 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, |
| 410 OnDidRunInsecureContent) | 410 OnDidRunInsecureContent) |
| 411 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, | 411 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, |
| 412 OnDocumentLoadedInFrame) | 412 OnDocumentLoadedInFrame) |
| 413 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) | 413 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) |
| 414 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, | 414 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, |
| 415 OnUpdateContentRestrictions) | 415 OnUpdateContentRestrictions) |
| 416 IPC_MESSAGE_HANDLER(ViewHostMsg_PDFHasUnsupportedFeature, | 416 IPC_MESSAGE_HANDLER(ViewHostMsg_PDFHasUnsupportedFeature, |
| 417 OnPDFHasUnsupportedFeature) | 417 OnPDFHasUnsupportedFeature) |
| 418 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) | 418 IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) |
| 419 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DidGetApplicationInfo, | |
| 420 OnDidGetApplicationInfo) | |
| 421 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InstallApplication, | |
| 422 OnInstallApplication) | |
| 423 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) | 419 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) |
| 424 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) | 420 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) |
| 425 IPC_MESSAGE_UNHANDLED(handled = false) | 421 IPC_MESSAGE_UNHANDLED(handled = false) |
| 426 IPC_END_MESSAGE_MAP_EX() | 422 IPC_END_MESSAGE_MAP_EX() |
| 427 | 423 |
| 428 if (!message_is_ok) { | 424 if (!message_is_ok) { |
| 429 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 425 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
| 430 GetRenderProcessHost()->ReceivedBadMessage(); | 426 GetRenderProcessHost()->ReceivedBadMessage(); |
| 431 } | 427 } |
| 432 | 428 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 NotificationService::current()->Notify( | 835 NotificationService::current()->Notify( |
| 840 NotificationType::TAB_ADDED, | 836 NotificationType::TAB_ADDED, |
| 841 Source<TabContentsDelegate>(delegate_), | 837 Source<TabContentsDelegate>(delegate_), |
| 842 Details<TabContents>(this)); | 838 Details<TabContents>(this)); |
| 843 } | 839 } |
| 844 | 840 |
| 845 // TODO(pkasting): Why is this necessary? | 841 // TODO(pkasting): Why is this necessary? |
| 846 PopupNotificationVisibilityChanged(blocked_contents_ != NULL); | 842 PopupNotificationVisibilityChanged(blocked_contents_ != NULL); |
| 847 } | 843 } |
| 848 | 844 |
| 849 bool TabContents::ExecuteCode(int request_id, const std::string& extension_id, | |
| 850 bool is_js_code, const std::string& code_string, | |
| 851 bool all_frames) { | |
| 852 RenderViewHost* host = render_view_host(); | |
| 853 if (!host) | |
| 854 return false; | |
| 855 | |
| 856 ExtensionMsg_ExecuteCode_Params params; | |
| 857 params.request_id = request_id; | |
| 858 params.extension_id = extension_id; | |
| 859 params.is_javascript = is_js_code; | |
| 860 params.code = code_string; | |
| 861 params.all_frames = all_frames; | |
| 862 return host->Send(new ExtensionMsg_ExecuteCode(host->routing_id(), params)); | |
| 863 } | |
| 864 | |
| 865 void TabContents::PopupNotificationVisibilityChanged(bool visible) { | 845 void TabContents::PopupNotificationVisibilityChanged(bool visible) { |
| 866 if (is_being_destroyed_) | 846 if (is_being_destroyed_) |
| 867 return; | 847 return; |
| 868 content_settings_delegate_->SetPopupsBlocked(visible); | 848 content_settings_delegate_->SetPopupsBlocked(visible); |
| 869 if (!dont_notify_render_view_) | 849 if (!dont_notify_render_view_) |
| 870 render_view_host()->AllowScriptToClose(!visible); | 850 render_view_host()->AllowScriptToClose(!visible); |
| 871 } | 851 } |
| 872 | 852 |
| 873 gfx::NativeView TabContents::GetContentNativeView() const { | 853 gfx::NativeView TabContents::GetContentNativeView() const { |
| 874 return view_->GetContentNativeView(); | 854 return view_->GetContentNativeView(); |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 return; | 1773 return; |
| 1794 // Note that we don't call NavigationController::GotToOffset() as we don't | 1774 // Note that we don't call NavigationController::GotToOffset() as we don't |
| 1795 // want to create a pending navigation entry (it might end up lingering | 1775 // want to create a pending navigation entry (it might end up lingering |
| 1796 // http://crbug.com/51680). | 1776 // http://crbug.com/51680). |
| 1797 entry->set_transition_type(entry->transition_type() | | 1777 entry->set_transition_type(entry->transition_type() | |
| 1798 PageTransition::FORWARD_BACK); | 1778 PageTransition::FORWARD_BACK); |
| 1799 NavigateToEntry(*entry, NavigationController::NO_RELOAD); | 1779 NavigateToEntry(*entry, NavigationController::NO_RELOAD); |
| 1800 } | 1780 } |
| 1801 } | 1781 } |
| 1802 | 1782 |
| 1803 void TabContents::OnDidGetApplicationInfo(int32 page_id, | |
| 1804 const WebApplicationInfo& info) { | |
| 1805 web_app_info_ = info; | |
| 1806 | |
| 1807 if (delegate()) | |
| 1808 delegate()->OnDidGetApplicationInfo(this, page_id); | |
| 1809 } | |
| 1810 | |
| 1811 void TabContents::OnInstallApplication(const WebApplicationInfo& info) { | |
| 1812 if (delegate()) | |
| 1813 delegate()->OnInstallApplication(this, info); | |
| 1814 } | |
| 1815 | |
| 1816 void TabContents::OnPageContents(const GURL& url, | 1783 void TabContents::OnPageContents(const GURL& url, |
| 1817 int32 page_id, | 1784 int32 page_id, |
| 1818 const string16& contents, | 1785 const string16& contents, |
| 1819 const std::string& language, | 1786 const std::string& language, |
| 1820 bool page_translatable) { | 1787 bool page_translatable) { |
| 1821 // Don't index any https pages. People generally don't want their bank | 1788 // Don't index any https pages. People generally don't want their bank |
| 1822 // accounts, etc. indexed on their computer, especially since some of these | 1789 // accounts, etc. indexed on their computer, especially since some of these |
| 1823 // things are not marked cachable. | 1790 // things are not marked cachable. |
| 1824 // TODO(brettw) we may want to consider more elaborate heuristics such as | 1791 // TODO(brettw) we may want to consider more elaborate heuristics such as |
| 1825 // the cachability of the page. We may also want to consider subframes (this | 1792 // the cachability of the page. We may also want to consider subframes (this |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2249 | 2216 |
| 2250 void TabContents::DomOperationResponse(const std::string& json_string, | 2217 void TabContents::DomOperationResponse(const std::string& json_string, |
| 2251 int automation_id) { | 2218 int automation_id) { |
| 2252 } | 2219 } |
| 2253 | 2220 |
| 2254 void TabContents::ProcessWebUIMessage( | 2221 void TabContents::ProcessWebUIMessage( |
| 2255 const ExtensionHostMsg_DomMessage_Params& params) { | 2222 const ExtensionHostMsg_DomMessage_Params& params) { |
| 2256 if (!render_manager_.web_ui()) { | 2223 if (!render_manager_.web_ui()) { |
| 2257 // This can happen if someone uses window.open() to open an extension URL | 2224 // This can happen if someone uses window.open() to open an extension URL |
| 2258 // from a non-extension context. | 2225 // from a non-extension context. |
| 2259 render_view_host()->BlockExtensionRequest(params.request_id); | 2226 render_view_host()->Send(new ExtensionMsg_Response( |
| 2227 render_view_host()->routing_id(), params.request_id, false, "", |
| 2228 "Access to extension API denied.")); |
| 2260 return; | 2229 return; |
| 2261 } | 2230 } |
| 2262 render_manager_.web_ui()->ProcessWebUIMessage(params); | 2231 render_manager_.web_ui()->ProcessWebUIMessage(params); |
| 2263 } | 2232 } |
| 2264 | 2233 |
| 2265 void TabContents::ProcessExternalHostMessage(const std::string& message, | 2234 void TabContents::ProcessExternalHostMessage(const std::string& message, |
| 2266 const std::string& origin, | 2235 const std::string& origin, |
| 2267 const std::string& target) { | 2236 const std::string& target) { |
| 2268 if (delegate()) | 2237 if (delegate()) |
| 2269 delegate()->ForwardMessageToExternalHost(message, origin, target); | 2238 delegate()->ForwardMessageToExternalHost(message, origin, target); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2649 | 2618 |
| 2650 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2619 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 2651 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 2620 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 2652 rwh_view->SetSize(view()->GetContainerSize()); | 2621 rwh_view->SetSize(view()->GetContainerSize()); |
| 2653 } | 2622 } |
| 2654 | 2623 |
| 2655 void TabContents::OnOnlineStateChanged(bool online) { | 2624 void TabContents::OnOnlineStateChanged(bool online) { |
| 2656 render_view_host()->Send(new ViewMsg_NetworkStateChanged( | 2625 render_view_host()->Send(new ViewMsg_NetworkStateChanged( |
| 2657 render_view_host()->routing_id(), online)); | 2626 render_view_host()->routing_id(), online)); |
| 2658 } | 2627 } |
| OLD | NEW |