| OLD | NEW |
| 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/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 return -1; | 529 return -1; |
| 530 | 530 |
| 531 if (item.httpBody().isNull()) | 531 if (item.httpBody().isNull()) |
| 532 return -1; | 532 return -1; |
| 533 | 533 |
| 534 return item.httpBody().identifier(); | 534 return item.httpBody().identifier(); |
| 535 } | 535 } |
| 536 | 536 |
| 537 } // namespace | 537 } // namespace |
| 538 | 538 |
| 539 RenderViewImpl::RenderViewImpl( | 539 RenderViewImplParams::RenderViewImplParams( |
| 540 int32 opener_id, | 540 int32 opener_id, |
| 541 const RendererPreferences& renderer_prefs, | 541 const RendererPreferences& renderer_prefs, |
| 542 const WebPreferences& webkit_prefs, | 542 const WebPreferences& webkit_prefs, |
| 543 SharedRenderViewCounter* counter, | 543 SharedRenderViewCounter* counter, |
| 544 int32 routing_id, | 544 int32 routing_id, |
| 545 int32 surface_id, | 545 int32 surface_id, |
| 546 int64 session_storage_namespace_id, | 546 int64 session_storage_namespace_id, |
| 547 const string16& frame_name, | 547 const string16& frame_name, |
| 548 bool is_renderer_created, | 548 bool is_renderer_created, |
| 549 bool swapped_out, | 549 bool swapped_out, |
| 550 int32 next_page_id, | 550 int32 next_page_id, |
| 551 const WebKit::WebScreenInfo& screen_info, | 551 const WebKit::WebScreenInfo& screen_info, |
| 552 AccessibilityMode accessibility_mode) | 552 AccessibilityMode accessibility_mode) |
| 553 : RenderWidget(WebKit::WebPopupTypeNone, screen_info, swapped_out), | 553 : opener_id(opener_id), |
| 554 webkit_preferences_(webkit_prefs), | 554 renderer_prefs(renderer_prefs), |
| 555 webkit_prefs(webkit_prefs), |
| 556 counter(counter), |
| 557 routing_id(routing_id), |
| 558 surface_id(surface_id), |
| 559 session_storage_namespace_id(session_storage_namespace_id), |
| 560 frame_name(frame_name), |
| 561 is_renderer_created(is_renderer_created), |
| 562 swapped_out(swapped_out), |
| 563 next_page_id(next_page_id), |
| 564 screen_info(screen_info), |
| 565 accessibility_mode(accessibility_mode) { |
| 566 } |
| 567 |
| 568 RenderViewImplParams::~RenderViewImplParams() {} |
| 569 |
| 570 RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) |
| 571 : RenderWidget(WebKit::WebPopupTypeNone, |
| 572 params->screen_info, |
| 573 params->swapped_out), |
| 574 webkit_preferences_(params->webkit_prefs), |
| 555 send_content_state_immediately_(false), | 575 send_content_state_immediately_(false), |
| 556 enabled_bindings_(0), | 576 enabled_bindings_(0), |
| 557 send_preferred_size_changes_(false), | 577 send_preferred_size_changes_(false), |
| 558 is_loading_(false), | 578 is_loading_(false), |
| 559 navigation_gesture_(NavigationGestureUnknown), | 579 navigation_gesture_(NavigationGestureUnknown), |
| 560 opened_by_user_gesture_(true), | 580 opened_by_user_gesture_(true), |
| 561 opener_suppressed_(false), | 581 opener_suppressed_(false), |
| 562 page_id_(-1), | 582 page_id_(-1), |
| 563 last_page_id_sent_to_browser_(-1), | 583 last_page_id_sent_to_browser_(-1), |
| 564 next_page_id_(next_page_id), | 584 next_page_id_(params->next_page_id), |
| 565 history_list_offset_(-1), | 585 history_list_offset_(-1), |
| 566 history_list_length_(0), | 586 history_list_length_(0), |
| 567 target_url_status_(TARGET_NONE), | 587 target_url_status_(TARGET_NONE), |
| 568 selection_text_offset_(0), | 588 selection_text_offset_(0), |
| 569 cached_is_main_frame_pinned_to_left_(false), | 589 cached_is_main_frame_pinned_to_left_(false), |
| 570 cached_is_main_frame_pinned_to_right_(false), | 590 cached_is_main_frame_pinned_to_right_(false), |
| 571 cached_has_main_frame_horizontal_scrollbar_(false), | 591 cached_has_main_frame_horizontal_scrollbar_(false), |
| 572 cached_has_main_frame_vertical_scrollbar_(false), | 592 cached_has_main_frame_vertical_scrollbar_(false), |
| 573 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 593 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
| 574 geolocation_dispatcher_(NULL), | 594 geolocation_dispatcher_(NULL), |
| 575 input_tag_speech_dispatcher_(NULL), | 595 input_tag_speech_dispatcher_(NULL), |
| 576 speech_recognition_dispatcher_(NULL), | 596 speech_recognition_dispatcher_(NULL), |
| 577 device_orientation_dispatcher_(NULL), | 597 device_orientation_dispatcher_(NULL), |
| 578 media_stream_dispatcher_(NULL), | 598 media_stream_dispatcher_(NULL), |
| 579 media_stream_impl_(NULL), | 599 media_stream_impl_(NULL), |
| 580 devtools_agent_(NULL), | 600 devtools_agent_(NULL), |
| 581 accessibility_mode_(AccessibilityModeOff), | 601 accessibility_mode_(AccessibilityModeOff), |
| 582 renderer_accessibility_(NULL), | 602 renderer_accessibility_(NULL), |
| 583 java_bridge_dispatcher_(NULL), | 603 java_bridge_dispatcher_(NULL), |
| 584 mouse_lock_dispatcher_(NULL), | 604 mouse_lock_dispatcher_(NULL), |
| 585 #if defined(OS_ANDROID) | 605 #if defined(OS_ANDROID) |
| 586 body_background_color_(SK_ColorWHITE), | 606 body_background_color_(SK_ColorWHITE), |
| 587 update_frame_info_scheduled_(false), | 607 update_frame_info_scheduled_(false), |
| 588 expected_content_intent_id_(0), | 608 expected_content_intent_id_(0), |
| 589 media_player_proxy_(NULL), | 609 media_player_proxy_(NULL), |
| 590 synchronous_find_active_match_ordinal_(-1), | 610 synchronous_find_active_match_ordinal_(-1), |
| 591 ALLOW_THIS_IN_INITIALIZER_LIST( | 611 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 592 load_progress_tracker_(new LoadProgressTracker(this))), | 612 load_progress_tracker_(new LoadProgressTracker(this))), |
| 593 #endif | 613 #endif |
| 594 session_storage_namespace_id_(session_storage_namespace_id), | 614 session_storage_namespace_id_(params->session_storage_namespace_id), |
| 595 handling_select_range_(false), | 615 handling_select_range_(false), |
| 596 #if defined(OS_WIN) | 616 #if defined(OS_WIN) |
| 597 focused_plugin_id_(-1), | 617 focused_plugin_id_(-1), |
| 598 #endif | 618 #endif |
| 599 updating_frame_tree_(false), | 619 updating_frame_tree_(false), |
| 600 pending_frame_tree_update_(false), | 620 pending_frame_tree_update_(false), |
| 601 target_process_id_(0), | 621 target_process_id_(0), |
| 602 target_routing_id_(0), | 622 target_routing_id_(0), |
| 603 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { | 623 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { |
| 604 set_throttle_input_events(renderer_prefs.throttle_input_events); | 624 set_throttle_input_events(params->renderer_prefs.throttle_input_events); |
| 605 routing_id_ = routing_id; | 625 routing_id_ = params->routing_id; |
| 606 surface_id_ = surface_id; | 626 surface_id_ = params->surface_id; |
| 607 if (opener_id != MSG_ROUTING_NONE && is_renderer_created) | 627 if (params->opener_id != MSG_ROUTING_NONE && params->is_renderer_created) |
| 608 opener_id_ = opener_id; | 628 opener_id_ = params->opener_id; |
| 609 | 629 |
| 610 // Ensure we start with a valid next_page_id_ from the browser. | 630 // Ensure we start with a valid next_page_id_ from the browser. |
| 611 DCHECK_GE(next_page_id_, 0); | 631 DCHECK_GE(next_page_id_, 0); |
| 612 | 632 |
| 613 #if defined(ENABLE_NOTIFICATIONS) | 633 #if defined(ENABLE_NOTIFICATIONS) |
| 614 notification_provider_ = new NotificationProvider(this); | 634 notification_provider_ = new NotificationProvider(this); |
| 615 #else | 635 #else |
| 616 notification_provider_ = NULL; | 636 notification_provider_ = NULL; |
| 617 #endif | 637 #endif |
| 618 | 638 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 631 ? command_line.GetSwitchValueASCII(switches::kNetworkCountryIso) | 651 ? command_line.GetSwitchValueASCII(switches::kNetworkCountryIso) |
| 632 : device_info->GetNetworkCountryIso(); | 652 : device_info->GetNetworkCountryIso(); |
| 633 content_detectors_.push_back(linked_ptr<ContentDetector>( | 653 content_detectors_.push_back(linked_ptr<ContentDetector>( |
| 634 new AddressDetector())); | 654 new AddressDetector())); |
| 635 content_detectors_.push_back(linked_ptr<ContentDetector>( | 655 content_detectors_.push_back(linked_ptr<ContentDetector>( |
| 636 new PhoneNumberDetector(region_code))); | 656 new PhoneNumberDetector(region_code))); |
| 637 content_detectors_.push_back(linked_ptr<ContentDetector>( | 657 content_detectors_.push_back(linked_ptr<ContentDetector>( |
| 638 new EmailDetector())); | 658 new EmailDetector())); |
| 639 #endif | 659 #endif |
| 640 | 660 |
| 641 if (counter) { | 661 if (params->counter) { |
| 642 shared_popup_counter_ = counter; | 662 shared_popup_counter_ = params->counter; |
| 643 // Only count this if it isn't swapped out upon creation. | 663 // Only count this if it isn't swapped out upon creation. |
| 644 if (!swapped_out) | 664 if (!params->swapped_out) |
| 645 shared_popup_counter_->data++; | 665 shared_popup_counter_->data++; |
| 646 decrement_shared_popup_at_destruction_ = true; | 666 decrement_shared_popup_at_destruction_ = true; |
| 647 } else { | 667 } else { |
| 648 shared_popup_counter_ = new SharedRenderViewCounter(0); | 668 shared_popup_counter_ = new SharedRenderViewCounter(0); |
| 649 decrement_shared_popup_at_destruction_ = false; | 669 decrement_shared_popup_at_destruction_ = false; |
| 650 } | 670 } |
| 651 | 671 |
| 652 RenderThread::Get()->AddRoute(routing_id_, this); | 672 RenderThread::Get()->AddRoute(routing_id_, this); |
| 653 // Take a reference on behalf of the RenderThread. This will be balanced | 673 // Take a reference on behalf of the RenderThread. This will be balanced |
| 654 // when we receive ViewMsg_ClosePage. | 674 // when we receive ViewMsg_ClosePage. |
| 655 AddRef(); | 675 AddRef(); |
| 656 | 676 |
| 657 // If this is a popup, we must wait for the CreatingNew_ACK message before | 677 // If this is a popup, we must wait for the CreatingNew_ACK message before |
| 658 // completing initialization. Otherwise, we can finish it now. | 678 // completing initialization. Otherwise, we can finish it now. |
| 659 if (opener_id_ == MSG_ROUTING_NONE) { | 679 if (opener_id_ == MSG_ROUTING_NONE) { |
| 660 did_show_ = true; | 680 did_show_ = true; |
| 661 CompleteInit(); | 681 CompleteInit(); |
| 662 } | 682 } |
| 663 | 683 |
| 664 g_view_map.Get().insert(std::make_pair(webview(), this)); | 684 g_view_map.Get().insert(std::make_pair(webview(), this)); |
| 665 webview()->setDeviceScaleFactor(device_scale_factor_); | 685 webview()->setDeviceScaleFactor(device_scale_factor_); |
| 666 webkit_preferences_.Apply(webview()); | 686 webkit_preferences_.Apply(webview()); |
| 667 webview()->initializeMainFrame(this); | 687 webview()->initializeMainFrame(this); |
| 668 if (!frame_name.empty()) | 688 if (!params->frame_name.empty()) |
| 669 webview()->mainFrame()->setName(frame_name); | 689 webview()->mainFrame()->setName(params->frame_name); |
| 670 webview()->settings()->setMinimumTimerInterval( | 690 webview()->settings()->setMinimumTimerInterval( |
| 671 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : | 691 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : |
| 672 webkit_glue::kForegroundTabTimerInterval); | 692 webkit_glue::kForegroundTabTimerInterval); |
| 673 | 693 |
| 674 OnSetRendererPrefs(renderer_prefs); | 694 OnSetRendererPrefs(params->renderer_prefs); |
| 675 | 695 |
| 676 #if defined(ENABLE_WEBRTC) | 696 #if defined(ENABLE_WEBRTC) |
| 677 if (!media_stream_dispatcher_) | 697 if (!media_stream_dispatcher_) |
| 678 media_stream_dispatcher_ = new MediaStreamDispatcher(this); | 698 media_stream_dispatcher_ = new MediaStreamDispatcher(this); |
| 679 #endif | 699 #endif |
| 680 | 700 |
| 681 new MHTMLGenerator(this); | 701 new MHTMLGenerator(this); |
| 682 #if defined(OS_MACOSX) | 702 #if defined(OS_MACOSX) |
| 683 new TextInputClientObserver(this); | 703 new TextInputClientObserver(this); |
| 684 #endif // defined(OS_MACOSX) | 704 #endif // defined(OS_MACOSX) |
| 685 | 705 |
| 686 #if defined(OS_ANDROID) | 706 #if defined(OS_ANDROID) |
| 687 media_player_manager_.reset( | 707 media_player_manager_.reset( |
| 688 new webkit_media::WebMediaPlayerManagerAndroid()); | 708 new webkit_media::WebMediaPlayerManagerAndroid()); |
| 689 #endif | 709 #endif |
| 690 | 710 |
| 691 // The next group of objects all implement RenderViewObserver, so are deleted | 711 // The next group of objects all implement RenderViewObserver, so are deleted |
| 692 // along with the RenderView automatically. | 712 // along with the RenderView automatically. |
| 693 devtools_agent_ = new DevToolsAgent(this); | 713 devtools_agent_ = new DevToolsAgent(this); |
| 694 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); | 714 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); |
| 695 intents_host_ = new WebIntentsHost(this); | 715 intents_host_ = new WebIntentsHost(this); |
| 696 | 716 |
| 697 // Create renderer_accessibility_ if needed. | 717 // Create renderer_accessibility_ if needed. |
| 698 OnSetAccessibilityMode(accessibility_mode); | 718 OnSetAccessibilityMode(params->accessibility_mode); |
| 699 | 719 |
| 700 new IdleUserDetector(this); | 720 new IdleUserDetector(this); |
| 701 | 721 |
| 702 if (command_line.HasSwitch(switches::kDomAutomationController)) | 722 if (command_line.HasSwitch(switches::kDomAutomationController)) |
| 703 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; | 723 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
| 704 | 724 |
| 705 ProcessViewLayoutFlags(command_line); | 725 ProcessViewLayoutFlags(command_line); |
| 706 | 726 |
| 707 GetContentClient()->renderer()->RenderViewCreated(this); | 727 GetContentClient()->renderer()->RenderViewCreated(this); |
| 708 | 728 |
| 709 // If we have an opener_id but we weren't created by a renderer, then | 729 // If we have an opener_id but we weren't created by a renderer, then |
| 710 // it's the browser asking us to set our opener to another RenderView. | 730 // it's the browser asking us to set our opener to another RenderView. |
| 711 if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) { | 731 if (params->opener_id != MSG_ROUTING_NONE && !params->is_renderer_created) { |
| 712 RenderViewImpl* opener_view = FromRoutingID(opener_id); | 732 RenderViewImpl* opener_view = FromRoutingID(params->opener_id); |
| 713 if (opener_view) | 733 if (opener_view) |
| 714 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); | 734 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); |
| 715 } | 735 } |
| 716 | 736 |
| 717 // If we are initially swapped out, navigate to kSwappedOutURL. | 737 // If we are initially swapped out, navigate to kSwappedOutURL. |
| 718 // This ensures we are in a unique origin that others cannot script. | 738 // This ensures we are in a unique origin that others cannot script. |
| 719 if (is_swapped_out_) | 739 if (is_swapped_out_) |
| 720 NavigateToSwappedOutURL(webview()->mainFrame()); | 740 NavigateToSwappedOutURL(webview()->mainFrame()); |
| 721 } | 741 } |
| 722 | 742 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 int32 routing_id, | 806 int32 routing_id, |
| 787 int32 surface_id, | 807 int32 surface_id, |
| 788 int64 session_storage_namespace_id, | 808 int64 session_storage_namespace_id, |
| 789 const string16& frame_name, | 809 const string16& frame_name, |
| 790 bool is_renderer_created, | 810 bool is_renderer_created, |
| 791 bool swapped_out, | 811 bool swapped_out, |
| 792 int32 next_page_id, | 812 int32 next_page_id, |
| 793 const WebKit::WebScreenInfo& screen_info, | 813 const WebKit::WebScreenInfo& screen_info, |
| 794 AccessibilityMode accessibility_mode) { | 814 AccessibilityMode accessibility_mode) { |
| 795 DCHECK(routing_id != MSG_ROUTING_NONE); | 815 DCHECK(routing_id != MSG_ROUTING_NONE); |
| 796 return new RenderViewImpl( | 816 RenderViewImplParams params( |
| 797 opener_id, | 817 opener_id, |
| 798 renderer_prefs, | 818 renderer_prefs, |
| 799 webkit_prefs, | 819 webkit_prefs, |
| 800 counter, | 820 counter, |
| 801 routing_id, | 821 routing_id, |
| 802 surface_id, | 822 surface_id, |
| 803 session_storage_namespace_id, | 823 session_storage_namespace_id, |
| 804 frame_name, | 824 frame_name, |
| 805 is_renderer_created, | 825 is_renderer_created, |
| 806 swapped_out, | 826 swapped_out, |
| 807 next_page_id, | 827 next_page_id, |
| 808 screen_info, | 828 screen_info, |
| 809 accessibility_mode); | 829 accessibility_mode); |
| 830 RenderViewImpl* render_view = NULL; |
| 831 if (GetContentClient()->renderer()->OverrideCreateRenderViewImpl( |
| 832 ¶ms, &render_view)) { |
| 833 return render_view; |
| 834 } |
| 835 return new RenderViewImpl(¶ms); |
| 810 } | 836 } |
| 811 | 837 |
| 812 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { | 838 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
| 813 observers_.AddObserver(observer); | 839 observers_.AddObserver(observer); |
| 814 } | 840 } |
| 815 | 841 |
| 816 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { | 842 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
| 817 observer->RenderViewGone(); | 843 observer->RenderViewGone(); |
| 818 observers_.RemoveObserver(observer); | 844 observers_.RemoveObserver(observer); |
| 819 } | 845 } |
| (...skipping 5541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6361 } | 6387 } |
| 6362 #endif | 6388 #endif |
| 6363 | 6389 |
| 6364 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( | 6390 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( |
| 6365 TransportDIB::Handle dib_handle) { | 6391 TransportDIB::Handle dib_handle) { |
| 6366 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); | 6392 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); |
| 6367 RenderProcess::current()->ReleaseTransportDIB(dib); | 6393 RenderProcess::current()->ReleaseTransportDIB(dib); |
| 6368 } | 6394 } |
| 6369 | 6395 |
| 6370 } // namespace content | 6396 } // namespace content |
| OLD | NEW |