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/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "content/common/request_extra_data.h" | 44 #include "content/common/request_extra_data.h" |
45 #include "content/common/socket_stream_handle_data.h" | 45 #include "content/common/socket_stream_handle_data.h" |
46 #include "content/common/ssl_status_serialization.h" | 46 #include "content/common/ssl_status_serialization.h" |
47 #include "content/common/view_messages.h" | 47 #include "content/common/view_messages.h" |
48 #include "content/common/webmessageportchannel_impl.h" | 48 #include "content/common/webmessageportchannel_impl.h" |
49 #include "content/public/common/bindings_policy.h" | 49 #include "content/public/common/bindings_policy.h" |
50 #include "content/public/common/content_client.h" | 50 #include "content/public/common/content_client.h" |
51 #include "content/public/common/content_constants.h" | 51 #include "content/public/common/content_constants.h" |
52 #include "content/public/common/content_switches.h" | 52 #include "content/public/common/content_switches.h" |
53 #include "content/public/common/context_menu_params.h" | 53 #include "content/public/common/context_menu_params.h" |
| 54 #include "content/public/common/favicon_url.h" |
54 #include "content/public/common/file_chooser_params.h" | 55 #include "content/public/common/file_chooser_params.h" |
55 #include "content/public/common/ssl_status.h" | 56 #include "content/public/common/ssl_status.h" |
56 #include "content/public/common/three_d_api_types.h" | 57 #include "content/public/common/three_d_api_types.h" |
57 #include "content/public/common/url_constants.h" | 58 #include "content/public/common/url_constants.h" |
58 #include "content/public/renderer/content_renderer_client.h" | 59 #include "content/public/renderer/content_renderer_client.h" |
59 #include "content/public/renderer/context_menu_client.h" | 60 #include "content/public/renderer/context_menu_client.h" |
60 #include "content/public/renderer/document_state.h" | 61 #include "content/public/renderer/document_state.h" |
61 #include "content/public/renderer/navigation_state.h" | 62 #include "content/public/renderer/navigation_state.h" |
62 #include "content/public/renderer/password_form_conversion_utils.h" | 63 #include "content/public/renderer/password_form_conversion_utils.h" |
63 #include "content/public/renderer/render_view_observer.h" | 64 #include "content/public/renderer/render_view_observer.h" |
64 #include "content/public/renderer/render_view_visitor.h" | 65 #include "content/public/renderer/render_view_visitor.h" |
65 #include "content/renderer/accessibility/renderer_accessibility.h" | 66 #include "content/renderer/accessibility/renderer_accessibility.h" |
66 #include "content/renderer/accessibility/renderer_accessibility_complete.h" | 67 #include "content/renderer/accessibility/renderer_accessibility_complete.h" |
67 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" | 68 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" |
68 #include "content/renderer/browser_plugin/browser_plugin.h" | 69 #include "content/renderer/browser_plugin/browser_plugin.h" |
69 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 70 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
70 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" | 71 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" |
71 #include "content/renderer/device_orientation_dispatcher.h" | 72 #include "content/renderer/device_orientation_dispatcher.h" |
72 #include "content/renderer/devtools/devtools_agent.h" | 73 #include "content/renderer/devtools/devtools_agent.h" |
73 #include "content/renderer/disambiguation_popup_helper.h" | 74 #include "content/renderer/disambiguation_popup_helper.h" |
74 #include "content/renderer/do_not_track_bindings.h" | 75 #include "content/renderer/do_not_track_bindings.h" |
75 #include "content/renderer/dom_automation_controller.h" | 76 #include "content/renderer/dom_automation_controller.h" |
76 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 77 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
77 #include "content/renderer/external_popup_menu.h" | 78 #include "content/renderer/external_popup_menu.h" |
78 #include "content/renderer/favicon_helper.h" | |
79 #include "content/renderer/geolocation_dispatcher.h" | 79 #include "content/renderer/geolocation_dispatcher.h" |
80 #include "content/renderer/gpu/input_handler_manager.h" | 80 #include "content/renderer/gpu/input_handler_manager.h" |
81 #include "content/renderer/gpu/render_widget_compositor.h" | 81 #include "content/renderer/gpu/render_widget_compositor.h" |
82 #include "content/renderer/idle_user_detector.h" | 82 #include "content/renderer/idle_user_detector.h" |
| 83 #include "content/renderer/image_loading_helper.h" |
83 #include "content/renderer/input_tag_speech_dispatcher.h" | 84 #include "content/renderer/input_tag_speech_dispatcher.h" |
84 #include "content/renderer/java/java_bridge_dispatcher.h" | 85 #include "content/renderer/java/java_bridge_dispatcher.h" |
85 #include "content/renderer/load_progress_tracker.h" | 86 #include "content/renderer/load_progress_tracker.h" |
86 #include "content/renderer/media/audio_device_factory.h" | 87 #include "content/renderer/media/audio_device_factory.h" |
87 #include "content/renderer/media/audio_renderer_mixer_manager.h" | 88 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
88 #include "content/renderer/media/media_stream_dependency_factory.h" | 89 #include "content/renderer/media/media_stream_dependency_factory.h" |
89 #include "content/renderer/media/media_stream_dispatcher.h" | 90 #include "content/renderer/media/media_stream_dispatcher.h" |
90 #include "content/renderer/media/media_stream_impl.h" | 91 #include "content/renderer/media/media_stream_impl.h" |
91 #include "content/renderer/media/render_media_log.h" | 92 #include "content/renderer/media/render_media_log.h" |
92 #include "content/renderer/media/renderer_audio_output_device.h" | 93 #include "content/renderer/media/renderer_audio_output_device.h" |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 540 |
540 if (device_scale_factor > 1.0f && | 541 if (device_scale_factor > 1.0f && |
541 command_line.HasSwitch( | 542 command_line.HasSwitch( |
542 switches::kEnableHighDpiCompositingForFixedPosition)) | 543 switches::kEnableHighDpiCompositingForFixedPosition)) |
543 return true; | 544 return true; |
544 | 545 |
545 // Default, when no switches are specified, is disabled. | 546 // Default, when no switches are specified, is disabled. |
546 return false; | 547 return false; |
547 } | 548 } |
548 | 549 |
| 550 static FaviconURL::IconType ToFaviconType(WebKit::WebIconURL::Type type) { |
| 551 switch (type) { |
| 552 case WebKit::WebIconURL::TypeFavicon: |
| 553 return FaviconURL::FAVICON; |
| 554 case WebKit::WebIconURL::TypeTouch: |
| 555 return FaviconURL::TOUCH_ICON; |
| 556 case WebKit::WebIconURL::TypeTouchPrecomposed: |
| 557 return FaviconURL::TOUCH_PRECOMPOSED_ICON; |
| 558 case WebKit::WebIconURL::TypeInvalid: |
| 559 return FaviconURL::INVALID_ICON; |
| 560 } |
| 561 return FaviconURL::INVALID_ICON; |
| 562 } |
| 563 |
549 /////////////////////////////////////////////////////////////////////////////// | 564 /////////////////////////////////////////////////////////////////////////////// |
550 | 565 |
551 struct RenderViewImpl::PendingFileChooser { | 566 struct RenderViewImpl::PendingFileChooser { |
552 PendingFileChooser(const FileChooserParams& p, WebFileChooserCompletion* c) | 567 PendingFileChooser(const FileChooserParams& p, WebFileChooserCompletion* c) |
553 : params(p), | 568 : params(p), |
554 completion(c) { | 569 completion(c) { |
555 } | 570 } |
556 FileChooserParams params; | 571 FileChooserParams params; |
557 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. | 572 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. |
558 }; | 573 }; |
(...skipping 29 matching lines...) Expand all Loading... |
588 int64 ExtractPostId(const WebHistoryItem& item) { | 603 int64 ExtractPostId(const WebHistoryItem& item) { |
589 if (item.isNull()) | 604 if (item.isNull()) |
590 return -1; | 605 return -1; |
591 | 606 |
592 if (item.httpBody().isNull()) | 607 if (item.httpBody().isNull()) |
593 return -1; | 608 return -1; |
594 | 609 |
595 return item.httpBody().identifier(); | 610 return item.httpBody().identifier(); |
596 } | 611 } |
597 | 612 |
| 613 bool TouchEnabled() { |
| 614 // Based on the definition of chrome::kEnableTouchIcon. |
| 615 #if defined(OS_ANDROID) |
| 616 return true; |
| 617 #else |
| 618 return false; |
| 619 #endif |
| 620 } |
| 621 |
598 } // namespace | 622 } // namespace |
599 | 623 |
600 RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) | 624 RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) |
601 : RenderWidget(WebKit::WebPopupTypeNone, | 625 : RenderWidget(WebKit::WebPopupTypeNone, |
602 params->screen_info, | 626 params->screen_info, |
603 params->swapped_out), | 627 params->swapped_out), |
604 webkit_preferences_(params->webkit_prefs), | 628 webkit_preferences_(params->webkit_prefs), |
605 send_content_state_immediately_(false), | 629 send_content_state_immediately_(false), |
606 enabled_bindings_(0), | 630 enabled_bindings_(0), |
607 send_preferred_size_changes_(false), | 631 send_preferred_size_changes_(false), |
(...skipping 20 matching lines...) Expand all Loading... |
628 speech_recognition_dispatcher_(NULL), | 652 speech_recognition_dispatcher_(NULL), |
629 device_orientation_dispatcher_(NULL), | 653 device_orientation_dispatcher_(NULL), |
630 media_stream_dispatcher_(NULL), | 654 media_stream_dispatcher_(NULL), |
631 browser_plugin_manager_(NULL), | 655 browser_plugin_manager_(NULL), |
632 media_stream_impl_(NULL), | 656 media_stream_impl_(NULL), |
633 devtools_agent_(NULL), | 657 devtools_agent_(NULL), |
634 accessibility_mode_(AccessibilityModeOff), | 658 accessibility_mode_(AccessibilityModeOff), |
635 renderer_accessibility_(NULL), | 659 renderer_accessibility_(NULL), |
636 java_bridge_dispatcher_(NULL), | 660 java_bridge_dispatcher_(NULL), |
637 mouse_lock_dispatcher_(NULL), | 661 mouse_lock_dispatcher_(NULL), |
638 favicon_helper_(NULL), | |
639 #if defined(OS_ANDROID) | 662 #if defined(OS_ANDROID) |
640 body_background_color_(SK_ColorWHITE), | 663 body_background_color_(SK_ColorWHITE), |
641 update_frame_info_scheduled_(false), | 664 update_frame_info_scheduled_(false), |
642 expected_content_intent_id_(0), | 665 expected_content_intent_id_(0), |
643 media_player_proxy_(NULL), | 666 media_player_proxy_(NULL), |
644 enumeration_completion_id_(0), | 667 enumeration_completion_id_(0), |
645 ALLOW_THIS_IN_INITIALIZER_LIST( | 668 ALLOW_THIS_IN_INITIALIZER_LIST( |
646 load_progress_tracker_(new LoadProgressTracker(this))), | 669 load_progress_tracker_(new LoadProgressTracker(this))), |
647 #endif | 670 #endif |
648 session_storage_namespace_id_(params->session_storage_namespace_id), | 671 session_storage_namespace_id_(params->session_storage_namespace_id), |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 | 778 |
756 #if defined(OS_ANDROID) | 779 #if defined(OS_ANDROID) |
757 media_player_manager_.reset( | 780 media_player_manager_.reset( |
758 new webkit_media::WebMediaPlayerManagerAndroid()); | 781 new webkit_media::WebMediaPlayerManagerAndroid()); |
759 #endif | 782 #endif |
760 | 783 |
761 // The next group of objects all implement RenderViewObserver, so are deleted | 784 // The next group of objects all implement RenderViewObserver, so are deleted |
762 // along with the RenderView automatically. | 785 // along with the RenderView automatically. |
763 devtools_agent_ = new DevToolsAgent(this); | 786 devtools_agent_ = new DevToolsAgent(this); |
764 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); | 787 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); |
765 favicon_helper_ = new FaviconHelper(this); | 788 |
| 789 new ImageLoadingHelper(this); |
766 | 790 |
767 // Create renderer_accessibility_ if needed. | 791 // Create renderer_accessibility_ if needed. |
768 OnSetAccessibilityMode(params->accessibility_mode); | 792 OnSetAccessibilityMode(params->accessibility_mode); |
769 | 793 |
770 new IdleUserDetector(this); | 794 new IdleUserDetector(this); |
771 | 795 |
772 if (command_line.HasSwitch(switches::kDomAutomationController)) | 796 if (command_line.HasSwitch(switches::kDomAutomationController)) |
773 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; | 797 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
774 | 798 |
775 ProcessViewLayoutFlags(command_line); | 799 ProcessViewLayoutFlags(command_line); |
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2102 // NOTE: For now we're doing the safest thing, and sending out notification | 2126 // NOTE: For now we're doing the safest thing, and sending out notification |
2103 // when done loading. This currently isn't an issue as the favicon is only | 2127 // when done loading. This currently isn't an issue as the favicon is only |
2104 // displayed when done loading. Ideally we would send notification when | 2128 // displayed when done loading. Ideally we would send notification when |
2105 // finished parsing the head, but webkit doesn't support that yet. | 2129 // finished parsing the head, but webkit doesn't support that yet. |
2106 // The feed discovery code would also benefit from access to the head. | 2130 // The feed discovery code would also benefit from access to the head. |
2107 Send(new ViewHostMsg_DidStopLoading(routing_id_)); | 2131 Send(new ViewHostMsg_DidStopLoading(routing_id_)); |
2108 | 2132 |
2109 if (load_progress_tracker_ != NULL) | 2133 if (load_progress_tracker_ != NULL) |
2110 load_progress_tracker_->DidStopLoading(); | 2134 load_progress_tracker_->DidStopLoading(); |
2111 | 2135 |
| 2136 DidStopLoadingIcons(); |
| 2137 |
2112 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); | 2138 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); |
2113 } | 2139 } |
2114 | 2140 |
2115 void RenderViewImpl::didChangeLoadProgress(WebFrame* frame, | 2141 void RenderViewImpl::didChangeLoadProgress(WebFrame* frame, |
2116 double load_progress) { | 2142 double load_progress) { |
2117 if (load_progress_tracker_ != NULL) | 2143 if (load_progress_tracker_ != NULL) |
2118 load_progress_tracker_->DidChangeLoadProgress(frame, load_progress); | 2144 load_progress_tracker_->DidChangeLoadProgress(frame, load_progress); |
2119 } | 2145 } |
2120 | 2146 |
2121 void RenderViewImpl::didCancelCompositionOnSelectionChange() { | 2147 void RenderViewImpl::didCancelCompositionOnSelectionChange() { |
(...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3627 } | 3653 } |
3628 | 3654 |
3629 void RenderViewImpl::didReceiveTitle(WebFrame* frame, const WebString& title, | 3655 void RenderViewImpl::didReceiveTitle(WebFrame* frame, const WebString& title, |
3630 WebTextDirection direction) { | 3656 WebTextDirection direction) { |
3631 UpdateTitle(frame, title, direction); | 3657 UpdateTitle(frame, title, direction); |
3632 | 3658 |
3633 // Also check whether we have new encoding name. | 3659 // Also check whether we have new encoding name. |
3634 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 3660 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
3635 } | 3661 } |
3636 | 3662 |
3637 void RenderViewImpl::didChangeIcon(WebFrame* frame, WebIconURL::Type type) { | 3663 void RenderViewImpl::didChangeIcon(WebFrame* frame, |
3638 favicon_helper_->DidChangeIcon(frame, type); | 3664 WebIconURL::Type icon_type) { |
| 3665 if (frame->parent()) |
| 3666 return; |
| 3667 |
| 3668 if (!TouchEnabled() && icon_type != WebIconURL::TypeFavicon) |
| 3669 return; |
| 3670 |
| 3671 WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type); |
| 3672 std::vector<FaviconURL> urls; |
| 3673 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 3674 urls.push_back(FaviconURL(icon_urls[i].iconURL(), |
| 3675 ToFaviconType(icon_urls[i].iconType()))); |
| 3676 } |
| 3677 SendUpdateFaviconURL(urls); |
3639 } | 3678 } |
3640 | 3679 |
3641 void RenderViewImpl::didFinishDocumentLoad(WebFrame* frame) { | 3680 void RenderViewImpl::didFinishDocumentLoad(WebFrame* frame) { |
3642 WebDataSource* ds = frame->dataSource(); | 3681 WebDataSource* ds = frame->dataSource(); |
3643 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3682 DocumentState* document_state = DocumentState::FromDataSource(ds); |
3644 document_state->set_finish_document_load_time(Time::Now()); | 3683 document_state->set_finish_document_load_time(Time::Now()); |
3645 | 3684 |
3646 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier())); | 3685 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier())); |
3647 | 3686 |
3648 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 3687 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
(...skipping 2899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6548 TransportDIB::Handle dib_handle) { | 6587 TransportDIB::Handle dib_handle) { |
6549 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); | 6588 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); |
6550 RenderProcess::current()->ReleaseTransportDIB(dib); | 6589 RenderProcess::current()->ReleaseTransportDIB(dib); |
6551 } | 6590 } |
6552 | 6591 |
6553 void RenderViewImpl::DidCommitCompositorFrame() { | 6592 void RenderViewImpl::DidCommitCompositorFrame() { |
6554 RenderWidget::DidCommitCompositorFrame(); | 6593 RenderWidget::DidCommitCompositorFrame(); |
6555 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame()); | 6594 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame()); |
6556 } | 6595 } |
6557 | 6596 |
| 6597 void RenderViewImpl::SendUpdateFaviconURL(const std::vector<FaviconURL>& urls) { |
| 6598 if (!urls.empty()) |
| 6599 Send(new ViewHostMsg_UpdateFaviconURL(routing_id_, page_id_, urls)); |
| 6600 } |
| 6601 |
| 6602 void RenderViewImpl::DidStopLoadingIcons() { |
| 6603 int icon_types = WebIconURL::TypeFavicon; |
| 6604 if (TouchEnabled()) |
| 6605 icon_types |= WebIconURL::TypeTouchPrecomposed | WebIconURL::TypeTouch; |
| 6606 |
| 6607 WebVector<WebIconURL> icon_urls = |
| 6608 webview()->mainFrame()->iconURLs(icon_types); |
| 6609 |
| 6610 std::vector<FaviconURL> urls; |
| 6611 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 6612 WebURL url = icon_urls[i].iconURL(); |
| 6613 if (!url.isEmpty()) |
| 6614 urls.push_back(FaviconURL(url, |
| 6615 ToFaviconType(icon_urls[i].iconType()))); |
| 6616 } |
| 6617 SendUpdateFaviconURL(urls); |
| 6618 } |
| 6619 |
| 6620 |
6558 } // namespace content | 6621 } // namespace content |
OLD | NEW |