OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/render_view_host.h" | 5 #include "chrome/browser/renderer_host/render_view_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 process()->id(), routing_id(), false); | 150 process()->id(), routing_id(), false); |
151 } | 151 } |
152 | 152 |
153 bool RenderViewHost::CreateRenderView(const string16& frame_name) { | 153 bool RenderViewHost::CreateRenderView(const string16& frame_name) { |
154 DCHECK(!IsRenderViewLive()) << "Creating view twice"; | 154 DCHECK(!IsRenderViewLive()) << "Creating view twice"; |
155 | 155 |
156 // The process may (if we're sharing a process with another host that already | 156 // The process may (if we're sharing a process with another host that already |
157 // initialized it) or may not (we have our own process or the old process | 157 // initialized it) or may not (we have our own process or the old process |
158 // crashed) have been initialized. Calling Init multiple times will be | 158 // crashed) have been initialized. Calling Init multiple times will be |
159 // ignored, so this is safe. | 159 // ignored, so this is safe. |
160 if (!process()->Init(is_extension_process_)) | 160 if (!process()->Init(renderer_accessible(), is_extension_process_)) |
161 return false; | 161 return false; |
162 DCHECK(process()->HasConnection()); | 162 DCHECK(process()->HasConnection()); |
163 DCHECK(process()->profile()); | 163 DCHECK(process()->profile()); |
164 | 164 |
165 if (BindingsPolicy::is_dom_ui_enabled(enabled_bindings_)) { | 165 if (BindingsPolicy::is_dom_ui_enabled(enabled_bindings_)) { |
166 ChildProcessSecurityPolicy::GetInstance()->GrantDOMUIBindings( | 166 ChildProcessSecurityPolicy::GetInstance()->GrantDOMUIBindings( |
167 process()->id()); | 167 process()->id()); |
168 } | 168 } |
169 | 169 |
170 if (BindingsPolicy::is_extension_enabled(enabled_bindings_)) { | 170 if (BindingsPolicy::is_extension_enabled(enabled_bindings_)) { |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDesktopNotification, | 837 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDesktopNotification, |
838 OnShowDesktopNotification) | 838 OnShowDesktopNotification) |
839 IPC_MESSAGE_HANDLER(ViewHostMsg_CancelDesktopNotification, | 839 IPC_MESSAGE_HANDLER(ViewHostMsg_CancelDesktopNotification, |
840 OnCancelDesktopNotification) | 840 OnCancelDesktopNotification) |
841 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestNotificationPermission, | 841 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestNotificationPermission, |
842 OnRequestNotificationPermission) | 842 OnRequestNotificationPermission) |
843 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionRequest, OnExtensionRequest) | 843 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionRequest, OnExtensionRequest) |
844 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) | 844 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) |
845 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionPostMessage, | 845 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionPostMessage, |
846 OnExtensionPostMessage) | 846 OnExtensionPostMessage) |
847 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityFocusChange, | |
848 OnAccessibilityFocusChange) | |
849 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, | 847 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, |
850 OnAccessibilityNotifications) | 848 OnAccessibilityNotifications) |
851 IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted) | 849 IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted) |
852 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) | 850 IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) |
853 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) | 851 IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) |
854 IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) | 852 IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) |
855 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 853 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
856 IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed) | 854 IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed) |
857 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityTree, OnAccessibilityTree) | |
858 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) | 855 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) |
859 IPC_MESSAGE_HANDLER(ViewHostMsg_SetDisplayingPDFContent, | 856 IPC_MESSAGE_HANDLER(ViewHostMsg_SetDisplayingPDFContent, |
860 OnSetDisplayingPDFContent) | 857 OnSetDisplayingPDFContent) |
861 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSuggestResult, OnSetSuggestResult) | 858 IPC_MESSAGE_HANDLER(ViewHostMsg_SetSuggestResult, OnSetSuggestResult) |
862 // Have the super handle all other messages. | 859 // Have the super handle all other messages. |
863 IPC_MESSAGE_UNHANDLED(RenderWidgetHost::OnMessageReceived(msg)) | 860 IPC_MESSAGE_UNHANDLED(RenderWidgetHost::OnMessageReceived(msg)) |
864 IPC_END_MESSAGE_MAP_EX() | 861 IPC_END_MESSAGE_MAP_EX() |
865 | 862 |
866 if (!msg_is_ok) { | 863 if (!msg_is_ok) { |
867 // The message had a handler, but its de-serialization failed. | 864 // The message had a handler, but its de-serialization failed. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 FilterURL(policy, renderer_id, &validated_params.url); | 1013 FilterURL(policy, renderer_id, &validated_params.url); |
1017 FilterURL(policy, renderer_id, &validated_params.referrer); | 1014 FilterURL(policy, renderer_id, &validated_params.referrer); |
1018 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); | 1015 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); |
1019 it != validated_params.redirects.end(); ++it) { | 1016 it != validated_params.redirects.end(); ++it) { |
1020 FilterURL(policy, renderer_id, &(*it)); | 1017 FilterURL(policy, renderer_id, &(*it)); |
1021 } | 1018 } |
1022 FilterURL(policy, renderer_id, &validated_params.searchable_form_url); | 1019 FilterURL(policy, renderer_id, &validated_params.searchable_form_url); |
1023 FilterURL(policy, renderer_id, &validated_params.password_form.origin); | 1020 FilterURL(policy, renderer_id, &validated_params.password_form.origin); |
1024 FilterURL(policy, renderer_id, &validated_params.password_form.action); | 1021 FilterURL(policy, renderer_id, &validated_params.password_form.action); |
1025 | 1022 |
1026 if (!validated_params.was_within_same_page) { | |
1027 // Only set that the document is not loaded if the navigation was not within | |
1028 // the current page. If it was within the same page, the document will not | |
1029 // load again. | |
1030 SetDocumentLoaded(false); | |
1031 } | |
1032 delegate_->DidNavigate(this, validated_params); | 1023 delegate_->DidNavigate(this, validated_params); |
1033 } | 1024 } |
1034 | 1025 |
1035 void RenderViewHost::OnMsgUpdateState(int32 page_id, | 1026 void RenderViewHost::OnMsgUpdateState(int32 page_id, |
1036 const std::string& state) { | 1027 const std::string& state) { |
1037 delegate_->UpdateState(this, page_id, state); | 1028 delegate_->UpdateState(this, page_id, state); |
1038 } | 1029 } |
1039 | 1030 |
1040 void RenderViewHost::OnMsgUpdateTitle(int32 page_id, | 1031 void RenderViewHost::OnMsgUpdateTitle(int32 page_id, |
1041 const std::wstring& title) { | 1032 const std::wstring& title) { |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 const std::string& message, const std::string& origin, | 1310 const std::string& message, const std::string& origin, |
1320 const std::string& target) { | 1311 const std::string& target) { |
1321 delegate_->ProcessExternalHostMessage(message, origin, target); | 1312 delegate_->ProcessExternalHostMessage(message, origin, target); |
1322 } | 1313 } |
1323 | 1314 |
1324 void RenderViewHost::OnMsgDocumentLoadedInFrame() { | 1315 void RenderViewHost::OnMsgDocumentLoadedInFrame() { |
1325 RenderViewHostDelegate::Resource* resource_delegate = | 1316 RenderViewHostDelegate::Resource* resource_delegate = |
1326 delegate_->GetResourceDelegate(); | 1317 delegate_->GetResourceDelegate(); |
1327 if (resource_delegate) | 1318 if (resource_delegate) |
1328 resource_delegate->DocumentLoadedInFrame(); | 1319 resource_delegate->DocumentLoadedInFrame(); |
1329 SetDocumentLoaded(true); | |
1330 } | 1320 } |
1331 | 1321 |
1332 void RenderViewHost::DisassociateFromPopupCount() { | 1322 void RenderViewHost::DisassociateFromPopupCount() { |
1333 Send(new ViewMsg_DisassociateFromPopupCount(routing_id())); | 1323 Send(new ViewMsg_DisassociateFromPopupCount(routing_id())); |
1334 } | 1324 } |
1335 | 1325 |
1336 void RenderViewHost::AllowScriptToClose(bool script_can_close) { | 1326 void RenderViewHost::AllowScriptToClose(bool script_can_close) { |
1337 Send(new ViewMsg_AllowScriptToClose(routing_id(), script_can_close)); | 1327 Send(new ViewMsg_AllowScriptToClose(routing_id(), script_can_close)); |
1338 } | 1328 } |
1339 | 1329 |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1951 } | 1941 } |
1952 | 1942 |
1953 void RenderViewHost::OnExtensionPostMessage( | 1943 void RenderViewHost::OnExtensionPostMessage( |
1954 int port_id, const std::string& message) { | 1944 int port_id, const std::string& message) { |
1955 if (process()->profile()->GetExtensionMessageService()) { | 1945 if (process()->profile()->GetExtensionMessageService()) { |
1956 process()->profile()->GetExtensionMessageService()-> | 1946 process()->profile()->GetExtensionMessageService()-> |
1957 PostMessageFromRenderer(port_id, message); | 1947 PostMessageFromRenderer(port_id, message); |
1958 } | 1948 } |
1959 } | 1949 } |
1960 | 1950 |
1961 void RenderViewHost::OnAccessibilityFocusChange(int acc_obj_id) { | |
1962 if (view()) | |
1963 view()->OnAccessibilityFocusChange(acc_obj_id); | |
1964 } | |
1965 | |
1966 void RenderViewHost::OnAccessibilityNotifications( | 1951 void RenderViewHost::OnAccessibilityNotifications( |
1967 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) { | 1952 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) { |
1968 if (view()) | 1953 if (view()) |
1969 view()->OnAccessibilityNotifications(params); | 1954 view()->OnAccessibilityNotifications(params); |
1970 | 1955 |
1971 if (params.size() > 0) { | 1956 if (params.size() > 0) { |
| 1957 for (unsigned i = 0; i < params.size(); i++) { |
| 1958 const ViewHostMsg_AccessibilityNotification_Params& param = params[i]; |
| 1959 |
| 1960 if (param.notification_type == |
| 1961 ViewHostMsg_AccessibilityNotification_Params:: |
| 1962 NOTIFICATION_TYPE_LOAD_COMPLETE) { |
| 1963 // TODO(ctguil): Remove when mac processes OnAccessibilityNotifications. |
| 1964 if (view()) |
| 1965 view()->UpdateAccessibilityTree(param.acc_obj); |
| 1966 |
| 1967 if (save_accessibility_tree_for_testing_) |
| 1968 accessibility_tree_ = param.acc_obj; |
| 1969 } |
| 1970 } |
| 1971 |
1972 NotificationService::current()->Notify( | 1972 NotificationService::current()->Notify( |
1973 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, | 1973 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, |
1974 Source<RenderViewHost>(this), | 1974 Source<RenderViewHost>(this), |
1975 NotificationService::NoDetails()); | 1975 NotificationService::NoDetails()); |
1976 } | 1976 } |
1977 } | 1977 } |
1978 | 1978 |
1979 void RenderViewHost::OnAccessibilityTree( | |
1980 const webkit_glue::WebAccessibility& tree) { | |
1981 if (view()) | |
1982 view()->UpdateAccessibilityTree(tree); | |
1983 | |
1984 if (save_accessibility_tree_for_testing_) | |
1985 accessibility_tree_ = tree; | |
1986 | |
1987 NotificationService::current()->Notify( | |
1988 NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, | |
1989 Source<RenderViewHost>(this), | |
1990 NotificationService::NoDetails()); | |
1991 } | |
1992 | |
1993 void RenderViewHost::OnCSSInserted() { | 1979 void RenderViewHost::OnCSSInserted() { |
1994 delegate_->DidInsertCSS(); | 1980 delegate_->DidInsertCSS(); |
1995 } | 1981 } |
1996 | 1982 |
1997 void RenderViewHost::OnPageContents(const GURL& url, | 1983 void RenderViewHost::OnPageContents(const GURL& url, |
1998 int32 page_id, | 1984 int32 page_id, |
1999 const string16& contents, | 1985 const string16& contents, |
2000 const std::string& language, | 1986 const std::string& language, |
2001 bool page_translatable) { | 1987 bool page_translatable) { |
2002 RenderViewHostDelegate::BrowserIntegration* integration_delegate = | 1988 RenderViewHostDelegate::BrowserIntegration* integration_delegate = |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 } | 2039 } |
2054 | 2040 |
2055 void RenderViewHost::OnSetSuggestResult(int32 page_id, | 2041 void RenderViewHost::OnSetSuggestResult(int32 page_id, |
2056 const std::string& result) { | 2042 const std::string& result) { |
2057 RenderViewHostDelegate::BrowserIntegration* integration_delegate = | 2043 RenderViewHostDelegate::BrowserIntegration* integration_delegate = |
2058 delegate_->GetBrowserIntegrationDelegate(); | 2044 delegate_->GetBrowserIntegrationDelegate(); |
2059 if (!integration_delegate) | 2045 if (!integration_delegate) |
2060 return; | 2046 return; |
2061 integration_delegate->OnSetSuggestResult(page_id, result); | 2047 integration_delegate->OnSetSuggestResult(page_id, result); |
2062 } | 2048 } |
OLD | NEW |