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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 #include "content/renderer/render_widget_fullscreen_pepper.h" | 92 #include "content/renderer/render_widget_fullscreen_pepper.h" |
93 #include "content/renderer/renderer_accessibility.h" | 93 #include "content/renderer/renderer_accessibility.h" |
94 #include "content/renderer/renderer_accessibility_complete.h" | 94 #include "content/renderer/renderer_accessibility_complete.h" |
95 #include "content/renderer/renderer_accessibility_focus_only.h" | 95 #include "content/renderer/renderer_accessibility_focus_only.h" |
96 #include "content/renderer/renderer_webapplicationcachehost_impl.h" | 96 #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
97 #include "content/renderer/renderer_webcolorchooser_impl.h" | 97 #include "content/renderer/renderer_webcolorchooser_impl.h" |
98 #include "content/renderer/speech_recognition_dispatcher.h" | 98 #include "content/renderer/speech_recognition_dispatcher.h" |
99 #include "content/renderer/text_input_client_observer.h" | 99 #include "content/renderer/text_input_client_observer.h" |
100 #include "content/renderer/v8_value_converter_impl.h" | 100 #include "content/renderer/v8_value_converter_impl.h" |
101 #include "content/renderer/web_intents_host.h" | 101 #include "content/renderer/web_intents_host.h" |
102 #include "content/renderer/web_ui_bindings.h" | 102 #include "content/renderer/web_ui_extension.h" |
| 103 #include "content/renderer/web_ui_extension_data.h" |
103 #include "content/renderer/webplugin_delegate_proxy.h" | 104 #include "content/renderer/webplugin_delegate_proxy.h" |
104 #include "content/renderer/websharedworker_proxy.h" | 105 #include "content/renderer/websharedworker_proxy.h" |
105 #include "media/base/filter_collection.h" | 106 #include "media/base/filter_collection.h" |
106 #include "media/base/media_switches.h" | 107 #include "media/base/media_switches.h" |
107 #include "media/base/message_loop_factory.h" | 108 #include "media/base/message_loop_factory.h" |
108 #include "media/filters/audio_renderer_impl.h" | 109 #include "media/filters/audio_renderer_impl.h" |
109 #include "media/filters/gpu_video_decoder.h" | 110 #include "media/filters/gpu_video_decoder.h" |
110 #include "net/base/data_url.h" | 111 #include "net/base/data_url.h" |
111 #include "net/base/escape.h" | 112 #include "net/base/escape.h" |
112 #include "net/base/net_errors.h" | 113 #include "net/base/net_errors.h" |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) | 921 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) |
921 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) | 922 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) |
922 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) | 923 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
923 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) | 924 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
924 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) | 925 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
925 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) | 926 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
926 IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) | 927 IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) |
927 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, | 928 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
928 OnDragSourceSystemDragEnded) | 929 OnDragSourceSystemDragEnded) |
929 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) | 930 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
930 IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty) | |
931 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) | 931 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
932 IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoRect, | 932 IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoRect, |
933 OnScrollFocusedEditableNodeIntoRect) | 933 OnScrollFocusedEditableNodeIntoRect) |
934 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) | 934 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
935 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) | 935 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
936 IPC_MESSAGE_HANDLER(ViewMsg_TimezoneChange, OnUpdateTimezone) | 936 IPC_MESSAGE_HANDLER(ViewMsg_TimezoneChange, OnUpdateTimezone) |
937 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) | 937 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) |
938 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, | 938 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
939 OnEnumerateDirectoryResponse) | 939 OnEnumerateDirectoryResponse) |
940 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) | 940 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
(...skipping 2441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3382 RenderViewNavigatedToHost(GURL(GetLoadingUrl(frame)).host(), | 3382 RenderViewNavigatedToHost(GURL(GetLoadingUrl(frame)).host(), |
3383 g_view_map.Get().size()); | 3383 g_view_map.Get().size()); |
3384 } | 3384 } |
3385 } | 3385 } |
3386 } | 3386 } |
3387 | 3387 |
3388 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { | 3388 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { |
3389 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 3389 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
3390 DidClearWindowObject(frame)); | 3390 DidClearWindowObject(frame)); |
3391 | 3391 |
3392 GURL frame_url = frame->document().url(); | |
3393 if ((enabled_bindings_ & BINDINGS_POLICY_WEB_UI) && | |
3394 (frame_url.SchemeIs(chrome::kChromeUIScheme) || | |
3395 frame_url.SchemeIs(chrome::kDataScheme))) { | |
3396 GetWebUIBindings()->BindToJavascript(frame, "chrome"); | |
3397 } | |
3398 | |
3399 if (enabled_bindings_ & BINDINGS_POLICY_DOM_AUTOMATION) { | 3392 if (enabled_bindings_ & BINDINGS_POLICY_DOM_AUTOMATION) { |
3400 if (!dom_automation_controller_.get()) | 3393 if (!dom_automation_controller_.get()) |
3401 dom_automation_controller_.reset(new DomAutomationController()); | 3394 dom_automation_controller_.reset(new DomAutomationController()); |
3402 dom_automation_controller_->set_message_sender( | 3395 dom_automation_controller_->set_message_sender( |
3403 static_cast<RenderView*>(this)); | 3396 static_cast<RenderView*>(this)); |
3404 dom_automation_controller_->set_routing_id(routing_id()); | 3397 dom_automation_controller_->set_routing_id(routing_id()); |
3405 dom_automation_controller_->BindToJavascript(frame, | 3398 dom_automation_controller_->BindToJavascript(frame, |
3406 "domAutomationController"); | 3399 "domAutomationController"); |
3407 } | 3400 } |
3408 | 3401 |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4599 | 4592 |
4600 GURL RenderViewImpl::GetLoadingUrl(WebKit::WebFrame* frame) const { | 4593 GURL RenderViewImpl::GetLoadingUrl(WebKit::WebFrame* frame) const { |
4601 WebDataSource* ds = frame->dataSource(); | 4594 WebDataSource* ds = frame->dataSource(); |
4602 if (ds->hasUnreachableURL()) | 4595 if (ds->hasUnreachableURL()) |
4603 return ds->unreachableURL(); | 4596 return ds->unreachableURL(); |
4604 | 4597 |
4605 const WebURLRequest& request = ds->request(); | 4598 const WebURLRequest& request = ds->request(); |
4606 return request.url(); | 4599 return request.url(); |
4607 } | 4600 } |
4608 | 4601 |
4609 WebUIBindings* RenderViewImpl::GetWebUIBindings() { | |
4610 if (!web_ui_bindings_.get()) { | |
4611 web_ui_bindings_.reset(new WebUIBindings( | |
4612 static_cast<RenderView*>(this), routing_id_)); | |
4613 } | |
4614 return web_ui_bindings_.get(); | |
4615 } | |
4616 | |
4617 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { | 4602 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { |
4618 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); | 4603 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
4619 } | 4604 } |
4620 | 4605 |
4621 void RenderViewImpl::OnFind(int request_id, | 4606 void RenderViewImpl::OnFind(int request_id, |
4622 const string16& search_text, | 4607 const string16& search_text, |
4623 const WebFindOptions& options) { | 4608 const WebFindOptions& options) { |
4624 #if defined(OS_ANDROID) | 4609 #if defined(OS_ANDROID) |
4625 // Make sure any asynchronous messages do not disrupt an ongoing synchronous | 4610 // Make sure any asynchronous messages do not disrupt an ongoing synchronous |
4626 // find request as it might lead to deadlocks. Also, these should be safe to | 4611 // 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... |
5010 WebFrame* frame = GetChildFrame(frame_xpath); | 4995 WebFrame* frame = GetChildFrame(frame_xpath); |
5011 if (!frame) | 4996 if (!frame) |
5012 return; | 4997 return; |
5013 | 4998 |
5014 frame->document().insertUserStyleSheet( | 4999 frame->document().insertUserStyleSheet( |
5015 WebString::fromUTF8(css), | 5000 WebString::fromUTF8(css), |
5016 WebDocument::UserStyleAuthorLevel); | 5001 WebDocument::UserStyleAuthorLevel); |
5017 } | 5002 } |
5018 | 5003 |
5019 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { | 5004 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
| 5005 if ((enabled_bindings_flags & BINDINGS_POLICY_WEB_UI) && |
| 5006 !(enabled_bindings_ & BINDINGS_POLICY_WEB_UI)) { |
| 5007 RenderThread::Get()->RegisterExtension(content::WebUIExtension::Get()); |
| 5008 new WebUIExtensionData(this); |
| 5009 } |
| 5010 |
5020 enabled_bindings_ |= enabled_bindings_flags; | 5011 enabled_bindings_ |= enabled_bindings_flags; |
5021 | 5012 |
5022 // Keep track of the total bindings accumulated in this process. | 5013 // Keep track of the total bindings accumulated in this process. |
5023 RenderProcess::current()->AddBindings(enabled_bindings_flags); | 5014 RenderProcess::current()->AddBindings(enabled_bindings_flags); |
5024 } | 5015 } |
5025 | 5016 |
5026 void RenderViewImpl::OnSetWebUIProperty(const std::string& name, | |
5027 const std::string& value) { | |
5028 if (enabled_bindings_ & BINDINGS_POLICY_WEB_UI) | |
5029 GetWebUIBindings()->SetProperty(name, value); | |
5030 else | |
5031 NOTREACHED() << "WebUI bindings not enabled."; | |
5032 } | |
5033 | |
5034 void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, | 5017 void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, |
5035 const gfx::Point& client_point, | 5018 const gfx::Point& client_point, |
5036 const gfx::Point& screen_point, | 5019 const gfx::Point& screen_point, |
5037 WebDragOperationsMask ops, | 5020 WebDragOperationsMask ops, |
5038 int key_modifiers) { | 5021 int key_modifiers) { |
5039 WebDragOperation operation = webview()->dragTargetDragEnter( | 5022 WebDragOperation operation = webview()->dragTargetDragEnter( |
5040 drop_data.ToDragData(), | 5023 drop_data.ToDragData(), |
5041 client_point, | 5024 client_point, |
5042 screen_point, | 5025 screen_point, |
5043 ops, | 5026 ops, |
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6361 } | 6344 } |
6362 #endif | 6345 #endif |
6363 | 6346 |
6364 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( | 6347 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( |
6365 TransportDIB::Handle dib_handle) { | 6348 TransportDIB::Handle dib_handle) { |
6366 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); | 6349 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); |
6367 RenderProcess::current()->ReleaseTransportDIB(dib); | 6350 RenderProcess::current()->ReleaseTransportDIB(dib); |
6368 } | 6351 } |
6369 | 6352 |
6370 } // namespace content | 6353 } // namespace content |
OLD | NEW |