| 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 "chrome/renderer/render_view.h" | 5 #include "chrome/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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 #include "chrome/renderer/media/ipc_video_decoder.h" | 71 #include "chrome/renderer/media/ipc_video_decoder.h" |
| 72 #include "chrome/renderer/navigation_state.h" | 72 #include "chrome/renderer/navigation_state.h" |
| 73 #include "chrome/renderer/notification_provider.h" | 73 #include "chrome/renderer/notification_provider.h" |
| 74 #include "chrome/renderer/page_click_tracker.h" | 74 #include "chrome/renderer/page_click_tracker.h" |
| 75 #include "chrome/renderer/page_load_histograms.h" | 75 #include "chrome/renderer/page_load_histograms.h" |
| 76 #include "chrome/renderer/password_autocomplete_manager.h" | 76 #include "chrome/renderer/password_autocomplete_manager.h" |
| 77 #include "chrome/renderer/plugin_channel_host.h" | 77 #include "chrome/renderer/plugin_channel_host.h" |
| 78 #include "chrome/renderer/print_web_view_helper.h" | 78 #include "chrome/renderer/print_web_view_helper.h" |
| 79 #include "chrome/renderer/render_process.h" | 79 #include "chrome/renderer/render_process.h" |
| 80 #include "chrome/renderer/render_thread.h" | 80 #include "chrome/renderer/render_thread.h" |
| 81 #include "chrome/renderer/render_view_observer.h" |
| 81 #include "chrome/renderer/render_view_visitor.h" | 82 #include "chrome/renderer/render_view_visitor.h" |
| 82 #include "chrome/renderer/render_widget_fullscreen.h" | 83 #include "chrome/renderer/render_widget_fullscreen.h" |
| 83 #include "chrome/renderer/render_widget_fullscreen_pepper.h" | 84 #include "chrome/renderer/render_widget_fullscreen_pepper.h" |
| 84 #include "chrome/renderer/renderer_webapplicationcachehost_impl.h" | 85 #include "chrome/renderer/renderer_webapplicationcachehost_impl.h" |
| 85 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" | 86 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" |
| 86 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 87 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
| 87 #include "chrome/renderer/searchbox_extension.h" | 88 #include "chrome/renderer/searchbox_extension.h" |
| 88 #include "chrome/renderer/speech_input_dispatcher.h" | 89 #include "chrome/renderer/speech_input_dispatcher.h" |
| 89 #include "chrome/renderer/spellchecker/spellcheck.h" | 90 #include "chrome/renderer/spellchecker/spellcheck.h" |
| 90 #include "chrome/renderer/user_script_idle_scheduler.h" | 91 #include "chrome/renderer/user_script_idle_scheduler.h" |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 PendingFileChooser(const ViewHostMsg_RunFileChooser_Params& p, | 514 PendingFileChooser(const ViewHostMsg_RunFileChooser_Params& p, |
| 514 WebFileChooserCompletion* c) | 515 WebFileChooserCompletion* c) |
| 515 : params(p), | 516 : params(p), |
| 516 completion(c) { | 517 completion(c) { |
| 517 } | 518 } |
| 518 ViewHostMsg_RunFileChooser_Params params; | 519 ViewHostMsg_RunFileChooser_Params params; |
| 519 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. | 520 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. |
| 520 }; | 521 }; |
| 521 | 522 |
| 522 RenderView::RenderView(RenderThreadBase* render_thread, | 523 RenderView::RenderView(RenderThreadBase* render_thread, |
| 523 const WebPreferences& webkit_preferences, | 524 gfx::NativeViewId parent_hwnd, |
| 524 int64 session_storage_namespace_id) | 525 int32 opener_id, |
| 526 const RendererPreferences& renderer_prefs, |
| 527 const WebPreferences& webkit_prefs, |
| 528 SharedRenderViewCounter* counter, |
| 529 int32 routing_id, |
| 530 int64 session_storage_namespace_id, |
| 531 const string16& frame_name) |
| 525 : RenderWidget(render_thread, WebKit::WebPopupTypeNone), | 532 : RenderWidget(render_thread, WebKit::WebPopupTypeNone), |
| 526 webkit_preferences_(webkit_preferences), | 533 webkit_preferences_(webkit_prefs), |
| 527 send_content_state_immediately_(false), | 534 send_content_state_immediately_(false), |
| 528 enabled_bindings_(0), | 535 enabled_bindings_(0), |
| 529 send_preferred_size_changes_(false), | 536 send_preferred_size_changes_(false), |
| 530 script_can_close_(true), | 537 script_can_close_(true), |
| 531 is_loading_(false), | 538 is_loading_(false), |
| 532 navigation_gesture_(NavigationGestureUnknown), | 539 navigation_gesture_(NavigationGestureUnknown), |
| 533 opened_by_user_gesture_(true), | 540 opened_by_user_gesture_(true), |
| 534 opener_suppressed_(false), | 541 opener_suppressed_(false), |
| 535 page_id_(-1), | 542 page_id_(-1), |
| 536 last_page_id_sent_to_browser_(-1), | 543 last_page_id_sent_to_browser_(-1), |
| 537 last_indexed_page_id_(-1), | 544 last_indexed_page_id_(-1), |
| 538 history_list_offset_(-1), | 545 history_list_offset_(-1), |
| 539 history_list_length_(0), | 546 history_list_length_(0), |
| 540 has_unload_listener_(false), | 547 has_unload_listener_(false), |
| 541 #if defined(OS_MACOSX) | 548 #if defined(OS_MACOSX) |
| 542 has_document_tag_(false), | 549 has_document_tag_(false), |
| 543 #endif | 550 #endif |
| 544 document_tag_(0), | 551 document_tag_(0), |
| 545 target_url_status_(TARGET_NONE), | 552 target_url_status_(TARGET_NONE), |
| 546 spelling_panel_visible_(false), | 553 spelling_panel_visible_(false), |
| 547 view_type_(ViewType::INVALID), | 554 view_type_(ViewType::INVALID), |
| 548 browser_window_id_(-1), | 555 browser_window_id_(-1), |
| 549 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), | 556 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), |
| 550 ALLOW_THIS_IN_INITIALIZER_LIST(page_info_method_factory_(this)), | 557 ALLOW_THIS_IN_INITIALIZER_LIST(page_info_method_factory_(this)), |
| 551 ALLOW_THIS_IN_INITIALIZER_LIST(autofill_method_factory_(this)), | |
| 552 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), | 558 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), |
| 553 ALLOW_THIS_IN_INITIALIZER_LIST(translate_helper_(this)), | 559 ALLOW_THIS_IN_INITIALIZER_LIST(translate_helper_(this)), |
| 554 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 560 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
| 555 ALLOW_THIS_IN_INITIALIZER_LIST( | 561 devtools_client_(NULL), |
| 556 notification_provider_(new NotificationProvider(this))), | 562 geolocation_dispatcher_(NULL), |
| 563 speech_input_dispatcher_(NULL), |
| 564 device_orientation_dispatcher_(NULL), |
| 557 accessibility_ack_pending_(false), | 565 accessibility_ack_pending_(false), |
| 558 pending_app_icon_requests_(0), | 566 pending_app_icon_requests_(0), |
| 559 session_storage_namespace_id_(session_storage_namespace_id), | 567 session_storage_namespace_id_(session_storage_namespace_id), |
| 560 decrement_shared_popup_at_destruction_(false), | |
| 561 custom_menu_listener_(NULL) { | 568 custom_menu_listener_(NULL) { |
| 562 #if defined(OS_MACOSX) | 569 #if defined(OS_MACOSX) |
| 563 // On Mac, the select popups are rendered by the browser. | 570 // On Mac, the select popups are rendered by the browser. |
| 564 // Note that we don't do this in RenderMain otherwise this would not be called | 571 // Note that we don't do this in RenderMain otherwise this would not be called |
| 565 // in single-process mode. | 572 // in single-process mode. |
| 566 WebKit::WebView::setUseExternalPopupMenus(true); | 573 WebKit::WebView::setUseExternalPopupMenus(true); |
| 567 #endif | 574 #endif |
| 568 password_autocomplete_manager_.reset(new PasswordAutocompleteManager(this)); | 575 |
| 569 autofill_helper_.reset(new AutoFillHelper(this)); | |
| 570 page_click_tracker_.reset(new PageClickTracker(this)); | |
| 571 // Note that the order of insertion of the listeners is important. | |
| 572 // The password_autocomplete_manager_ takes the first shot at processing the | |
| 573 // notification and can stop the propagation. | |
| 574 page_click_tracker_->AddListener(password_autocomplete_manager_.get()); | |
| 575 page_click_tracker_->AddListener(autofill_helper_.get()); | |
| 576 ClearBlockedContentSettings(); | 576 ClearBlockedContentSettings(); |
| 577 if (CommandLine::ForCurrentProcess()->HasSwitch( | 577 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 578 switches::kEnableClientSidePhishingDetection)) { | 578 switches::kEnableClientSidePhishingDetection)) { |
| 579 phishing_delegate_.reset( | 579 phishing_delegate_.reset( |
| 580 new safe_browsing::PhishingClassifierDelegate(this, NULL)); | 580 new safe_browsing::PhishingClassifierDelegate(this, NULL)); |
| 581 RenderThread* thread = RenderThread::current(); | 581 RenderThread* thread = RenderThread::current(); |
| 582 if (thread && thread->phishing_scorer()) { | 582 if (thread && thread->phishing_scorer()) { |
| 583 phishing_delegate_->SetPhishingScorer(thread->phishing_scorer()); | 583 phishing_delegate_->SetPhishingScorer(thread->phishing_scorer()); |
| 584 } | 584 } |
| 585 } | 585 } |
| 586 |
| 587 routing_id_ = routing_id; |
| 588 if (opener_id != MSG_ROUTING_NONE) |
| 589 opener_id_ = opener_id; |
| 590 |
| 591 if (counter) { |
| 592 shared_popup_counter_ = counter; |
| 593 shared_popup_counter_->data++; |
| 594 decrement_shared_popup_at_destruction_ = true; |
| 595 } else { |
| 596 shared_popup_counter_ = new SharedRenderViewCounter(0); |
| 597 decrement_shared_popup_at_destruction_ = false; |
| 598 } |
| 599 |
| 600 notification_provider_ = new NotificationProvider(this); |
| 601 |
| 602 devtools_agent_ = new DevToolsAgent(this); |
| 603 PasswordAutocompleteManager* password_autocomplete_manager = |
| 604 new PasswordAutocompleteManager(this); |
| 605 AutoFillHelper* autofill_helper = new AutoFillHelper( |
| 606 this, password_autocomplete_manager); |
| 607 |
| 608 webwidget_ = WebView::create(this, devtools_agent_, autofill_helper); |
| 609 g_view_map.Get().insert(std::make_pair(webview(), this)); |
| 610 webkit_preferences_.Apply(webview()); |
| 611 webview()->initializeMainFrame(this); |
| 612 if (!frame_name.empty()) |
| 613 webview()->mainFrame()->setName(frame_name); |
| 614 |
| 615 OnSetRendererPrefs(renderer_prefs); |
| 616 |
| 617 render_thread_->AddRoute(routing_id_, this); |
| 618 // Take a reference on behalf of the RenderThread. This will be balanced |
| 619 // when we receive ViewMsg_Close. |
| 620 AddRef(); |
| 621 |
| 622 // If this is a popup, we must wait for the CreatingNew_ACK message before |
| 623 // completing initialization. Otherwise, we can finish it now. |
| 624 if (opener_id == MSG_ROUTING_NONE) { |
| 625 did_show_ = true; |
| 626 CompleteInit(parent_hwnd); |
| 627 } |
| 628 |
| 629 host_window_ = parent_hwnd; |
| 630 |
| 631 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 632 if (command_line.HasSwitch(switches::kDomAutomationController)) |
| 633 enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION; |
| 634 if (command_line.HasSwitch(switches::kEnableAccessibility)) |
| 635 WebAccessibilityCache::enableAccessibility(); |
| 636 |
| 637 audio_message_filter_ = new AudioMessageFilter(routing_id_); |
| 638 render_thread_->AddFilter(audio_message_filter_); |
| 639 |
| 640 PageClickTracker* page_click_tracker = new PageClickTracker(this); |
| 641 // Note that the order of insertion of the listeners is important. |
| 642 // The password_autocomplete_manager takes the first shot at processing the |
| 643 // notification and can stop the propagation. |
| 644 page_click_tracker->AddListener(password_autocomplete_manager); |
| 645 page_click_tracker->AddListener(autofill_helper); |
| 586 } | 646 } |
| 587 | 647 |
| 588 RenderView::~RenderView() { | 648 RenderView::~RenderView() { |
| 589 if (decrement_shared_popup_at_destruction_) | 649 if (decrement_shared_popup_at_destruction_) |
| 590 shared_popup_counter_->data--; | 650 shared_popup_counter_->data--; |
| 591 | 651 |
| 592 // If file chooser is still waiting for answer, dispatch empty answer. | 652 // If file chooser is still waiting for answer, dispatch empty answer. |
| 593 while (!file_chooser_completions_.empty()) { | 653 while (!file_chooser_completions_.empty()) { |
| 594 if (file_chooser_completions_.front()->completion) { | 654 if (file_chooser_completions_.front()->completion) { |
| 595 file_chooser_completions_.front()->completion->didChooseFile( | 655 file_chooser_completions_.front()->completion->didChooseFile( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 617 // Tell the PhishingClassifierDelegate that the view is going away. | 677 // Tell the PhishingClassifierDelegate that the view is going away. |
| 618 if (phishing_delegate_.get()) | 678 if (phishing_delegate_.get()) |
| 619 phishing_delegate_->CancelPendingClassification(); | 679 phishing_delegate_->CancelPendingClassification(); |
| 620 | 680 |
| 621 #ifndef NDEBUG | 681 #ifndef NDEBUG |
| 622 // Make sure we are no longer referenced by the ViewMap. | 682 // Make sure we are no longer referenced by the ViewMap. |
| 623 ViewMap* views = g_view_map.Pointer(); | 683 ViewMap* views = g_view_map.Pointer(); |
| 624 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) | 684 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
| 625 DCHECK_NE(this, it->second) << "Failed to call Close?"; | 685 DCHECK_NE(this, it->second) << "Failed to call Close?"; |
| 626 #endif | 686 #endif |
| 687 |
| 688 FOR_EACH_OBSERVER(RenderViewObserver, observers_, set_render_view(NULL)); |
| 689 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); |
| 627 } | 690 } |
| 628 | 691 |
| 629 /*static*/ | 692 /*static*/ |
| 630 void RenderView::ForEach(RenderViewVisitor* visitor) { | 693 void RenderView::ForEach(RenderViewVisitor* visitor) { |
| 631 ViewMap* views = g_view_map.Pointer(); | 694 ViewMap* views = g_view_map.Pointer(); |
| 632 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { | 695 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { |
| 633 if (!visitor->Visit(it->second)) | 696 if (!visitor->Visit(it->second)) |
| 634 return; | 697 return; |
| 635 } | 698 } |
| 636 } | 699 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 647 RenderThreadBase* render_thread, | 710 RenderThreadBase* render_thread, |
| 648 gfx::NativeViewId parent_hwnd, | 711 gfx::NativeViewId parent_hwnd, |
| 649 int32 opener_id, | 712 int32 opener_id, |
| 650 const RendererPreferences& renderer_prefs, | 713 const RendererPreferences& renderer_prefs, |
| 651 const WebPreferences& webkit_prefs, | 714 const WebPreferences& webkit_prefs, |
| 652 SharedRenderViewCounter* counter, | 715 SharedRenderViewCounter* counter, |
| 653 int32 routing_id, | 716 int32 routing_id, |
| 654 int64 session_storage_namespace_id, | 717 int64 session_storage_namespace_id, |
| 655 const string16& frame_name) { | 718 const string16& frame_name) { |
| 656 DCHECK(routing_id != MSG_ROUTING_NONE); | 719 DCHECK(routing_id != MSG_ROUTING_NONE); |
| 657 scoped_refptr<RenderView> view(new RenderView(render_thread, webkit_prefs, | 720 return new RenderView( |
| 658 session_storage_namespace_id)); | 721 render_thread, |
| 659 view->Init(parent_hwnd, | 722 parent_hwnd, |
| 660 opener_id, | 723 opener_id, |
| 661 renderer_prefs, | 724 renderer_prefs, |
| 662 counter, | 725 webkit_prefs, |
| 663 routing_id, | 726 counter, |
| 664 frame_name); // adds reference | 727 routing_id, |
| 665 return view; | 728 session_storage_namespace_id, |
| 729 frame_name); // adds reference |
| 666 } | 730 } |
| 667 | 731 |
| 668 // static | 732 // static |
| 669 void RenderView::SetNextPageID(int32 next_page_id) { | 733 void RenderView::SetNextPageID(int32 next_page_id) { |
| 670 // This method should only be called during process startup, and the given | 734 // This method should only be called during process startup, and the given |
| 671 // page id had better not exceed our current next page id! | 735 // page id had better not exceed our current next page id! |
| 672 DCHECK_EQ(next_page_id_, 1); | 736 DCHECK_EQ(next_page_id_, 1); |
| 673 DCHECK(next_page_id >= next_page_id_); | 737 DCHECK(next_page_id >= next_page_id_); |
| 674 next_page_id_ = next_page_id; | 738 next_page_id_ = next_page_id; |
| 675 } | 739 } |
| 676 | 740 |
| 741 void RenderView::AddObserver(RenderViewObserver* observer) { |
| 742 observers_.AddObserver(observer); |
| 743 } |
| 744 |
| 745 void RenderView::RemoveObserver(RenderViewObserver* observer) { |
| 746 observer->set_render_view(NULL); |
| 747 observers_.RemoveObserver(observer); |
| 748 } |
| 749 |
| 677 bool RenderView::RendererAccessibilityNotification::ShouldIncludeChildren() { | 750 bool RenderView::RendererAccessibilityNotification::ShouldIncludeChildren() { |
| 678 typedef ViewHostMsg_AccessibilityNotification_Params params; | 751 typedef ViewHostMsg_AccessibilityNotification_Params params; |
| 679 if (type == params::NOTIFICATION_TYPE_CHILDREN_CHANGED || | 752 if (type == params::NOTIFICATION_TYPE_CHILDREN_CHANGED || |
| 680 type == params::NOTIFICATION_TYPE_LOAD_COMPLETE) { | 753 type == params::NOTIFICATION_TYPE_LOAD_COMPLETE) { |
| 681 return true; | 754 return true; |
| 682 } | 755 } |
| 683 return false; | 756 return false; |
| 684 } | 757 } |
| 685 | 758 |
| 686 WebKit::WebView* RenderView::webview() const { | 759 WebKit::WebView* RenderView::webview() const { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 } | 960 } |
| 888 | 961 |
| 889 void RenderView::RegisterBlockedPlugin(BlockedPlugin* blocked_plugin) { | 962 void RenderView::RegisterBlockedPlugin(BlockedPlugin* blocked_plugin) { |
| 890 blocked_plugins_.insert(blocked_plugin); | 963 blocked_plugins_.insert(blocked_plugin); |
| 891 } | 964 } |
| 892 | 965 |
| 893 void RenderView::UnregisterBlockedPlugin(BlockedPlugin* blocked_plugin) { | 966 void RenderView::UnregisterBlockedPlugin(BlockedPlugin* blocked_plugin) { |
| 894 blocked_plugins_.erase(blocked_plugin); | 967 blocked_plugins_.erase(blocked_plugin); |
| 895 } | 968 } |
| 896 | 969 |
| 897 void RenderView::Init(gfx::NativeViewId parent_hwnd, | |
| 898 int32 opener_id, | |
| 899 const RendererPreferences& renderer_prefs, | |
| 900 SharedRenderViewCounter* counter, | |
| 901 int32 routing_id, | |
| 902 const string16& frame_name) { | |
| 903 DCHECK(!webview()); | |
| 904 | |
| 905 if (opener_id != MSG_ROUTING_NONE) | |
| 906 opener_id_ = opener_id; | |
| 907 | |
| 908 if (counter) { | |
| 909 shared_popup_counter_ = counter; | |
| 910 shared_popup_counter_->data++; | |
| 911 decrement_shared_popup_at_destruction_ = true; | |
| 912 } else { | |
| 913 shared_popup_counter_ = new SharedRenderViewCounter(0); | |
| 914 decrement_shared_popup_at_destruction_ = false; | |
| 915 } | |
| 916 | |
| 917 devtools_agent_.reset(new DevToolsAgent(routing_id, this)); | |
| 918 | |
| 919 // TODO(jam): remove this once WebKit is rolled | |
| 920 #if defined(WEBKIT_HAS_WEB_AUTO_FILL_CLIENT) | |
| 921 webwidget_ = WebView::create(this, devtools_agent_.get(), this); | |
| 922 #else | |
| 923 webwidget_ = WebView::create(this, devtools_agent_.get()); | |
| 924 #endif | |
| 925 g_view_map.Get().insert(std::make_pair(webview(), this)); | |
| 926 webkit_preferences_.Apply(webview()); | |
| 927 webview()->initializeMainFrame(this); | |
| 928 if (!frame_name.empty()) | |
| 929 webview()->mainFrame()->setName(frame_name); | |
| 930 | |
| 931 OnSetRendererPrefs(renderer_prefs); | |
| 932 | |
| 933 routing_id_ = routing_id; | |
| 934 render_thread_->AddRoute(routing_id_, this); | |
| 935 // Take a reference on behalf of the RenderThread. This will be balanced | |
| 936 // when we receive ViewMsg_Close. | |
| 937 AddRef(); | |
| 938 | |
| 939 // If this is a popup, we must wait for the CreatingNew_ACK message before | |
| 940 // completing initialization. Otherwise, we can finish it now. | |
| 941 if (opener_id == MSG_ROUTING_NONE) { | |
| 942 did_show_ = true; | |
| 943 CompleteInit(parent_hwnd); | |
| 944 } | |
| 945 | |
| 946 host_window_ = parent_hwnd; | |
| 947 | |
| 948 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 949 if (command_line.HasSwitch(switches::kDomAutomationController)) | |
| 950 enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION; | |
| 951 if (command_line.HasSwitch(switches::kEnableAccessibility)) | |
| 952 WebAccessibilityCache::enableAccessibility(); | |
| 953 | |
| 954 audio_message_filter_ = new AudioMessageFilter(routing_id_); | |
| 955 render_thread_->AddFilter(audio_message_filter_); | |
| 956 } | |
| 957 | |
| 958 bool RenderView::OnMessageReceived(const IPC::Message& message) { | 970 bool RenderView::OnMessageReceived(const IPC::Message& message) { |
| 959 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; | 971 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
| 960 if (main_frame) | 972 if (main_frame) |
| 961 child_process_logging::SetActiveURL(main_frame->url()); | 973 child_process_logging::SetActiveURL(main_frame->url()); |
| 962 | 974 |
| 963 // If this is developer tools renderer intercept tools messages first. | 975 ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
| 964 if (devtools_client_.get() && devtools_client_->OnMessageReceived(message)) | 976 RenderViewObserver* observer; |
| 965 return true; | 977 while ((observer = it.GetNext()) != NULL) |
| 966 if (devtools_agent_.get() && devtools_agent_->OnMessageReceived(message)) | 978 if (observer->OnMessageReceived(message)) |
| 967 return true; | 979 return true; |
| 968 if (notification_provider_->OnMessageReceived(message)) | |
| 969 return true; | |
| 970 if (geolocation_dispatcher_.get() && | |
| 971 geolocation_dispatcher_->OnMessageReceived(message)) { | |
| 972 return true; | |
| 973 } | |
| 974 if (speech_input_dispatcher_.get() && | |
| 975 speech_input_dispatcher_->OnMessageReceived(message)) { | |
| 976 return true; | |
| 977 } | |
| 978 if (device_orientation_dispatcher_.get() && | |
| 979 device_orientation_dispatcher_->OnMessageReceived(message)) { | |
| 980 return true; | |
| 981 } | |
| 982 | 980 |
| 983 bool handled = true; | 981 bool handled = true; |
| 984 IPC_BEGIN_MESSAGE_MAP(RenderView, message) | 982 IPC_BEGIN_MESSAGE_MAP(RenderView, message) |
| 985 IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, OnCaptureThumbnail) | 983 IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, OnCaptureThumbnail) |
| 986 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot) | 984 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot) |
| 987 IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages) | 985 IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages) |
| 988 IPC_MESSAGE_HANDLER(ViewMsg_PrintingDone, OnPrintingDone) | 986 IPC_MESSAGE_HANDLER(ViewMsg_PrintingDone, OnPrintingDone) |
| 989 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) | 987 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) |
| 990 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) | 988 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
| 991 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) | 989 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1017 OnSetZoomLevelForLoadingURL) | 1015 OnSetZoomLevelForLoadingURL) |
| 1018 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) | 1016 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
| 1019 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, | 1017 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
| 1020 OnResetPageEncodingToDefault) | 1018 OnResetPageEncodingToDefault) |
| 1021 IPC_MESSAGE_HANDLER(ViewMsg_SetupDevToolsClient, OnSetupDevToolsClient) | 1019 IPC_MESSAGE_HANDLER(ViewMsg_SetupDevToolsClient, OnSetupDevToolsClient) |
| 1022 IPC_MESSAGE_HANDLER(ViewMsg_DownloadFavIcon, OnDownloadFavIcon) | 1020 IPC_MESSAGE_HANDLER(ViewMsg_DownloadFavIcon, OnDownloadFavIcon) |
| 1023 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) | 1021 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) |
| 1024 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) | 1022 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) |
| 1025 IPC_MESSAGE_HANDLER(ViewMsg_AddMessageToConsole, OnAddMessageToConsole) | 1023 IPC_MESSAGE_HANDLER(ViewMsg_AddMessageToConsole, OnAddMessageToConsole) |
| 1026 IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange) | 1024 IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange) |
| 1027 IPC_MESSAGE_HANDLER(ViewMsg_FillPasswordForm, OnFillPasswordForm) | |
| 1028 IPC_MESSAGE_HANDLER(ViewMsg_DragTargetDragEnter, OnDragTargetDragEnter) | 1025 IPC_MESSAGE_HANDLER(ViewMsg_DragTargetDragEnter, OnDragTargetDragEnter) |
| 1029 IPC_MESSAGE_HANDLER(ViewMsg_DragTargetDragOver, OnDragTargetDragOver) | 1026 IPC_MESSAGE_HANDLER(ViewMsg_DragTargetDragOver, OnDragTargetDragOver) |
| 1030 IPC_MESSAGE_HANDLER(ViewMsg_DragTargetDragLeave, OnDragTargetDragLeave) | 1027 IPC_MESSAGE_HANDLER(ViewMsg_DragTargetDragLeave, OnDragTargetDragLeave) |
| 1031 IPC_MESSAGE_HANDLER(ViewMsg_DragTargetDrop, OnDragTargetDrop) | 1028 IPC_MESSAGE_HANDLER(ViewMsg_DragTargetDrop, OnDragTargetDrop) |
| 1032 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) | 1029 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
| 1033 IPC_MESSAGE_HANDLER(ViewMsg_SetDOMUIProperty, OnSetDOMUIProperty) | 1030 IPC_MESSAGE_HANDLER(ViewMsg_SetDOMUIProperty, OnSetDOMUIProperty) |
| 1034 IPC_MESSAGE_HANDLER(ViewMsg_DragSourceEndedOrMoved, | 1031 IPC_MESSAGE_HANDLER(ViewMsg_DragSourceEndedOrMoved, |
| 1035 OnDragSourceEndedOrMoved) | 1032 OnDragSourceEndedOrMoved) |
| 1036 IPC_MESSAGE_HANDLER(ViewMsg_DragSourceSystemDragEnded, | 1033 IPC_MESSAGE_HANDLER(ViewMsg_DragSourceSystemDragEnded, |
| 1037 OnDragSourceSystemDragEnded) | 1034 OnDragSourceSystemDragEnded) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1051 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 1048 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
| 1052 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 1049 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
| 1053 IPC_MESSAGE_HANDLER(ViewMsg_GetApplicationInfo, OnGetApplicationInfo) | 1050 IPC_MESSAGE_HANDLER(ViewMsg_GetApplicationInfo, OnGetApplicationInfo) |
| 1054 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) | 1051 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) |
| 1055 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) | 1052 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
| 1056 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) | 1053 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) |
| 1057 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, | 1054 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, |
| 1058 OnHandleMessageFromExternalHost) | 1055 OnHandleMessageFromExternalHost) |
| 1059 IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, | 1056 IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, |
| 1060 OnDisassociateFromPopupCount) | 1057 OnDisassociateFromPopupCount) |
| 1061 IPC_MESSAGE_HANDLER(ViewMsg_AutoFillSuggestionsReturned, | |
| 1062 OnAutoFillSuggestionsReturned) | |
| 1063 IPC_MESSAGE_HANDLER(ViewMsg_AutoFillFormDataFilled, | |
| 1064 OnAutoFillFormDataFilled) | |
| 1065 IPC_MESSAGE_HANDLER(ViewMsg_AllowScriptToClose, | 1058 IPC_MESSAGE_HANDLER(ViewMsg_AllowScriptToClose, |
| 1066 OnAllowScriptToClose) | 1059 OnAllowScriptToClose) |
| 1067 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) | 1060 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
| 1068 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionResponse, OnExtensionResponse) | 1061 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionResponse, OnExtensionResponse) |
| 1069 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionMessageInvoke, | 1062 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionMessageInvoke, |
| 1070 OnExtensionMessageInvoke) | 1063 OnExtensionMessageInvoke) |
| 1071 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedNode, OnClearFocusedNode) | 1064 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedNode, OnClearFocusedNode) |
| 1072 IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground) | 1065 IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground) |
| 1073 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, | 1066 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
| 1074 OnEnablePreferredSizeChangedMode) | 1067 OnEnablePreferredSizeChangedMode) |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 return true; | 1369 return true; |
| 1377 } | 1370 } |
| 1378 | 1371 |
| 1379 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { | 1372 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { |
| 1380 if (!webview()) | 1373 if (!webview()) |
| 1381 return; | 1374 return; |
| 1382 | 1375 |
| 1383 history_list_offset_ = params.current_history_list_offset; | 1376 history_list_offset_ = params.current_history_list_offset; |
| 1384 history_list_length_ = params.current_history_list_length; | 1377 history_list_length_ = params.current_history_list_length; |
| 1385 | 1378 |
| 1386 if (devtools_agent_.get()) | |
| 1387 devtools_agent_->OnNavigate(); | |
| 1388 | |
| 1389 if (notification_provider_.get()) | |
| 1390 notification_provider_->OnNavigate(); | |
| 1391 | |
| 1392 child_process_logging::SetActiveURL(params.url); | 1379 child_process_logging::SetActiveURL(params.url); |
| 1393 | 1380 |
| 1394 AboutHandler::MaybeHandle(params.url); | 1381 AboutHandler::MaybeHandle(params.url); |
| 1395 | 1382 |
| 1396 bool is_reload = | 1383 bool is_reload = |
| 1397 params.navigation_type == ViewMsg_Navigate_Params::RELOAD || | 1384 params.navigation_type == ViewMsg_Navigate_Params::RELOAD || |
| 1398 params.navigation_type == ViewMsg_Navigate_Params::RELOAD_IGNORING_CACHE; | 1385 params.navigation_type == ViewMsg_Navigate_Params::RELOAD_IGNORING_CACHE; |
| 1399 | 1386 |
| 1400 WebFrame* main_frame = webview()->mainFrame(); | 1387 WebFrame* main_frame = webview()->mainFrame(); |
| 1401 if (is_reload && main_frame->currentHistoryItem().isNull()) { | 1388 if (is_reload && main_frame->currentHistoryItem().isNull()) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 void RenderView::OnExecuteEditCommand(const std::string& name, | 1489 void RenderView::OnExecuteEditCommand(const std::string& name, |
| 1503 const std::string& value) { | 1490 const std::string& value) { |
| 1504 if (!webview() || !webview()->focusedFrame()) | 1491 if (!webview() || !webview()->focusedFrame()) |
| 1505 return; | 1492 return; |
| 1506 | 1493 |
| 1507 webview()->focusedFrame()->executeCommand( | 1494 webview()->focusedFrame()->executeCommand( |
| 1508 WebString::fromUTF8(name), WebString::fromUTF8(value)); | 1495 WebString::fromUTF8(name), WebString::fromUTF8(value)); |
| 1509 } | 1496 } |
| 1510 | 1497 |
| 1511 void RenderView::OnSetupDevToolsClient() { | 1498 void RenderView::OnSetupDevToolsClient() { |
| 1512 DCHECK(!devtools_client_.get()); | 1499 DCHECK(!devtools_client_); |
| 1513 devtools_client_.reset(new DevToolsClient(this)); | 1500 devtools_client_ = new DevToolsClient(this); |
| 1514 } | 1501 } |
| 1515 | 1502 |
| 1516 void RenderView::OnUpdateTargetURLAck() { | 1503 void RenderView::OnUpdateTargetURLAck() { |
| 1517 // Check if there is a targeturl waiting to be sent. | 1504 // Check if there is a targeturl waiting to be sent. |
| 1518 if (target_url_status_ == TARGET_PENDING) { | 1505 if (target_url_status_ == TARGET_PENDING) { |
| 1519 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, | 1506 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, |
| 1520 pending_target_url_)); | 1507 pending_target_url_)); |
| 1521 } | 1508 } |
| 1522 | 1509 |
| 1523 target_url_status_ = TARGET_NONE; | 1510 target_url_status_ = TARGET_NONE; |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1980 } | 1967 } |
| 1981 | 1968 |
| 1982 void RenderView::AddGURLSearchProvider( | 1969 void RenderView::AddGURLSearchProvider( |
| 1983 const GURL& osd_url, | 1970 const GURL& osd_url, |
| 1984 const ViewHostMsg_PageHasOSDD_Type& provider_type) { | 1971 const ViewHostMsg_PageHasOSDD_Type& provider_type) { |
| 1985 if (!osd_url.is_empty()) | 1972 if (!osd_url.is_empty()) |
| 1986 Send(new ViewHostMsg_PageHasOSDD(routing_id_, page_id_, osd_url, | 1973 Send(new ViewHostMsg_PageHasOSDD(routing_id_, page_id_, osd_url, |
| 1987 provider_type)); | 1974 provider_type)); |
| 1988 } | 1975 } |
| 1989 | 1976 |
| 1990 void RenderView::OnAutoFillSuggestionsReturned( | |
| 1991 int query_id, | |
| 1992 const std::vector<string16>& values, | |
| 1993 const std::vector<string16>& labels, | |
| 1994 const std::vector<string16>& icons, | |
| 1995 const std::vector<int>& unique_ids) { | |
| 1996 autofill_helper_->SuggestionsReceived( | |
| 1997 query_id, values, labels, icons, unique_ids); | |
| 1998 } | |
| 1999 | |
| 2000 void RenderView::OnAutoFillFormDataFilled(int query_id, | |
| 2001 const webkit_glue::FormData& form) { | |
| 2002 autofill_helper_->FormDataFilled(query_id, form); | |
| 2003 } | |
| 2004 | |
| 2005 void RenderView::OnAllowScriptToClose(bool script_can_close) { | 1977 void RenderView::OnAllowScriptToClose(bool script_can_close) { |
| 2006 script_can_close_ = script_can_close; | 1978 script_can_close_ = script_can_close; |
| 2007 } | 1979 } |
| 2008 | 1980 |
| 2009 uint32 RenderView::GetCPBrowsingContext() { | 1981 uint32 RenderView::GetCPBrowsingContext() { |
| 2010 uint32 context = 0; | 1982 uint32 context = 0; |
| 2011 Send(new ViewHostMsg_GetCPBrowsingContext(&context)); | 1983 Send(new ViewHostMsg_GetCPBrowsingContext(&context)); |
| 2012 return context; | 1984 return context; |
| 2013 } | 1985 } |
| 2014 | 1986 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2184 DCHECK(frame); | 2156 DCHECK(frame); |
| 2185 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2157 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2186 switches::kEnablePrintPreview)) { | 2158 switches::kEnablePrintPreview)) { |
| 2187 Print(frame, true, true); | 2159 Print(frame, true, true); |
| 2188 } else { | 2160 } else { |
| 2189 Print(frame, true, false); | 2161 Print(frame, true, false); |
| 2190 } | 2162 } |
| 2191 } | 2163 } |
| 2192 | 2164 |
| 2193 WebKit::WebNotificationPresenter* RenderView::notificationPresenter() { | 2165 WebKit::WebNotificationPresenter* RenderView::notificationPresenter() { |
| 2194 return notification_provider_.get(); | 2166 return notification_provider_; |
| 2195 } | 2167 } |
| 2196 | 2168 |
| 2197 void RenderView::didStartLoading() { | 2169 void RenderView::didStartLoading() { |
| 2198 if (is_loading_) { | 2170 if (is_loading_) { |
| 2199 DLOG(WARNING) << "didStartLoading called while loading"; | 2171 DLOG(WARNING) << "didStartLoading called while loading"; |
| 2200 return; | 2172 return; |
| 2201 } | 2173 } |
| 2202 | 2174 |
| 2203 is_loading_ = true; | 2175 is_loading_ = true; |
| 2204 // Clear the pointer so that we can assign it only when there is an unknown | 2176 // Clear the pointer so that we can assign it only when there is an unknown |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2289 | 2261 |
| 2290 void RenderView::didExecuteCommand(const WebString& command_name) { | 2262 void RenderView::didExecuteCommand(const WebString& command_name) { |
| 2291 const std::string& name = UTF16ToUTF8(command_name); | 2263 const std::string& name = UTF16ToUTF8(command_name); |
| 2292 if (StartsWithASCII(name, "Move", true) || | 2264 if (StartsWithASCII(name, "Move", true) || |
| 2293 StartsWithASCII(name, "Insert", true) || | 2265 StartsWithASCII(name, "Insert", true) || |
| 2294 StartsWithASCII(name, "Delete", true)) | 2266 StartsWithASCII(name, "Delete", true)) |
| 2295 return; | 2267 return; |
| 2296 UserMetricsRecordAction(name); | 2268 UserMetricsRecordAction(name); |
| 2297 } | 2269 } |
| 2298 | 2270 |
| 2299 void RenderView::textFieldDidEndEditing( | |
| 2300 const WebKit::WebInputElement& element) { | |
| 2301 password_autocomplete_manager_->TextFieldDidEndEditing(element); | |
| 2302 } | |
| 2303 | |
| 2304 void RenderView::textFieldDidChange(const WebKit::WebInputElement& element) { | |
| 2305 // We post a task for doing the AutoFill as the caret position is not set | |
| 2306 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and | |
| 2307 // it is needed to trigger autofill. | |
| 2308 autofill_method_factory_.RevokeAll(); | |
| 2309 MessageLoop::current()->PostTask( | |
| 2310 FROM_HERE, | |
| 2311 autofill_method_factory_.NewRunnableMethod( | |
| 2312 &RenderView::TextFieldDidChangeImpl, element)); | |
| 2313 } | |
| 2314 | |
| 2315 void RenderView::TextFieldDidChangeImpl( | |
| 2316 const WebKit::WebInputElement& element) { | |
| 2317 if (password_autocomplete_manager_->TextDidChangeInTextField(element)) | |
| 2318 return; | |
| 2319 autofill_helper_->TextDidChangeInTextField(element); | |
| 2320 } | |
| 2321 | |
| 2322 void RenderView::SendPendingAccessibilityNotifications() { | 2271 void RenderView::SendPendingAccessibilityNotifications() { |
| 2323 if (!accessibility_.get()) | 2272 if (!accessibility_.get()) |
| 2324 return; | 2273 return; |
| 2325 | 2274 |
| 2326 if (pending_accessibility_notifications_.empty()) | 2275 if (pending_accessibility_notifications_.empty()) |
| 2327 return; | 2276 return; |
| 2328 | 2277 |
| 2329 // Send all pending accessibility notifications. | 2278 // Send all pending accessibility notifications. |
| 2330 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; | 2279 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; |
| 2331 for (size_t i = 0; i < pending_accessibility_notifications_.size(); i++) { | 2280 for (size_t i = 0; i < pending_accessibility_notifications_.size(); i++) { |
| 2332 RendererAccessibilityNotification& notification = | 2281 RendererAccessibilityNotification& notification = |
| 2333 pending_accessibility_notifications_[i]; | 2282 pending_accessibility_notifications_[i]; |
| 2334 WebAccessibilityObject obj = accessibility_->getObjectById(notification.id); | 2283 WebAccessibilityObject obj = accessibility_->getObjectById(notification.id); |
| 2335 if (!obj.isValid()) | 2284 if (!obj.isValid()) |
| 2336 continue; | 2285 continue; |
| 2337 | 2286 |
| 2338 ViewHostMsg_AccessibilityNotification_Params param; | 2287 ViewHostMsg_AccessibilityNotification_Params param; |
| 2339 param.notification_type = pending_accessibility_notifications_[i].type; | 2288 param.notification_type = pending_accessibility_notifications_[i].type; |
| 2340 param.acc_obj = WebAccessibility( | 2289 param.acc_obj = WebAccessibility( |
| 2341 obj, accessibility_.get(), notification.ShouldIncludeChildren()); | 2290 obj, accessibility_.get(), notification.ShouldIncludeChildren()); |
| 2342 notifications.push_back(param); | 2291 notifications.push_back(param); |
| 2343 } | 2292 } |
| 2344 pending_accessibility_notifications_.clear(); | 2293 pending_accessibility_notifications_.clear(); |
| 2345 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications)); | 2294 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications)); |
| 2346 accessibility_ack_pending_ = true; | 2295 accessibility_ack_pending_ = true; |
| 2347 } | 2296 } |
| 2348 | 2297 |
| 2349 void RenderView::textFieldDidReceiveKeyDown( | |
| 2350 const WebKit::WebInputElement& element, | |
| 2351 const WebKit::WebKeyboardEvent& event) { | |
| 2352 password_autocomplete_manager_->TextFieldHandlingKeyDown(element, event); | |
| 2353 autofill_helper_->KeyDownInTextField(element, event); | |
| 2354 } | |
| 2355 | |
| 2356 bool RenderView::handleCurrentKeyboardEvent() { | 2298 bool RenderView::handleCurrentKeyboardEvent() { |
| 2357 if (edit_commands_.empty()) | 2299 if (edit_commands_.empty()) |
| 2358 return false; | 2300 return false; |
| 2359 | 2301 |
| 2360 WebFrame* frame = webview()->focusedFrame(); | 2302 WebFrame* frame = webview()->focusedFrame(); |
| 2361 if (!frame) | 2303 if (!frame) |
| 2362 return false; | 2304 return false; |
| 2363 | 2305 |
| 2364 EditCommands::iterator it = edit_commands_.begin(); | 2306 EditCommands::iterator it = edit_commands_.begin(); |
| 2365 EditCommands::iterator end = edit_commands_.end(); | 2307 EditCommands::iterator end = edit_commands_.end(); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2638 return history_list_length_ - historyBackListCount() - 1; | 2580 return history_list_length_ - historyBackListCount() - 1; |
| 2639 } | 2581 } |
| 2640 | 2582 |
| 2641 void RenderView::didUpdateInspectorSetting(const WebString& key, | 2583 void RenderView::didUpdateInspectorSetting(const WebString& key, |
| 2642 const WebString& value) { | 2584 const WebString& value) { |
| 2643 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, | 2585 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, |
| 2644 key.utf8(), | 2586 key.utf8(), |
| 2645 value.utf8())); | 2587 value.utf8())); |
| 2646 } | 2588 } |
| 2647 | 2589 |
| 2648 void RenderView::didAcceptAutoFillSuggestion(const WebKit::WebNode& node, | |
| 2649 const WebKit::WebString& value, | |
| 2650 const WebKit::WebString& label, | |
| 2651 int unique_id, | |
| 2652 unsigned index) { | |
| 2653 autofill_helper_->DidAcceptAutoFillSuggestion(node, value, unique_id, index); | |
| 2654 } | |
| 2655 | |
| 2656 void RenderView::didSelectAutoFillSuggestion(const WebKit::WebNode& node, | |
| 2657 const WebKit::WebString& value, | |
| 2658 const WebKit::WebString& label, | |
| 2659 int unique_id) { | |
| 2660 autofill_helper_->DidSelectAutoFillSuggestion(node, unique_id); | |
| 2661 } | |
| 2662 | |
| 2663 void RenderView::didClearAutoFillSelection(const WebKit::WebNode& node) { | |
| 2664 autofill_helper_->DidClearAutoFillSelection(node); | |
| 2665 } | |
| 2666 | |
| 2667 void RenderView::didAcceptAutocompleteSuggestion( | |
| 2668 const WebKit::WebInputElement& user_element) { | |
| 2669 bool result = password_autocomplete_manager_->FillPassword(user_element); | |
| 2670 // Since this user name was selected from a suggestion list, we should always | |
| 2671 // have password for it. | |
| 2672 DCHECK(result); | |
| 2673 } | |
| 2674 | |
| 2675 void RenderView::removeAutocompleteSuggestion(const WebKit::WebString& name, | |
| 2676 const WebKit::WebString& value) { | |
| 2677 autofill_helper_->RemoveAutocompleteSuggestion(name, value); | |
| 2678 } | |
| 2679 | |
| 2680 void RenderView::removeAutofillSuggestions(const WebString& name, | |
| 2681 const WebString& value) { | |
| 2682 removeAutocompleteSuggestion(name, value); | |
| 2683 } | |
| 2684 | |
| 2685 // WebKit::WebWidgetClient ---------------------------------------------------- | 2590 // WebKit::WebWidgetClient ---------------------------------------------------- |
| 2686 | 2591 |
| 2687 void RenderView::didFocus() { | 2592 void RenderView::didFocus() { |
| 2688 // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed | 2593 // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed |
| 2689 // we won't have to test for user gesture anymore and we can | 2594 // we won't have to test for user gesture anymore and we can |
| 2690 // move that code back to render_widget.cc | 2595 // move that code back to render_widget.cc |
| 2691 if (webview() && webview()->mainFrame() && | 2596 if (webview() && webview()->mainFrame() && |
| 2692 webview()->mainFrame()->isProcessingUserGesture()) { | 2597 webview()->mainFrame()->isProcessingUserGesture()) { |
| 2693 Send(new ViewHostMsg_Focus(routing_id_)); | 2598 Send(new ViewHostMsg_Focus(routing_id_)); |
| 2694 } | 2599 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2930 return new RendererWebApplicationCacheHostImpl( | 2835 return new RendererWebApplicationCacheHostImpl( |
| 2931 FromWebView(frame->view()), client, | 2836 FromWebView(frame->view()), client, |
| 2932 RenderThread::current()->appcache_dispatcher()->backend_proxy()); | 2837 RenderThread::current()->appcache_dispatcher()->backend_proxy()); |
| 2933 } | 2838 } |
| 2934 | 2839 |
| 2935 WebCookieJar* RenderView::cookieJar(WebFrame* frame) { | 2840 WebCookieJar* RenderView::cookieJar(WebFrame* frame) { |
| 2936 return &cookie_jar_; | 2841 return &cookie_jar_; |
| 2937 } | 2842 } |
| 2938 | 2843 |
| 2939 void RenderView::frameDetached(WebFrame* frame) { | 2844 void RenderView::frameDetached(WebFrame* frame) { |
| 2940 autofill_helper_->FrameDetached(frame); | 2845 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameDetached(frame)); |
| 2941 page_click_tracker_->StopTrackingFrame(frame, true); | |
| 2942 } | 2846 } |
| 2943 | 2847 |
| 2944 void RenderView::willClose(WebFrame* frame) { | 2848 void RenderView::willClose(WebFrame* frame) { |
| 2945 WebDataSource* ds = frame->dataSource(); | 2849 WebDataSource* ds = frame->dataSource(); |
| 2946 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 2850 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 2947 | 2851 |
| 2948 page_load_histograms_.Dump(frame); | 2852 page_load_histograms_.Dump(frame); |
| 2949 navigation_state->user_script_idle_scheduler()->Cancel(); | 2853 navigation_state->user_script_idle_scheduler()->Cancel(); |
| 2950 | 2854 |
| 2951 // TODO(jhawkins): Remove once frameDetached is called by WebKit. | 2855 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameWillClose(frame)); |
| 2952 // NOTE: taking this out results in lots of increased memory usage! This is | |
| 2953 // because frameDetached is NOT like wilLClose. The latter happens between | |
| 2954 // navigations, but the former only happens when the RenderView is going away. | |
| 2955 autofill_helper_->FrameWillClose(frame); | |
| 2956 } | 2856 } |
| 2957 | 2857 |
| 2958 bool RenderView::allowImages(WebFrame* frame, bool enabled_per_settings) { | 2858 bool RenderView::allowImages(WebFrame* frame, bool enabled_per_settings) { |
| 2959 if (enabled_per_settings && | 2859 if (enabled_per_settings && |
| 2960 AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES)) | 2860 AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES)) |
| 2961 return true; | 2861 return true; |
| 2962 | 2862 |
| 2963 if (IsWhitelistedForContentSettings(frame)) | 2863 if (IsWhitelistedForContentSettings(frame)) |
| 2964 return true; | 2864 return true; |
| 2965 | 2865 |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3539 } | 3439 } |
| 3540 | 3440 |
| 3541 void RenderView::didFinishDocumentLoad(WebFrame* frame) { | 3441 void RenderView::didFinishDocumentLoad(WebFrame* frame) { |
| 3542 WebDataSource* ds = frame->dataSource(); | 3442 WebDataSource* ds = frame->dataSource(); |
| 3543 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 3443 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 3544 DCHECK(navigation_state); | 3444 DCHECK(navigation_state); |
| 3545 navigation_state->set_finish_document_load_time(Time::Now()); | 3445 navigation_state->set_finish_document_load_time(Time::Now()); |
| 3546 | 3446 |
| 3547 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier())); | 3447 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier())); |
| 3548 | 3448 |
| 3549 page_click_tracker_->StartTrackingFrame(frame); | 3449 FOR_EACH_OBSERVER( |
| 3550 // The document has now been fully loaded. Scan for forms to be sent up to | 3450 RenderViewObserver, observers_, DidFinishDocumentLoad(frame)); |
| 3551 // the browser. | |
| 3552 autofill_helper_->FrameContentsAvailable(frame); | |
| 3553 password_autocomplete_manager_->SendPasswordForms(frame, false); | |
| 3554 | 3451 |
| 3555 // Check whether we have new encoding name. | 3452 // Check whether we have new encoding name. |
| 3556 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 3453 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
| 3557 | 3454 |
| 3558 if (RenderThread::current()) { // Will be NULL during unit tests. | 3455 if (RenderThread::current()) { // Will be NULL during unit tests. |
| 3559 RenderThread::current()->user_script_slave()->InjectScripts( | 3456 RenderThread::current()->user_script_slave()->InjectScripts( |
| 3560 frame, UserScript::DOCUMENT_END); | 3457 frame, UserScript::DOCUMENT_END); |
| 3561 } | 3458 } |
| 3562 | 3459 |
| 3563 // InjectScripts() can end up creating a new NavigationState if it triggers a | 3460 // InjectScripts() can end up creating a new NavigationState if it triggers a |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3594 // Ignore | 3491 // Ignore |
| 3595 } | 3492 } |
| 3596 | 3493 |
| 3597 void RenderView::didFinishLoad(WebFrame* frame) { | 3494 void RenderView::didFinishLoad(WebFrame* frame) { |
| 3598 WebDataSource* ds = frame->dataSource(); | 3495 WebDataSource* ds = frame->dataSource(); |
| 3599 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 3496 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 3600 DCHECK(navigation_state); | 3497 DCHECK(navigation_state); |
| 3601 navigation_state->set_finish_load_time(Time::Now()); | 3498 navigation_state->set_finish_load_time(Time::Now()); |
| 3602 navigation_state->user_script_idle_scheduler()->DidFinishLoad(); | 3499 navigation_state->user_script_idle_scheduler()->DidFinishLoad(); |
| 3603 | 3500 |
| 3604 // Let the password manager know which password forms are actually visible. | 3501 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame)); |
| 3605 password_autocomplete_manager_->SendPasswordForms(frame, true); | |
| 3606 | 3502 |
| 3607 Send(new ViewHostMsg_DidFinishLoad(routing_id_, frame->identifier())); | 3503 Send(new ViewHostMsg_DidFinishLoad(routing_id_, frame->identifier())); |
| 3608 } | 3504 } |
| 3609 | 3505 |
| 3610 void RenderView::didNavigateWithinPage( | 3506 void RenderView::didNavigateWithinPage( |
| 3611 WebFrame* frame, bool is_new_navigation) { | 3507 WebFrame* frame, bool is_new_navigation) { |
| 3612 // Determine if the UserScriptIdleScheduler already ran scripts on this page, | 3508 // Determine if the UserScriptIdleScheduler already ran scripts on this page, |
| 3613 // since a new one gets created by didCreateDataSource. | 3509 // since a new one gets created by didCreateDataSource. |
| 3614 NavigationState* state = NavigationState::FromDataSource(frame->dataSource()); | 3510 NavigationState* state = NavigationState::FromDataSource(frame->dataSource()); |
| 3615 bool idle_scheduler_ran = state->user_script_idle_scheduler()->has_run(); | 3511 bool idle_scheduler_ran = state->user_script_idle_scheduler()->has_run(); |
| (...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4709 webview()->dragSourceEndedAt(client_point, screen_point, op); | 4605 webview()->dragSourceEndedAt(client_point, screen_point, op); |
| 4710 } else { | 4606 } else { |
| 4711 webview()->dragSourceMovedTo(client_point, screen_point, op); | 4607 webview()->dragSourceMovedTo(client_point, screen_point, op); |
| 4712 } | 4608 } |
| 4713 } | 4609 } |
| 4714 | 4610 |
| 4715 void RenderView::OnDragSourceSystemDragEnded() { | 4611 void RenderView::OnDragSourceSystemDragEnded() { |
| 4716 webview()->dragSourceSystemDragEnded(); | 4612 webview()->dragSourceSystemDragEnded(); |
| 4717 } | 4613 } |
| 4718 | 4614 |
| 4719 void RenderView::OnFillPasswordForm( | |
| 4720 const webkit_glue::PasswordFormFillData& form_data) { | |
| 4721 password_autocomplete_manager_->ReceivedPasswordFormFillData(webview(), | |
| 4722 form_data); | |
| 4723 } | |
| 4724 | |
| 4725 void RenderView::OnDragTargetDragEnter(const WebDropData& drop_data, | 4615 void RenderView::OnDragTargetDragEnter(const WebDropData& drop_data, |
| 4726 const gfx::Point& client_point, | 4616 const gfx::Point& client_point, |
| 4727 const gfx::Point& screen_point, | 4617 const gfx::Point& screen_point, |
| 4728 WebDragOperationsMask ops) { | 4618 WebDragOperationsMask ops) { |
| 4729 WebDragOperation operation = webview()->dragTargetDragEnter( | 4619 WebDragOperation operation = webview()->dragTargetDragEnter( |
| 4730 drop_data.ToDragData(), | 4620 drop_data.ToDragData(), |
| 4731 drop_data.identity, | 4621 drop_data.identity, |
| 4732 client_point, | 4622 client_point, |
| 4733 screen_point, | 4623 screen_point, |
| 4734 ops); | 4624 ops); |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5487 WebView* doomed = webview(); | 5377 WebView* doomed = webview(); |
| 5488 RenderWidget::Close(); | 5378 RenderWidget::Close(); |
| 5489 g_view_map.Get().erase(doomed); | 5379 g_view_map.Get().erase(doomed); |
| 5490 } | 5380 } |
| 5491 | 5381 |
| 5492 void RenderView::DidHandleKeyEvent() { | 5382 void RenderView::DidHandleKeyEvent() { |
| 5493 edit_commands_.clear(); | 5383 edit_commands_.clear(); |
| 5494 } | 5384 } |
| 5495 | 5385 |
| 5496 void RenderView::DidHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 5386 void RenderView::DidHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 5497 page_click_tracker_->DidHandleMouseEvent(event); | 5387 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); |
| 5498 } | 5388 } |
| 5499 | 5389 |
| 5500 #if defined(OS_MACOSX) | 5390 #if defined(OS_MACOSX) |
| 5501 void RenderView::OnWasHidden() { | 5391 void RenderView::OnWasHidden() { |
| 5502 RenderWidget::OnWasHidden(); | 5392 RenderWidget::OnWasHidden(); |
| 5503 | 5393 |
| 5504 // Inform plugins that their container is no longer visible. | 5394 // Inform plugins that their container is no longer visible. |
| 5505 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 5395 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 5506 for (plugin_it = plugin_delegates_.begin(); | 5396 for (plugin_it = plugin_delegates_.begin(); |
| 5507 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 5397 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5645 Send(new ViewHostMsg_RunFileChooser(routing_id_, params)); | 5535 Send(new ViewHostMsg_RunFileChooser(routing_id_, params)); |
| 5646 } | 5536 } |
| 5647 return true; | 5537 return true; |
| 5648 } | 5538 } |
| 5649 | 5539 |
| 5650 void RenderView::OnPageTranslated() { | 5540 void RenderView::OnPageTranslated() { |
| 5651 WebFrame* frame = webview()->mainFrame(); | 5541 WebFrame* frame = webview()->mainFrame(); |
| 5652 if (!frame) | 5542 if (!frame) |
| 5653 return; | 5543 return; |
| 5654 | 5544 |
| 5655 // The page is translated, so try to extract the form data again. | 5545 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameTranslated(frame)); |
| 5656 autofill_helper_->FrameContentsAvailable(frame); | |
| 5657 } | 5546 } |
| 5658 | 5547 |
| 5659 WebKit::WebGeolocationClient* RenderView::geolocationClient() { | 5548 WebKit::WebGeolocationClient* RenderView::geolocationClient() { |
| 5660 if (!geolocation_dispatcher_.get()) | 5549 if (!geolocation_dispatcher_) |
| 5661 geolocation_dispatcher_.reset(new GeolocationDispatcher(this)); | 5550 geolocation_dispatcher_ = new GeolocationDispatcher(this); |
| 5662 return geolocation_dispatcher_.get(); | 5551 return geolocation_dispatcher_; |
| 5663 } | 5552 } |
| 5664 | 5553 |
| 5665 WebKit::WebSpeechInputController* RenderView::speechInputController( | 5554 WebKit::WebSpeechInputController* RenderView::speechInputController( |
| 5666 WebKit::WebSpeechInputListener* listener) { | 5555 WebKit::WebSpeechInputListener* listener) { |
| 5667 if (!speech_input_dispatcher_.get()) | 5556 if (!speech_input_dispatcher_) |
| 5668 speech_input_dispatcher_.reset(new SpeechInputDispatcher(this, listener)); | 5557 speech_input_dispatcher_ = new SpeechInputDispatcher(this, listener); |
| 5669 return speech_input_dispatcher_.get(); | 5558 return speech_input_dispatcher_; |
| 5670 } | 5559 } |
| 5671 | 5560 |
| 5672 WebKit::WebDeviceOrientationClient* RenderView::deviceOrientationClient() { | 5561 WebKit::WebDeviceOrientationClient* RenderView::deviceOrientationClient() { |
| 5673 if (!device_orientation_dispatcher_.get()) | 5562 if (!device_orientation_dispatcher_) |
| 5674 device_orientation_dispatcher_.reset(new DeviceOrientationDispatcher(this)); | 5563 device_orientation_dispatcher_ = new DeviceOrientationDispatcher(this); |
| 5675 return device_orientation_dispatcher_.get(); | 5564 return device_orientation_dispatcher_; |
| 5676 } | 5565 } |
| 5677 | 5566 |
| 5678 void RenderView::zoomLimitsChanged(double minimum_level, double maximum_level) { | 5567 void RenderView::zoomLimitsChanged(double minimum_level, double maximum_level) { |
| 5679 // For now, don't remember plugin zoom values. We don't want to mix them with | 5568 // For now, don't remember plugin zoom values. We don't want to mix them with |
| 5680 // normal web content (i.e. a fixed layout plugin would usually want them | 5569 // normal web content (i.e. a fixed layout plugin would usually want them |
| 5681 // different). | 5570 // different). |
| 5682 bool remember = !webview()->mainFrame()->document().isPluginDocument(); | 5571 bool remember = !webview()->mainFrame()->document().isPluginDocument(); |
| 5683 | 5572 |
| 5684 int minimum_percent = static_cast<int>( | 5573 int minimum_percent = static_cast<int>( |
| 5685 WebView::zoomLevelToZoomFactor(minimum_level) * 100); | 5574 WebView::zoomLevelToZoomFactor(minimum_level) * 100); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5792 } | 5681 } |
| 5793 #endif | 5682 #endif |
| 5794 | 5683 |
| 5795 void RenderView::OnJavaScriptStressTestControl(int cmd, int param) { | 5684 void RenderView::OnJavaScriptStressTestControl(int cmd, int param) { |
| 5796 if (cmd == kJavaScriptStressTestSetStressRunType) { | 5685 if (cmd == kJavaScriptStressTestSetStressRunType) { |
| 5797 v8::Testing::SetStressRunType(static_cast<v8::Testing::StressType>(param)); | 5686 v8::Testing::SetStressRunType(static_cast<v8::Testing::StressType>(param)); |
| 5798 } else if (cmd == kJavaScriptStressTestPrepareStressRun) { | 5687 } else if (cmd == kJavaScriptStressTestPrepareStressRun) { |
| 5799 v8::Testing::PrepareStressRun(param); | 5688 v8::Testing::PrepareStressRun(param); |
| 5800 } | 5689 } |
| 5801 } | 5690 } |
| OLD | NEW |