| 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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 // Create renderer_accessibility_ if needed. | 700 // Create renderer_accessibility_ if needed. |
| 701 OnSetAccessibilityMode(accessibility_mode); | 701 OnSetAccessibilityMode(accessibility_mode); |
| 702 | 702 |
| 703 new IdleUserDetector(this); | 703 new IdleUserDetector(this); |
| 704 | 704 |
| 705 if (command_line.HasSwitch(switches::kDomAutomationController)) | 705 if (command_line.HasSwitch(switches::kDomAutomationController)) |
| 706 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; | 706 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
| 707 | 707 |
| 708 ProcessViewLayoutFlags(command_line); | 708 ProcessViewLayoutFlags(command_line); |
| 709 | 709 |
| 710 new WebUIExtensionData(this); |
| 711 |
| 710 GetContentClient()->renderer()->RenderViewCreated(this); | 712 GetContentClient()->renderer()->RenderViewCreated(this); |
| 711 | 713 |
| 712 // If we have an opener_id but we weren't created by a renderer, then | 714 // If we have an opener_id but we weren't created by a renderer, then |
| 713 // it's the browser asking us to set our opener to another RenderView. | 715 // it's the browser asking us to set our opener to another RenderView. |
| 714 if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) { | 716 if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) { |
| 715 RenderViewImpl* opener_view = FromRoutingID(opener_id); | 717 RenderViewImpl* opener_view = FromRoutingID(opener_id); |
| 716 if (opener_view) | 718 if (opener_view) |
| 717 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); | 719 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); |
| 718 } | 720 } |
| 719 | 721 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) | 927 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) |
| 926 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) | 928 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) |
| 927 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) | 929 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
| 928 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) | 930 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
| 929 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) | 931 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
| 930 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) | 932 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
| 931 IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) | 933 IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) |
| 932 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, | 934 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
| 933 OnDragSourceSystemDragEnded) | 935 OnDragSourceSystemDragEnded) |
| 934 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) | 936 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
| 935 IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty) | |
| 936 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) | 937 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
| 937 IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoRect, | 938 IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoRect, |
| 938 OnScrollFocusedEditableNodeIntoRect) | 939 OnScrollFocusedEditableNodeIntoRect) |
| 939 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) | 940 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
| 940 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) | 941 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
| 941 IPC_MESSAGE_HANDLER(ViewMsg_TimezoneChange, OnUpdateTimezone) | 942 IPC_MESSAGE_HANDLER(ViewMsg_TimezoneChange, OnUpdateTimezone) |
| 942 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) | 943 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) |
| 943 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, | 944 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
| 944 OnEnumerateDirectoryResponse) | 945 OnEnumerateDirectoryResponse) |
| 945 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) | 946 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
| (...skipping 2439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3385 RenderViewNavigatedToHost(GURL(GetLoadingUrl(frame)).host(), | 3386 RenderViewNavigatedToHost(GURL(GetLoadingUrl(frame)).host(), |
| 3386 g_view_map.Get().size()); | 3387 g_view_map.Get().size()); |
| 3387 } | 3388 } |
| 3388 } | 3389 } |
| 3389 } | 3390 } |
| 3390 | 3391 |
| 3391 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { | 3392 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { |
| 3392 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 3393 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 3393 DidClearWindowObject(frame)); | 3394 DidClearWindowObject(frame)); |
| 3394 | 3395 |
| 3395 GURL frame_url = frame->document().url(); | |
| 3396 if ((enabled_bindings_ & BINDINGS_POLICY_WEB_UI) && | |
| 3397 (frame_url.SchemeIs(chrome::kChromeUIScheme) || | |
| 3398 frame_url.SchemeIs(chrome::kDataScheme))) { | |
| 3399 GetWebUIBindings()->BindToJavascript(frame, "chrome"); | |
| 3400 } | |
| 3401 | |
| 3402 if (enabled_bindings_ & BINDINGS_POLICY_DOM_AUTOMATION) { | 3396 if (enabled_bindings_ & BINDINGS_POLICY_DOM_AUTOMATION) { |
| 3403 if (!dom_automation_controller_.get()) | 3397 if (!dom_automation_controller_.get()) |
| 3404 dom_automation_controller_.reset(new DomAutomationController()); | 3398 dom_automation_controller_.reset(new DomAutomationController()); |
| 3405 dom_automation_controller_->set_message_sender( | 3399 dom_automation_controller_->set_message_sender( |
| 3406 static_cast<RenderView*>(this)); | 3400 static_cast<RenderView*>(this)); |
| 3407 dom_automation_controller_->set_routing_id(routing_id()); | 3401 dom_automation_controller_->set_routing_id(routing_id()); |
| 3408 dom_automation_controller_->BindToJavascript(frame, | 3402 dom_automation_controller_->BindToJavascript(frame, |
| 3409 "domAutomationController"); | 3403 "domAutomationController"); |
| 3410 } | 3404 } |
| 3411 | 3405 |
| (...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4602 | 4596 |
| 4603 GURL RenderViewImpl::GetLoadingUrl(WebKit::WebFrame* frame) const { | 4597 GURL RenderViewImpl::GetLoadingUrl(WebKit::WebFrame* frame) const { |
| 4604 WebDataSource* ds = frame->dataSource(); | 4598 WebDataSource* ds = frame->dataSource(); |
| 4605 if (ds->hasUnreachableURL()) | 4599 if (ds->hasUnreachableURL()) |
| 4606 return ds->unreachableURL(); | 4600 return ds->unreachableURL(); |
| 4607 | 4601 |
| 4608 const WebURLRequest& request = ds->request(); | 4602 const WebURLRequest& request = ds->request(); |
| 4609 return request.url(); | 4603 return request.url(); |
| 4610 } | 4604 } |
| 4611 | 4605 |
| 4612 WebUIBindings* RenderViewImpl::GetWebUIBindings() { | |
| 4613 if (!web_ui_bindings_.get()) { | |
| 4614 web_ui_bindings_.reset(new WebUIBindings( | |
| 4615 static_cast<RenderView*>(this), routing_id_)); | |
| 4616 } | |
| 4617 return web_ui_bindings_.get(); | |
| 4618 } | |
| 4619 | |
| 4620 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { | 4606 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { |
| 4621 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); | 4607 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
| 4622 } | 4608 } |
| 4623 | 4609 |
| 4624 void RenderViewImpl::OnFind(int request_id, | 4610 void RenderViewImpl::OnFind(int request_id, |
| 4625 const string16& search_text, | 4611 const string16& search_text, |
| 4626 const WebFindOptions& options) { | 4612 const WebFindOptions& options) { |
| 4627 #if defined(OS_ANDROID) | 4613 #if defined(OS_ANDROID) |
| 4628 // Make sure any asynchronous messages do not disrupt an ongoing synchronous | 4614 // Make sure any asynchronous messages do not disrupt an ongoing synchronous |
| 4629 // find request as it might lead to deadlocks. Also, these should be safe to | 4615 // 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... |
| 5019 WebDocument::UserStyleAuthorLevel); | 5005 WebDocument::UserStyleAuthorLevel); |
| 5020 } | 5006 } |
| 5021 | 5007 |
| 5022 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { | 5008 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
| 5023 enabled_bindings_ |= enabled_bindings_flags; | 5009 enabled_bindings_ |= enabled_bindings_flags; |
| 5024 | 5010 |
| 5025 // Keep track of the total bindings accumulated in this process. | 5011 // Keep track of the total bindings accumulated in this process. |
| 5026 RenderProcess::current()->AddBindings(enabled_bindings_flags); | 5012 RenderProcess::current()->AddBindings(enabled_bindings_flags); |
| 5027 } | 5013 } |
| 5028 | 5014 |
| 5029 void RenderViewImpl::OnSetWebUIProperty(const std::string& name, | |
| 5030 const std::string& value) { | |
| 5031 if (enabled_bindings_ & BINDINGS_POLICY_WEB_UI) | |
| 5032 GetWebUIBindings()->SetProperty(name, value); | |
| 5033 else | |
| 5034 NOTREACHED() << "WebUI bindings not enabled."; | |
| 5035 } | |
| 5036 | |
| 5037 void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, | 5015 void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, |
| 5038 const gfx::Point& client_point, | 5016 const gfx::Point& client_point, |
| 5039 const gfx::Point& screen_point, | 5017 const gfx::Point& screen_point, |
| 5040 WebDragOperationsMask ops, | 5018 WebDragOperationsMask ops, |
| 5041 int key_modifiers) { | 5019 int key_modifiers) { |
| 5042 WebDragOperation operation = webview()->dragTargetDragEnter( | 5020 WebDragOperation operation = webview()->dragTargetDragEnter( |
| 5043 drop_data.ToDragData(), | 5021 drop_data.ToDragData(), |
| 5044 client_point, | 5022 client_point, |
| 5045 screen_point, | 5023 screen_point, |
| 5046 ops, | 5024 ops, |
| (...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6349 } | 6327 } |
| 6350 #endif | 6328 #endif |
| 6351 | 6329 |
| 6352 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( | 6330 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( |
| 6353 TransportDIB::Handle dib_handle) { | 6331 TransportDIB::Handle dib_handle) { |
| 6354 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); | 6332 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); |
| 6355 RenderProcess::current()->ReleaseTransportDIB(dib); | 6333 RenderProcess::current()->ReleaseTransportDIB(dib); |
| 6356 } | 6334 } |
| 6357 | 6335 |
| 6358 } // namespace content | 6336 } // namespace content |
| OLD | NEW |