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

Side by Side Diff: webkit/glue/webview_delegate.h

Issue 196128: Hook up WebViewClient, part 1.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | « webkit/glue/webframeloaderclient_impl.cc ('k') | webkit/glue/webview_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 // WebCore provides hooks for several kinds of functionality, allowing separate 5 // WebCore provides hooks for several kinds of functionality, allowing separate
6 // classes termed "delegates" to receive notifications (in the form of direct 6 // classes termed "delegates" to receive notifications (in the form of direct
7 // function calls) when certain events are about to occur or have just occurred. 7 // function calls) when certain events are about to occur or have just occurred.
8 // In some cases, the delegate implements the needed functionality; in others, 8 // In some cases, the delegate implements the needed functionality; in others,
9 // the delegate has some control over the behavior but doesn't actually 9 // the delegate has some control over the behavior but doesn't actually
10 // implement it. For example, the UI delegate is responsible for showing a 10 // implement it. For example, the UI delegate is responsible for showing a
(...skipping 13 matching lines...) Expand all
24 // implementation; and some WebView additions. 24 // implementation; and some WebView additions.
25 25
26 #ifndef WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ 26 #ifndef WEBKIT_GLUE_WEBVIEW_DELEGATE_H_
27 #define WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ 27 #define WEBKIT_GLUE_WEBVIEW_DELEGATE_H_
28 28
29 #include <vector> 29 #include <vector>
30 30
31 #include "webkit/api/public/WebDragOperation.h" 31 #include "webkit/api/public/WebDragOperation.h"
32 #include "webkit/api/public/WebFrame.h" 32 #include "webkit/api/public/WebFrame.h"
33 #include "webkit/api/public/WebTextDirection.h" 33 #include "webkit/api/public/WebTextDirection.h"
34 #include "webkit/api/public/WebWidgetClient.h" 34 #include "webkit/api/public/WebViewClient.h"
35 #include "webkit/glue/context_menu.h" 35 #include "webkit/glue/context_menu.h"
36 36
37 namespace WebCore { 37 namespace WebCore {
38 class AccessibilityObject; 38 class AccessibilityObject;
39 } 39 }
40 40
41 namespace WebKit { 41 namespace WebKit {
42 class WebDragData; 42 class WebDragData;
43 class WebNotificationPresenter; 43 class WebNotificationPresenter;
44 class WebWidget; 44 class WebWidget;
(...skipping 13 matching lines...) Expand all
58 class WebFileChooserCallback { 58 class WebFileChooserCallback {
59 public: 59 public:
60 WebFileChooserCallback() {} 60 WebFileChooserCallback() {}
61 virtual ~WebFileChooserCallback() {} 61 virtual ~WebFileChooserCallback() {}
62 virtual void OnFileChoose(const std::vector<FilePath>& file_names) { } 62 virtual void OnFileChoose(const std::vector<FilePath>& file_names) { }
63 63
64 private: 64 private:
65 DISALLOW_COPY_AND_ASSIGN(WebFileChooserCallback); 65 DISALLOW_COPY_AND_ASSIGN(WebFileChooserCallback);
66 }; 66 };
67 67
68 68 // TODO(darin): Eliminate WebViewDelegate in favor of WebViewClient.
69 // Inheritance here is somewhat weird, but since a WebView is a WebWidget, 69 class WebViewDelegate : public WebKit::WebViewClient {
70 // it makes sense that a WebViewDelegate is a WebWidgetClient.
71 class WebViewDelegate : virtual public WebKit::WebWidgetClient {
72 public: 70 public:
73 // WebView additions ------------------------------------------------------- 71 // WebView additions -------------------------------------------------------
74 72
75 // This method is called to create a new WebView. The WebView should not be
76 // made visible until the new WebView's Delegate has its Show method called.
77 // The returned WebView pointer is assumed to be owned by the host window,
78 // and the caller of CreateWebView should not release the given WebView.
79 // |user_gesture| is true if a user action initiated this call.
80 // |creator_url|, if nonempty, holds the security origin of the page creating
81 // this WebView.
82 virtual WebView* CreateWebView(WebView* webview,
83 bool user_gesture,
84 const GURL& creator_url) {
85 return NULL;
86 }
87
88 // This method is called to create a new WebWidget to act as a popup
89 // (like a drop-down menu).
90 virtual WebKit::WebWidget* CreatePopupWidget(
91 WebView* webview,
92 bool activatable) {
93 return NULL;
94 }
95
96 // Like CreatePopupWidget, except the actual widget is rendered by the
97 // embedder using the supplied info.
98 virtual WebKit::WebWidget* CreatePopupWidgetWithInfo(
99 WebView* webview,
100 const WebKit::WebPopupMenuInfo& info) {
101 return NULL;
102 }
103
104 // Notifies how many matches have been found so far, for a given request_id. 73 // Notifies how many matches have been found so far, for a given request_id.
105 // |final_update| specifies whether this is the last update (all frames have 74 // |final_update| specifies whether this is the last update (all frames have
106 // completed scoping). 75 // completed scoping).
107 virtual void ReportFindInPageMatchCount(int count, int request_id, 76 virtual void ReportFindInPageMatchCount(int count, int request_id,
108 bool final_update) { 77 bool final_update) {
109 } 78 }
110 79
111 // Notifies the browser what tick-mark rect is currently selected. Parameter 80 // Notifies the browser what tick-mark rect is currently selected. Parameter
112 // |request_id| lets the recipient know which request this message belongs to, 81 // |request_id| lets the recipient know which request this message belongs to,
113 // so that it can choose to ignore the message if it has moved on to other 82 // so that it can choose to ignore the message if it has moved on to other
(...skipping 18 matching lines...) Expand all
132 } 101 }
133 102
134 // FrameLoaderClient ------------------------------------------------------- 103 // FrameLoaderClient -------------------------------------------------------
135 104
136 virtual bool CanAcceptLoadDrops() const { 105 virtual bool CanAcceptLoadDrops() const {
137 // Always return true here so layout tests (which use the default WebView 106 // Always return true here so layout tests (which use the default WebView
138 // delegate) continue to pass. 107 // delegate) continue to pass.
139 return true; 108 return true;
140 } 109 }
141 110
142 // Notifies the delegate that a load has begun.
143 virtual void DidStartLoading(WebView* webview) {
144 }
145
146 // Notifies the delegate that all loads are finished.
147 virtual void DidStopLoading(WebView* webview) {
148 }
149
150 // Notifies that a new script context has been created for this frame. 111 // Notifies that a new script context has been created for this frame.
151 // This is similar to WindowObjectCleared but only called once per frame 112 // This is similar to WindowObjectCleared but only called once per frame
152 // context. 113 // context.
153 virtual void DidCreateScriptContextForFrame(WebKit::WebFrame* webframe) { 114 virtual void DidCreateScriptContextForFrame(WebKit::WebFrame* webframe) {
154 } 115 }
155 116
156 // Notifies that this frame's script context has been destroyed. 117 // Notifies that this frame's script context has been destroyed.
157 virtual void DidDestroyScriptContextForFrame(WebKit::WebFrame* webframe) { 118 virtual void DidDestroyScriptContextForFrame(WebKit::WebFrame* webframe) {
158 } 119 }
159 120
160 // Notifies that a garbage-collected context was created - content scripts. 121 // Notifies that a garbage-collected context was created - content scripts.
161 virtual void DidCreateIsolatedScriptContext(WebKit::WebFrame* webframe) { 122 virtual void DidCreateIsolatedScriptContext(WebKit::WebFrame* webframe) {
162 } 123 }
163 124
164 // ChromeClient ------------------------------------------------------------ 125 // ChromeClient ------------------------------------------------------------
165 126
166 // Appends a line to the application's error console. The message contains
167 // an error description or other information, the line_no provides a line
168 // number (e.g. for a JavaScript error report), and the source_id contains
169 // a URL or other description of the source of the message.
170 virtual void AddMessageToConsole(WebView* webview,
171 const std::wstring& message,
172 unsigned int line_no,
173 const std::wstring& source_id) {
174 }
175
176 // Queries the browser for suggestions to be shown for the form text field 127 // Queries the browser for suggestions to be shown for the form text field
177 // named |field_name|. |text| is the text entered by the user so far and 128 // named |field_name|. |text| is the text entered by the user so far and
178 // |node_id| is the id of the node of the input field. 129 // |node_id| is the id of the node of the input field.
179 virtual void QueryFormFieldAutofill(const std::wstring& field_name, 130 virtual void QueryFormFieldAutofill(const std::wstring& field_name,
180 const std::wstring& text, 131 const std::wstring& text,
181 int64 node_id) { 132 int64 node_id) {
182 } 133 }
183 134
184 // Instructs the browser to remove the autofill entry specified from it DB. 135 // Instructs the browser to remove the autofill entry specified from it DB.
185 virtual void RemoveStoredAutofillEntry(const std::wstring& name, 136 virtual void RemoveStoredAutofillEntry(const std::wstring& name,
186 const std::wstring& value) { 137 const std::wstring& value) {
187 } 138 }
188 139
189 // Called to retrieve the provider of desktop notifications. Pointer 140 // Called to retrieve the provider of desktop notifications. Pointer
190 // is owned by the implementation of WebViewDelegate. 141 // is owned by the implementation of WebViewDelegate.
191 virtual WebKit::WebNotificationPresenter* GetNotificationPresenter() { 142 virtual WebKit::WebNotificationPresenter* GetNotificationPresenter() {
192 return NULL; 143 return NULL;
193 } 144 }
194 145
195 // UIDelegate -------------------------------------------------------------- 146 // UIDelegate --------------------------------------------------------------
196 147
197 // Displays a JavaScript alert panel associated with the given view. Clients
198 // should visually indicate that this panel comes from JavaScript and some
199 // information about the originating frame (at least the domain). The panel
200 // should have a single OK button.
201 virtual void RunJavaScriptAlert(WebKit::WebFrame* webframe,
202 const std::wstring& message) {
203 }
204
205 // Displays a JavaScript confirm panel associated with the given view.
206 // Clients should visually indicate that this panel comes
207 // from JavaScript. The panel should have two buttons, e.g. "OK" and
208 // "Cancel". Returns true if the user hit OK, or false if the user hit Cancel.
209 virtual bool RunJavaScriptConfirm(WebKit::WebFrame* webframe,
210 const std::wstring& message) {
211 return false;
212 }
213
214 // Displays a JavaScript text input panel associated with the given view.
215 // Clients should visually indicate that this panel comes from JavaScript.
216 // The panel should have two buttons, e.g. "OK" and "Cancel", and an area to
217 // type text. The default_value should appear as the initial text in the
218 // panel when it is shown. If the user hit OK, returns true and fills result
219 // with the text in the box. The value of result is undefined if the user
220 // hit Cancel.
221 virtual bool RunJavaScriptPrompt(WebKit::WebFrame* webframe,
222 const std::wstring& message,
223 const std::wstring& default_value,
224 std::wstring* result) {
225 return false;
226 }
227
228 // Sets the status bar text.
229 virtual void SetStatusbarText(WebView* webview,
230 const std::wstring& message) { }
231
232 // Displays a "before unload" confirm panel associated with the given view.
233 // The panel should have two buttons, e.g. "OK" and "Cancel", where OK means
234 // that the navigation should continue, and Cancel means that the navigation
235 // should be cancelled, leaving the user on the current page. Returns true
236 // if the user hit OK, or false if the user hit Cancel.
237 virtual bool RunBeforeUnloadConfirm(WebKit::WebFrame* webframe,
238 const std::wstring& message) {
239 return true; // OK, continue to navigate away
240 }
241
242 // Tells the client that we're hovering over a link with a given URL,
243 // if the node is not a link, the URL will be an empty GURL.
244 virtual void UpdateTargetURL(WebView* webview,
245 const GURL& url) {
246 }
247
248 // Called to display a file chooser prompt. The prompt should be pre- 148 // Called to display a file chooser prompt. The prompt should be pre-
249 // populated with the given initial_filename string. The WebViewDelegate 149 // populated with the given initial_filename string. The WebViewDelegate
250 // will own the WebFileChooserCallback object and is responsible for 150 // will own the WebFileChooserCallback object and is responsible for
251 // freeing it. 151 // freeing it.
252 virtual void RunFileChooser(bool multi_select, 152 virtual void RunFileChooser(bool multi_select,
253 const string16& title, 153 const string16& title,
254 const FilePath& initial_filename, 154 const FilePath& initial_filename,
255 WebFileChooserCallback* file_chooser) { 155 WebFileChooserCallback* file_chooser) {
256 delete file_chooser; 156 delete file_chooser;
257 } 157 }
(...skipping 30 matching lines...) Expand all
288 const GURL& page_url, 188 const GURL& page_url,
289 const GURL& frame_url, 189 const GURL& frame_url,
290 const ContextMenuMediaParams& media_params, 190 const ContextMenuMediaParams& media_params,
291 const std::wstring& selection_text, 191 const std::wstring& selection_text,
292 const std::wstring& misspelled_word, 192 const std::wstring& misspelled_word,
293 int edit_flags, 193 int edit_flags,
294 const std::string& security_info, 194 const std::string& security_info,
295 const std::string& frame_charset) { 195 const std::string& frame_charset) {
296 } 196 }
297 197
298 // Starts a drag session with the supplied contextual information.
299 // webview: The WebView sending the delegate method.
300 // mouseCoords: Current mouse coordinates
301 // drop_data: a WebDropData struct which should contain all the necessary
302 // information for dragging data out of the webview.
303 // drag_source_operation_mask: indicates what drag operations are allowed
304 virtual void StartDragging(WebView* webview,
305 const WebKit::WebPoint &mouseCoords,
306 const WebKit::WebDragData& drag_data,
307 WebKit::WebDragOperationsMask operations_mask) {
308 }
309
310 // Returns the focus to the client.
311 // reverse: Whether the focus should go to the previous (if true) or the next
312 // focusable element.
313 virtual void TakeFocus(WebView* webview, bool reverse) {
314 }
315
316 // Notification that a user metric has occurred. 198 // Notification that a user metric has occurred.
317 virtual void UserMetricsRecordAction(const std::wstring& action) { } 199 virtual void UserMetricsRecordAction(const std::wstring& action) { }
318 200
319 // ------------------------------------------------------------------------- 201 // -------------------------------------------------------------------------
320 202
321 // Notification that a request to download an image has completed. |errored| 203 // Notification that a request to download an image has completed. |errored|
322 // indicates if there was a network error. The image is empty if there was 204 // indicates if there was a network error. The image is empty if there was
323 // a network error, the contents of the page couldn't by converted to an 205 // a network error, the contents of the page couldn't by converted to an
324 // image, or the response from the host was not 200. 206 // image, or the response from the host was not 200.
325 // NOTE: image is empty if the response didn't contain image data. 207 // NOTE: image is empty if the response didn't contain image data.
326 virtual void DidDownloadImage(int id, 208 virtual void DidDownloadImage(int id,
327 const GURL& image_url, 209 const GURL& image_url,
328 bool errored, 210 bool errored,
329 const SkBitmap& image) { 211 const SkBitmap& image) {
330 } 212 }
331 213
332 // History Related --------------------------------------------------------- 214 // History Related ---------------------------------------------------------
333 215
334 // Tells the embedder to navigate back or forward in session history by the
335 // given offset (relative to the current position in session history).
336 virtual void NavigateBackForwardSoon(int offset) {
337 }
338
339 // Returns how many entries are in the back and forward lists, respectively.
340 virtual int GetHistoryBackListCount() {
341 return 0;
342 }
343 virtual int GetHistoryForwardListCount() {
344 return 0;
345 }
346
347 // -------------------------------------------------------------------------
348
349 // Tell the delegate the tooltip text and its directionality hint for the
350 // current mouse position.
351 virtual void SetTooltipText(WebView* webview,
352 const std::wstring& tooltip_text,
353 WebKit::WebTextDirection text_direction_hint) { }
354
355 // InspectorClient --------------------------------------------------------- 216 // InspectorClient ---------------------------------------------------------
356 217
357 virtual void UpdateInspectorSettings(const std::wstring& raw_settings) { } 218 virtual void UpdateInspectorSettings(const std::wstring& raw_settings) { }
358 219
359 // DevTools ---------------------------------------------------------------- 220 // DevTools ----------------------------------------------------------------
360 221
361 virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate() { 222 virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate() {
362 return NULL; 223 return NULL;
363 } 224 }
364 225
(...skipping 18 matching lines...) Expand all
383 virtual std::wstring GetAutoCorrectWord(const std::wstring& misspelled_word) { 244 virtual std::wstring GetAutoCorrectWord(const std::wstring& misspelled_word) {
384 return std::wstring(); 245 return std::wstring();
385 } 246 }
386 247
387 // Switches the spelling panel to be displayed or not based on |show|. 248 // Switches the spelling panel to be displayed or not based on |show|.
388 virtual void ShowSpellingUI(bool show) { } 249 virtual void ShowSpellingUI(bool show) { }
389 250
390 // Update the spelling panel with the |word|. 251 // Update the spelling panel with the |word|.
391 virtual void UpdateSpellingUIWithMisspelledWord(const std::wstring& word) { } 252 virtual void UpdateSpellingUIWithMisspelledWord(const std::wstring& word) { }
392 253
393 // Asks the user to print the page or a specific frame. Called in response to
394 // a window.print() call.
395 virtual void ScriptedPrint(WebKit::WebFrame* frame) { }
396
397 // Called when an item was added to the history
398 virtual void DidAddHistoryItem() { }
399
400 // The "CurrentKeyboardEvent" refers to the keyboard event passed to 254 // The "CurrentKeyboardEvent" refers to the keyboard event passed to
401 // WebView's handleInputEvent method. 255 // WebView's handleInputEvent method.
402 // 256 //
403 // This method is called in response to WebView's handleInputEvent() when 257 // This method is called in response to WebView's handleInputEvent() when
404 // the default action for the current keyboard event is not suppressed by the 258 // the default action for the current keyboard event is not suppressed by the
405 // page, to give WebViewDelegate a chance to handle the keyboard event 259 // page, to give WebViewDelegate a chance to handle the keyboard event
406 // specially. 260 // specially.
407 // 261 //
408 // Returns true if the keyboard event was handled by WebViewDelegate. 262 // Returns true if the keyboard event was handled by WebViewDelegate.
409 virtual bool HandleCurrentKeyboardEvent() { 263 virtual bool HandleCurrentKeyboardEvent() {
410 return false; 264 return false;
411 } 265 }
412 266
413 protected: 267 protected:
414 ~WebViewDelegate() { } 268 ~WebViewDelegate() { }
415 }; 269 };
416 270
417 #endif // WEBKIT_GLUE_WEBVIEW_DELEGATE_H_ 271 #endif // WEBKIT_GLUE_WEBVIEW_DELEGATE_H_
OLDNEW
« no previous file with comments | « webkit/glue/webframeloaderclient_impl.cc ('k') | webkit/glue/webview_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698