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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 int64 ExtractPostId(const WebHistoryItem& item) { | 589 int64 ExtractPostId(const WebHistoryItem& item) { |
589 if (item.isNull()) | 590 if (item.isNull()) |
590 return -1; | 591 return -1; |
591 | 592 |
592 if (item.httpBody().isNull()) | 593 if (item.httpBody().isNull()) |
593 return -1; | 594 return -1; |
594 | 595 |
595 return item.httpBody().identifier(); | 596 return item.httpBody().identifier(); |
596 } | 597 } |
597 | 598 |
| 599 bool TouchEnabled() { |
| 600 // Based on the definition of chrome::kEnableTouchIcon. |
| 601 #if defined(OS_ANDROID) |
| 602 return true; |
| 603 #else |
| 604 return false; |
| 605 #endif |
| 606 } |
| 607 |
598 } // namespace | 608 } // namespace |
599 | 609 |
600 RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) | 610 RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) |
601 : RenderWidget(WebKit::WebPopupTypeNone, | 611 : RenderWidget(WebKit::WebPopupTypeNone, |
602 params->screen_info, | 612 params->screen_info, |
603 params->swapped_out), | 613 params->swapped_out), |
604 webkit_preferences_(params->webkit_prefs), | 614 webkit_preferences_(params->webkit_prefs), |
605 send_content_state_immediately_(false), | 615 send_content_state_immediately_(false), |
606 enabled_bindings_(0), | 616 enabled_bindings_(0), |
607 send_preferred_size_changes_(false), | 617 send_preferred_size_changes_(false), |
(...skipping 20 matching lines...) Expand all Loading... |
628 speech_recognition_dispatcher_(NULL), | 638 speech_recognition_dispatcher_(NULL), |
629 device_orientation_dispatcher_(NULL), | 639 device_orientation_dispatcher_(NULL), |
630 media_stream_dispatcher_(NULL), | 640 media_stream_dispatcher_(NULL), |
631 browser_plugin_manager_(NULL), | 641 browser_plugin_manager_(NULL), |
632 media_stream_impl_(NULL), | 642 media_stream_impl_(NULL), |
633 devtools_agent_(NULL), | 643 devtools_agent_(NULL), |
634 accessibility_mode_(AccessibilityModeOff), | 644 accessibility_mode_(AccessibilityModeOff), |
635 renderer_accessibility_(NULL), | 645 renderer_accessibility_(NULL), |
636 java_bridge_dispatcher_(NULL), | 646 java_bridge_dispatcher_(NULL), |
637 mouse_lock_dispatcher_(NULL), | 647 mouse_lock_dispatcher_(NULL), |
638 favicon_helper_(NULL), | |
639 #if defined(OS_ANDROID) | 648 #if defined(OS_ANDROID) |
640 body_background_color_(SK_ColorWHITE), | 649 body_background_color_(SK_ColorWHITE), |
641 update_frame_info_scheduled_(false), | 650 update_frame_info_scheduled_(false), |
642 expected_content_intent_id_(0), | 651 expected_content_intent_id_(0), |
643 media_player_proxy_(NULL), | 652 media_player_proxy_(NULL), |
644 enumeration_completion_id_(0), | 653 enumeration_completion_id_(0), |
645 ALLOW_THIS_IN_INITIALIZER_LIST( | 654 ALLOW_THIS_IN_INITIALIZER_LIST( |
646 load_progress_tracker_(new LoadProgressTracker(this))), | 655 load_progress_tracker_(new LoadProgressTracker(this))), |
647 #endif | 656 #endif |
648 session_storage_namespace_id_(params->session_storage_namespace_id), | 657 session_storage_namespace_id_(params->session_storage_namespace_id), |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 | 764 |
756 #if defined(OS_ANDROID) | 765 #if defined(OS_ANDROID) |
757 media_player_manager_.reset( | 766 media_player_manager_.reset( |
758 new webkit_media::WebMediaPlayerManagerAndroid()); | 767 new webkit_media::WebMediaPlayerManagerAndroid()); |
759 #endif | 768 #endif |
760 | 769 |
761 // The next group of objects all implement RenderViewObserver, so are deleted | 770 // The next group of objects all implement RenderViewObserver, so are deleted |
762 // along with the RenderView automatically. | 771 // along with the RenderView automatically. |
763 devtools_agent_ = new DevToolsAgent(this); | 772 devtools_agent_ = new DevToolsAgent(this); |
764 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); | 773 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); |
765 favicon_helper_ = new FaviconHelper(this); | 774 |
| 775 new ImageLoadingHelper(this); |
766 | 776 |
767 // Create renderer_accessibility_ if needed. | 777 // Create renderer_accessibility_ if needed. |
768 OnSetAccessibilityMode(params->accessibility_mode); | 778 OnSetAccessibilityMode(params->accessibility_mode); |
769 | 779 |
770 new IdleUserDetector(this); | 780 new IdleUserDetector(this); |
771 | 781 |
772 if (command_line.HasSwitch(switches::kDomAutomationController)) | 782 if (command_line.HasSwitch(switches::kDomAutomationController)) |
773 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; | 783 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
774 | 784 |
775 ProcessViewLayoutFlags(command_line); | 785 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 | 2112 // 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 | 2113 // 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 | 2114 // displayed when done loading. Ideally we would send notification when |
2105 // finished parsing the head, but webkit doesn't support that yet. | 2115 // finished parsing the head, but webkit doesn't support that yet. |
2106 // The feed discovery code would also benefit from access to the head. | 2116 // The feed discovery code would also benefit from access to the head. |
2107 Send(new ViewHostMsg_DidStopLoading(routing_id_)); | 2117 Send(new ViewHostMsg_DidStopLoading(routing_id_)); |
2108 | 2118 |
2109 if (load_progress_tracker_ != NULL) | 2119 if (load_progress_tracker_ != NULL) |
2110 load_progress_tracker_->DidStopLoading(); | 2120 load_progress_tracker_->DidStopLoading(); |
2111 | 2121 |
| 2122 DidStopLoadingIcons(); |
| 2123 |
2112 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); | 2124 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); |
2113 } | 2125 } |
2114 | 2126 |
2115 void RenderViewImpl::didChangeLoadProgress(WebFrame* frame, | 2127 void RenderViewImpl::didChangeLoadProgress(WebFrame* frame, |
2116 double load_progress) { | 2128 double load_progress) { |
2117 if (load_progress_tracker_ != NULL) | 2129 if (load_progress_tracker_ != NULL) |
2118 load_progress_tracker_->DidChangeLoadProgress(frame, load_progress); | 2130 load_progress_tracker_->DidChangeLoadProgress(frame, load_progress); |
2119 } | 2131 } |
2120 | 2132 |
2121 void RenderViewImpl::didCancelCompositionOnSelectionChange() { | 2133 void RenderViewImpl::didCancelCompositionOnSelectionChange() { |
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3626 } | 3638 } |
3627 | 3639 |
3628 void RenderViewImpl::didReceiveTitle(WebFrame* frame, const WebString& title, | 3640 void RenderViewImpl::didReceiveTitle(WebFrame* frame, const WebString& title, |
3629 WebTextDirection direction) { | 3641 WebTextDirection direction) { |
3630 UpdateTitle(frame, title, direction); | 3642 UpdateTitle(frame, title, direction); |
3631 | 3643 |
3632 // Also check whether we have new encoding name. | 3644 // Also check whether we have new encoding name. |
3633 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 3645 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
3634 } | 3646 } |
3635 | 3647 |
3636 void RenderViewImpl::didChangeIcon(WebFrame* frame, WebIconURL::Type type) { | 3648 void RenderViewImpl::didChangeIcon(WebFrame* frame, |
3637 favicon_helper_->DidChangeIcon(frame, type); | 3649 WebIconURL::Type icon_type) { |
| 3650 if (frame->parent()) |
| 3651 return; |
| 3652 |
| 3653 if (!TouchEnabled() && icon_type != WebIconURL::TypeFavicon) |
| 3654 return; |
| 3655 |
| 3656 WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type); |
| 3657 std::vector<FaviconURL> urls; |
| 3658 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 3659 urls.push_back(FaviconURL(icon_urls[i].iconURL(), |
| 3660 FaviconURL::ToFaviconType(icon_urls[i].iconType()))); |
| 3661 } |
| 3662 SendUpdateFaviconURL(urls); |
3638 } | 3663 } |
3639 | 3664 |
3640 void RenderViewImpl::didFinishDocumentLoad(WebFrame* frame) { | 3665 void RenderViewImpl::didFinishDocumentLoad(WebFrame* frame) { |
3641 WebDataSource* ds = frame->dataSource(); | 3666 WebDataSource* ds = frame->dataSource(); |
3642 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3667 DocumentState* document_state = DocumentState::FromDataSource(ds); |
3643 document_state->set_finish_document_load_time(Time::Now()); | 3668 document_state->set_finish_document_load_time(Time::Now()); |
3644 | 3669 |
3645 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier())); | 3670 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier())); |
3646 | 3671 |
3647 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 3672 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
(...skipping 2945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6593 TransportDIB::Handle dib_handle) { | 6618 TransportDIB::Handle dib_handle) { |
6594 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); | 6619 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); |
6595 RenderProcess::current()->ReleaseTransportDIB(dib); | 6620 RenderProcess::current()->ReleaseTransportDIB(dib); |
6596 } | 6621 } |
6597 | 6622 |
6598 void RenderViewImpl::DidCommitCompositorFrame() { | 6623 void RenderViewImpl::DidCommitCompositorFrame() { |
6599 RenderWidget::DidCommitCompositorFrame(); | 6624 RenderWidget::DidCommitCompositorFrame(); |
6600 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame()); | 6625 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame()); |
6601 } | 6626 } |
6602 | 6627 |
| 6628 void RenderViewImpl::SendUpdateFaviconURL(const std::vector<FaviconURL>& urls) { |
| 6629 if (!urls.empty()) |
| 6630 Send(new ViewHostMsg_UpdateFaviconURL(routing_id_, page_id_, urls)); |
| 6631 } |
| 6632 |
| 6633 void RenderViewImpl::DidStopLoadingIcons() { |
| 6634 int icon_types = WebIconURL::TypeFavicon; |
| 6635 if (TouchEnabled()) |
| 6636 icon_types |= WebIconURL::TypeTouchPrecomposed | WebIconURL::TypeTouch; |
| 6637 |
| 6638 WebVector<WebIconURL> icon_urls = |
| 6639 webview()->mainFrame()->iconURLs(icon_types); |
| 6640 |
| 6641 std::vector<FaviconURL> urls; |
| 6642 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 6643 WebURL url = icon_urls[i].iconURL(); |
| 6644 if (!url.isEmpty()) |
| 6645 urls.push_back(FaviconURL(url, |
| 6646 FaviconURL::ToFaviconType(icon_urls[i].iconType()))); |
| 6647 } |
| 6648 SendUpdateFaviconURL(urls); |
| 6649 } |
| 6650 |
| 6651 |
6603 } // namespace content | 6652 } // namespace content |
OLD | NEW |