Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(648)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 273423004: Migrate accessibility from RenderView to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix more compile errors Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/metrics/stats_counters.h" 14 #include "base/metrics/stats_counters.h"
15 #include "base/process/process.h" 15 #include "base/process/process.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "content/browser/accessibility/accessibility_mode_helper.h"
22 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
21 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 23 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
22 #include "content/browser/browser_plugin/browser_plugin_guest.h" 24 #include "content/browser/browser_plugin/browser_plugin_guest.h"
23 #include "content/browser/child_process_security_policy_impl.h" 25 #include "content/browser/child_process_security_policy_impl.h"
24 #include "content/browser/devtools/render_view_devtools_agent_host.h" 26 #include "content/browser/devtools/render_view_devtools_agent_host.h"
25 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" 27 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
26 #include "content/browser/dom_storage/session_storage_namespace_impl.h" 28 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
27 #include "content/browser/download/download_stats.h" 29 #include "content/browser/download/download_stats.h"
28 #include "content/browser/download/mhtml_generation_manager.h" 30 #include "content/browser/download/mhtml_generation_manager.h"
29 #include "content/browser/download/save_package.h" 31 #include "content/browser/download/save_package.h"
30 #include "content/browser/frame_host/cross_process_frame_connector.h" 32 #include "content/browser/frame_host/cross_process_frame_connector.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "content/public/browser/devtools_agent_host.h" 65 #include "content/public/browser/devtools_agent_host.h"
64 #include "content/public/browser/download_manager.h" 66 #include "content/public/browser/download_manager.h"
65 #include "content/public/browser/download_url_parameters.h" 67 #include "content/public/browser/download_url_parameters.h"
66 #include "content/public/browser/invalidate_type.h" 68 #include "content/public/browser/invalidate_type.h"
67 #include "content/public/browser/javascript_dialog_manager.h" 69 #include "content/public/browser/javascript_dialog_manager.h"
68 #include "content/public/browser/load_from_memory_cache_details.h" 70 #include "content/public/browser/load_from_memory_cache_details.h"
69 #include "content/public/browser/load_notification_details.h" 71 #include "content/public/browser/load_notification_details.h"
70 #include "content/public/browser/navigation_details.h" 72 #include "content/public/browser/navigation_details.h"
71 #include "content/public/browser/notification_details.h" 73 #include "content/public/browser/notification_details.h"
72 #include "content/public/browser/notification_service.h" 74 #include "content/public/browser/notification_service.h"
75 #include "content/public/browser/render_widget_host_iterator.h"
73 #include "content/public/browser/resource_request_details.h" 76 #include "content/public/browser/resource_request_details.h"
74 #include "content/public/browser/storage_partition.h" 77 #include "content/public/browser/storage_partition.h"
75 #include "content/public/browser/user_metrics.h" 78 #include "content/public/browser/user_metrics.h"
76 #include "content/public/browser/web_contents_delegate.h" 79 #include "content/public/browser/web_contents_delegate.h"
77 #include "content/public/browser/web_contents_observer.h" 80 #include "content/public/browser/web_contents_observer.h"
78 #include "content/public/common/bindings_policy.h" 81 #include "content/public/common/bindings_policy.h"
79 #include "content/public/common/content_constants.h" 82 #include "content/public/common/content_constants.h"
80 #include "content/public/common/content_switches.h" 83 #include "content/public/common/content_switches.h"
81 #include "content/public/common/page_zoom.h" 84 #include "content/public/common/page_zoom.h"
82 #include "content/public/common/result_codes.h" 85 #include "content/public/common/result_codes.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 225 }
223 226
224 void RunRenderFrameDeleted( 227 void RunRenderFrameDeleted(
225 ObserverList<WebContentsObserver>* observer_list, 228 ObserverList<WebContentsObserver>* observer_list,
226 RenderFrameHost* render_frame_host) { 229 RenderFrameHost* render_frame_host) {
227 FOR_EACH_OBSERVER(WebContentsObserver, 230 FOR_EACH_OBSERVER(WebContentsObserver,
228 *observer_list, 231 *observer_list,
229 RenderFrameDeleted(render_frame_host)); 232 RenderFrameDeleted(render_frame_host));
230 } 233 }
231 234
235 void SetAccessibilityModeOnFrame(AccessibilityMode mode,
236 RenderFrameHost* frame_host) {
237 static_cast<RenderFrameHostImpl*>(frame_host)->SetAccessibilityMode(mode);
238 }
239
232 } // namespace 240 } // namespace
233 241
234 WebContents* WebContents::Create(const WebContents::CreateParams& params) { 242 WebContents* WebContents::Create(const WebContents::CreateParams& params) {
235 return WebContentsImpl::CreateWithOpener( 243 return WebContentsImpl::CreateWithOpener(
236 params, static_cast<WebContentsImpl*>(params.opener)); 244 params, static_cast<WebContentsImpl*>(params.opener));
237 } 245 }
238 246
239 WebContents* WebContents::CreateWithSessionStorage( 247 WebContents* WebContents::CreateWithSessionStorage(
240 const WebContents::CreateParams& params, 248 const WebContents::CreateParams& params,
241 const SessionStorageNamespaceMap& session_storage_namespace_map) { 249 const SessionStorageNamespaceMap& session_storage_namespace_map) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 last_active_time_(base::TimeTicks::Now()), 353 last_active_time_(base::TimeTicks::Now()),
346 closed_by_user_gesture_(false), 354 closed_by_user_gesture_(false),
347 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), 355 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)),
348 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), 356 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)),
349 temporary_zoom_settings_(false), 357 temporary_zoom_settings_(false),
350 totalPinchGestureAmount_(0), 358 totalPinchGestureAmount_(0),
351 currentPinchZoomStepDelta_(0), 359 currentPinchZoomStepDelta_(0),
352 render_view_message_source_(NULL), 360 render_view_message_source_(NULL),
353 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), 361 fullscreen_widget_routing_id_(MSG_ROUTING_NONE),
354 is_subframe_(false), 362 is_subframe_(false),
355 last_dialog_suppressed_(false) { 363 last_dialog_suppressed_(false),
364 accessibility_mode_(
365 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()) {
356 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) 366 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
357 g_created_callbacks.Get().at(i).Run(this); 367 g_created_callbacks.Get().at(i).Run(this);
358 frame_tree_.SetFrameRemoveListener( 368 frame_tree_.SetFrameRemoveListener(
359 base::Bind(&WebContentsImpl::OnFrameRemoved, 369 base::Bind(&WebContentsImpl::OnFrameRemoved,
360 base::Unretained(this))); 370 base::Unretained(this)));
361 } 371 }
362 372
363 WebContentsImpl::~WebContentsImpl() { 373 WebContentsImpl::~WebContentsImpl() {
364 is_being_destroyed_ = true; 374 is_being_destroyed_ = true;
365 375
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 new_contents, 450 new_contents,
441 extra_params.Pass()); 451 extra_params.Pass());
442 // We are instantiating a WebContents for browser plugin. Set its subframe 452 // We are instantiating a WebContents for browser plugin. Set its subframe
443 // bit to true. 453 // bit to true.
444 new_contents->is_subframe_ = true; 454 new_contents->is_subframe_ = true;
445 } 455 }
446 new_contents->Init(params); 456 new_contents->Init(params);
447 return new_contents; 457 return new_contents;
448 } 458 }
449 459
460 // static
461 std::vector<WebContentsImpl*> WebContentsImpl::GetAllWebContents() {
462 std::vector<WebContentsImpl*> result;
463 scoped_ptr<RenderWidgetHostIterator> widgets(
464 RenderWidgetHostImpl::GetRenderWidgetHosts());
465 std::set<WebContentsImpl*> web_contents_set;
466 while (RenderWidgetHost* rwh = widgets->GetNextHost()) {
467 if (!rwh->IsRenderView())
468 continue;
469 RenderViewHost* rvh = RenderViewHost::From(rwh);
470 if (!rvh)
471 continue;
472 WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
473 if (!web_contents)
474 continue;
475 WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents);
476 if (web_contents_set.find(wci) == web_contents_set.end()) {
477 web_contents_set.insert(wci);
478 result.push_back(wci);
479 }
480 }
481 return result;
482 }
483
450 RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() { 484 RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() {
451 return GetRenderManager(); 485 return GetRenderManager();
452 } 486 }
453 487
454 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, 488 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host,
455 const IPC::Message& message) { 489 const IPC::Message& message) {
456 return OnMessageReceived(render_view_host, NULL, message); 490 return OnMessageReceived(render_view_host, NULL, message);
457 } 491 }
458 492
459 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, 493 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host,
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 RenderWidgetHost* const widget_host = 712 RenderWidgetHost* const widget_host =
679 RenderWidgetHostImpl::FromID(GetRenderProcessHost()->GetID(), 713 RenderWidgetHostImpl::FromID(GetRenderProcessHost()->GetID(),
680 GetFullscreenWidgetRoutingID()); 714 GetFullscreenWidgetRoutingID());
681 return widget_host ? widget_host->GetView() : NULL; 715 return widget_host ? widget_host->GetView() : NULL;
682 } 716 }
683 717
684 WebContentsView* WebContentsImpl::GetView() const { 718 WebContentsView* WebContentsImpl::GetView() const {
685 return view_.get(); 719 return view_.get();
686 } 720 }
687 721
722 void WebContentsImpl::SetAccessibilityMode(AccessibilityMode mode) {
723 if (mode == accessibility_mode_)
724 return;
725
726 accessibility_mode_ = mode;
727 ForEachFrame(base::Bind(&SetAccessibilityModeOnFrame, mode));
ncarter (slow) 2014/05/14 23:56:23 ForEachFrame does not run on all RenderFrameHosts
dmazzoni 2014/05/19 07:25:01 I added a public ForEachFrameAndPendingFrame and u
728 }
729
730 void WebContentsImpl::AddAccessibilityMode(AccessibilityMode mode) {
731 SetAccessibilityMode(
732 content::AddAccessibilityModeTo(accessibility_mode_, mode));
733 }
734
735 void WebContentsImpl::RemoveAccessibilityMode(AccessibilityMode mode) {
736 SetAccessibilityMode(
737 content::RemoveAccessibilityModeFrom(accessibility_mode_, mode));
738 }
739
688 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { 740 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) {
689 WebUIImpl* web_ui = new WebUIImpl(this); 741 WebUIImpl* web_ui = new WebUIImpl(this);
690 WebUIController* controller = WebUIControllerFactoryRegistry::GetInstance()-> 742 WebUIController* controller = WebUIControllerFactoryRegistry::GetInstance()->
691 CreateWebUIControllerForURL(web_ui, url); 743 CreateWebUIControllerForURL(web_ui, url);
692 if (controller) { 744 if (controller) {
693 web_ui->AddMessageHandler(new GenericHandler()); 745 web_ui->AddMessageHandler(new GenericHandler());
694 web_ui->SetController(controller); 746 web_ui->SetController(controller);
695 return web_ui; 747 return web_ui;
696 } 748 }
697 749
(...skipping 28 matching lines...) Expand all
726 controller_.ReloadIgnoringCache(true); 778 controller_.ReloadIgnoringCache(true);
727 779
728 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 780 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
729 UserAgentOverrideSet(override)); 781 UserAgentOverrideSet(override));
730 } 782 }
731 783
732 const std::string& WebContentsImpl::GetUserAgentOverride() const { 784 const std::string& WebContentsImpl::GetUserAgentOverride() const {
733 return renderer_preferences_.user_agent_override; 785 return renderer_preferences_.user_agent_override;
734 } 786 }
735 787
788 void WebContentsImpl::EnableTreeOnlyAccessibilityMode() {
789 AddAccessibilityMode(AccessibilityModeTreeOnly);
790 }
791
792 bool WebContentsImpl::IsTreeOnlyAccessibilityModeForTesting() const {
793 return accessibility_mode() == AccessibilityModeTreeOnly;
794 }
795
796 bool WebContentsImpl::IsFullAccessibilityModeForTesting() const {
797 return accessibility_mode() == AccessibilityModeComplete;
798 }
799
736 #if defined(OS_WIN) 800 #if defined(OS_WIN)
737 void WebContentsImpl::SetParentNativeViewAccessible( 801 void WebContentsImpl::SetParentNativeViewAccessible(
738 gfx::NativeViewAccessible accessible_parent) { 802 gfx::NativeViewAccessible accessible_parent) {
739 accessible_parent_ = accessible_parent; 803 accessible_parent_ = accessible_parent;
740 if (GetRenderViewHost()) 804 RenderFrameHostImpl* rfh = static_cast<RenderFrameHostImpl*>(GetMainFrame());
741 GetRenderViewHostImpl()->SetParentNativeViewAccessible(accessible_parent); 805 if (rfh)
806 rfh->SetParentNativeViewAccessible(accessible_parent);
742 } 807 }
743 #endif 808 #endif
744 809
745 const base::string16& WebContentsImpl::GetTitle() const { 810 const base::string16& WebContentsImpl::GetTitle() const {
746 // Transient entries take precedence. They are used for interstitial pages 811 // Transient entries take precedence. They are used for interstitial pages
747 // that are shown on top of existing pages. 812 // that are shown on top of existing pages.
748 NavigationEntry* entry = controller_.GetTransientEntry(); 813 NavigationEntry* entry = controller_.GetTransientEntry();
749 std::string accept_languages = 814 std::string accept_languages =
750 GetContentClient()->browser()->GetAcceptLangs( 815 GetContentClient()->browser()->GetAcceptLangs(
751 GetBrowserContext()); 816 GetBrowserContext());
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 currentPinchZoomStepDelta_--; 1321 currentPinchZoomStepDelta_--;
1257 if (delegate_) 1322 if (delegate_)
1258 delegate_->ContentsZoomChange(false); 1323 delegate_->ContentsZoomChange(false);
1259 } 1324 }
1260 return true; 1325 return true;
1261 } 1326 }
1262 1327
1263 return false; 1328 return false;
1264 } 1329 }
1265 1330
1266 #if defined(OS_WIN)
1267 gfx::NativeViewAccessible WebContentsImpl::GetParentNativeViewAccessible() {
1268 return accessible_parent_;
1269 }
1270 #endif
1271
1272 void WebContentsImpl::HandleMouseDown() { 1331 void WebContentsImpl::HandleMouseDown() {
1273 if (delegate_) 1332 if (delegate_)
1274 delegate_->HandleMouseDown(); 1333 delegate_->HandleMouseDown();
1275 } 1334 }
1276 1335
1277 void WebContentsImpl::HandleMouseUp() { 1336 void WebContentsImpl::HandleMouseUp() {
1278 if (delegate_) 1337 if (delegate_)
1279 delegate_->HandleMouseUp(); 1338 delegate_->HandleMouseUp();
1280 } 1339 }
1281 1340
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 1718
1660 SessionStorageNamespace* WebContentsImpl::GetSessionStorageNamespace( 1719 SessionStorageNamespace* WebContentsImpl::GetSessionStorageNamespace(
1661 SiteInstance* instance) { 1720 SiteInstance* instance) {
1662 return controller_.GetSessionStorageNamespace(instance); 1721 return controller_.GetSessionStorageNamespace(instance);
1663 } 1722 }
1664 1723
1665 FrameTree* WebContentsImpl::GetFrameTree() { 1724 FrameTree* WebContentsImpl::GetFrameTree() {
1666 return &frame_tree_; 1725 return &frame_tree_;
1667 } 1726 }
1668 1727
1728 AccessibilityMode WebContentsImpl::GetAccessibilityMode() const {
1729 return accessibility_mode_;
1730 }
1731
1669 void WebContentsImpl::AccessibilityEventReceived( 1732 void WebContentsImpl::AccessibilityEventReceived(
1670 const std::vector<AXEventNotificationDetails>& details) { 1733 const std::vector<AXEventNotificationDetails>& details) {
1671 FOR_EACH_OBSERVER( 1734 FOR_EACH_OBSERVER(
1672 WebContentsObserver, observers_, AccessibilityEventReceived(details)); 1735 WebContentsObserver, observers_, AccessibilityEventReceived(details));
1673 } 1736 }
1674 1737
1675 void WebContentsImpl::OnShowValidationMessage( 1738 void WebContentsImpl::OnShowValidationMessage(
1676 const gfx::Rect& anchor_in_root_view, 1739 const gfx::Rect& anchor_in_root_view,
1677 const base::string16& main_text, 1740 const base::string16& main_text,
1678 const base::string16& sub_text) { 1741 const base::string16& sub_text) {
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
3174 WebContents* WebContentsImpl::GetAsWebContents() { 3237 WebContents* WebContentsImpl::GetAsWebContents() {
3175 return this; 3238 return this;
3176 } 3239 }
3177 3240
3178 bool WebContentsImpl::IsNeverVisible() { 3241 bool WebContentsImpl::IsNeverVisible() {
3179 if (!delegate_) 3242 if (!delegate_)
3180 return false; 3243 return false;
3181 return delegate_->IsNeverVisible(this); 3244 return delegate_->IsNeverVisible(this);
3182 } 3245 }
3183 3246
3247 #if defined(OS_WIN)
3248 gfx::NativeViewAccessible WebContentsImpl::GetParentNativeViewAccessible() {
3249 return accessible_parent_;
3250 }
3251 #endif
3252
3184 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { 3253 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() {
3185 return render_view_host_delegate_view_; 3254 return render_view_host_delegate_view_;
3186 } 3255 }
3187 3256
3188 RendererPreferences WebContentsImpl::GetRendererPrefs( 3257 RendererPreferences WebContentsImpl::GetRendererPrefs(
3189 BrowserContext* browser_context) const { 3258 BrowserContext* browser_context) const {
3190 return renderer_preferences_; 3259 return renderer_preferences_;
3191 } 3260 }
3192 3261
3193 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const { 3262 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const {
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
3965 4034
3966 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { 4035 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
3967 if (!delegate_) 4036 if (!delegate_)
3968 return; 4037 return;
3969 const gfx::Size new_size = GetPreferredSize(); 4038 const gfx::Size new_size = GetPreferredSize();
3970 if (new_size != old_size) 4039 if (new_size != old_size)
3971 delegate_->UpdatePreferredSize(this, new_size); 4040 delegate_->UpdatePreferredSize(this, new_size);
3972 } 4041 }
3973 4042
3974 } // namespace content 4043 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698