Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: content/renderer/render_frame_impl.cc

Issue 226503002: Move modal dialogs from WebViewClient to WebFrameClient, part 1/3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: works Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 357ddbf4277a09fba084fb21b590eb0dde412b75..a0ddeefe0146ad12c26c9d4c62fc3b2fd60a84c4 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -1091,6 +1091,28 @@ bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams(
return trimmed_params_text != trimmed_selection_text;
}
+bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type,
+ const base::string16& message,
+ const base::string16& default_value,
+ const GURL& frame_url,
+ base::string16* result) {
+ // Don't allow further dialogs if we are waiting to swap out, since the
+ // PageGroupLoadDeferrer in our stack prevents it.
+ if (render_view()->suppress_dialogs_until_swap_out_)
+ return false;
+
+ bool success = false;
+ base::string16 result_temp;
+ if (!result)
+ result = &result_temp;
+
+ render_view()->SendAndRunNestedMessageLoop(
+ new FrameHostMsg_RunJavaScriptMessage(
+ routing_id_, message, default_value, frame_url, type, &success,
+ result));
+ return success;
+}
+
void RenderFrameImpl::DidCommitCompositorFrame() {
if (compositing_helper_)
compositing_helper_->DidCommitCompositorFrame();
@@ -2016,6 +2038,62 @@ void RenderFrameImpl::didChangeSelection(bool is_empty_selection) {
#endif
}
+void RenderFrameImpl::runModalAlertDialog(const blink::WebString& message) {
+ RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_ALERT,
+ message,
+ base::string16(),
+ frame_->document().url(),
+ NULL);
+}
+
+bool RenderFrameImpl::runModalConfirmDialog(const blink::WebString& message) {
+ return RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_CONFIRM,
+ message,
+ base::string16(),
+ frame_->document().url(),
+ NULL);
+}
+
+bool RenderFrameImpl::runModalPromptDialog(
+ const blink::WebString& message,
+ const blink::WebString& default_value,
+ blink::WebString* actual_value) {
+ base::string16 result;
+ bool ok = RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_PROMPT,
+ message,
+ default_value,
+ frame_->document().url(),
+ &result);
+ if (ok)
+ actual_value->assign(result);
+ return ok;
+}
+
+bool RenderFrameImpl::runModalBeforeUnloadDialog(
+ bool is_reload,
+ const blink::WebString& message) {
+ // If we are swapping out, we have already run the beforeunload handler.
+ // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload
+ // at all, to avoid running it twice.
+ if (render_view()->is_swapped_out_)
+ return true;
+
+ // Don't allow further dialogs if we are waiting to swap out, since the
+ // PageGroupLoadDeferrer in our stack prevents it.
+ if (render_view()->suppress_dialogs_until_swap_out_)
+ return false;
+
+ bool success = false;
+ // This is an ignored return value, but is included so we can accept the same
+ // response as RunJavaScriptMessage.
+ base::string16 ignored_result;
+ render_view()->SendAndRunNestedMessageLoop(
+ new FrameHostMsg_RunBeforeUnloadConfirm(
+ routing_id_, frame_->document().url(), message, is_reload,
+ &success, &ignored_result));
+ return success;
+}
+
void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) {
ContextMenuParams params = ContextMenuParamsBuilder::Build(data);
params.source_type = GetRenderWidget()->context_menu_source_type();

Powered by Google App Engine
This is Rietveld 408576698