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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 #if BUILDFLAG(ENABLE_PLUGINS) | 166 #if BUILDFLAG(ENABLE_PLUGINS) |
167 #include "content/browser/media/session/pepper_playback_observer.h" | 167 #include "content/browser/media/session/pepper_playback_observer.h" |
168 #endif // ENABLE_PLUGINS | 168 #endif // ENABLE_PLUGINS |
169 | 169 |
170 namespace content { | 170 namespace content { |
171 namespace { | 171 namespace { |
172 | 172 |
173 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; | 173 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; |
174 const char kDotGoogleDotCom[] = ".google.com"; | 174 const char kDotGoogleDotCom[] = ".google.com"; |
175 | 175 |
| 176 const AccessibilityMode kAccessibilityModeWebContent( |
| 177 AccessibilityMode::kWebContents | AccessibilityMode::kInlineTextBoxes | |
| 178 AccessibilityMode::kScreenReader | |
| 179 AccessibilityMode::kHTML); |
| 180 |
176 #if defined(OS_ANDROID) | 181 #if defined(OS_ANDROID) |
177 const char kWebContentsAndroidKey[] = "web_contents_android"; | 182 const char kWebContentsAndroidKey[] = "web_contents_android"; |
178 #endif // OS_ANDROID | 183 #endif // OS_ANDROID |
179 | 184 |
180 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > | 185 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > |
181 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; | 186 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; |
182 | 187 |
183 void NotifyCacheOnIO( | 188 void NotifyCacheOnIO( |
184 scoped_refptr<net::URLRequestContextGetter> request_context, | 189 scoped_refptr<net::URLRequestContextGetter> request_context, |
185 const GURL& url, | 190 const GURL& url, |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 for (FrameTreeNode* node : frame_tree_.Nodes()) { | 967 for (FrameTreeNode* node : frame_tree_.Nodes()) { |
963 UpdateAccessibilityModeOnFrame(node->current_frame_host()); | 968 UpdateAccessibilityModeOnFrame(node->current_frame_host()); |
964 RenderFrameHost* pending_frame_host = | 969 RenderFrameHost* pending_frame_host = |
965 node->render_manager()->pending_frame_host(); | 970 node->render_manager()->pending_frame_host(); |
966 if (pending_frame_host) | 971 if (pending_frame_host) |
967 UpdateAccessibilityModeOnFrame(pending_frame_host); | 972 UpdateAccessibilityModeOnFrame(pending_frame_host); |
968 } | 973 } |
969 } | 974 } |
970 | 975 |
971 void WebContentsImpl::AddAccessibilityMode(AccessibilityMode mode) { | 976 void WebContentsImpl::AddAccessibilityMode(AccessibilityMode mode) { |
972 SetAccessibilityMode(accessibility_mode_ | mode); | 977 AccessibilityMode new_mode(accessibility_mode_); |
| 978 new_mode |= mode; |
| 979 SetAccessibilityMode(new_mode); |
973 } | 980 } |
974 | 981 |
975 void WebContentsImpl::RequestAXTreeSnapshot(AXTreeSnapshotCallback callback) { | 982 void WebContentsImpl::RequestAXTreeSnapshot(AXTreeSnapshotCallback callback) { |
976 // Send a request to each of the frames in parallel. Each one will return | 983 // Send a request to each of the frames in parallel. Each one will return |
977 // an accessibility tree snapshot, and AXTreeSnapshotCombiner will combine | 984 // an accessibility tree snapshot, and AXTreeSnapshotCombiner will combine |
978 // them into a single tree and call |callback| with that result, then | 985 // them into a single tree and call |callback| with that result, then |
979 // delete |combiner|. | 986 // delete |combiner|. |
980 AXTreeSnapshotCombiner* combiner = new AXTreeSnapshotCombiner(callback); | 987 AXTreeSnapshotCombiner* combiner = new AXTreeSnapshotCombiner(callback); |
981 for (FrameTreeNode* frame_tree_node : frame_tree_.Nodes()) { | 988 for (FrameTreeNode* frame_tree_node : frame_tree_.Nodes()) { |
982 bool is_root = frame_tree_node->parent() == nullptr; | 989 bool is_root = frame_tree_node->parent() == nullptr; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 | 1081 |
1075 for (auto& observer : observers_) | 1082 for (auto& observer : observers_) |
1076 observer.UserAgentOverrideSet(override); | 1083 observer.UserAgentOverrideSet(override); |
1077 } | 1084 } |
1078 | 1085 |
1079 const std::string& WebContentsImpl::GetUserAgentOverride() const { | 1086 const std::string& WebContentsImpl::GetUserAgentOverride() const { |
1080 return renderer_preferences_.user_agent_override; | 1087 return renderer_preferences_.user_agent_override; |
1081 } | 1088 } |
1082 | 1089 |
1083 void WebContentsImpl::EnableWebContentsOnlyAccessibilityMode() { | 1090 void WebContentsImpl::EnableWebContentsOnlyAccessibilityMode() { |
1084 if (GetAccessibilityMode() != AccessibilityModeOff) { | 1091 if (!GetAccessibilityMode().is_mode_off()) { |
1085 for (RenderFrameHost* rfh : GetAllFrames()) | 1092 for (RenderFrameHost* rfh : GetAllFrames()) |
1086 ResetAccessibility(rfh); | 1093 ResetAccessibility(rfh); |
1087 } else { | 1094 } else { |
1088 AddAccessibilityMode(ACCESSIBILITY_MODE_WEB_CONTENTS_ONLY); | 1095 AddAccessibilityMode(kAccessibilityModeWebContent); |
1089 } | 1096 } |
1090 } | 1097 } |
1091 | 1098 |
1092 bool WebContentsImpl::IsWebContentsOnlyAccessibilityModeForTesting() const { | 1099 bool WebContentsImpl::IsWebContentsOnlyAccessibilityModeForTesting() const { |
1093 return accessibility_mode_ == ACCESSIBILITY_MODE_WEB_CONTENTS_ONLY; | 1100 return accessibility_mode_ == kAccessibilityModeWebContent; |
1094 } | 1101 } |
1095 | 1102 |
1096 bool WebContentsImpl::IsFullAccessibilityModeForTesting() const { | 1103 bool WebContentsImpl::IsFullAccessibilityModeForTesting() const { |
1097 return accessibility_mode_ == ACCESSIBILITY_MODE_COMPLETE; | 1104 AccessibilityMode complete_mode( |
| 1105 AccessibilityMode::kNativeAPIs | AccessibilityMode::kWebContents | |
| 1106 AccessibilityMode::kInlineTextBoxes | AccessibilityMode::kScreenReader | |
| 1107 AccessibilityMode::kHTML); |
| 1108 return accessibility_mode_ == complete_mode; |
1098 } | 1109 } |
1099 | 1110 |
1100 const PageImportanceSignals& WebContentsImpl::GetPageImportanceSignals() const { | 1111 const PageImportanceSignals& WebContentsImpl::GetPageImportanceSignals() const { |
1101 return page_importance_signals_; | 1112 return page_importance_signals_; |
1102 } | 1113 } |
1103 | 1114 |
1104 const base::string16& WebContentsImpl::GetTitle() const { | 1115 const base::string16& WebContentsImpl::GetTitle() const { |
1105 // Transient entries take precedence. They are used for interstitial pages | 1116 // Transient entries take precedence. They are used for interstitial pages |
1106 // that are shown on top of existing pages. | 1117 // that are shown on top of existing pages. |
1107 NavigationEntry* entry = controller_.GetTransientEntry(); | 1118 NavigationEntry* entry = controller_.GetTransientEntry(); |
(...skipping 4321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5429 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); | 5440 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); |
5430 if (!render_view_host) | 5441 if (!render_view_host) |
5431 continue; | 5442 continue; |
5432 render_view_host_set.insert(render_view_host); | 5443 render_view_host_set.insert(render_view_host); |
5433 } | 5444 } |
5434 for (RenderViewHost* render_view_host : render_view_host_set) | 5445 for (RenderViewHost* render_view_host : render_view_host_set) |
5435 render_view_host->OnWebkitPreferencesChanged(); | 5446 render_view_host->OnWebkitPreferencesChanged(); |
5436 } | 5447 } |
5437 | 5448 |
5438 } // namespace content | 5449 } // namespace content |
OLD | NEW |