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_data.h" |
103 #include "content/renderer/webplugin_delegate_proxy.h" | 103 #include "content/renderer/webplugin_delegate_proxy.h" |
104 #include "content/renderer/websharedworker_proxy.h" | 104 #include "content/renderer/websharedworker_proxy.h" |
105 #include "media/base/filter_collection.h" | 105 #include "media/base/filter_collection.h" |
106 #include "media/base/media_switches.h" | 106 #include "media/base/media_switches.h" |
107 #include "media/base/message_loop_factory.h" | 107 #include "media/base/message_loop_factory.h" |
108 #include "media/filters/audio_renderer_impl.h" | 108 #include "media/filters/audio_renderer_impl.h" |
109 #include "media/filters/gpu_video_decoder.h" | 109 #include "media/filters/gpu_video_decoder.h" |
110 #include "net/base/data_url.h" | 110 #include "net/base/data_url.h" |
111 #include "net/base/escape.h" | 111 #include "net/base/escape.h" |
112 #include "net/base/net_errors.h" | 112 #include "net/base/net_errors.h" |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 // Create renderer_accessibility_ if needed. | 697 // Create renderer_accessibility_ if needed. |
698 OnSetAccessibilityMode(accessibility_mode); | 698 OnSetAccessibilityMode(accessibility_mode); |
699 | 699 |
700 new IdleUserDetector(this); | 700 new IdleUserDetector(this); |
701 | 701 |
702 if (command_line.HasSwitch(switches::kDomAutomationController)) | 702 if (command_line.HasSwitch(switches::kDomAutomationController)) |
703 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; | 703 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
704 | 704 |
705 ProcessViewLayoutFlags(command_line); | 705 ProcessViewLayoutFlags(command_line); |
706 | 706 |
| 707 new WebUIExtensionData(this); |
| 708 |
707 GetContentClient()->renderer()->RenderViewCreated(this); | 709 GetContentClient()->renderer()->RenderViewCreated(this); |
708 | 710 |
709 // If we have an opener_id but we weren't created by a renderer, then | 711 // If we have an opener_id but we weren't created by a renderer, then |
710 // it's the browser asking us to set our opener to another RenderView. | 712 // it's the browser asking us to set our opener to another RenderView. |
711 if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) { | 713 if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) { |
712 RenderViewImpl* opener_view = FromRoutingID(opener_id); | 714 RenderViewImpl* opener_view = FromRoutingID(opener_id); |
713 if (opener_view) | 715 if (opener_view) |
714 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); | 716 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); |
715 } | 717 } |
716 | 718 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) | 922 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) |
921 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) | 923 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) |
922 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) | 924 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
923 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) | 925 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
924 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) | 926 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
925 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) | 927 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
926 IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) | 928 IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) |
927 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, | 929 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
928 OnDragSourceSystemDragEnded) | 930 OnDragSourceSystemDragEnded) |
929 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) | 931 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
930 IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty) | |
931 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) | 932 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
932 IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoRect, | 933 IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoRect, |
933 OnScrollFocusedEditableNodeIntoRect) | 934 OnScrollFocusedEditableNodeIntoRect) |
934 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) | 935 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
935 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) | 936 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
936 IPC_MESSAGE_HANDLER(ViewMsg_TimezoneChange, OnUpdateTimezone) | 937 IPC_MESSAGE_HANDLER(ViewMsg_TimezoneChange, OnUpdateTimezone) |
937 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) | 938 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) |
938 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, | 939 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
939 OnEnumerateDirectoryResponse) | 940 OnEnumerateDirectoryResponse) |
940 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) | 941 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(), | 3383 RenderViewNavigatedToHost(GURL(GetLoadingUrl(frame)).host(), |
3383 g_view_map.Get().size()); | 3384 g_view_map.Get().size()); |
3384 } | 3385 } |
3385 } | 3386 } |
3386 } | 3387 } |
3387 | 3388 |
3388 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { | 3389 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { |
3389 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 3390 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
3390 DidClearWindowObject(frame)); | 3391 DidClearWindowObject(frame)); |
3391 | 3392 |
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) { | 3393 if (enabled_bindings_ & BINDINGS_POLICY_DOM_AUTOMATION) { |
3400 if (!dom_automation_controller_.get()) | 3394 if (!dom_automation_controller_.get()) |
3401 dom_automation_controller_.reset(new DomAutomationController()); | 3395 dom_automation_controller_.reset(new DomAutomationController()); |
3402 dom_automation_controller_->set_message_sender( | 3396 dom_automation_controller_->set_message_sender( |
3403 static_cast<RenderView*>(this)); | 3397 static_cast<RenderView*>(this)); |
3404 dom_automation_controller_->set_routing_id(routing_id()); | 3398 dom_automation_controller_->set_routing_id(routing_id()); |
3405 dom_automation_controller_->BindToJavascript(frame, | 3399 dom_automation_controller_->BindToJavascript(frame, |
3406 "domAutomationController"); | 3400 "domAutomationController"); |
3407 } | 3401 } |
3408 | 3402 |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4599 | 4593 |
4600 GURL RenderViewImpl::GetLoadingUrl(WebKit::WebFrame* frame) const { | 4594 GURL RenderViewImpl::GetLoadingUrl(WebKit::WebFrame* frame) const { |
4601 WebDataSource* ds = frame->dataSource(); | 4595 WebDataSource* ds = frame->dataSource(); |
4602 if (ds->hasUnreachableURL()) | 4596 if (ds->hasUnreachableURL()) |
4603 return ds->unreachableURL(); | 4597 return ds->unreachableURL(); |
4604 | 4598 |
4605 const WebURLRequest& request = ds->request(); | 4599 const WebURLRequest& request = ds->request(); |
4606 return request.url(); | 4600 return request.url(); |
4607 } | 4601 } |
4608 | 4602 |
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() { | 4603 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { |
4618 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); | 4604 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
4619 } | 4605 } |
4620 | 4606 |
4621 void RenderViewImpl::OnFind(int request_id, | 4607 void RenderViewImpl::OnFind(int request_id, |
4622 const string16& search_text, | 4608 const string16& search_text, |
4623 const WebFindOptions& options) { | 4609 const WebFindOptions& options) { |
4624 #if defined(OS_ANDROID) | 4610 #if defined(OS_ANDROID) |
4625 // Make sure any asynchronous messages do not disrupt an ongoing synchronous | 4611 // 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 | 4612 // find request as it might lead to deadlocks. Also, these should be safe to |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5016 WebDocument::UserStyleAuthorLevel); | 5002 WebDocument::UserStyleAuthorLevel); |
5017 } | 5003 } |
5018 | 5004 |
5019 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { | 5005 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
5020 enabled_bindings_ |= enabled_bindings_flags; | 5006 enabled_bindings_ |= enabled_bindings_flags; |
5021 | 5007 |
5022 // Keep track of the total bindings accumulated in this process. | 5008 // Keep track of the total bindings accumulated in this process. |
5023 RenderProcess::current()->AddBindings(enabled_bindings_flags); | 5009 RenderProcess::current()->AddBindings(enabled_bindings_flags); |
5024 } | 5010 } |
5025 | 5011 |
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, | 5012 void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, |
5035 const gfx::Point& client_point, | 5013 const gfx::Point& client_point, |
5036 const gfx::Point& screen_point, | 5014 const gfx::Point& screen_point, |
5037 WebDragOperationsMask ops, | 5015 WebDragOperationsMask ops, |
5038 int key_modifiers) { | 5016 int key_modifiers) { |
5039 WebDragOperation operation = webview()->dragTargetDragEnter( | 5017 WebDragOperation operation = webview()->dragTargetDragEnter( |
5040 drop_data.ToDragData(), | 5018 drop_data.ToDragData(), |
5041 client_point, | 5019 client_point, |
5042 screen_point, | 5020 screen_point, |
5043 ops, | 5021 ops, |
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6359 } | 6337 } |
6360 #endif | 6338 #endif |
6361 | 6339 |
6362 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( | 6340 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( |
6363 TransportDIB::Handle dib_handle) { | 6341 TransportDIB::Handle dib_handle) { |
6364 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); | 6342 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); |
6365 RenderProcess::current()->ReleaseTransportDIB(dib); | 6343 RenderProcess::current()->ReleaseTransportDIB(dib); |
6366 } | 6344 } |
6367 | 6345 |
6368 } // namespace content | 6346 } // namespace content |
OLD | NEW |