| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { | 271 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
| 272 WebVector<WebURL> urls; | 272 WebVector<WebURL> urls; |
| 273 ds->redirectChain(urls); | 273 ds->redirectChain(urls); |
| 274 result->reserve(urls.size()); | 274 result->reserve(urls.size()); |
| 275 for (size_t i = 0; i < urls.size(); ++i) | 275 for (size_t i = 0; i < urls.size(); ++i) |
| 276 result->push_back(urls[i]); | 276 result->push_back(urls[i]); |
| 277 } | 277 } |
| 278 | 278 |
| 279 static bool WebAccessibilityNotificationToViewHostMsg( | 279 static bool WebAccessibilityNotificationToViewHostMsg( |
| 280 WebAccessibilityNotification notification, | 280 WebAccessibilityNotification notification, |
| 281 ViewHostMsg_AccessibilityNotification_Type::Value* type) { | 281 ViewHostMsg_AccEvent::Value* type) { |
| 282 switch (notification) { | 282 switch (notification) { |
| 283 case WebKit::WebAccessibilityNotificationActiveDescendantChanged: |
| 284 *type = ViewHostMsg_AccEvent::ACTIVE_DESCENDANT_CHANGED; |
| 285 break; |
| 283 case WebKit::WebAccessibilityNotificationCheckedStateChanged: | 286 case WebKit::WebAccessibilityNotificationCheckedStateChanged: |
| 284 *type = ViewHostMsg_AccessibilityNotification_Type:: | 287 *type = ViewHostMsg_AccEvent::CHECK_STATE_CHANGED; |
| 285 NOTIFICATION_TYPE_CHECK_STATE_CHANGED; | |
| 286 break; | 288 break; |
| 287 case WebKit::WebAccessibilityNotificationChildrenChanged: | 289 case WebKit::WebAccessibilityNotificationChildrenChanged: |
| 288 *type = ViewHostMsg_AccessibilityNotification_Type:: | 290 *type = ViewHostMsg_AccEvent::CHILDREN_CHANGED; |
| 289 NOTIFICATION_TYPE_CHILDREN_CHANGED; | |
| 290 break; | 291 break; |
| 291 case WebKit::WebAccessibilityNotificationFocusedUIElementChanged: | 292 case WebKit::WebAccessibilityNotificationFocusedUIElementChanged: |
| 292 *type = ViewHostMsg_AccessibilityNotification_Type:: | 293 *type = ViewHostMsg_AccEvent::FOCUS_CHANGED; |
| 293 NOTIFICATION_TYPE_FOCUS_CHANGED; | 294 break; |
| 295 case WebKit::WebAccessibilityNotificationLayoutComplete: |
| 296 *type = ViewHostMsg_AccEvent::LAYOUT_COMPLETE; |
| 297 break; |
| 298 case WebKit::WebAccessibilityNotificationLiveRegionChanged: |
| 299 *type = ViewHostMsg_AccEvent::LIVE_REGION_CHANGED; |
| 294 break; | 300 break; |
| 295 case WebKit::WebAccessibilityNotificationLoadComplete: | 301 case WebKit::WebAccessibilityNotificationLoadComplete: |
| 296 *type = ViewHostMsg_AccessibilityNotification_Type:: | 302 *type = ViewHostMsg_AccEvent::LOAD_COMPLETE; |
| 297 NOTIFICATION_TYPE_LOAD_COMPLETE; | 303 break; |
| 304 case WebKit::WebAccessibilityNotificationMenuListValueChanged: |
| 305 *type = ViewHostMsg_AccEvent::MENU_LIST_VALUE_CHANGED; |
| 306 break; |
| 307 case WebKit::WebAccessibilityNotificationRowCollapsed: |
| 308 *type = ViewHostMsg_AccEvent::ROW_COLLAPSED; |
| 309 break; |
| 310 case WebKit::WebAccessibilityNotificationRowCountChanged: |
| 311 *type = ViewHostMsg_AccEvent::ROW_COUNT_CHANGED; |
| 312 break; |
| 313 case WebKit::WebAccessibilityNotificationRowExpanded: |
| 314 *type = ViewHostMsg_AccEvent::ROW_EXPANDED; |
| 315 break; |
| 316 case WebKit::WebAccessibilityNotificationScrolledToAnchor: |
| 317 *type = ViewHostMsg_AccEvent::SCROLLED_TO_ANCHOR; |
| 318 break; |
| 319 case WebKit::WebAccessibilityNotificationSelectedChildrenChanged: |
| 320 *type = ViewHostMsg_AccEvent::SELECTED_CHILDREN_CHANGED; |
| 321 break; |
| 322 case WebKit::WebAccessibilityNotificationSelectedTextChanged: |
| 323 *type = ViewHostMsg_AccEvent::SELECTED_TEXT_CHANGED; |
| 298 break; | 324 break; |
| 299 case WebKit::WebAccessibilityNotificationValueChanged: | 325 case WebKit::WebAccessibilityNotificationValueChanged: |
| 300 *type = ViewHostMsg_AccessibilityNotification_Type:: | 326 *type = ViewHostMsg_AccEvent::VALUE_CHANGED; |
| 301 NOTIFICATION_TYPE_VALUE_CHANGED; | |
| 302 break; | |
| 303 case WebKit::WebAccessibilityNotificationSelectedTextChanged: | |
| 304 *type = ViewHostMsg_AccessibilityNotification_Type:: | |
| 305 NOTIFICATION_TYPE_SELECTED_TEXT_CHANGED; | |
| 306 break; | 327 break; |
| 307 default: | 328 default: |
| 308 // TODO(ctguil): Support additional webkit notifications. | |
| 309 return false; | 329 return false; |
| 310 } | 330 } |
| 311 return true; | 331 return true; |
| 312 } | 332 } |
| 313 | 333 |
| 314 // If |data_source| is non-null and has a NavigationState associated with it, | 334 // If |data_source| is non-null and has a NavigationState associated with it, |
| 315 // the AltErrorPageResourceFetcher is reset. | 335 // the AltErrorPageResourceFetcher is reset. |
| 316 static void StopAltErrorPageFetcher(WebDataSource* data_source) { | 336 static void StopAltErrorPageFetcher(WebDataSource* data_source) { |
| 317 if (data_source) { | 337 if (data_source) { |
| 318 NavigationState* state = NavigationState::FromDataSource(data_source); | 338 NavigationState* state = NavigationState::FromDataSource(data_source); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 cached_is_main_frame_pinned_to_right_(false), | 382 cached_is_main_frame_pinned_to_right_(false), |
| 363 cached_has_main_frame_horizontal_scrollbar_(false), | 383 cached_has_main_frame_horizontal_scrollbar_(false), |
| 364 cached_has_main_frame_vertical_scrollbar_(false), | 384 cached_has_main_frame_vertical_scrollbar_(false), |
| 365 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), | 385 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), |
| 366 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), | 386 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), |
| 367 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 387 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
| 368 geolocation_dispatcher_(NULL), | 388 geolocation_dispatcher_(NULL), |
| 369 speech_input_dispatcher_(NULL), | 389 speech_input_dispatcher_(NULL), |
| 370 device_orientation_dispatcher_(NULL), | 390 device_orientation_dispatcher_(NULL), |
| 371 accessibility_ack_pending_(false), | 391 accessibility_ack_pending_(false), |
| 392 accessibility_logging_(false), |
| 372 p2p_socket_dispatcher_(NULL), | 393 p2p_socket_dispatcher_(NULL), |
| 373 devtools_agent_(NULL), | 394 devtools_agent_(NULL), |
| 374 session_storage_namespace_id_(session_storage_namespace_id), | 395 session_storage_namespace_id_(session_storage_namespace_id), |
| 375 handling_select_range_(false) { | 396 handling_select_range_(false) { |
| 376 routing_id_ = routing_id; | 397 routing_id_ = routing_id; |
| 377 if (opener_id != MSG_ROUTING_NONE) | 398 if (opener_id != MSG_ROUTING_NONE) |
| 378 opener_id_ = opener_id; | 399 opener_id_ = opener_id; |
| 379 | 400 |
| 380 webwidget_ = WebView::create(this); | 401 webwidget_ = WebView::create(this); |
| 381 | 402 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 409 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : | 430 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : |
| 410 webkit_glue::kForegroundTabTimerInterval); | 431 webkit_glue::kForegroundTabTimerInterval); |
| 411 | 432 |
| 412 OnSetRendererPrefs(renderer_prefs); | 433 OnSetRendererPrefs(renderer_prefs); |
| 413 | 434 |
| 414 host_window_ = parent_hwnd; | 435 host_window_ = parent_hwnd; |
| 415 | 436 |
| 416 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 437 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 417 if (command_line.HasSwitch(switches::kEnableAccessibility)) | 438 if (command_line.HasSwitch(switches::kEnableAccessibility)) |
| 418 WebAccessibilityCache::enableAccessibility(); | 439 WebAccessibilityCache::enableAccessibility(); |
| 440 if (command_line.HasSwitch(switches::kEnableAccessibilityLogging)) |
| 441 accessibility_logging_ = true; |
| 419 | 442 |
| 420 #if defined(ENABLE_P2P_APIS) | 443 #if defined(ENABLE_P2P_APIS) |
| 421 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); | 444 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); |
| 422 #endif | 445 #endif |
| 423 | 446 |
| 424 new MHTMLGenerator(this); | 447 new MHTMLGenerator(this); |
| 425 | 448 |
| 426 devtools_agent_ = new DevToolsAgent(this); | 449 devtools_agent_ = new DevToolsAgent(this); |
| 427 | 450 |
| 428 if (command_line.HasSwitch(switches::kEnableMediaStream)) { | 451 if (command_line.HasSwitch(switches::kEnableMediaStream)) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 } | 546 } |
| 524 | 547 |
| 525 void RenderView::RemoveObserver(RenderViewObserver* observer) { | 548 void RenderView::RemoveObserver(RenderViewObserver* observer) { |
| 526 observer->set_render_view(NULL); | 549 observer->set_render_view(NULL); |
| 527 observers_.RemoveObserver(observer); | 550 observers_.RemoveObserver(observer); |
| 528 } | 551 } |
| 529 | 552 |
| 530 bool RenderView::RendererAccessibilityNotification::ShouldIncludeChildren() { | 553 bool RenderView::RendererAccessibilityNotification::ShouldIncludeChildren() { |
| 531 typedef ViewHostMsg_AccessibilityNotification_Params params; | 554 typedef ViewHostMsg_AccessibilityNotification_Params params; |
| 532 if (type == WebKit::WebAccessibilityNotificationChildrenChanged || | 555 if (type == WebKit::WebAccessibilityNotificationChildrenChanged || |
| 533 type == WebKit::WebAccessibilityNotificationLoadComplete) { | 556 type == WebKit::WebAccessibilityNotificationLoadComplete || |
| 557 type == WebKit::WebAccessibilityNotificationLiveRegionChanged) { |
| 534 return true; | 558 return true; |
| 535 } | 559 } |
| 536 return false; | 560 return false; |
| 537 } | 561 } |
| 538 | 562 |
| 539 WebKit::WebView* RenderView::webview() const { | 563 WebKit::WebView* RenderView::webview() const { |
| 540 return static_cast<WebKit::WebView*>(webwidget()); | 564 return static_cast<WebKit::WebView*>(webwidget()); |
| 541 } | 565 } |
| 542 | 566 |
| 543 void RenderView::SetReportLoadProgressEnabled(bool enabled) { | 567 void RenderView::SetReportLoadProgressEnabled(bool enabled) { |
| (...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1617 WebAccessibilityObject obj = accessibility_->getObjectById(notification.id); | 1641 WebAccessibilityObject obj = accessibility_->getObjectById(notification.id); |
| 1618 if (!obj.isValid()) | 1642 if (!obj.isValid()) |
| 1619 continue; | 1643 continue; |
| 1620 | 1644 |
| 1621 ViewHostMsg_AccessibilityNotification_Params param; | 1645 ViewHostMsg_AccessibilityNotification_Params param; |
| 1622 WebAccessibilityNotificationToViewHostMsg( | 1646 WebAccessibilityNotificationToViewHostMsg( |
| 1623 pending_accessibility_notifications_[i].type, ¶m.notification_type); | 1647 pending_accessibility_notifications_[i].type, ¶m.notification_type); |
| 1624 param.acc_obj = WebAccessibility( | 1648 param.acc_obj = WebAccessibility( |
| 1625 obj, accessibility_.get(), notification.ShouldIncludeChildren()); | 1649 obj, accessibility_.get(), notification.ShouldIncludeChildren()); |
| 1626 notifications.push_back(param); | 1650 notifications.push_back(param); |
| 1651 |
| 1652 #ifndef NDEBUG |
| 1653 if (accessibility_logging_) { |
| 1654 LOG(INFO) << "Accessibility update: \n" |
| 1655 << param.acc_obj.DebugString(true); |
| 1656 } |
| 1657 #endif |
| 1627 } | 1658 } |
| 1628 pending_accessibility_notifications_.clear(); | 1659 pending_accessibility_notifications_.clear(); |
| 1629 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications)); | 1660 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications)); |
| 1630 accessibility_ack_pending_ = true; | 1661 accessibility_ack_pending_ = true; |
| 1631 } | 1662 } |
| 1632 | 1663 |
| 1633 bool RenderView::handleCurrentKeyboardEvent() { | 1664 bool RenderView::handleCurrentKeyboardEvent() { |
| 1634 if (edit_commands_.empty()) | 1665 if (edit_commands_.empty()) |
| 1635 return false; | 1666 return false; |
| 1636 | 1667 |
| (...skipping 2495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4132 return; | 4163 return; |
| 4133 } | 4164 } |
| 4134 | 4165 |
| 4135 // Add the accessibility object to our cache and ensure it's valid. | 4166 // Add the accessibility object to our cache and ensure it's valid. |
| 4136 RendererAccessibilityNotification acc_notification; | 4167 RendererAccessibilityNotification acc_notification; |
| 4137 acc_notification.id = accessibility_->addOrGetId(obj); | 4168 acc_notification.id = accessibility_->addOrGetId(obj); |
| 4138 acc_notification.type = notification; | 4169 acc_notification.type = notification; |
| 4139 if (acc_notification.id < 0) | 4170 if (acc_notification.id < 0) |
| 4140 return; | 4171 return; |
| 4141 | 4172 |
| 4142 ViewHostMsg_AccessibilityNotification_Type::Value temp; | 4173 ViewHostMsg_AccEvent::Value temp; |
| 4143 if (!WebAccessibilityNotificationToViewHostMsg(notification, &temp)) | 4174 if (!WebAccessibilityNotificationToViewHostMsg(notification, &temp)) |
| 4144 return; | 4175 return; |
| 4145 | 4176 |
| 4146 // Discard duplicate accessibility notifications. | 4177 // Discard duplicate accessibility notifications. |
| 4147 for (uint32 i = 0; i < pending_accessibility_notifications_.size(); i++) { | 4178 for (uint32 i = 0; i < pending_accessibility_notifications_.size(); i++) { |
| 4148 if (pending_accessibility_notifications_[i].id == acc_notification.id && | 4179 if (pending_accessibility_notifications_[i].id == acc_notification.id && |
| 4149 pending_accessibility_notifications_[i].type == acc_notification.type) { | 4180 pending_accessibility_notifications_[i].type == acc_notification.type) { |
| 4150 return; | 4181 return; |
| 4151 } | 4182 } |
| 4152 } | 4183 } |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4605 } | 4636 } |
| 4606 | 4637 |
| 4607 void RenderView::OnEnableViewSourceMode() { | 4638 void RenderView::OnEnableViewSourceMode() { |
| 4608 if (!webview()) | 4639 if (!webview()) |
| 4609 return; | 4640 return; |
| 4610 WebFrame* main_frame = webview()->mainFrame(); | 4641 WebFrame* main_frame = webview()->mainFrame(); |
| 4611 if (!main_frame) | 4642 if (!main_frame) |
| 4612 return; | 4643 return; |
| 4613 main_frame->enableViewSourceMode(true); | 4644 main_frame->enableViewSourceMode(true); |
| 4614 } | 4645 } |
| OLD | NEW |