Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/render_view.h" | 5 #include "content/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 ds->redirectChain(urls); | 269 ds->redirectChain(urls); |
| 270 result->reserve(urls.size()); | 270 result->reserve(urls.size()); |
| 271 for (size_t i = 0; i < urls.size(); ++i) | 271 for (size_t i = 0; i < urls.size(); ++i) |
| 272 result->push_back(urls[i]); | 272 result->push_back(urls[i]); |
| 273 } | 273 } |
| 274 | 274 |
| 275 static bool WebAccessibilityNotificationToViewHostMsg( | 275 static bool WebAccessibilityNotificationToViewHostMsg( |
| 276 WebAccessibilityNotification notification, | 276 WebAccessibilityNotification notification, |
| 277 ViewHostMsg_AccessibilityNotification_Type::Value* type) { | 277 ViewHostMsg_AccessibilityNotification_Type::Value* type) { |
| 278 switch (notification) { | 278 switch (notification) { |
| 279 case WebKit::WebAccessibilityNotificationActiveDescendantChanged: | |
| 280 *type = ViewHostMsg_AccessibilityNotification_Type:: | |
| 281 NOTIFICATION_TYPE_ACTIVE_DESCENDANT_CHANGED; | |
| 282 break; | |
| 279 case WebKit::WebAccessibilityNotificationCheckedStateChanged: | 283 case WebKit::WebAccessibilityNotificationCheckedStateChanged: |
| 280 *type = ViewHostMsg_AccessibilityNotification_Type:: | 284 *type = ViewHostMsg_AccessibilityNotification_Type:: |
| 281 NOTIFICATION_TYPE_CHECK_STATE_CHANGED; | 285 NOTIFICATION_TYPE_CHECK_STATE_CHANGED; |
| 282 break; | 286 break; |
| 283 case WebKit::WebAccessibilityNotificationChildrenChanged: | 287 case WebKit::WebAccessibilityNotificationChildrenChanged: |
| 284 *type = ViewHostMsg_AccessibilityNotification_Type:: | 288 *type = ViewHostMsg_AccessibilityNotification_Type:: |
| 285 NOTIFICATION_TYPE_CHILDREN_CHANGED; | 289 NOTIFICATION_TYPE_CHILDREN_CHANGED; |
| 286 break; | 290 break; |
| 287 case WebKit::WebAccessibilityNotificationFocusedUIElementChanged: | 291 case WebKit::WebAccessibilityNotificationFocusedUIElementChanged: |
| 288 *type = ViewHostMsg_AccessibilityNotification_Type:: | 292 *type = ViewHostMsg_AccessibilityNotification_Type:: |
| 289 NOTIFICATION_TYPE_FOCUS_CHANGED; | 293 NOTIFICATION_TYPE_FOCUS_CHANGED; |
| 290 break; | 294 break; |
| 295 case WebKit::WebAccessibilityNotificationLayoutComplete: | |
| 296 *type = ViewHostMsg_AccessibilityNotification_Type:: | |
| 297 NOTIFICATION_TYPE_LAYOUT_COMPLETE; | |
| 298 break; | |
| 291 case WebKit::WebAccessibilityNotificationLoadComplete: | 299 case WebKit::WebAccessibilityNotificationLoadComplete: |
| 292 *type = ViewHostMsg_AccessibilityNotification_Type:: | 300 *type = ViewHostMsg_AccessibilityNotification_Type:: |
| 293 NOTIFICATION_TYPE_LOAD_COMPLETE; | 301 NOTIFICATION_TYPE_LOAD_COMPLETE; |
| 294 break; | 302 break; |
| 295 case WebKit::WebAccessibilityNotificationValueChanged: | 303 case WebKit::WebAccessibilityNotificationSelectedChildrenChanged: |
| 296 *type = ViewHostMsg_AccessibilityNotification_Type:: | 304 *type = ViewHostMsg_AccessibilityNotification_Type:: |
| 297 NOTIFICATION_TYPE_VALUE_CHANGED; | 305 NOTIFICATION_TYPE_SELECTED_CHILDREN_CHANGED; |
| 298 break; | 306 break; |
| 299 case WebKit::WebAccessibilityNotificationSelectedTextChanged: | 307 case WebKit::WebAccessibilityNotificationSelectedTextChanged: |
| 300 *type = ViewHostMsg_AccessibilityNotification_Type:: | 308 *type = ViewHostMsg_AccessibilityNotification_Type:: |
| 301 NOTIFICATION_TYPE_SELECTED_TEXT_CHANGED; | 309 NOTIFICATION_TYPE_SELECTED_TEXT_CHANGED; |
| 302 break; | 310 break; |
| 311 case WebKit::WebAccessibilityNotificationValueChanged: | |
| 312 *type = ViewHostMsg_AccessibilityNotification_Type:: | |
| 313 NOTIFICATION_TYPE_VALUE_CHANGED; | |
| 314 break; | |
| 315 case WebKit::WebAccessibilityNotificationScrolledToAnchor: | |
| 316 *type = ViewHostMsg_AccessibilityNotification_Type:: | |
| 317 NOTIFICATION_TYPE_SCROLLED_TO_ANCHOR; | |
| 318 break; | |
| 319 case WebKit::WebAccessibilityNotificationLiveRegionChanged: | |
| 320 *type = ViewHostMsg_AccessibilityNotification_Type:: | |
| 321 NOTIFICATION_TYPE_LIVE_REGION_CHANGED; | |
| 322 break; | |
| 323 case WebKit::WebAccessibilityNotificationMenuListValueChanged: | |
| 324 *type = ViewHostMsg_AccessibilityNotification_Type:: | |
| 325 NOTIFICATION_TYPE_MENU_LIST_VALUE_CHANGED; | |
| 326 break; | |
| 327 case WebKit::WebAccessibilityNotificationRowCountChanged: | |
| 328 *type = ViewHostMsg_AccessibilityNotification_Type:: | |
| 329 NOTIFICATION_TYPE_ROW_COUNT_CHANGED; | |
| 330 break; | |
| 331 case WebKit::WebAccessibilityNotificationRowCollapsed: | |
| 332 *type = ViewHostMsg_AccessibilityNotification_Type:: | |
| 333 NOTIFICATION_TYPE_ROW_COLLAPSED; | |
| 334 break; | |
| 335 case WebKit::WebAccessibilityNotificationRowExpanded: | |
| 336 *type = ViewHostMsg_AccessibilityNotification_Type:: | |
| 337 NOTIFICATION_TYPE_ROW_EXPANDED; | |
| 338 break; | |
| 303 default: | 339 default: |
| 304 // TODO(ctguil): Support additional webkit notifications. | |
| 305 return false; | 340 return false; |
| 306 } | 341 } |
| 307 return true; | 342 return true; |
| 308 } | 343 } |
| 309 | 344 |
| 310 // If |data_source| is non-null and has a NavigationState associated with it, | 345 // If |data_source| is non-null and has a NavigationState associated with it, |
| 311 // the AltErrorPageResourceFetcher is reset. | 346 // the AltErrorPageResourceFetcher is reset. |
| 312 static void StopAltErrorPageFetcher(WebDataSource* data_source) { | 347 static void StopAltErrorPageFetcher(WebDataSource* data_source) { |
| 313 if (data_source) { | 348 if (data_source) { |
| 314 NavigationState* state = NavigationState::FromDataSource(data_source); | 349 NavigationState* state = NavigationState::FromDataSource(data_source); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 cached_is_main_frame_pinned_to_right_(false), | 393 cached_is_main_frame_pinned_to_right_(false), |
| 359 cached_has_main_frame_horizontal_scrollbar_(false), | 394 cached_has_main_frame_horizontal_scrollbar_(false), |
| 360 cached_has_main_frame_vertical_scrollbar_(false), | 395 cached_has_main_frame_vertical_scrollbar_(false), |
| 361 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), | 396 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), |
| 362 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), | 397 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), |
| 363 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 398 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
| 364 geolocation_dispatcher_(NULL), | 399 geolocation_dispatcher_(NULL), |
| 365 speech_input_dispatcher_(NULL), | 400 speech_input_dispatcher_(NULL), |
| 366 device_orientation_dispatcher_(NULL), | 401 device_orientation_dispatcher_(NULL), |
| 367 accessibility_ack_pending_(false), | 402 accessibility_ack_pending_(false), |
| 403 accessibility_logging_(false), | |
| 368 p2p_socket_dispatcher_(NULL), | 404 p2p_socket_dispatcher_(NULL), |
| 369 devtools_agent_(NULL), | 405 devtools_agent_(NULL), |
| 370 session_storage_namespace_id_(session_storage_namespace_id), | 406 session_storage_namespace_id_(session_storage_namespace_id), |
| 371 handling_select_range_(false) { | 407 handling_select_range_(false) { |
| 372 routing_id_ = routing_id; | 408 routing_id_ = routing_id; |
| 373 if (opener_id != MSG_ROUTING_NONE) | 409 if (opener_id != MSG_ROUTING_NONE) |
| 374 opener_id_ = opener_id; | 410 opener_id_ = opener_id; |
| 375 | 411 |
| 376 webwidget_ = WebView::create(this); | 412 webwidget_ = WebView::create(this); |
| 377 | 413 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 407 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : | 443 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : |
| 408 webkit_glue::kForegroundTabTimerInterval); | 444 webkit_glue::kForegroundTabTimerInterval); |
| 409 | 445 |
| 410 OnSetRendererPrefs(renderer_prefs); | 446 OnSetRendererPrefs(renderer_prefs); |
| 411 | 447 |
| 412 host_window_ = parent_hwnd; | 448 host_window_ = parent_hwnd; |
| 413 | 449 |
| 414 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 450 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 415 if (command_line.HasSwitch(switches::kEnableAccessibility)) | 451 if (command_line.HasSwitch(switches::kEnableAccessibility)) |
| 416 WebAccessibilityCache::enableAccessibility(); | 452 WebAccessibilityCache::enableAccessibility(); |
| 453 if (command_line.HasSwitch(switches::kEnableAccessibilityLogging)) | |
| 454 accessibility_logging_ = true; | |
| 417 | 455 |
| 418 #if defined(ENABLE_P2P_APIS) | 456 #if defined(ENABLE_P2P_APIS) |
| 419 p2p_socket_dispatcher_ = new P2PSocketDispatcher(this); | 457 p2p_socket_dispatcher_ = new P2PSocketDispatcher(this); |
| 420 #endif | 458 #endif |
| 421 | 459 |
| 422 new MHTMLGenerator(this); | 460 new MHTMLGenerator(this); |
| 423 | 461 |
| 424 devtools_agent_ = new DevToolsAgent(this); | 462 devtools_agent_ = new DevToolsAgent(this); |
| 425 | 463 |
| 426 if (command_line.HasSwitch(switches::kEnableMediaStream)) { | 464 if (command_line.HasSwitch(switches::kEnableMediaStream)) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 521 } | 559 } |
| 522 | 560 |
| 523 void RenderView::RemoveObserver(RenderViewObserver* observer) { | 561 void RenderView::RemoveObserver(RenderViewObserver* observer) { |
| 524 observer->set_render_view(NULL); | 562 observer->set_render_view(NULL); |
| 525 observers_.RemoveObserver(observer); | 563 observers_.RemoveObserver(observer); |
| 526 } | 564 } |
| 527 | 565 |
| 528 bool RenderView::RendererAccessibilityNotification::ShouldIncludeChildren() { | 566 bool RenderView::RendererAccessibilityNotification::ShouldIncludeChildren() { |
| 529 typedef ViewHostMsg_AccessibilityNotification_Params params; | 567 typedef ViewHostMsg_AccessibilityNotification_Params params; |
| 530 if (type == WebKit::WebAccessibilityNotificationChildrenChanged || | 568 if (type == WebKit::WebAccessibilityNotificationChildrenChanged || |
| 531 type == WebKit::WebAccessibilityNotificationLoadComplete) { | 569 type == WebKit::WebAccessibilityNotificationLoadComplete || |
| 570 type == WebKit::WebAccessibilityNotificationLiveRegionChanged) { | |
| 532 return true; | 571 return true; |
| 533 } | 572 } |
| 534 return false; | 573 return false; |
| 535 } | 574 } |
| 536 | 575 |
| 537 WebKit::WebView* RenderView::webview() const { | 576 WebKit::WebView* RenderView::webview() const { |
| 538 return static_cast<WebKit::WebView*>(webwidget()); | 577 return static_cast<WebKit::WebView*>(webwidget()); |
| 539 } | 578 } |
| 540 | 579 |
| 541 void RenderView::SetReportLoadProgressEnabled(bool enabled) { | 580 void RenderView::SetReportLoadProgressEnabled(bool enabled) { |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1589 return; | 1628 return; |
| 1590 | 1629 |
| 1591 if (pending_accessibility_notifications_.empty()) | 1630 if (pending_accessibility_notifications_.empty()) |
| 1592 return; | 1631 return; |
| 1593 | 1632 |
| 1594 // Send all pending accessibility notifications. | 1633 // Send all pending accessibility notifications. |
| 1595 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; | 1634 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; |
| 1596 for (size_t i = 0; i < pending_accessibility_notifications_.size(); i++) { | 1635 for (size_t i = 0; i < pending_accessibility_notifications_.size(); i++) { |
| 1597 RendererAccessibilityNotification& notification = | 1636 RendererAccessibilityNotification& notification = |
| 1598 pending_accessibility_notifications_[i]; | 1637 pending_accessibility_notifications_[i]; |
| 1599 WebAccessibilityObject obj = accessibility_->getObjectById(notification.id); | 1638 WebAccessibilityObject obj = accessibility_->getObjectById( |
| 1639 notification.id); | |
| 1600 if (!obj.isValid()) | 1640 if (!obj.isValid()) |
| 1601 continue; | 1641 continue; |
| 1602 | 1642 |
| 1603 ViewHostMsg_AccessibilityNotification_Params param; | 1643 ViewHostMsg_AccessibilityNotification_Params param; |
| 1604 WebAccessibilityNotificationToViewHostMsg( | 1644 WebAccessibilityNotificationToViewHostMsg( |
| 1605 pending_accessibility_notifications_[i].type, ¶m.notification_type); | 1645 pending_accessibility_notifications_[i].type, |
| 1646 ¶m.notification_type); | |
| 1606 param.acc_obj = WebAccessibility( | 1647 param.acc_obj = WebAccessibility( |
| 1607 obj, accessibility_.get(), notification.ShouldIncludeChildren()); | 1648 obj, accessibility_.get(), notification.ShouldIncludeChildren()); |
| 1608 notifications.push_back(param); | 1649 notifications.push_back(param); |
| 1650 | |
| 1651 if (accessibility_logging_) { | |
| 1652 LOG(INFO) << "Accessibility update: \n" | |
|
David Tseng
2011/08/29 19:05:34
Might be useful to also output
|param.notification
| |
| 1653 << param.acc_obj.DebugString(true); | |
| 1654 } | |
| 1609 } | 1655 } |
| 1610 pending_accessibility_notifications_.clear(); | 1656 pending_accessibility_notifications_.clear(); |
| 1611 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications)); | 1657 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications)); |
| 1612 accessibility_ack_pending_ = true; | 1658 accessibility_ack_pending_ = true; |
| 1613 } | 1659 } |
| 1614 | 1660 |
| 1615 bool RenderView::handleCurrentKeyboardEvent() { | 1661 bool RenderView::handleCurrentKeyboardEvent() { |
| 1616 if (edit_commands_.empty()) | 1662 if (edit_commands_.empty()) |
| 1617 return false; | 1663 return false; |
| 1618 | 1664 |
| (...skipping 2964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4583 | 4629 |
| 4584 void RenderView::OnEnableViewSourceMode() { | 4630 void RenderView::OnEnableViewSourceMode() { |
| 4585 if (!webview()) | 4631 if (!webview()) |
| 4586 return; | 4632 return; |
| 4587 WebFrame* main_frame = webview()->mainFrame(); | 4633 WebFrame* main_frame = webview()->mainFrame(); |
| 4588 if (!main_frame) | 4634 if (!main_frame) |
| 4589 return; | 4635 return; |
| 4590 main_frame->enableViewSourceMode(true); | 4636 main_frame->enableViewSourceMode(true); |
| 4591 } | 4637 } |
| 4592 | 4638 |
| OLD | NEW |