Chromium Code Reviews| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 #if BUILDFLAG(ENABLE_PLUGINS) | 165 #if BUILDFLAG(ENABLE_PLUGINS) |
| 166 #include "content/browser/media/session/pepper_playback_observer.h" | 166 #include "content/browser/media/session/pepper_playback_observer.h" |
| 167 #endif // ENABLE_PLUGINS | 167 #endif // ENABLE_PLUGINS |
| 168 | 168 |
| 169 namespace content { | 169 namespace content { |
| 170 namespace { | 170 namespace { |
| 171 | 171 |
| 172 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; | 172 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; |
| 173 const char kDotGoogleDotCom[] = ".google.com"; | 173 const char kDotGoogleDotCom[] = ".google.com"; |
| 174 | 174 |
| 175 const AccessibilityMode kAccessibilityModeWebContent( | |
|
dcheng
2017/03/07 08:41:48
constexpr
(I'm a little surprised that this doesn
dougt
2017/03/07 16:50:46
Yes, if it is a constexpr you do get an error/warn
dcheng
2017/03/07 18:05:12
If the constructor is constexpr as well, it should
| |
| 176 AccessibilityMode::kWebContents | AccessibilityMode::kInlineTextBoxes | | |
| 177 AccessibilityMode::kScreenReader | | |
| 178 AccessibilityMode::kHTML); | |
| 179 | |
| 175 #if defined(OS_ANDROID) | 180 #if defined(OS_ANDROID) |
| 176 const char kWebContentsAndroidKey[] = "web_contents_android"; | 181 const char kWebContentsAndroidKey[] = "web_contents_android"; |
| 177 #endif // OS_ANDROID | 182 #endif // OS_ANDROID |
| 178 | 183 |
| 179 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > | 184 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > |
| 180 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; | 185 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; |
| 181 | 186 |
| 182 void NotifyCacheOnIO( | 187 void NotifyCacheOnIO( |
| 183 scoped_refptr<net::URLRequestContextGetter> request_context, | 188 scoped_refptr<net::URLRequestContextGetter> request_context, |
| 184 const GURL& url, | 189 const GURL& url, |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 961 for (FrameTreeNode* node : frame_tree_.Nodes()) { | 966 for (FrameTreeNode* node : frame_tree_.Nodes()) { |
| 962 UpdateAccessibilityModeOnFrame(node->current_frame_host()); | 967 UpdateAccessibilityModeOnFrame(node->current_frame_host()); |
| 963 RenderFrameHost* pending_frame_host = | 968 RenderFrameHost* pending_frame_host = |
| 964 node->render_manager()->pending_frame_host(); | 969 node->render_manager()->pending_frame_host(); |
| 965 if (pending_frame_host) | 970 if (pending_frame_host) |
| 966 UpdateAccessibilityModeOnFrame(pending_frame_host); | 971 UpdateAccessibilityModeOnFrame(pending_frame_host); |
| 967 } | 972 } |
| 968 } | 973 } |
| 969 | 974 |
| 970 void WebContentsImpl::AddAccessibilityMode(AccessibilityMode mode) { | 975 void WebContentsImpl::AddAccessibilityMode(AccessibilityMode mode) { |
| 971 SetAccessibilityMode(accessibility_mode_ | mode); | 976 AccessibilityMode new_mode(accessibility_mode_); |
| 977 new_mode |= mode; | |
| 978 SetAccessibilityMode(new_mode); | |
| 972 } | 979 } |
| 973 | 980 |
| 974 void WebContentsImpl::RequestAXTreeSnapshot(AXTreeSnapshotCallback callback) { | 981 void WebContentsImpl::RequestAXTreeSnapshot(AXTreeSnapshotCallback callback) { |
| 975 // Send a request to each of the frames in parallel. Each one will return | 982 // Send a request to each of the frames in parallel. Each one will return |
| 976 // an accessibility tree snapshot, and AXTreeSnapshotCombiner will combine | 983 // an accessibility tree snapshot, and AXTreeSnapshotCombiner will combine |
| 977 // them into a single tree and call |callback| with that result, then | 984 // them into a single tree and call |callback| with that result, then |
| 978 // delete |combiner|. | 985 // delete |combiner|. |
| 979 AXTreeSnapshotCombiner* combiner = new AXTreeSnapshotCombiner(callback); | 986 AXTreeSnapshotCombiner* combiner = new AXTreeSnapshotCombiner(callback); |
| 980 for (FrameTreeNode* frame_tree_node : frame_tree_.Nodes()) { | 987 for (FrameTreeNode* frame_tree_node : frame_tree_.Nodes()) { |
| 981 bool is_root = frame_tree_node->parent() == nullptr; | 988 bool is_root = frame_tree_node->parent() == nullptr; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1073 | 1080 |
| 1074 for (auto& observer : observers_) | 1081 for (auto& observer : observers_) |
| 1075 observer.UserAgentOverrideSet(override); | 1082 observer.UserAgentOverrideSet(override); |
| 1076 } | 1083 } |
| 1077 | 1084 |
| 1078 const std::string& WebContentsImpl::GetUserAgentOverride() const { | 1085 const std::string& WebContentsImpl::GetUserAgentOverride() const { |
| 1079 return renderer_preferences_.user_agent_override; | 1086 return renderer_preferences_.user_agent_override; |
| 1080 } | 1087 } |
| 1081 | 1088 |
| 1082 void WebContentsImpl::EnableWebContentsOnlyAccessibilityMode() { | 1089 void WebContentsImpl::EnableWebContentsOnlyAccessibilityMode() { |
| 1083 if (GetAccessibilityMode() != AccessibilityModeOff) { | 1090 if (!GetAccessibilityMode().is_mode_off()) { |
| 1084 for (RenderFrameHost* rfh : GetAllFrames()) | 1091 for (RenderFrameHost* rfh : GetAllFrames()) |
| 1085 ResetAccessibility(rfh); | 1092 ResetAccessibility(rfh); |
| 1086 } else { | 1093 } else { |
| 1087 AddAccessibilityMode(ACCESSIBILITY_MODE_WEB_CONTENTS_ONLY); | 1094 AddAccessibilityMode(kAccessibilityModeWebContent); |
| 1088 } | 1095 } |
| 1089 } | 1096 } |
| 1090 | 1097 |
| 1091 bool WebContentsImpl::IsWebContentsOnlyAccessibilityModeForTesting() const { | 1098 bool WebContentsImpl::IsWebContentsOnlyAccessibilityModeForTesting() const { |
| 1092 return accessibility_mode_ == ACCESSIBILITY_MODE_WEB_CONTENTS_ONLY; | 1099 return accessibility_mode_ == kAccessibilityModeWebContent; |
| 1093 } | 1100 } |
| 1094 | 1101 |
| 1095 bool WebContentsImpl::IsFullAccessibilityModeForTesting() const { | 1102 bool WebContentsImpl::IsFullAccessibilityModeForTesting() const { |
| 1096 return accessibility_mode_ == ACCESSIBILITY_MODE_COMPLETE; | 1103 AccessibilityMode complete_mode( |
| 1104 AccessibilityMode::kNativeAPIs | AccessibilityMode::kWebContents | | |
| 1105 AccessibilityMode::kInlineTextBoxes | AccessibilityMode::kScreenReader | | |
| 1106 AccessibilityMode::kHTML); | |
|
dcheng
2017/03/07 08:41:48
Would be nice not to have this duplicated in https
dougt
2017/03/07 16:50:46
I considered doing that, but would that mean that
dcheng
2017/03/07 18:05:12
See my previous comment about constexpr. Explicit-
| |
| 1107 return accessibility_mode_ == complete_mode; | |
| 1097 } | 1108 } |
| 1098 | 1109 |
| 1099 const PageImportanceSignals& WebContentsImpl::GetPageImportanceSignals() const { | 1110 const PageImportanceSignals& WebContentsImpl::GetPageImportanceSignals() const { |
| 1100 return page_importance_signals_; | 1111 return page_importance_signals_; |
| 1101 } | 1112 } |
| 1102 | 1113 |
| 1103 const base::string16& WebContentsImpl::GetTitle() const { | 1114 const base::string16& WebContentsImpl::GetTitle() const { |
| 1104 // Transient entries take precedence. They are used for interstitial pages | 1115 // Transient entries take precedence. They are used for interstitial pages |
| 1105 // that are shown on top of existing pages. | 1116 // that are shown on top of existing pages. |
| 1106 NavigationEntry* entry = controller_.GetTransientEntry(); | 1117 NavigationEntry* entry = controller_.GetTransientEntry(); |
| (...skipping 4312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5419 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); | 5430 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); |
| 5420 if (!render_view_host) | 5431 if (!render_view_host) |
| 5421 continue; | 5432 continue; |
| 5422 render_view_host_set.insert(render_view_host); | 5433 render_view_host_set.insert(render_view_host); |
| 5423 } | 5434 } |
| 5424 for (RenderViewHost* render_view_host : render_view_host_set) | 5435 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5425 render_view_host->OnWebkitPreferencesChanged(); | 5436 render_view_host->OnWebkitPreferencesChanged(); |
| 5426 } | 5437 } |
| 5427 | 5438 |
| 5428 } // namespace content | 5439 } // namespace content |
| OLD | NEW |