| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 if (!host) | 199 if (!host) |
| 200 return false; | 200 return false; |
| 201 | 201 |
| 202 for (FrameTreeNode* node : tree->Nodes()) { | 202 for (FrameTreeNode* node : tree->Nodes()) { |
| 203 if (node->current_frame_host()->GetRenderWidgetHost() == host) | 203 if (node->current_frame_host()->GetRenderWidgetHost() == host) |
| 204 return true; | 204 return true; |
| 205 } | 205 } |
| 206 return false; | 206 return false; |
| 207 } | 207 } |
| 208 | 208 |
| 209 void SetAccessibilityModeOnFrame(AccessibilityMode mode, | 209 void UpdateAccessibilityModeOnFrame(RenderFrameHost* frame_host) { |
| 210 RenderFrameHost* frame_host) { | 210 static_cast<RenderFrameHostImpl*>(frame_host)->UpdateAccessibilityMode(); |
| 211 static_cast<RenderFrameHostImpl*>(frame_host)->SetAccessibilityMode(mode); | |
| 212 } | 211 } |
| 213 | 212 |
| 214 void ResetAccessibility(RenderFrameHost* rfh) { | 213 void ResetAccessibility(RenderFrameHost* rfh) { |
| 215 static_cast<RenderFrameHostImpl*>(rfh)->AccessibilityReset(); | 214 static_cast<RenderFrameHostImpl*>(rfh)->AccessibilityReset(); |
| 216 } | 215 } |
| 217 | 216 |
| 218 using AXTreeSnapshotCallback = | 217 using AXTreeSnapshotCallback = |
| 219 base::Callback<void(const ui::AXTreeUpdate&)>; | 218 base::Callback<void(const ui::AXTreeUpdate&)>; |
| 220 | 219 |
| 221 // Helper class used by WebContentsImpl::RequestAXTreeSnapshot. | 220 // Helper class used by WebContentsImpl::RequestAXTreeSnapshot. |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 } | 939 } |
| 941 | 940 |
| 942 SkColor WebContentsImpl::GetThemeColor() const { | 941 SkColor WebContentsImpl::GetThemeColor() const { |
| 943 return theme_color_; | 942 return theme_color_; |
| 944 } | 943 } |
| 945 | 944 |
| 946 void WebContentsImpl::SetAccessibilityMode(AccessibilityMode mode) { | 945 void WebContentsImpl::SetAccessibilityMode(AccessibilityMode mode) { |
| 947 if (mode == accessibility_mode_) | 946 if (mode == accessibility_mode_) |
| 948 return; | 947 return; |
| 949 | 948 |
| 949 // Don't allow accessibility to be enabled for WebContents that are never |
| 950 // visible, like background pages. |
| 951 if (IsNeverVisible()) |
| 952 return; |
| 953 |
| 950 accessibility_mode_ = mode; | 954 accessibility_mode_ = mode; |
| 951 | 955 |
| 952 for (FrameTreeNode* node : frame_tree_.Nodes()) { | 956 for (FrameTreeNode* node : frame_tree_.Nodes()) { |
| 953 SetAccessibilityModeOnFrame(mode, node->current_frame_host()); | 957 UpdateAccessibilityModeOnFrame(node->current_frame_host()); |
| 954 RenderFrameHost* pending_frame_host = | 958 RenderFrameHost* pending_frame_host = |
| 955 node->render_manager()->pending_frame_host(); | 959 node->render_manager()->pending_frame_host(); |
| 956 if (pending_frame_host) | 960 if (pending_frame_host) |
| 957 SetAccessibilityModeOnFrame(mode, pending_frame_host); | 961 UpdateAccessibilityModeOnFrame(pending_frame_host); |
| 958 } | 962 } |
| 959 } | 963 } |
| 960 | 964 |
| 961 void WebContentsImpl::AddAccessibilityMode(AccessibilityMode mode) { | 965 void WebContentsImpl::AddAccessibilityMode(AccessibilityMode mode) { |
| 962 SetAccessibilityMode(AddAccessibilityModeTo(accessibility_mode_, mode)); | 966 SetAccessibilityMode(AddAccessibilityModeTo(accessibility_mode_, mode)); |
| 963 } | 967 } |
| 964 | 968 |
| 965 void WebContentsImpl::RemoveAccessibilityMode(AccessibilityMode mode) { | 969 void WebContentsImpl::RemoveAccessibilityMode(AccessibilityMode mode) { |
| 966 SetAccessibilityMode(RemoveAccessibilityModeFrom(accessibility_mode_, mode)); | 970 SetAccessibilityMode(RemoveAccessibilityModeFrom(accessibility_mode_, mode)); |
| 967 } | 971 } |
| (...skipping 3090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4058 it->second->OnRequestForFrame(render_frame_host, std::move(handle)); | 4062 it->second->OnRequestForFrame(render_frame_host, std::move(handle)); |
| 4059 } | 4063 } |
| 4060 | 4064 |
| 4061 const GURL& WebContentsImpl::GetMainFrameLastCommittedURL() const { | 4065 const GURL& WebContentsImpl::GetMainFrameLastCommittedURL() const { |
| 4062 return GetLastCommittedURL(); | 4066 return GetLastCommittedURL(); |
| 4063 } | 4067 } |
| 4064 | 4068 |
| 4065 void WebContentsImpl::RenderFrameCreated(RenderFrameHost* render_frame_host) { | 4069 void WebContentsImpl::RenderFrameCreated(RenderFrameHost* render_frame_host) { |
| 4066 for (auto& observer : observers_) | 4070 for (auto& observer : observers_) |
| 4067 observer.RenderFrameCreated(render_frame_host); | 4071 observer.RenderFrameCreated(render_frame_host); |
| 4068 SetAccessibilityModeOnFrame(accessibility_mode_, render_frame_host); | 4072 UpdateAccessibilityModeOnFrame(render_frame_host); |
| 4069 | 4073 |
| 4070 if (!render_frame_host->IsRenderFrameLive() || render_frame_host->GetParent()) | 4074 if (!render_frame_host->IsRenderFrameLive() || render_frame_host->GetParent()) |
| 4071 return; | 4075 return; |
| 4072 | 4076 |
| 4073 NavigationEntry* entry = controller_.GetPendingEntry(); | 4077 NavigationEntry* entry = controller_.GetPendingEntry(); |
| 4074 if (entry && entry->IsViewSourceMode()) { | 4078 if (entry && entry->IsViewSourceMode()) { |
| 4075 // Put the renderer in view source mode. | 4079 // Put the renderer in view source mode. |
| 4076 render_frame_host->Send( | 4080 render_frame_host->Send( |
| 4077 new FrameMsg_EnableViewSourceMode(render_frame_host->GetRoutingID())); | 4081 new FrameMsg_EnableViewSourceMode(render_frame_host->GetRoutingID())); |
| 4078 } | 4082 } |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5281 dialog_manager_ = dialog_manager; | 5285 dialog_manager_ = dialog_manager; |
| 5282 } | 5286 } |
| 5283 | 5287 |
| 5284 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { | 5288 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { |
| 5285 auto it = binding_sets_.find(interface_name); | 5289 auto it = binding_sets_.find(interface_name); |
| 5286 if (it != binding_sets_.end()) | 5290 if (it != binding_sets_.end()) |
| 5287 binding_sets_.erase(it); | 5291 binding_sets_.erase(it); |
| 5288 } | 5292 } |
| 5289 | 5293 |
| 5290 } // namespace content | 5294 } // namespace content |
| OLD | NEW |