OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "content/public/common/content_switches.h" | 40 #include "content/public/common/content_switches.h" |
41 #include "content/public/common/context_menu_params.h" | 41 #include "content/public/common/context_menu_params.h" |
42 #include "content/public/common/url_constants.h" | 42 #include "content/public/common/url_constants.h" |
43 #include "content/public/common/url_utils.h" | 43 #include "content/public/common/url_utils.h" |
44 #include "content/public/renderer/content_renderer_client.h" | 44 #include "content/public/renderer/content_renderer_client.h" |
45 #include "content/public/renderer/context_menu_client.h" | 45 #include "content/public/renderer/context_menu_client.h" |
46 #include "content/public/renderer/document_state.h" | 46 #include "content/public/renderer/document_state.h" |
47 #include "content/public/renderer/navigation_state.h" | 47 #include "content/public/renderer/navigation_state.h" |
48 #include "content/public/renderer/render_frame_observer.h" | 48 #include "content/public/renderer/render_frame_observer.h" |
49 #include "content/renderer/accessibility/renderer_accessibility.h" | 49 #include "content/renderer/accessibility/renderer_accessibility.h" |
50 #include "content/renderer/accessibility/renderer_accessibility_complete.h" | |
51 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" | |
52 #include "content/renderer/browser_plugin/browser_plugin.h" | 50 #include "content/renderer/browser_plugin/browser_plugin.h" |
53 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 51 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
54 #include "content/renderer/child_frame_compositing_helper.h" | 52 #include "content/renderer/child_frame_compositing_helper.h" |
55 #include "content/renderer/context_menu_params_builder.h" | 53 #include "content/renderer/context_menu_params_builder.h" |
56 #include "content/renderer/devtools/devtools_agent.h" | 54 #include "content/renderer/devtools/devtools_agent.h" |
57 #include "content/renderer/dom_automation_controller.h" | 55 #include "content/renderer/dom_automation_controller.h" |
58 #include "content/renderer/geolocation_dispatcher.h" | 56 #include "content/renderer/geolocation_dispatcher.h" |
59 #include "content/renderer/history_controller.h" | 57 #include "content/renderer/history_controller.h" |
60 #include "content/renderer/history_serialization.h" | 58 #include "content/renderer/history_serialization.h" |
61 #include "content/renderer/image_loading_helper.h" | 59 #include "content/renderer/image_loading_helper.h" |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 #endif | 410 #endif |
413 #if defined(ENABLE_BROWSER_CDMS) | 411 #if defined(ENABLE_BROWSER_CDMS) |
414 cdm_manager_(NULL), | 412 cdm_manager_(NULL), |
415 #endif | 413 #endif |
416 #if defined(VIDEO_HOLE) | 414 #if defined(VIDEO_HOLE) |
417 contains_media_player_(false), | 415 contains_media_player_(false), |
418 #endif | 416 #endif |
419 geolocation_dispatcher_(NULL), | 417 geolocation_dispatcher_(NULL), |
420 push_messaging_dispatcher_(NULL), | 418 push_messaging_dispatcher_(NULL), |
421 screen_orientation_dispatcher_(NULL), | 419 screen_orientation_dispatcher_(NULL), |
422 accessibility_mode_(AccessibilityModeOff), | |
423 renderer_accessibility_(NULL), | |
424 weak_factory_(this) { | 420 weak_factory_(this) { |
425 std::pair<RoutingIDFrameMap::iterator, bool> result = | 421 std::pair<RoutingIDFrameMap::iterator, bool> result = |
426 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); | 422 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); |
427 CHECK(result.second) << "Inserting a duplicate item."; | 423 CHECK(result.second) << "Inserting a duplicate item."; |
428 | 424 |
429 RenderThread::Get()->AddRoute(routing_id_, this); | 425 RenderThread::Get()->AddRoute(routing_id_, this); |
430 | 426 |
431 render_view_->RegisterRenderFrame(this); | 427 render_view_->RegisterRenderFrame(this); |
432 | 428 |
433 #if defined(OS_ANDROID) | 429 #if defined(OS_ANDROID) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 render_view_->set_pepper_last_mouse_event_target(instance); | 500 render_view_->set_pepper_last_mouse_event_target(instance); |
505 } | 501 } |
506 | 502 |
507 void RenderFrameImpl::PepperTextInputTypeChanged( | 503 void RenderFrameImpl::PepperTextInputTypeChanged( |
508 PepperPluginInstanceImpl* instance) { | 504 PepperPluginInstanceImpl* instance) { |
509 if (instance != render_view_->focused_pepper_plugin()) | 505 if (instance != render_view_->focused_pepper_plugin()) |
510 return; | 506 return; |
511 | 507 |
512 GetRenderWidget()->UpdateTextInputState( | 508 GetRenderWidget()->UpdateTextInputState( |
513 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); | 509 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); |
514 if (renderer_accessibility()) | 510 if (render_view_->renderer_accessibility()) |
515 renderer_accessibility()->FocusedNodeChanged(WebNode()); | 511 render_view_->renderer_accessibility()->FocusedNodeChanged(WebNode()); |
516 } | 512 } |
517 | 513 |
518 void RenderFrameImpl::PepperCaretPositionChanged( | 514 void RenderFrameImpl::PepperCaretPositionChanged( |
519 PepperPluginInstanceImpl* instance) { | 515 PepperPluginInstanceImpl* instance) { |
520 if (instance != render_view_->focused_pepper_plugin()) | 516 if (instance != render_view_->focused_pepper_plugin()) |
521 return; | 517 return; |
522 GetRenderWidget()->UpdateSelectionBounds(); | 518 GetRenderWidget()->UpdateSelectionBounds(); |
523 } | 519 } |
524 | 520 |
525 void RenderFrameImpl::PepperCancelComposition( | 521 void RenderFrameImpl::PepperCancelComposition( |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest) | 722 IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest) |
727 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest, | 723 IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest, |
728 OnJavaScriptExecuteRequest) | 724 OnJavaScriptExecuteRequest) |
729 IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets, | 725 IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets, |
730 OnSetEditableSelectionOffsets) | 726 OnSetEditableSelectionOffsets) |
731 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload) | 727 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload) |
732 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest, | 728 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest, |
733 OnTextSurroundingSelectionRequest) | 729 OnTextSurroundingSelectionRequest) |
734 IPC_MESSAGE_HANDLER(FrameMsg_AddStyleSheetByURL, | 730 IPC_MESSAGE_HANDLER(FrameMsg_AddStyleSheetByURL, |
735 OnAddStyleSheetByURL) | 731 OnAddStyleSheetByURL) |
736 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode, | |
737 OnSetAccessibilityMode) | |
738 #if defined(OS_MACOSX) | 732 #if defined(OS_MACOSX) |
739 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) | 733 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) |
740 #endif | 734 #endif |
741 IPC_END_MESSAGE_MAP() | 735 IPC_END_MESSAGE_MAP() |
742 | 736 |
743 return handled; | 737 return handled; |
744 } | 738 } |
745 | 739 |
746 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { | 740 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { |
747 MaybeHandleDebugURL(params.url); | 741 MaybeHandleDebugURL(params.url); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 frame_->setCompositionFromExistingText(start, end, underlines); | 1177 frame_->setCompositionFromExistingText(start, end, underlines); |
1184 } | 1178 } |
1185 | 1179 |
1186 void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) { | 1180 void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) { |
1187 if (!GetRenderWidget()->ShouldHandleImeEvent()) | 1181 if (!GetRenderWidget()->ShouldHandleImeEvent()) |
1188 return; | 1182 return; |
1189 ImeEventGuard guard(GetRenderWidget()); | 1183 ImeEventGuard guard(GetRenderWidget()); |
1190 frame_->extendSelectionAndDelete(before, after); | 1184 frame_->extendSelectionAndDelete(before, after); |
1191 } | 1185 } |
1192 | 1186 |
1193 void RenderFrameImpl::OnSetAccessibilityMode(AccessibilityMode new_mode) { | |
1194 if (accessibility_mode_ == new_mode) | |
1195 return; | |
1196 accessibility_mode_ = new_mode; | |
1197 if (renderer_accessibility_) { | |
1198 delete renderer_accessibility_; | |
1199 renderer_accessibility_ = NULL; | |
1200 } | |
1201 if (accessibility_mode_ == AccessibilityModeOff) | |
1202 return; | |
1203 | |
1204 if (accessibility_mode_ & AccessibilityModeFlagFullTree) | |
1205 renderer_accessibility_ = new RendererAccessibilityComplete(this); | |
1206 #if !defined(OS_ANDROID) | |
1207 else | |
1208 renderer_accessibility_ = new RendererAccessibilityFocusOnly(this); | |
1209 #endif | |
1210 } | |
1211 | |
1212 void RenderFrameImpl::OnReload(bool ignore_cache) { | 1187 void RenderFrameImpl::OnReload(bool ignore_cache) { |
1213 frame_->reload(ignore_cache); | 1188 frame_->reload(ignore_cache); |
1214 } | 1189 } |
1215 | 1190 |
1216 void RenderFrameImpl::OnTextSurroundingSelectionRequest(size_t max_length) { | 1191 void RenderFrameImpl::OnTextSurroundingSelectionRequest(size_t max_length) { |
1217 blink::WebSurroundingText surroundingText; | 1192 blink::WebSurroundingText surroundingText; |
1218 surroundingText.initialize(frame_->selectionRange(), max_length); | 1193 surroundingText.initialize(frame_->selectionRange(), max_length); |
1219 | 1194 |
1220 if (surroundingText.isNull()) { | 1195 if (surroundingText.isNull()) { |
1221 // |surroundingText| might not be correctly initialized, for example if | 1196 // |surroundingText| might not be correctly initialized, for example if |
(...skipping 1938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3160 | 3135 |
3161 void RenderFrameImpl::didStopLoading() { | 3136 void RenderFrameImpl::didStopLoading() { |
3162 render_view_->FrameDidStopLoading(frame_); | 3137 render_view_->FrameDidStopLoading(frame_); |
3163 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 3138 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
3164 } | 3139 } |
3165 | 3140 |
3166 void RenderFrameImpl::didChangeLoadProgress(double load_progress) { | 3141 void RenderFrameImpl::didChangeLoadProgress(double load_progress) { |
3167 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); | 3142 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); |
3168 } | 3143 } |
3169 | 3144 |
3170 void RenderFrameImpl::HandleWebAccessibilityEvent( | |
3171 const blink::WebAXObject& obj, blink::WebAXEvent event) { | |
3172 if (renderer_accessibility_) | |
3173 renderer_accessibility_->HandleWebAccessibilityEvent(obj, event); | |
3174 } | |
3175 | |
3176 void RenderFrameImpl::FocusedNodeChanged(const WebNode& node) { | |
3177 if (renderer_accessibility_) | |
3178 renderer_accessibility_->FocusedNodeChanged(node); | |
3179 } | |
3180 | |
3181 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( | 3145 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( |
3182 RenderFrame* render_frame, | 3146 RenderFrame* render_frame, |
3183 WebFrame* frame, | 3147 WebFrame* frame, |
3184 WebDataSource::ExtraData* extraData, | 3148 WebDataSource::ExtraData* extraData, |
3185 const WebURLRequest& request, | 3149 const WebURLRequest& request, |
3186 WebNavigationType type, | 3150 WebNavigationType type, |
3187 WebNavigationPolicy default_policy, | 3151 WebNavigationPolicy default_policy, |
3188 bool is_redirect) { | 3152 bool is_redirect) { |
3189 #ifdef OS_ANDROID | 3153 #ifdef OS_ANDROID |
3190 // The handlenavigation API is deprecated and will be removed once | 3154 // The handlenavigation API is deprecated and will be removed once |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3610 | 3574 |
3611 #if defined(ENABLE_BROWSER_CDMS) | 3575 #if defined(ENABLE_BROWSER_CDMS) |
3612 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 3576 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
3613 if (!cdm_manager_) | 3577 if (!cdm_manager_) |
3614 cdm_manager_ = new RendererCdmManager(this); | 3578 cdm_manager_ = new RendererCdmManager(this); |
3615 return cdm_manager_; | 3579 return cdm_manager_; |
3616 } | 3580 } |
3617 #endif // defined(ENABLE_BROWSER_CDMS) | 3581 #endif // defined(ENABLE_BROWSER_CDMS) |
3618 | 3582 |
3619 } // namespace content | 3583 } // namespace content |
OLD | NEW |