OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 #include "content/renderer/render_widget_fullscreen_pepper.h" | 96 #include "content/renderer/render_widget_fullscreen_pepper.h" |
97 #include "content/renderer/renderer_accessibility.h" | 97 #include "content/renderer/renderer_accessibility.h" |
98 #include "content/renderer/renderer_accessibility_complete.h" | 98 #include "content/renderer/renderer_accessibility_complete.h" |
99 #include "content/renderer/renderer_accessibility_focus_only.h" | 99 #include "content/renderer/renderer_accessibility_focus_only.h" |
100 #include "content/renderer/renderer_webapplicationcachehost_impl.h" | 100 #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
101 #include "content/renderer/renderer_webcolorchooser_impl.h" | 101 #include "content/renderer/renderer_webcolorchooser_impl.h" |
102 #include "content/renderer/speech_recognition_dispatcher.h" | 102 #include "content/renderer/speech_recognition_dispatcher.h" |
103 #include "content/renderer/text_input_client_observer.h" | 103 #include "content/renderer/text_input_client_observer.h" |
104 #include "content/renderer/v8_value_converter_impl.h" | 104 #include "content/renderer/v8_value_converter_impl.h" |
105 #include "content/renderer/web_intents_host.h" | 105 #include "content/renderer/web_intents_host.h" |
106 #include "content/renderer/web_ui_bindings.h" | 106 #include "content/renderer/web_ui_extension.h" |
| 107 #include "content/renderer/web_ui_extension_data.h" |
107 #include "content/renderer/webplugin_delegate_proxy.h" | 108 #include "content/renderer/webplugin_delegate_proxy.h" |
108 #include "content/renderer/websharedworker_proxy.h" | 109 #include "content/renderer/websharedworker_proxy.h" |
109 #include "media/base/filter_collection.h" | 110 #include "media/base/filter_collection.h" |
110 #include "media/base/media_switches.h" | 111 #include "media/base/media_switches.h" |
111 #include "media/base/message_loop_factory.h" | 112 #include "media/base/message_loop_factory.h" |
112 #include "media/filters/audio_renderer_impl.h" | 113 #include "media/filters/audio_renderer_impl.h" |
113 #include "media/filters/gpu_video_decoder.h" | 114 #include "media/filters/gpu_video_decoder.h" |
114 #include "net/base/data_url.h" | 115 #include "net/base/data_url.h" |
115 #include "net/base/escape.h" | 116 #include "net/base/escape.h" |
116 #include "net/base/net_errors.h" | 117 #include "net/base/net_errors.h" |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) | 932 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) |
932 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) | 933 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) |
933 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) | 934 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
934 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) | 935 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
935 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) | 936 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
936 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) | 937 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
937 IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) | 938 IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) |
938 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, | 939 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
939 OnDragSourceSystemDragEnded) | 940 OnDragSourceSystemDragEnded) |
940 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) | 941 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
941 IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty) | |
942 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) | 942 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
943 IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoRect, | 943 IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoRect, |
944 OnScrollFocusedEditableNodeIntoRect) | 944 OnScrollFocusedEditableNodeIntoRect) |
945 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) | 945 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
946 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) | 946 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
947 IPC_MESSAGE_HANDLER(ViewMsg_TimezoneChange, OnUpdateTimezone) | 947 IPC_MESSAGE_HANDLER(ViewMsg_TimezoneChange, OnUpdateTimezone) |
948 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) | 948 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) |
949 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, | 949 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
950 OnEnumerateDirectoryResponse) | 950 OnEnumerateDirectoryResponse) |
951 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) | 951 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
(...skipping 2476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3428 RenderViewNavigatedToHost(GURL(GetLoadingUrl(frame)).host(), | 3428 RenderViewNavigatedToHost(GURL(GetLoadingUrl(frame)).host(), |
3429 g_view_map.Get().size()); | 3429 g_view_map.Get().size()); |
3430 } | 3430 } |
3431 } | 3431 } |
3432 } | 3432 } |
3433 | 3433 |
3434 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { | 3434 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { |
3435 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 3435 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
3436 DidClearWindowObject(frame)); | 3436 DidClearWindowObject(frame)); |
3437 | 3437 |
3438 GURL frame_url = frame->document().url(); | |
3439 if ((enabled_bindings_ & BINDINGS_POLICY_WEB_UI) && | |
3440 (frame_url.SchemeIs(chrome::kChromeUIScheme) || | |
3441 frame_url.SchemeIs(chrome::kDataScheme))) { | |
3442 GetWebUIBindings()->BindToJavascript(frame, "chrome"); | |
3443 } | |
3444 | |
3445 if (enabled_bindings_ & BINDINGS_POLICY_DOM_AUTOMATION) { | 3438 if (enabled_bindings_ & BINDINGS_POLICY_DOM_AUTOMATION) { |
3446 if (!dom_automation_controller_.get()) | 3439 if (!dom_automation_controller_.get()) |
3447 dom_automation_controller_.reset(new DomAutomationController()); | 3440 dom_automation_controller_.reset(new DomAutomationController()); |
3448 dom_automation_controller_->set_message_sender( | 3441 dom_automation_controller_->set_message_sender( |
3449 static_cast<RenderView*>(this)); | 3442 static_cast<RenderView*>(this)); |
3450 dom_automation_controller_->set_routing_id(routing_id()); | 3443 dom_automation_controller_->set_routing_id(routing_id()); |
3451 dom_automation_controller_->BindToJavascript(frame, | 3444 dom_automation_controller_->BindToJavascript(frame, |
3452 "domAutomationController"); | 3445 "domAutomationController"); |
3453 } | 3446 } |
3454 | 3447 |
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4673 | 4666 |
4674 GURL RenderViewImpl::GetLoadingUrl(WebKit::WebFrame* frame) const { | 4667 GURL RenderViewImpl::GetLoadingUrl(WebKit::WebFrame* frame) const { |
4675 WebDataSource* ds = frame->dataSource(); | 4668 WebDataSource* ds = frame->dataSource(); |
4676 if (ds->hasUnreachableURL()) | 4669 if (ds->hasUnreachableURL()) |
4677 return ds->unreachableURL(); | 4670 return ds->unreachableURL(); |
4678 | 4671 |
4679 const WebURLRequest& request = ds->request(); | 4672 const WebURLRequest& request = ds->request(); |
4680 return request.url(); | 4673 return request.url(); |
4681 } | 4674 } |
4682 | 4675 |
4683 WebUIBindings* RenderViewImpl::GetWebUIBindings() { | |
4684 if (!web_ui_bindings_.get()) { | |
4685 web_ui_bindings_.reset(new WebUIBindings( | |
4686 static_cast<RenderView*>(this), routing_id_)); | |
4687 } | |
4688 return web_ui_bindings_.get(); | |
4689 } | |
4690 | |
4691 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { | 4676 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { |
4692 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); | 4677 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
4693 } | 4678 } |
4694 | 4679 |
4695 void RenderViewImpl::OnFind(int request_id, | 4680 void RenderViewImpl::OnFind(int request_id, |
4696 const string16& search_text, | 4681 const string16& search_text, |
4697 const WebFindOptions& options) { | 4682 const WebFindOptions& options) { |
4698 #if defined(OS_ANDROID) | 4683 #if defined(OS_ANDROID) |
4699 // Make sure any asynchronous messages do not disrupt an ongoing synchronous | 4684 // Make sure any asynchronous messages do not disrupt an ongoing synchronous |
4700 // find request as it might lead to deadlocks. Also, these should be safe to | 4685 // find request as it might lead to deadlocks. Also, these should be safe to |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5084 WebFrame* frame = GetChildFrame(frame_xpath); | 5069 WebFrame* frame = GetChildFrame(frame_xpath); |
5085 if (!frame) | 5070 if (!frame) |
5086 return; | 5071 return; |
5087 | 5072 |
5088 frame->document().insertUserStyleSheet( | 5073 frame->document().insertUserStyleSheet( |
5089 WebString::fromUTF8(css), | 5074 WebString::fromUTF8(css), |
5090 WebDocument::UserStyleAuthorLevel); | 5075 WebDocument::UserStyleAuthorLevel); |
5091 } | 5076 } |
5092 | 5077 |
5093 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { | 5078 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
| 5079 if ((enabled_bindings_flags & BINDINGS_POLICY_WEB_UI) && |
| 5080 !(enabled_bindings_ & BINDINGS_POLICY_WEB_UI)) { |
| 5081 RenderThread::Get()->RegisterExtension(content::WebUIExtension::Get()); |
| 5082 new WebUIExtensionData(this); |
| 5083 } |
| 5084 |
5094 enabled_bindings_ |= enabled_bindings_flags; | 5085 enabled_bindings_ |= enabled_bindings_flags; |
5095 | 5086 |
5096 // Keep track of the total bindings accumulated in this process. | 5087 // Keep track of the total bindings accumulated in this process. |
5097 RenderProcess::current()->AddBindings(enabled_bindings_flags); | 5088 RenderProcess::current()->AddBindings(enabled_bindings_flags); |
5098 } | 5089 } |
5099 | 5090 |
5100 void RenderViewImpl::OnSetWebUIProperty(const std::string& name, | |
5101 const std::string& value) { | |
5102 if (enabled_bindings_ & BINDINGS_POLICY_WEB_UI) | |
5103 GetWebUIBindings()->SetProperty(name, value); | |
5104 else | |
5105 NOTREACHED() << "WebUI bindings not enabled."; | |
5106 } | |
5107 | |
5108 void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, | 5091 void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, |
5109 const gfx::Point& client_point, | 5092 const gfx::Point& client_point, |
5110 const gfx::Point& screen_point, | 5093 const gfx::Point& screen_point, |
5111 WebDragOperationsMask ops, | 5094 WebDragOperationsMask ops, |
5112 int key_modifiers) { | 5095 int key_modifiers) { |
5113 WebDragOperation operation = webview()->dragTargetDragEnter( | 5096 WebDragOperation operation = webview()->dragTargetDragEnter( |
5114 drop_data.ToDragData(), | 5097 drop_data.ToDragData(), |
5115 client_point, | 5098 client_point, |
5116 screen_point, | 5099 screen_point, |
5117 ops, | 5100 ops, |
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6440 } | 6423 } |
6441 #endif | 6424 #endif |
6442 | 6425 |
6443 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( | 6426 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( |
6444 TransportDIB::Handle dib_handle) { | 6427 TransportDIB::Handle dib_handle) { |
6445 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); | 6428 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); |
6446 RenderProcess::current()->ReleaseTransportDIB(dib); | 6429 RenderProcess::current()->ReleaseTransportDIB(dib); |
6447 } | 6430 } |
6448 | 6431 |
6449 } // namespace content | 6432 } // namespace content |
OLD | NEW |