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

Side by Side Diff: chrome/renderer/render_view.cc

Issue 3380017: Support additional webkit accessibility notifications and states. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Adding missig file. Created 10 years, 2 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
« no previous file with comments | « chrome/renderer/render_view.h ('k') | webkit/glue/webaccessibility.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/render_view.h" 5 #include "chrome/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 if (opener_id == MSG_ROUTING_NONE) { 658 if (opener_id == MSG_ROUTING_NONE) {
659 did_show_ = true; 659 did_show_ = true;
660 CompleteInit(parent_hwnd); 660 CompleteInit(parent_hwnd);
661 } 661 }
662 662
663 host_window_ = parent_hwnd; 663 host_window_ = parent_hwnd;
664 664
665 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 665 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
666 if (command_line.HasSwitch(switches::kDomAutomationController)) 666 if (command_line.HasSwitch(switches::kDomAutomationController))
667 enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION; 667 enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION;
668 if (command_line.HasSwitch(switches::kEnableAccessibility))
669 WebAccessibilityCache::enableAccessibility();
668 670
669 audio_message_filter_ = new AudioMessageFilter(routing_id_); 671 audio_message_filter_ = new AudioMessageFilter(routing_id_);
670 render_thread_->AddFilter(audio_message_filter_); 672 render_thread_->AddFilter(audio_message_filter_);
671 } 673 }
672 674
673 void RenderView::OnMessageReceived(const IPC::Message& message) { 675 void RenderView::OnMessageReceived(const IPC::Message& message) {
674 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; 676 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL;
675 if (main_frame) 677 if (main_frame)
676 child_process_logging::SetActiveURL(main_frame->url()); 678 child_process_logging::SetActiveURL(main_frame->url());
677 679
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) 799 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged)
798 #endif 800 #endif
799 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, 801 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent,
800 OnSetEditCommandsForNextKeyEvent) 802 OnSetEditCommandsForNextKeyEvent)
801 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode, 803 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode,
802 OnExecuteCode) 804 OnExecuteCode)
803 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, 805 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction,
804 OnCustomContextMenuAction) 806 OnCustomContextMenuAction)
805 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) 807 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage)
806 IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation) 808 IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation)
807 IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityTree, OnGetAccessibilityTree) 809 IPC_MESSAGE_HANDLER(ViewMsg_EnableAccessibility, OnEnableAccessibility)
808 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityFocus, OnSetAccessibilityFocus) 810 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityFocus, OnSetAccessibilityFocus)
809 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityDoDefaultAction, 811 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityDoDefaultAction,
810 OnAccessibilityDoDefaultAction) 812 OnAccessibilityDoDefaultAction)
811 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityNotifications_ACK, 813 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityNotifications_ACK,
812 OnAccessibilityNotificationsAck) 814 OnAccessibilityNotificationsAck)
813 IPC_MESSAGE_HANDLER(ViewMsg_OpenFileSystemRequest_Complete, 815 IPC_MESSAGE_HANDLER(ViewMsg_OpenFileSystemRequest_Complete,
814 OnOpenFileSystemRequestComplete) 816 OnOpenFileSystemRequestComplete)
815 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) 817 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened)
816 818
817 // Have the super handle all other messages. 819 // Have the super handle all other messages.
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 1473
1472 // If we end up reusing this WebRequest (for example, due to a #ref click), 1474 // If we end up reusing this WebRequest (for example, due to a #ref click),
1473 // we don't want the transition type to persist. Just clear it. 1475 // we don't want the transition type to persist. Just clear it.
1474 navigation_state->set_transition_type(PageTransition::LINK); 1476 navigation_state->set_transition_type(PageTransition::LINK);
1475 1477
1476 // Check if the navigation was within the same page, in which case we don't 1478 // Check if the navigation was within the same page, in which case we don't
1477 // want to clear the accessibility cache. 1479 // want to clear the accessibility cache.
1478 if (accessibility_.get() && !navigation_state->was_within_same_page()) { 1480 if (accessibility_.get() && !navigation_state->was_within_same_page()) {
1479 accessibility_->clear(); 1481 accessibility_->clear();
1480 accessibility_.reset(); 1482 accessibility_.reset();
1483 pending_accessibility_notifications_.clear();
1481 } 1484 }
1482 pending_accessibility_notifications_.clear();
1483 } 1485 }
1484 1486
1485 // Tell the embedding application that the title of the active page has changed 1487 // Tell the embedding application that the title of the active page has changed
1486 void RenderView::UpdateTitle(WebFrame* frame, const string16& title) { 1488 void RenderView::UpdateTitle(WebFrame* frame, const string16& title) {
1487 // Ignore all but top level navigations... 1489 // Ignore all but top level navigations...
1488 if (!frame->parent()) { 1490 if (!frame->parent()) {
1489 Send(new ViewHostMsg_UpdateTitle( 1491 Send(new ViewHostMsg_UpdateTitle(
1490 routing_id_, 1492 routing_id_,
1491 page_id_, 1493 page_id_,
1492 UTF16ToWideHack(title.length() > chrome::kMaxTitleChars ? 1494 UTF16ToWideHack(title.length() > chrome::kMaxTitleChars ?
(...skipping 2898 matching lines...) Expand 10 before | Expand all | Expand 10 after
4391 } 4393 }
4392 4394
4393 void RenderView::OnNotifyRendererViewType(ViewType::Type type) { 4395 void RenderView::OnNotifyRendererViewType(ViewType::Type type) {
4394 view_type_ = type; 4396 view_type_ = type;
4395 } 4397 }
4396 4398
4397 void RenderView::OnUpdateBrowserWindowId(int window_id) { 4399 void RenderView::OnUpdateBrowserWindowId(int window_id) {
4398 browser_window_id_ = window_id; 4400 browser_window_id_ = window_id;
4399 } 4401 }
4400 4402
4401 void RenderView::OnGetAccessibilityTree() { 4403 void RenderView::OnEnableAccessibility() {
4402 if (accessibility_.get()) 4404 if (WebAccessibilityCache::accessibilityEnabled())
4403 accessibility_->clear(); 4405 return;
4404 accessibility_.reset(WebAccessibilityCache::create());
4405 accessibility_->initialize(webview());
4406 pending_accessibility_notifications_.clear();
4407 4406
4408 WebAccessibilityObject src_tree = webview()->accessibilityObject(); 4407 WebAccessibilityCache::enableAccessibility();
4409 WebAccessibility dst_tree(src_tree, accessibility_.get()); 4408
4410 Send(new ViewHostMsg_AccessibilityTree(routing_id_, dst_tree)); 4409 if (webview()) {
4410 // It's possible that the webview has already loaded a webpage without
4411 // accessibility being enabled. Initialize the browser's cached
4412 // accessibility tree by sending it a 'load complete' notification.
4413 postAccessibilityNotification(
4414 webview()->accessibilityObject(),
4415 WebKit::WebAccessibilityNotificationLoadComplete);
4416 }
4411 } 4417 }
4412 4418
4413 void RenderView::OnSetAccessibilityFocus(int acc_obj_id) { 4419 void RenderView::OnSetAccessibilityFocus(int acc_obj_id) {
4414 if (!accessibility_.get()) 4420 if (!accessibility_.get())
4415 return; 4421 return;
4416 if (accessibility_->isValidId(acc_obj_id)) { 4422 if (accessibility_->isValidId(acc_obj_id)) {
4417 // TODO(dmazzoni) fix the cache so that id=1000 is not a magic number. 4423 // TODO(dmazzoni) fix the cache so that id=1000 is not a magic number.
4418 // By convention, calling SetFocus on the root of the tree (id = 1000) 4424 // By convention, calling SetFocus on the root of the tree (id = 1000)
4419 // should clear the current focus. Otherwise set the focus to the new 4425 // should clear the current focus. Otherwise set the focus to the new
4420 // node. 4426 // node.
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
5460 GURL url(ds->request().url()); 5466 GURL url(ds->request().url());
5461 Time start = state->start_load_time(); 5467 Time start = state->start_load_time();
5462 Time finish = state->finish_load_time(); 5468 Time finish = state->finish_load_time();
5463 // TODO(mbelshe): should we log more stats? 5469 // TODO(mbelshe): should we log more stats?
5464 LOG(INFO) << "PLT: " 5470 LOG(INFO) << "PLT: "
5465 << (finish - start).InMilliseconds() 5471 << (finish - start).InMilliseconds()
5466 << "ms " 5472 << "ms "
5467 << url.spec(); 5473 << url.spec();
5468 } 5474 }
5469 5475
5470 void RenderView::focusAccessibilityObject(
5471 const WebAccessibilityObject& acc_obj) {
5472 #if defined(OS_WIN)
5473 // TODO(dglazkov): Current logic implies that focus change can only be made
5474 // after at least one call to RenderView::OnGetAccessibilityInfo, which is
5475 // where accessibility is initialized. We should determine whether that's
5476 // right.
5477 if (!accessibility_.get())
5478 return;
5479
5480 // Retrieve the accessibility object id of the AccessibilityObject.
5481 int acc_obj_id = accessibility_->addOrGetId(acc_obj);
5482
5483 // If id is valid, alert the browser side that an accessibility focus change
5484 // occurred.
5485 if (acc_obj_id >= 0)
5486 Send(new ViewHostMsg_AccessibilityFocusChange(routing_id_, acc_obj_id));
5487
5488 #else // defined(OS_WIN)
5489 // TODO(port): accessibility not yet implemented
5490 NOTIMPLEMENTED();
5491 #endif
5492 }
5493
5494 void RenderView::postAccessibilityNotification( 5476 void RenderView::postAccessibilityNotification(
5495 const WebAccessibilityObject& obj, 5477 const WebAccessibilityObject& obj,
5496 WebAccessibilityNotification notification) { 5478 WebAccessibilityNotification notification) {
5497 if (!accessibility_.get() || (accessibility_->addOrGetId(obj) < 0)) 5479 if (!accessibility_.get() && webview()) {
5480 // Load complete should be our first notification sent.
5481 // TODO(ctguil): Investigate if a different notification is a WebCore bug.
5482 if (notification != WebKit::WebAccessibilityNotificationLoadComplete)
5483 return;
5484
5485 // Create and initialize our accessibility cache
5486 accessibility_.reset(WebAccessibilityCache::create());
5487 accessibility_->initialize(webview());
5488 }
5489
5490 // Add the accessibility object to our cache and ensure it's valid.
5491 if (accessibility_->addOrGetId(obj) < 0)
5498 return; 5492 return;
5499 5493
5500 ViewHostMsg_AccessibilityNotification_Params param; 5494 ViewHostMsg_AccessibilityNotification_Params param;
5501 switch (notification) { 5495 switch (notification) {
5502 case WebKit::WebAccessibilityNotificationCheckedStateChanged: 5496 case WebKit::WebAccessibilityNotificationCheckedStateChanged:
5503 param.notification_type = 5497 param.notification_type =
5504 ViewHostMsg_AccessibilityNotification_Params:: 5498 ViewHostMsg_AccessibilityNotification_Params::
5505 NOTIFICATION_TYPE_CHECK_STATE_CHANGED; 5499 NOTIFICATION_TYPE_CHECK_STATE_CHANGED;
5506 break; 5500 break;
5507 case WebKit::WebAccessibilityNotificationChildrenChanged: 5501 case WebKit::WebAccessibilityNotificationChildrenChanged:
5508 param.notification_type = 5502 param.notification_type =
5509 ViewHostMsg_AccessibilityNotification_Params:: 5503 ViewHostMsg_AccessibilityNotification_Params::
5510 NOTIFICATION_TYPE_CHILDREN_CHANGED; 5504 NOTIFICATION_TYPE_CHILDREN_CHANGED;
5511 break; 5505 break;
5506 case WebKit::WebAccessibilityNotificationFocusedUIElementChanged:
5507 param.notification_type =
5508 ViewHostMsg_AccessibilityNotification_Params::
5509 NOTIFICATION_TYPE_FOCUS_CHANGED;
5510 break;
5511 case WebKit::WebAccessibilityNotificationLoadComplete:
5512 param.notification_type =
5513 ViewHostMsg_AccessibilityNotification_Params::
5514 NOTIFICATION_TYPE_LOAD_COMPLETE;
5515 break;
5512 case WebKit::WebAccessibilityNotificationValueChanged: 5516 case WebKit::WebAccessibilityNotificationValueChanged:
5513 param.notification_type = 5517 param.notification_type =
5514 ViewHostMsg_AccessibilityNotification_Params:: 5518 ViewHostMsg_AccessibilityNotification_Params::
5515 NOTIFICATION_TYPE_VALUE_CHANGED; 5519 NOTIFICATION_TYPE_VALUE_CHANGED;
5516 break; 5520 break;
5517 default: 5521 default:
5518 return; 5522 return;
5519 } 5523 }
5520 param.acc_obj = WebAccessibility(obj, accessibility_.get()); 5524 param.acc_obj = WebAccessibility(obj, accessibility_.get());
5521 5525
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
5837 } 5841 }
5838 5842
5839 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code, 5843 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code,
5840 IPC::PlatformFileForTransit file_for_transit, 5844 IPC::PlatformFileForTransit file_for_transit,
5841 int message_id) { 5845 int message_id) {
5842 pepper_delegate_.OnAsyncFileOpened( 5846 pepper_delegate_.OnAsyncFileOpened(
5843 error_code, 5847 error_code,
5844 IPC::PlatformFileForTransitToPlatformFile(file_for_transit), 5848 IPC::PlatformFileForTransitToPlatformFile(file_for_transit),
5845 message_id); 5849 message_id);
5846 } 5850 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.h ('k') | webkit/glue/webaccessibility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698