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

Side by Side Diff: Source/core/page/ChromeClient.cpp

Issue 1180843006: [DevTools] Add dialog type and return value to Page.javascriptDialog{Opening,Closed}. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: frontend Created 5 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/page/ChromeClient.h ('k') | Source/devtools/front_end/sdk/ResourceTreeModel.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2009, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2009, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2012, Samsung Electronics. All rights reserved. 4 * Copyright (C) 2012, Samsung Electronics. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 void ChromeClient::setWindowFeatures(const WindowFeatures& features) 71 void ChromeClient::setWindowFeatures(const WindowFeatures& features)
72 { 72 {
73 setToolbarsVisible(features.toolBarVisible || features.locationBarVisible); 73 setToolbarsVisible(features.toolBarVisible || features.locationBarVisible);
74 setStatusbarVisible(features.statusBarVisible); 74 setStatusbarVisible(features.statusBarVisible);
75 setScrollbarsVisible(features.scrollbarsVisible); 75 setScrollbarsVisible(features.scrollbarsVisible);
76 setMenubarVisible(features.menuBarVisible); 76 setMenubarVisible(features.menuBarVisible);
77 setResizable(features.resizable); 77 setResizable(features.resizable);
78 } 78 }
79 79
80 class ScopedJavaScriptDialogInstrumentation { 80 template<typename... Params>
81 STACK_ALLOCATED(); 81 bool openJavaScriptDialog(
82 public:
83 ScopedJavaScriptDialogInstrumentation(LocalFrame& frame, const String& messa ge)
84 : m_cookie(InspectorInstrumentation::willRunJavaScriptDialog(&frame, mes sage))
85 {
86 }
87 ~ScopedJavaScriptDialogInstrumentation()
88 {
89 InspectorInstrumentation::didRunJavaScriptDialog(m_cookie);
90 }
91
92 private:
93 InspectorInstrumentationCookie m_cookie;
94 };
95
96 template<typename ReturnType, typename... Params>
97 ReturnType openJavaScriptDialog(
98 ChromeClient* chromeClient, 82 ChromeClient* chromeClient,
99 ReturnType(ChromeClient::*function)(LocalFrame*, const String& message, Para ms&...), 83 bool(ChromeClient::*function)(LocalFrame*, const String& message, Params&... ),
100 LocalFrame& frame, 84 LocalFrame& frame,
101 const String& message, 85 const String& message,
86 ChromeClient::DialogType dialogType,
102 Params&... parameters) 87 Params&... parameters)
103 { 88 {
104 // Defer loads in case the client method runs a new event loop that would 89 // Defer loads in case the client method runs a new event loop that would
105 // otherwise cause the load to continue while we're in the middle of 90 // otherwise cause the load to continue while we're in the middle of
106 // executing JavaScript. 91 // executing JavaScript.
107 ScopedPageLoadDeferrer deferrer; 92 ScopedPageLoadDeferrer deferrer;
108 93
109 ScopedJavaScriptDialogInstrumentation instrumentation(frame, message); 94 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRunJav aScriptDialog(&frame, message, dialogType);
110 return (chromeClient->*function)(&frame, message, parameters...); 95 bool result = (chromeClient->*function)(&frame, message, parameters...);
96 InspectorInstrumentation::didRunJavaScriptDialog(cookie, result);
97 return result;
111 } 98 }
112 99
113 bool ChromeClient::openBeforeUnloadConfirmPanel(const String& message, LocalFram e* frame) 100 bool ChromeClient::openBeforeUnloadConfirmPanel(const String& message, LocalFram e* frame)
114 { 101 {
115 ASSERT(frame); 102 ASSERT(frame);
116 return openJavaScriptDialog(this, &ChromeClient::openBeforeUnloadConfirmPane lDelegate, *frame, message); 103 return openJavaScriptDialog(this, &ChromeClient::openBeforeUnloadConfirmPane lDelegate, *frame, message, ChromeClient::HTMLDialog);
117 } 104 }
118 105
119 void ChromeClient::openJavaScriptAlert(LocalFrame* frame, const String& message) 106 bool ChromeClient::openJavaScriptAlert(LocalFrame* frame, const String& message)
120 { 107 {
121 ASSERT(frame); 108 ASSERT(frame);
122 if (!canOpenModalIfDuringPageDismissal(frame->tree().top(), ChromeClient::Al ertDialog, message)) 109 if (!canOpenModalIfDuringPageDismissal(frame->tree().top(), ChromeClient::Al ertDialog, message))
123 return; 110 return false;
124 openJavaScriptDialog(this, &ChromeClient::openJavaScriptAlertDelegate, *fram e, message); 111 return openJavaScriptDialog(this, &ChromeClient::openJavaScriptAlertDelegate , *frame, message, ChromeClient::AlertDialog);
125 } 112 }
126 113
127 bool ChromeClient::openJavaScriptConfirm(LocalFrame* frame, const String& messag e) 114 bool ChromeClient::openJavaScriptConfirm(LocalFrame* frame, const String& messag e)
128 { 115 {
129 ASSERT(frame); 116 ASSERT(frame);
130 if (!canOpenModalIfDuringPageDismissal(frame->tree().top(), ChromeClient::Co nfirmDialog, message)) 117 if (!canOpenModalIfDuringPageDismissal(frame->tree().top(), ChromeClient::Co nfirmDialog, message))
131 return false; 118 return false;
132 return openJavaScriptDialog(this, &ChromeClient::openJavaScriptConfirmDelega te, *frame, message); 119 return openJavaScriptDialog(this, &ChromeClient::openJavaScriptConfirmDelega te, *frame, message, ChromeClient::ConfirmDialog);
133 } 120 }
134 121
135 bool ChromeClient::openJavaScriptPrompt(LocalFrame* frame, const String& prompt, const String& defaultValue, String& result) 122 bool ChromeClient::openJavaScriptPrompt(LocalFrame* frame, const String& prompt, const String& defaultValue, String& result)
136 { 123 {
137 ASSERT(frame); 124 ASSERT(frame);
138 if (!canOpenModalIfDuringPageDismissal(frame->tree().top(), ChromeClient::Pr omptDialog, prompt)) 125 if (!canOpenModalIfDuringPageDismissal(frame->tree().top(), ChromeClient::Pr omptDialog, prompt))
139 return false; 126 return false;
140 return openJavaScriptDialog(this, &ChromeClient::openJavaScriptPromptDelegat e, *frame, prompt, defaultValue, result); 127 return openJavaScriptDialog(this, &ChromeClient::openJavaScriptPromptDelegat e, *frame, prompt, ChromeClient::PromptDialog, defaultValue, result);
141 } 128 }
142 129
143 void ChromeClient::mouseDidMoveOverElement(const HitTestResult& result) 130 void ChromeClient::mouseDidMoveOverElement(const HitTestResult& result)
144 { 131 {
145 if (result.innerNode() && result.innerNode()->document().isDNSPrefetchEnable d()) 132 if (result.innerNode() && result.innerNode()->document().isDNSPrefetchEnable d())
146 prefetchDNS(result.absoluteLinkURL().host()); 133 prefetchDNS(result.absoluteLinkURL().host());
147 134
148 showMouseOverURL(result); 135 showMouseOverURL(result);
149 136
150 setToolTip(result); 137 setToolTip(result);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 { 173 {
187 // Defer loads in case the client method runs a new event loop that would 174 // Defer loads in case the client method runs a new event loop that would
188 // otherwise cause the load to continue while we're in the middle of 175 // otherwise cause the load to continue while we're in the middle of
189 // executing JavaScript. 176 // executing JavaScript.
190 ScopedPageLoadDeferrer deferrer; 177 ScopedPageLoadDeferrer deferrer;
191 178
192 printDelegate(frame); 179 printDelegate(frame);
193 } 180 }
194 181
195 } // namespace blink 182 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/page/ChromeClient.h ('k') | Source/devtools/front_end/sdk/ResourceTreeModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698