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

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: 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/browser_plugin/browser_plugin_guest_manager.h" 25 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h"
24 #include "content/browser/child_process_security_policy_impl.h" 26 #include "content/browser/child_process_security_policy_impl.h"
25 #include "content/browser/devtools/render_view_devtools_agent_host.h" 27 #include "content/browser/devtools/render_view_devtools_agent_host.h"
26 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" 28 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
27 #include "content/browser/dom_storage/session_storage_namespace_impl.h" 29 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
28 #include "content/browser/download/download_stats.h" 30 #include "content/browser/download/download_stats.h"
29 #include "content/browser/download/mhtml_generation_manager.h" 31 #include "content/browser/download/mhtml_generation_manager.h"
30 #include "content/browser/download/save_package.h" 32 #include "content/browser/download/save_package.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include "content/public/browser/devtools_agent_host.h" 64 #include "content/public/browser/devtools_agent_host.h"
63 #include "content/public/browser/download_manager.h" 65 #include "content/public/browser/download_manager.h"
64 #include "content/public/browser/download_url_parameters.h" 66 #include "content/public/browser/download_url_parameters.h"
65 #include "content/public/browser/invalidate_type.h" 67 #include "content/public/browser/invalidate_type.h"
66 #include "content/public/browser/javascript_dialog_manager.h" 68 #include "content/public/browser/javascript_dialog_manager.h"
67 #include "content/public/browser/load_from_memory_cache_details.h" 69 #include "content/public/browser/load_from_memory_cache_details.h"
68 #include "content/public/browser/load_notification_details.h" 70 #include "content/public/browser/load_notification_details.h"
69 #include "content/public/browser/navigation_details.h" 71 #include "content/public/browser/navigation_details.h"
70 #include "content/public/browser/notification_details.h" 72 #include "content/public/browser/notification_details.h"
71 #include "content/public/browser/notification_service.h" 73 #include "content/public/browser/notification_service.h"
74 #include "content/public/browser/render_widget_host_iterator.h"
72 #include "content/public/browser/resource_request_details.h" 75 #include "content/public/browser/resource_request_details.h"
73 #include "content/public/browser/storage_partition.h" 76 #include "content/public/browser/storage_partition.h"
74 #include "content/public/browser/user_metrics.h" 77 #include "content/public/browser/user_metrics.h"
75 #include "content/public/browser/web_contents_delegate.h" 78 #include "content/public/browser/web_contents_delegate.h"
76 #include "content/public/browser/web_contents_observer.h" 79 #include "content/public/browser/web_contents_observer.h"
77 #include "content/public/common/bindings_policy.h" 80 #include "content/public/common/bindings_policy.h"
78 #include "content/public/common/content_constants.h" 81 #include "content/public/common/content_constants.h"
79 #include "content/public/common/content_switches.h" 82 #include "content/public/common/content_switches.h"
80 #include "content/public/common/page_zoom.h" 83 #include "content/public/common/page_zoom.h"
81 #include "content/public/common/result_codes.h" 84 #include "content/public/common/result_codes.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 224 }
222 225
223 void RunRenderFrameDeleted( 226 void RunRenderFrameDeleted(
224 ObserverList<WebContentsObserver>* observer_list, 227 ObserverList<WebContentsObserver>* observer_list,
225 RenderFrameHost* render_frame_host) { 228 RenderFrameHost* render_frame_host) {
226 FOR_EACH_OBSERVER(WebContentsObserver, 229 FOR_EACH_OBSERVER(WebContentsObserver,
227 *observer_list, 230 *observer_list,
228 RenderFrameDeleted(render_frame_host)); 231 RenderFrameDeleted(render_frame_host));
229 } 232 }
230 233
234 void SetAccessibilityModeOnFrame(AccessibilityMode mode,
235 RenderFrameHost* frame_host) {
236 static_cast<RenderFrameHostImpl*>(frame_host)->SetAccessibilityMode(mode);
237 }
238
231 } // namespace 239 } // namespace
232 240
233 WebContents* WebContents::Create(const WebContents::CreateParams& params) { 241 WebContents* WebContents::Create(const WebContents::CreateParams& params) {
234 return WebContentsImpl::CreateWithOpener( 242 return WebContentsImpl::CreateWithOpener(
235 params, static_cast<WebContentsImpl*>(params.opener)); 243 params, static_cast<WebContentsImpl*>(params.opener));
236 } 244 }
237 245
238 WebContents* WebContents::CreateWithSessionStorage( 246 WebContents* WebContents::CreateWithSessionStorage(
239 const WebContents::CreateParams& params, 247 const WebContents::CreateParams& params,
240 const SessionStorageNamespaceMap& session_storage_namespace_map) { 248 const SessionStorageNamespaceMap& session_storage_namespace_map) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 last_active_time_(base::TimeTicks::Now()), 351 last_active_time_(base::TimeTicks::Now()),
344 closed_by_user_gesture_(false), 352 closed_by_user_gesture_(false),
345 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), 353 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)),
346 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), 354 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)),
347 temporary_zoom_settings_(false), 355 temporary_zoom_settings_(false),
348 totalPinchGestureAmount_(0), 356 totalPinchGestureAmount_(0),
349 currentPinchZoomStepDelta_(0), 357 currentPinchZoomStepDelta_(0),
350 render_view_message_source_(NULL), 358 render_view_message_source_(NULL),
351 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), 359 fullscreen_widget_routing_id_(MSG_ROUTING_NONE),
352 is_subframe_(false), 360 is_subframe_(false),
353 last_dialog_suppressed_(false) { 361 last_dialog_suppressed_(false),
362 accessibility_mode_(
363 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()) {
354 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) 364 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
355 g_created_callbacks.Get().at(i).Run(this); 365 g_created_callbacks.Get().at(i).Run(this);
356 frame_tree_.SetFrameRemoveListener( 366 frame_tree_.SetFrameRemoveListener(
357 base::Bind(&WebContentsImpl::OnFrameRemoved, 367 base::Bind(&WebContentsImpl::OnFrameRemoved,
358 base::Unretained(this))); 368 base::Unretained(this)));
359 } 369 }
360 370
361 WebContentsImpl::~WebContentsImpl() { 371 WebContentsImpl::~WebContentsImpl() {
362 is_being_destroyed_ = true; 372 is_being_destroyed_ = true;
363 373
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 WebContentsImpl* opener) { 440 WebContentsImpl* opener) {
431 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener"); 441 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener");
432 WebContentsImpl* new_contents = new WebContentsImpl( 442 WebContentsImpl* new_contents = new WebContentsImpl(
433 params.browser_context, opener); 443 params.browser_context, opener);
434 444
435 new_contents->Init(params); 445 new_contents->Init(params);
436 return new_contents; 446 return new_contents;
437 } 447 }
438 448
439 // static 449 // static
450 void WebContentsImpl::GetAllWebContents(
451 std::vector<WebContentsImpl*>* web_contents_vector) {
nasko 2014/05/12 17:28:01 Why not return the vector as output element instea
dmazzoni 2014/05/13 06:36:52 Done.
452 scoped_ptr<RenderWidgetHostIterator> widgets(
453 RenderWidgetHostImpl::GetAllRenderWidgetHosts());
nasko 2014/05/12 17:28:01 You probably don't want the *All* version of the m
dmazzoni 2014/05/13 06:36:52 OK. Just to check, though, we want to be sure to s
454 std::set<WebContentsImpl*> web_contents_set;
455 while (RenderWidgetHost* rwh = widgets->GetNextHost()) {
456 if (!rwh->IsRenderView())
457 continue;
458 RenderViewHost* rvh = RenderViewHost::From(rwh);
459 if (!rvh)
460 continue;
461 WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
462 if (!web_contents)
463 continue;
464 WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents);
465 if (web_contents_set.find(wci) == web_contents_set.end()) {
466 web_contents_set.insert(wci);
467 web_contents_vector->push_back(wci);
468 }
469 }
470 }
471
472 // static
440 BrowserPluginGuest* WebContentsImpl::CreateGuest( 473 BrowserPluginGuest* WebContentsImpl::CreateGuest(
441 BrowserContext* browser_context, 474 BrowserContext* browser_context,
442 SiteInstance* site_instance, 475 SiteInstance* site_instance,
443 int guest_instance_id, 476 int guest_instance_id,
444 scoped_ptr<base::DictionaryValue> extra_params) { 477 scoped_ptr<base::DictionaryValue> extra_params) {
445 WebContentsImpl* new_contents = new WebContentsImpl(browser_context, NULL); 478 WebContentsImpl* new_contents = new WebContentsImpl(browser_context, NULL);
446 479
447 // This makes |new_contents| act as a guest. 480 // This makes |new_contents| act as a guest.
448 // For more info, see comment above class BrowserPluginGuest. 481 // For more info, see comment above class BrowserPluginGuest.
449 BrowserPluginGuest::Create( 482 BrowserPluginGuest::Create(
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 RenderWidgetHost* const widget_host = 723 RenderWidgetHost* const widget_host =
691 RenderWidgetHostImpl::FromID(GetRenderProcessHost()->GetID(), 724 RenderWidgetHostImpl::FromID(GetRenderProcessHost()->GetID(),
692 GetFullscreenWidgetRoutingID()); 725 GetFullscreenWidgetRoutingID());
693 return widget_host ? widget_host->GetView() : NULL; 726 return widget_host ? widget_host->GetView() : NULL;
694 } 727 }
695 728
696 WebContentsView* WebContentsImpl::GetView() const { 729 WebContentsView* WebContentsImpl::GetView() const {
697 return view_.get(); 730 return view_.get();
698 } 731 }
699 732
733 void WebContentsImpl::SetAccessibilityMode(AccessibilityMode mode) {
734 if (mode == accessibility_mode_)
735 return;
736
737 accessibility_mode_ = mode;
738 ForEachFrame(base::Bind(&SetAccessibilityModeOnFrame, mode));
739 }
740
741 void WebContentsImpl::AddAccessibilityMode(AccessibilityMode mode) {
742 SetAccessibilityMode(
743 content::AddAccessibilityModeTo(accessibility_mode_, mode));
744 }
745
746 void WebContentsImpl::RemoveAccessibilityMode(AccessibilityMode mode) {
747 SetAccessibilityMode(
748 content::RemoveAccessibilityModeFrom(accessibility_mode_, mode));
749 }
750
700 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { 751 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) {
701 WebUIImpl* web_ui = new WebUIImpl(this); 752 WebUIImpl* web_ui = new WebUIImpl(this);
702 WebUIController* controller = WebUIControllerFactoryRegistry::GetInstance()-> 753 WebUIController* controller = WebUIControllerFactoryRegistry::GetInstance()->
703 CreateWebUIControllerForURL(web_ui, url); 754 CreateWebUIControllerForURL(web_ui, url);
704 if (controller) { 755 if (controller) {
705 web_ui->AddMessageHandler(new GenericHandler()); 756 web_ui->AddMessageHandler(new GenericHandler());
706 web_ui->SetController(controller); 757 web_ui->SetController(controller);
707 return web_ui; 758 return web_ui;
708 } 759 }
709 760
(...skipping 28 matching lines...) Expand all
738 controller_.ReloadIgnoringCache(true); 789 controller_.ReloadIgnoringCache(true);
739 790
740 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 791 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
741 UserAgentOverrideSet(override)); 792 UserAgentOverrideSet(override));
742 } 793 }
743 794
744 const std::string& WebContentsImpl::GetUserAgentOverride() const { 795 const std::string& WebContentsImpl::GetUserAgentOverride() const {
745 return renderer_preferences_.user_agent_override; 796 return renderer_preferences_.user_agent_override;
746 } 797 }
747 798
799 void WebContentsImpl::EnableTreeOnlyAccessibilityMode() {
800 AddAccessibilityMode(AccessibilityModeTreeOnly);
801 }
802
803 bool WebContentsImpl::IsTreeOnlyAccessibilityModeForTesting() const {
804 return accessibility_mode() == AccessibilityModeTreeOnly;
805 }
806
807 bool WebContentsImpl::IsFullAccessibilityModeForTesting() const {
808 return accessibility_mode() == AccessibilityModeComplete;
809 }
810
748 #if defined(OS_WIN) 811 #if defined(OS_WIN)
749 void WebContentsImpl::SetParentNativeViewAccessible( 812 void WebContentsImpl::SetParentNativeViewAccessible(
750 gfx::NativeViewAccessible accessible_parent) { 813 gfx::NativeViewAccessible accessible_parent) {
751 accessible_parent_ = accessible_parent; 814 accessible_parent_ = accessible_parent;
752 if (GetRenderViewHost()) 815 if (GetRenderViewHost())
753 GetRenderViewHostImpl()->SetParentNativeViewAccessible(accessible_parent); 816 GetRenderViewHostImpl()->SetParentNativeViewAccessible(accessible_parent);
754 } 817 }
755 #endif 818 #endif
756 819
757 const base::string16& WebContentsImpl::GetTitle() const { 820 const base::string16& WebContentsImpl::GetTitle() const {
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 currentPinchZoomStepDelta_--; 1328 currentPinchZoomStepDelta_--;
1266 if (delegate_) 1329 if (delegate_)
1267 delegate_->ContentsZoomChange(false); 1330 delegate_->ContentsZoomChange(false);
1268 } 1331 }
1269 return true; 1332 return true;
1270 } 1333 }
1271 1334
1272 return false; 1335 return false;
1273 } 1336 }
1274 1337
1275 #if defined(OS_WIN)
1276 gfx::NativeViewAccessible WebContentsImpl::GetParentNativeViewAccessible() {
1277 return accessible_parent_;
1278 }
1279 #endif
1280
1281 void WebContentsImpl::HandleMouseDown() { 1338 void WebContentsImpl::HandleMouseDown() {
1282 if (delegate_) 1339 if (delegate_)
1283 delegate_->HandleMouseDown(); 1340 delegate_->HandleMouseDown();
1284 } 1341 }
1285 1342
1286 void WebContentsImpl::HandleMouseUp() { 1343 void WebContentsImpl::HandleMouseUp() {
1287 if (delegate_) 1344 if (delegate_)
1288 delegate_->HandleMouseUp(); 1345 delegate_->HandleMouseUp();
1289 } 1346 }
1290 1347
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 1726
1670 SessionStorageNamespace* WebContentsImpl::GetSessionStorageNamespace( 1727 SessionStorageNamespace* WebContentsImpl::GetSessionStorageNamespace(
1671 SiteInstance* instance) { 1728 SiteInstance* instance) {
1672 return controller_.GetSessionStorageNamespace(instance); 1729 return controller_.GetSessionStorageNamespace(instance);
1673 } 1730 }
1674 1731
1675 FrameTree* WebContentsImpl::GetFrameTree() { 1732 FrameTree* WebContentsImpl::GetFrameTree() {
1676 return &frame_tree_; 1733 return &frame_tree_;
1677 } 1734 }
1678 1735
1736 AccessibilityMode WebContentsImpl::GetAccessibilityMode() const {
1737 return accessibility_mode_;
1738 }
1739
1679 void WebContentsImpl::AccessibilityEventReceived( 1740 void WebContentsImpl::AccessibilityEventReceived(
1680 const std::vector<AXEventNotificationDetails>& details) { 1741 const std::vector<AXEventNotificationDetails>& details) {
1681 FOR_EACH_OBSERVER( 1742 FOR_EACH_OBSERVER(
1682 WebContentsObserver, observers_, AccessibilityEventReceived(details)); 1743 WebContentsObserver, observers_, AccessibilityEventReceived(details));
1683 } 1744 }
1684 1745
1685 void WebContentsImpl::OnShowValidationMessage( 1746 void WebContentsImpl::OnShowValidationMessage(
1686 const gfx::Rect& anchor_in_root_view, 1747 const gfx::Rect& anchor_in_root_view,
1687 const base::string16& main_text, 1748 const base::string16& main_text,
1688 const base::string16& sub_text) { 1749 const base::string16& sub_text) {
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
3184 WebContents* WebContentsImpl::GetAsWebContents() { 3245 WebContents* WebContentsImpl::GetAsWebContents() {
3185 return this; 3246 return this;
3186 } 3247 }
3187 3248
3188 bool WebContentsImpl::IsNeverVisible() { 3249 bool WebContentsImpl::IsNeverVisible() {
3189 if (!delegate_) 3250 if (!delegate_)
3190 return false; 3251 return false;
3191 return delegate_->IsNeverVisible(this); 3252 return delegate_->IsNeverVisible(this);
3192 } 3253 }
3193 3254
3255 #if defined(OS_WIN)
3256 gfx::NativeViewAccessible WebContentsImpl::GetParentNativeViewAccessible() {
3257 return accessible_parent_;
3258 }
3259 #endif
3260
3194 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { 3261 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() {
3195 return render_view_host_delegate_view_; 3262 return render_view_host_delegate_view_;
3196 } 3263 }
3197 3264
3198 RendererPreferences WebContentsImpl::GetRendererPrefs( 3265 RendererPreferences WebContentsImpl::GetRendererPrefs(
3199 BrowserContext* browser_context) const { 3266 BrowserContext* browser_context) const {
3200 return renderer_preferences_; 3267 return renderer_preferences_;
3201 } 3268 }
3202 3269
3203 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const { 3270 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const {
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
3974 4041
3975 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { 4042 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
3976 if (!delegate_) 4043 if (!delegate_)
3977 return; 4044 return;
3978 const gfx::Size new_size = GetPreferredSize(); 4045 const gfx::Size new_size = GetPreferredSize();
3979 if (new_size != old_size) 4046 if (new_size != old_size)
3980 delegate_->UpdatePreferredSize(this, new_size); 4047 delegate_->UpdatePreferredSize(this, new_size);
3981 } 4048 }
3982 4049
3983 } // namespace content 4050 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698