| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { | 267 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
| 268 WebVector<WebURL> urls; | 268 WebVector<WebURL> urls; |
| 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_AccEvent::Value* type) { |
| 278 switch (notification) { | 278 switch (notification) { |
| 279 case WebKit::WebAccessibilityNotificationActiveDescendantChanged: |
| 280 *type = ViewHostMsg_AccEvent::ACTIVE_DESCENDANT_CHANGED; |
| 281 break; |
| 279 case WebKit::WebAccessibilityNotificationCheckedStateChanged: | 282 case WebKit::WebAccessibilityNotificationCheckedStateChanged: |
| 280 *type = ViewHostMsg_AccessibilityNotification_Type:: | 283 *type = ViewHostMsg_AccEvent::CHECK_STATE_CHANGED; |
| 281 NOTIFICATION_TYPE_CHECK_STATE_CHANGED; | |
| 282 break; | 284 break; |
| 283 case WebKit::WebAccessibilityNotificationChildrenChanged: | 285 case WebKit::WebAccessibilityNotificationChildrenChanged: |
| 284 *type = ViewHostMsg_AccessibilityNotification_Type:: | 286 *type = ViewHostMsg_AccEvent::CHILDREN_CHANGED; |
| 285 NOTIFICATION_TYPE_CHILDREN_CHANGED; | |
| 286 break; | 287 break; |
| 287 case WebKit::WebAccessibilityNotificationFocusedUIElementChanged: | 288 case WebKit::WebAccessibilityNotificationFocusedUIElementChanged: |
| 288 *type = ViewHostMsg_AccessibilityNotification_Type:: | 289 *type = ViewHostMsg_AccEvent::FOCUS_CHANGED; |
| 289 NOTIFICATION_TYPE_FOCUS_CHANGED; | 290 break; |
| 291 case WebKit::WebAccessibilityNotificationLayoutComplete: |
| 292 *type = ViewHostMsg_AccEvent::LAYOUT_COMPLETE; |
| 293 break; |
| 294 case WebKit::WebAccessibilityNotificationLiveRegionChanged: |
| 295 *type = ViewHostMsg_AccEvent::LIVE_REGION_CHANGED; |
| 290 break; | 296 break; |
| 291 case WebKit::WebAccessibilityNotificationLoadComplete: | 297 case WebKit::WebAccessibilityNotificationLoadComplete: |
| 292 *type = ViewHostMsg_AccessibilityNotification_Type:: | 298 *type = ViewHostMsg_AccEvent::LOAD_COMPLETE; |
| 293 NOTIFICATION_TYPE_LOAD_COMPLETE; | 299 break; |
| 300 case WebKit::WebAccessibilityNotificationMenuListValueChanged: |
| 301 *type = ViewHostMsg_AccEvent::MENU_LIST_VALUE_CHANGED; |
| 302 break; |
| 303 case WebKit::WebAccessibilityNotificationRowCollapsed: |
| 304 *type = ViewHostMsg_AccEvent::ROW_COLLAPSED; |
| 305 break; |
| 306 case WebKit::WebAccessibilityNotificationRowCountChanged: |
| 307 *type = ViewHostMsg_AccEvent::ROW_COUNT_CHANGED; |
| 308 break; |
| 309 case WebKit::WebAccessibilityNotificationRowExpanded: |
| 310 *type = ViewHostMsg_AccEvent::ROW_EXPANDED; |
| 311 break; |
| 312 case WebKit::WebAccessibilityNotificationScrolledToAnchor: |
| 313 *type = ViewHostMsg_AccEvent::SCROLLED_TO_ANCHOR; |
| 314 break; |
| 315 case WebKit::WebAccessibilityNotificationSelectedChildrenChanged: |
| 316 *type = ViewHostMsg_AccEvent::SELECTED_CHILDREN_CHANGED; |
| 317 break; |
| 318 case WebKit::WebAccessibilityNotificationSelectedTextChanged: |
| 319 *type = ViewHostMsg_AccEvent::SELECTED_TEXT_CHANGED; |
| 294 break; | 320 break; |
| 295 case WebKit::WebAccessibilityNotificationValueChanged: | 321 case WebKit::WebAccessibilityNotificationValueChanged: |
| 296 *type = ViewHostMsg_AccessibilityNotification_Type:: | 322 *type = ViewHostMsg_AccEvent::VALUE_CHANGED; |
| 297 NOTIFICATION_TYPE_VALUE_CHANGED; | |
| 298 break; | |
| 299 case WebKit::WebAccessibilityNotificationSelectedTextChanged: | |
| 300 *type = ViewHostMsg_AccessibilityNotification_Type:: | |
| 301 NOTIFICATION_TYPE_SELECTED_TEXT_CHANGED; | |
| 302 break; | 323 break; |
| 303 default: | 324 default: |
| 304 // TODO(ctguil): Support additional webkit notifications. | |
| 305 return false; | 325 return false; |
| 306 } | 326 } |
| 307 return true; | 327 return true; |
| 308 } | 328 } |
| 309 | 329 |
| 310 // If |data_source| is non-null and has a NavigationState associated with it, | 330 // If |data_source| is non-null and has a NavigationState associated with it, |
| 311 // the AltErrorPageResourceFetcher is reset. | 331 // the AltErrorPageResourceFetcher is reset. |
| 312 static void StopAltErrorPageFetcher(WebDataSource* data_source) { | 332 static void StopAltErrorPageFetcher(WebDataSource* data_source) { |
| 313 if (data_source) { | 333 if (data_source) { |
| 314 NavigationState* state = NavigationState::FromDataSource(data_source); | 334 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), | 378 cached_is_main_frame_pinned_to_right_(false), |
| 359 cached_has_main_frame_horizontal_scrollbar_(false), | 379 cached_has_main_frame_horizontal_scrollbar_(false), |
| 360 cached_has_main_frame_vertical_scrollbar_(false), | 380 cached_has_main_frame_vertical_scrollbar_(false), |
| 361 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), | 381 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), |
| 362 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), | 382 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), |
| 363 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 383 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
| 364 geolocation_dispatcher_(NULL), | 384 geolocation_dispatcher_(NULL), |
| 365 speech_input_dispatcher_(NULL), | 385 speech_input_dispatcher_(NULL), |
| 366 device_orientation_dispatcher_(NULL), | 386 device_orientation_dispatcher_(NULL), |
| 367 accessibility_ack_pending_(false), | 387 accessibility_ack_pending_(false), |
| 388 accessibility_logging_(false), |
| 368 p2p_socket_dispatcher_(NULL), | 389 p2p_socket_dispatcher_(NULL), |
| 369 devtools_agent_(NULL), | 390 devtools_agent_(NULL), |
| 370 session_storage_namespace_id_(session_storage_namespace_id), | 391 session_storage_namespace_id_(session_storage_namespace_id), |
| 371 handling_select_range_(false) { | 392 handling_select_range_(false) { |
| 372 routing_id_ = routing_id; | 393 routing_id_ = routing_id; |
| 373 if (opener_id != MSG_ROUTING_NONE) | 394 if (opener_id != MSG_ROUTING_NONE) |
| 374 opener_id_ = opener_id; | 395 opener_id_ = opener_id; |
| 375 | 396 |
| 376 webwidget_ = WebView::create(this); | 397 webwidget_ = WebView::create(this); |
| 377 | 398 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 407 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : | 428 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : |
| 408 webkit_glue::kForegroundTabTimerInterval); | 429 webkit_glue::kForegroundTabTimerInterval); |
| 409 | 430 |
| 410 OnSetRendererPrefs(renderer_prefs); | 431 OnSetRendererPrefs(renderer_prefs); |
| 411 | 432 |
| 412 host_window_ = parent_hwnd; | 433 host_window_ = parent_hwnd; |
| 413 | 434 |
| 414 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 435 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 415 if (command_line.HasSwitch(switches::kEnableAccessibility)) | 436 if (command_line.HasSwitch(switches::kEnableAccessibility)) |
| 416 WebAccessibilityCache::enableAccessibility(); | 437 WebAccessibilityCache::enableAccessibility(); |
| 438 if (command_line.HasSwitch(switches::kEnableAccessibilityLogging)) |
| 439 accessibility_logging_ = true; |
| 417 | 440 |
| 418 #if defined(ENABLE_P2P_APIS) | 441 #if defined(ENABLE_P2P_APIS) |
| 419 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); | 442 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); |
| 420 #endif | 443 #endif |
| 421 | 444 |
| 422 new MHTMLGenerator(this); | 445 new MHTMLGenerator(this); |
| 423 | 446 |
| 424 devtools_agent_ = new DevToolsAgent(this); | 447 devtools_agent_ = new DevToolsAgent(this); |
| 425 | 448 |
| 426 if (command_line.HasSwitch(switches::kEnableMediaStream)) { | 449 if (command_line.HasSwitch(switches::kEnableMediaStream)) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 } | 544 } |
| 522 | 545 |
| 523 void RenderView::RemoveObserver(RenderViewObserver* observer) { | 546 void RenderView::RemoveObserver(RenderViewObserver* observer) { |
| 524 observer->set_render_view(NULL); | 547 observer->set_render_view(NULL); |
| 525 observers_.RemoveObserver(observer); | 548 observers_.RemoveObserver(observer); |
| 526 } | 549 } |
| 527 | 550 |
| 528 bool RenderView::RendererAccessibilityNotification::ShouldIncludeChildren() { | 551 bool RenderView::RendererAccessibilityNotification::ShouldIncludeChildren() { |
| 529 typedef ViewHostMsg_AccessibilityNotification_Params params; | 552 typedef ViewHostMsg_AccessibilityNotification_Params params; |
| 530 if (type == WebKit::WebAccessibilityNotificationChildrenChanged || | 553 if (type == WebKit::WebAccessibilityNotificationChildrenChanged || |
| 531 type == WebKit::WebAccessibilityNotificationLoadComplete) { | 554 type == WebKit::WebAccessibilityNotificationLoadComplete || |
| 555 type == WebKit::WebAccessibilityNotificationLiveRegionChanged) { |
| 532 return true; | 556 return true; |
| 533 } | 557 } |
| 534 return false; | 558 return false; |
| 535 } | 559 } |
| 536 | 560 |
| 537 WebKit::WebView* RenderView::webview() const { | 561 WebKit::WebView* RenderView::webview() const { |
| 538 return static_cast<WebKit::WebView*>(webwidget()); | 562 return static_cast<WebKit::WebView*>(webwidget()); |
| 539 } | 563 } |
| 540 | 564 |
| 541 void RenderView::SetReportLoadProgressEnabled(bool enabled) { | 565 void RenderView::SetReportLoadProgressEnabled(bool enabled) { |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 return; | 1613 return; |
| 1590 | 1614 |
| 1591 if (pending_accessibility_notifications_.empty()) | 1615 if (pending_accessibility_notifications_.empty()) |
| 1592 return; | 1616 return; |
| 1593 | 1617 |
| 1594 // Send all pending accessibility notifications. | 1618 // Send all pending accessibility notifications. |
| 1595 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; | 1619 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; |
| 1596 for (size_t i = 0; i < pending_accessibility_notifications_.size(); i++) { | 1620 for (size_t i = 0; i < pending_accessibility_notifications_.size(); i++) { |
| 1597 RendererAccessibilityNotification& notification = | 1621 RendererAccessibilityNotification& notification = |
| 1598 pending_accessibility_notifications_[i]; | 1622 pending_accessibility_notifications_[i]; |
| 1599 WebAccessibilityObject obj = accessibility_->getObjectById(notification.id); | 1623 WebAccessibilityObject obj = accessibility_->getObjectById( |
| 1624 notification.id); |
| 1600 if (!obj.isValid()) | 1625 if (!obj.isValid()) |
| 1601 continue; | 1626 continue; |
| 1602 | 1627 |
| 1603 ViewHostMsg_AccessibilityNotification_Params param; | 1628 ViewHostMsg_AccessibilityNotification_Params param; |
| 1604 WebAccessibilityNotificationToViewHostMsg( | 1629 WebAccessibilityNotificationToViewHostMsg( |
| 1605 pending_accessibility_notifications_[i].type, ¶m.notification_type); | 1630 pending_accessibility_notifications_[i].type, |
| 1631 ¶m.notification_type); |
| 1606 param.acc_obj = WebAccessibility( | 1632 param.acc_obj = WebAccessibility( |
| 1607 obj, accessibility_.get(), notification.ShouldIncludeChildren()); | 1633 obj, accessibility_.get(), notification.ShouldIncludeChildren()); |
| 1608 notifications.push_back(param); | 1634 notifications.push_back(param); |
| 1635 |
| 1636 if (accessibility_logging_) { |
| 1637 LOG(INFO) << "Accessibility update: \n" |
| 1638 << param.acc_obj.DebugString(true); |
| 1639 } |
| 1609 } | 1640 } |
| 1610 pending_accessibility_notifications_.clear(); | 1641 pending_accessibility_notifications_.clear(); |
| 1611 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications)); | 1642 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications)); |
| 1612 accessibility_ack_pending_ = true; | 1643 accessibility_ack_pending_ = true; |
| 1613 } | 1644 } |
| 1614 | 1645 |
| 1615 bool RenderView::handleCurrentKeyboardEvent() { | 1646 bool RenderView::handleCurrentKeyboardEvent() { |
| 1616 if (edit_commands_.empty()) | 1647 if (edit_commands_.empty()) |
| 1617 return false; | 1648 return false; |
| 1618 | 1649 |
| (...skipping 2493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4112 return; | 4143 return; |
| 4113 } | 4144 } |
| 4114 | 4145 |
| 4115 // Add the accessibility object to our cache and ensure it's valid. | 4146 // Add the accessibility object to our cache and ensure it's valid. |
| 4116 RendererAccessibilityNotification acc_notification; | 4147 RendererAccessibilityNotification acc_notification; |
| 4117 acc_notification.id = accessibility_->addOrGetId(obj); | 4148 acc_notification.id = accessibility_->addOrGetId(obj); |
| 4118 acc_notification.type = notification; | 4149 acc_notification.type = notification; |
| 4119 if (acc_notification.id < 0) | 4150 if (acc_notification.id < 0) |
| 4120 return; | 4151 return; |
| 4121 | 4152 |
| 4122 ViewHostMsg_AccessibilityNotification_Type::Value temp; | 4153 ViewHostMsg_AccEvent::Value temp; |
| 4123 if (!WebAccessibilityNotificationToViewHostMsg(notification, &temp)) | 4154 if (!WebAccessibilityNotificationToViewHostMsg(notification, &temp)) |
| 4124 return; | 4155 return; |
| 4125 | 4156 |
| 4126 // Discard duplicate accessibility notifications. | 4157 // Discard duplicate accessibility notifications. |
| 4127 for (uint32 i = 0; i < pending_accessibility_notifications_.size(); i++) { | 4158 for (uint32 i = 0; i < pending_accessibility_notifications_.size(); i++) { |
| 4128 if (pending_accessibility_notifications_[i].id == acc_notification.id && | 4159 if (pending_accessibility_notifications_[i].id == acc_notification.id && |
| 4129 pending_accessibility_notifications_[i].type == acc_notification.type) { | 4160 pending_accessibility_notifications_[i].type == acc_notification.type) { |
| 4130 return; | 4161 return; |
| 4131 } | 4162 } |
| 4132 } | 4163 } |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4585 } | 4616 } |
| 4586 | 4617 |
| 4587 void RenderView::OnEnableViewSourceMode() { | 4618 void RenderView::OnEnableViewSourceMode() { |
| 4588 if (!webview()) | 4619 if (!webview()) |
| 4589 return; | 4620 return; |
| 4590 WebFrame* main_frame = webview()->mainFrame(); | 4621 WebFrame* main_frame = webview()->mainFrame(); |
| 4591 if (!main_frame) | 4622 if (!main_frame) |
| 4592 return; | 4623 return; |
| 4593 main_frame->enableViewSourceMode(true); | 4624 main_frame->enableViewSourceMode(true); |
| 4594 } | 4625 } |
| OLD | NEW |