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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1084 base::TrimWhitespace(selection_text.substr(start, length), base::TRIM_ALL, | 1084 base::TrimWhitespace(selection_text.substr(start, length), base::TRIM_ALL, |
1085 &trimmed_selection_text); | 1085 &trimmed_selection_text); |
1086 } | 1086 } |
1087 } | 1087 } |
1088 base::string16 trimmed_params_text; | 1088 base::string16 trimmed_params_text; |
1089 base::TrimWhitespace(params.selection_text, base::TRIM_ALL, | 1089 base::TrimWhitespace(params.selection_text, base::TRIM_ALL, |
1090 &trimmed_params_text); | 1090 &trimmed_params_text); |
1091 return trimmed_params_text != trimmed_selection_text; | 1091 return trimmed_params_text != trimmed_selection_text; |
1092 } | 1092 } |
1093 | 1093 |
1094 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type, | |
1095 const base::string16& message, | |
1096 const base::string16& default_value, | |
1097 const GURL& frame_url, | |
1098 base::string16* result) { | |
1099 // Don't allow further dialogs if we are waiting to swap out, since the | |
1100 // PageGroupLoadDeferrer in our stack prevents it. | |
1101 if (render_view()->suppress_dialogs_until_swap_out_) | |
1102 return false; | |
1103 | |
1104 bool success = false; | |
1105 base::string16 result_temp; | |
1106 if (!result) | |
1107 result = &result_temp; | |
1108 | |
1109 render_view()->SendAndRunNestedMessageLoop( | |
1110 new FrameHostMsg_RunJavaScriptMessage( | |
1111 routing_id_, message, default_value, frame_url, type, &success, | |
1112 result)); | |
1113 return success; | |
1114 } | |
1115 | |
1094 void RenderFrameImpl::DidCommitCompositorFrame() { | 1116 void RenderFrameImpl::DidCommitCompositorFrame() { |
1095 if (compositing_helper_) | 1117 if (compositing_helper_) |
1096 compositing_helper_->DidCommitCompositorFrame(); | 1118 compositing_helper_->DidCommitCompositorFrame(); |
1097 } | 1119 } |
1098 | 1120 |
1099 RenderView* RenderFrameImpl::GetRenderView() { | 1121 RenderView* RenderFrameImpl::GetRenderView() { |
1100 return render_view_.get(); | 1122 return render_view_.get(); |
1101 } | 1123 } |
1102 | 1124 |
1103 int RenderFrameImpl::GetRoutingID() { | 1125 int RenderFrameImpl::GetRoutingID() { |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2009 // was changed, and SyncSelectionIfRequired may send SelectionChanged | 2031 // was changed, and SyncSelectionIfRequired may send SelectionChanged |
2010 // to notify the selection was changed. Focus change should be notified | 2032 // to notify the selection was changed. Focus change should be notified |
2011 // before selection change. | 2033 // before selection change. |
2012 GetRenderWidget()->UpdateTextInputType(); | 2034 GetRenderWidget()->UpdateTextInputType(); |
2013 SyncSelectionIfRequired(); | 2035 SyncSelectionIfRequired(); |
2014 #if defined(OS_ANDROID) | 2036 #if defined(OS_ANDROID) |
2015 GetRenderWidget()->UpdateTextInputState(false, true); | 2037 GetRenderWidget()->UpdateTextInputState(false, true); |
2016 #endif | 2038 #endif |
2017 } | 2039 } |
2018 | 2040 |
2041 void RenderFrameImpl::runModalAlertDialog(blink::WebFrame* frame, | |
2042 const blink::WebString& message) { | |
2043 DCHECK(!frame_ || frame_ == frame); | |
jam
2014/04/05 00:21:38
please move renderviewimpl to call renderframeimpl
Avi (use Gerrit)
2014/04/07 18:03:46
Done.
| |
2044 RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_ALERT, | |
2045 message, | |
2046 base::string16(), | |
2047 frame->document().url(), | |
2048 NULL); | |
2049 } | |
2050 | |
2051 bool RenderFrameImpl::runModalConfirmDialog(blink::WebFrame* frame, | |
2052 const blink::WebString& message) { | |
2053 DCHECK(!frame_ || frame_ == frame); | |
2054 return RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_CONFIRM, | |
2055 message, | |
2056 base::string16(), | |
2057 frame->document().url(), | |
2058 NULL); | |
2059 } | |
2060 | |
2061 bool RenderFrameImpl::runModalPromptDialog( | |
2062 blink::WebFrame* frame, | |
2063 const blink::WebString& message, | |
2064 const blink::WebString& default_value, | |
2065 blink::WebString* actual_value) { | |
2066 DCHECK(!frame_ || frame_ == frame); | |
2067 base::string16 result; | |
2068 bool ok = RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_PROMPT, | |
2069 message, | |
2070 default_value, | |
2071 frame->document().url(), | |
2072 &result); | |
2073 if (ok) | |
2074 actual_value->assign(result); | |
2075 return ok; | |
2076 } | |
2077 | |
2078 bool RenderFrameImpl::runModalBeforeUnloadDialog( | |
2079 blink::WebFrame* frame, | |
2080 bool is_reload, | |
2081 const blink::WebString& message) { | |
2082 DCHECK(!frame_ || frame_ == frame); | |
2083 // If we are swapping out, we have already run the beforeunload handler. | |
2084 // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload | |
2085 // at all, to avoid running it twice. | |
2086 if (is_swapped_out_) | |
nasko
2014/04/07 15:45:51
This should check the swapped out sate on the rend
Avi (use Gerrit)
2014/04/07 15:51:54
Huh? I thought that the RenderFrameHost swapped st
Avi (use Gerrit)
2014/04/07 18:03:46
Done.
| |
2087 return true; | |
2088 | |
2089 // Don't allow further dialogs if we are waiting to swap out, since the | |
2090 // PageGroupLoadDeferrer in our stack prevents it. | |
2091 if (render_view()->suppress_dialogs_until_swap_out_) | |
2092 return false; | |
2093 | |
2094 bool success = false; | |
2095 // This is an ignored return value, but is included so we can accept the same | |
2096 // response as RunJavaScriptMessage. | |
2097 base::string16 ignored_result; | |
2098 render_view()->SendAndRunNestedMessageLoop( | |
2099 new FrameHostMsg_RunBeforeUnloadConfirm( | |
2100 routing_id_, frame->document().url(), message, is_reload, | |
2101 &success, &ignored_result)); | |
2102 return success; | |
2103 } | |
2104 | |
2019 void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) { | 2105 void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) { |
2020 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); | 2106 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); |
2021 params.source_type = GetRenderWidget()->context_menu_source_type(); | 2107 params.source_type = GetRenderWidget()->context_menu_source_type(); |
2022 if (params.source_type == ui::MENU_SOURCE_TOUCH_EDIT_MENU) { | 2108 if (params.source_type == ui::MENU_SOURCE_TOUCH_EDIT_MENU) { |
2023 params.x = GetRenderWidget()->touch_editing_context_menu_location().x(); | 2109 params.x = GetRenderWidget()->touch_editing_context_menu_location().x(); |
2024 params.y = GetRenderWidget()->touch_editing_context_menu_location().y(); | 2110 params.y = GetRenderWidget()->touch_editing_context_menu_location().y(); |
2025 } | 2111 } |
2026 GetRenderWidget()->OnShowHostContextMenu(¶ms); | 2112 GetRenderWidget()->OnShowHostContextMenu(¶ms); |
2027 | 2113 |
2028 // Plugins, e.g. PDF, don't currently update the render view when their | 2114 // Plugins, e.g. PDF, don't currently update the render view when their |
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3078 selection_text_offset_ = offset; | 3164 selection_text_offset_ = offset; |
3079 selection_range_ = range; | 3165 selection_range_ = range; |
3080 // This IPC is dispatched by RenderWidetHost, so use its routing ID. | 3166 // This IPC is dispatched by RenderWidetHost, so use its routing ID. |
3081 Send(new ViewHostMsg_SelectionChanged( | 3167 Send(new ViewHostMsg_SelectionChanged( |
3082 GetRenderWidget()->routing_id(), text, offset, range)); | 3168 GetRenderWidget()->routing_id(), text, offset, range)); |
3083 } | 3169 } |
3084 GetRenderWidget()->UpdateSelectionBounds(); | 3170 GetRenderWidget()->UpdateSelectionBounds(); |
3085 } | 3171 } |
3086 | 3172 |
3087 } // namespace content | 3173 } // namespace content |
OLD | NEW |