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

Side by Side Diff: chrome/common/navigation_gesture.h

Issue 200054: Hook up WebFrameClient, replacing many WebViewDelegate methods.... (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 | « chrome/chrome.gyp ('k') | chrome/common/render_messages.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 #ifndef CHROME_COMMON_NAVIGATION_GESTURE_H_
6 // classes termed "delegates" to receive notifications (in the form of direct 6 #define CHROME_COMMON_NAVIGATION_GESTURE_H_
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,
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
11 // dialog box or otherwise handling a JavaScript window.alert() call, via the
12 // RunJavaScriptAlert() method. On the other hand, the editor delegate doesn't
13 // actually handle editing functionality, although it could (for example)
14 // override whether a content-editable node accepts editing focus by returning
15 // false from ShouldBeginEditing(). (It would also possible for a more
16 // special-purpose editing delegate to act on the edited node in some way, e.g.
17 // to highlight modified text in the DidChangeContents() method.)
18
19 // WebKit divides the delegated tasks into several different classes, but we
20 // combine them into a single WebViewDelegate. This single delegate encompasses
21 // the needed functionality of the WebKit UIDelegate, ContextMenuDelegate,
22 // PolicyDelegate, FrameLoadDelegate, and EditorDelegate; additional portions
23 // of ChromeClient and FrameLoaderClient not delegated in the WebKit
24 // implementation; and some WebView additions.
25
26 #ifndef WEBKIT_GLUE_WEBVIEW_DELEGATE_H_
27 #define WEBKIT_GLUE_WEBVIEW_DELEGATE_H_
28
29 #include <vector>
30
31 #include "webkit/api/public/WebFrame.h"
32 #include "webkit/api/public/WebNavigationPolicy.h"
33 #include "webkit/api/public/WebNavigationType.h"
34 #include "webkit/api/public/WebTextDirection.h"
35 #include "webkit/api/public/WebWidgetClient.h"
36 #include "webkit/glue/context_menu.h"
37
38 namespace webkit_glue {
39 class WebMediaPlayerDelegate;
40 struct WebPluginGeometry;
41 }
42
43 namespace WebCore {
44 class AccessibilityObject;
45 }
46
47 namespace WebKit {
48 class WebDataSource;
49 class WebDragData;
50 class WebForm;
51 class WebWorker;
52 class WebWorkerClient;
53 class WebMediaPlayer;
54 class WebMediaPlayerClient;
55 class WebNode;
56 class WebNotificationPresenter;
57 class WebPlugin;
58 class WebURLRequest;
59 class WebURLResponse;
60 class WebWidget;
61 struct WebPluginParams;
62 struct WebPoint;
63 struct WebPopupMenuInfo;
64 struct WebRect;
65 struct WebURLError;
66 }
67
68 class FilePath;
69 class SkBitmap;
70 class WebDevToolsAgentDelegate;
71 class WebMediaPlayerDelegate;
72 class WebView;
73 struct ContextMenuMediaParams;
74 struct WebPreferences;
75 7
76 enum NavigationGesture { 8 enum NavigationGesture {
77 NavigationGestureUser, // User initiated navigation/load. This is not 9 NavigationGestureUser, // User initiated navigation/load. This is not
78 // currently used due to the untrustworthy nature 10 // currently used due to the untrustworthy nature
79 // of userGestureHint (wasRunByUserGesture). See 11 // of userGestureHint (wasRunByUserGesture). See
80 // bug 1051891. 12 // bug 1051891.
81 NavigationGestureAuto, // Non-user initiated navigation / load. For example 13 NavigationGestureAuto, // Non-user initiated navigation / load. For example
82 // onload or setTimeout triggered document.location 14 // onload or setTimeout triggered document.location
83 // changes, and form.submits. See bug 1046841 for 15 // changes, and form.submits. See bug 1046841 for
84 // some cases that should be treated this way but 16 // some cases that should be treated this way but
85 // aren't yet. 17 // aren't yet.
86 NavigationGestureUnknown, // What we assign when userGestureHint returns true 18 NavigationGestureUnknown, // What we assign when userGestureHint returns true
87 // because we can't trust it. 19 // because we can't trust it.
88 }; 20 };
89 21
90 22 #endif // CHROME_COMMON_NAVIGATION_GESTURE_H_
91 // Interface passed in to the WebViewDelegate to receive notification of the
92 // result of an open file dialog.
93 class WebFileChooserCallback {
94 public:
95 WebFileChooserCallback() {}
96 virtual ~WebFileChooserCallback() {}
97 virtual void OnFileChoose(const std::vector<FilePath>& file_names) { }
98
99 private:
100 DISALLOW_COPY_AND_ASSIGN(WebFileChooserCallback);
101 };
102
103
104 // Inheritance here is somewhat weird, but since a WebView is a WebWidget,
105 // it makes sense that a WebViewDelegate is a WebWidgetClient.
106 class WebViewDelegate : virtual public WebKit::WebWidgetClient {
107 public:
108 // WebView additions -------------------------------------------------------
109
110 // This method is called to create a new WebView. The WebView should not be
111 // made visible until the new WebView's Delegate has its Show method called.
112 // The returned WebView pointer is assumed to be owned by the host window,
113 // and the caller of CreateWebView should not release the given WebView.
114 // |user_gesture| is true if a user action initiated this call.
115 // |creator_url|, if nonempty, holds the security origin of the page creating
116 // this WebView.
117 virtual WebView* CreateWebView(WebView* webview,
118 bool user_gesture,
119 const GURL& creator_url) {
120 return NULL;
121 }
122
123 // This method is called to create a new WebWidget to act as a popup
124 // (like a drop-down menu).
125 virtual WebKit::WebWidget* CreatePopupWidget(
126 WebView* webview,
127 bool activatable) {
128 return NULL;
129 }
130
131 // Like CreatePopupWidget, except the actual widget is rendered by the
132 // embedder using the supplied info.
133 virtual WebKit::WebWidget* CreatePopupWidgetWithInfo(
134 WebView* webview,
135 const WebKit::WebPopupMenuInfo& info) {
136 return NULL;
137 }
138
139 virtual WebKit::WebPlugin* CreatePlugin(
140 WebKit::WebFrame* parent_frame,
141 const WebKit::WebPluginParams& params) {
142 return NULL;
143 }
144
145 // This method is called when the renderer creates a worker object.
146 virtual WebKit::WebWorker* CreateWebWorker(WebKit::WebWorkerClient* client) {
147 return NULL;
148 }
149
150 // Called when a WebMediaPlayer is needed.
151 virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer(
152 WebKit::WebMediaPlayerClient* client) {
153 return NULL;
154 }
155
156 // This method is called to open a URL in the specified manner.
157 virtual void OpenURL(WebView* webview, const GURL& url,
158 const GURL& referrer,
159 WebKit::WebNavigationPolicy policy) {
160 }
161
162 // Notifies how many matches have been found so far, for a given request_id.
163 // |final_update| specifies whether this is the last update (all frames have
164 // completed scoping).
165 virtual void ReportFindInPageMatchCount(int count, int request_id,
166 bool final_update) {
167 }
168
169 // Notifies the browser what tick-mark rect is currently selected. Parameter
170 // |request_id| lets the recipient know which request this message belongs to,
171 // so that it can choose to ignore the message if it has moved on to other
172 // things. |selection_rect| is expected to have coordinates relative to the
173 // top left corner of the web page area and represent where on the screen the
174 // selection rect is currently located.
175 virtual void ReportFindInPageSelection(int request_id,
176 int active_match_ordinal,
177 const WebKit::WebRect& selection) {
178 }
179
180 // Returns whether this WebView was opened by a user gesture.
181 virtual bool WasOpenedByUserGesture() const {
182 return true;
183 }
184
185 // Called by ChromeClientImpl::focus() if accessibility on the renderer side
186 // is enabled, and a focus change has occurred. Will retrieve the id of the
187 // input AccessibilityObject and send it through IPC for handling on the
188 // browser side.
189 virtual void FocusAccessibilityObject(WebCore::AccessibilityObject* acc_obj) {
190 }
191
192 // FrameLoaderClient -------------------------------------------------------
193
194 virtual bool CanAcceptLoadDrops() const {
195 // Always return true here so layout tests (which use the default WebView
196 // delegate) continue to pass.
197 return true;
198 }
199
200 // Notifies the delegate that a load has begun.
201 virtual void DidStartLoading(WebView* webview) {
202 }
203
204 // Notifies the delegate that all loads are finished.
205 virtual void DidStopLoading(WebView* webview) {
206 }
207
208 // The original version of this is WindowScriptObjectAvailable, below. This
209 // is a Chrome-specific version that serves the same purpose, but has been
210 // renamed since we haven't implemented WebScriptObject. Our embedding
211 // implementation binds native objects to the window via the webframe instead.
212 // TODO(pamg): If we do implement WebScriptObject, we may wish to switch to
213 // using the original version of this function.
214 virtual void WindowObjectCleared(WebKit::WebFrame* webframe) {
215 }
216
217 // Notifies that the documentElement for the document in a webframe has been
218 // created. This is called before anything else is parsed or executed for the
219 // document.
220 virtual void DocumentElementAvailable(WebKit::WebFrame* webframe) {
221 }
222
223 // Notifies that a new script context has been created for this frame.
224 // This is similar to WindowObjectCleared but only called once per frame
225 // context.
226 virtual void DidCreateScriptContextForFrame(WebKit::WebFrame* webframe) {
227 }
228
229 // Notifies that this frame's script context has been destroyed.
230 virtual void DidDestroyScriptContextForFrame(WebKit::WebFrame* webframe) {
231 }
232
233 // Notifies that a garbage-collected context was created - content scripts.
234 virtual void DidCreateIsolatedScriptContext(WebKit::WebFrame* webframe) {
235 }
236
237 // PolicyDelegate ----------------------------------------------------------
238
239 // This method is called to notify the delegate, and let it modify a
240 // proposed navigation. It will be called before loading starts, and
241 // on every redirect.
242 //
243 // default_policy specifies what should normally happen for this
244 // navigation (open in current tab, start a new tab, start a new
245 // window, etc). This method can return an altered policy, and
246 // take any additional separate action it wants to.
247 //
248 // is_redirect is true if this is a redirect rather than user action.
249 virtual WebKit::WebNavigationPolicy PolicyForNavigationAction(
250 WebView* webview,
251 WebKit::WebFrame* frame,
252 const WebKit::WebURLRequest& request,
253 WebKit::WebNavigationType type,
254 WebKit::WebNavigationPolicy default_policy,
255 bool is_redirect) {
256 return default_policy;
257 }
258
259 // FrameLoadDelegate -------------------------------------------------------
260
261 // A datasource has been created for a new navigation. The given datasource
262 // will become the provisional datasource for the frame.
263 virtual void DidCreateDataSource(WebKit::WebFrame* frame,
264 WebKit::WebDataSource* ds) {
265 }
266
267 // Notifies the delegate that the provisional load of a specified frame in a
268 // given WebView has started. By the time the provisional load for a frame has
269 // started, we know whether or not the current load is due to a client
270 // redirect or not, so we pass this information through to allow us to set
271 // the referrer properly in those cases. The consumed_client_redirect_src is
272 // an empty invalid GURL in other cases.
273 virtual void DidStartProvisionalLoadForFrame(
274 WebView* webview,
275 WebKit::WebFrame* frame,
276 NavigationGesture gesture) {
277 }
278
279 // Called when a provisional load is redirected (see GetProvisionalDataSource
280 // for more info on provisional loads). This happens when the server sends
281 // back any type of redirect HTTP response.
282 //
283 // The redirect information can be retrieved from the provisional data
284 // source's redirect chain, which will be updated prior to this callback.
285 // The last element in that vector will be the new URL (which will be the
286 // same as the provisional data source's current URL), and the next-to-last
287 // element will be the referring URL.
288 virtual void DidReceiveProvisionalLoadServerRedirect(WebView* webview,
289 WebKit::WebFrame* frame) {
290 }
291
292 // @method webView:didFailProvisionalLoadWithError:forFrame:
293 // @abstract Notifies the delegate that the provisional load has failed
294 // @param webView The WebView sending the message
295 // @param error The error that occurred
296 // @param frame The frame for which the error occurred
297 // @discussion This method is called after the provisional data source has
298 // failed to load. The frame will continue to display the contents of the
299 // committed data source if there is one.
300 // This notification is only received for errors like network errors.
301 virtual void DidFailProvisionalLoadWithError(WebView* webview,
302 const WebKit::WebURLError& error,
303 WebKit::WebFrame* frame) {
304 }
305
306 // Notifies the delegate to commit data for the given frame. The delegate
307 // may optionally convert the data before calling CommitDocumentData or
308 // suppress a call to CommitDocumentData. For example, if CommitDocumentData
309 // is never called, then an empty document will be created.
310 virtual void DidReceiveDocumentData(WebKit::WebFrame* frame,
311 const char* data,
312 size_t data_len) {
313 frame->commitDocumentData(data, data_len);
314 }
315
316 // Notifies the delegate that the load has changed from provisional to
317 // committed. This method is called after the provisional data source has
318 // become the committed data source.
319 //
320 // In some cases, a single load may be committed more than once. This
321 // happens in the case of multipart/x-mixed-replace, also known as "server
322 // push". In this case, a single location change leads to multiple documents
323 // that are loaded in sequence. When this happens, a new commit will be sent
324 // for each document.
325 //
326 // The "is_new_navigation" flag will be true when a new session history entry
327 // was created for the load. The frame's GetHistoryState method can be used
328 // to get the corresponding session history state.
329 virtual void DidCommitLoadForFrame(WebView* webview, WebKit::WebFrame* frame,
330 bool is_new_navigation) {
331 }
332
333 //
334 // @method webView:didReceiveTitle:forFrame:
335 // @abstract Notifies the delegate that the page title for a frame has been r eceived
336 // @param webView The WebView sending the message
337 // @param title The new page title
338 // @param frame The frame for which the title has been received
339 // @discussion The title may update during loading; clients should be prepare d for this.
340 // - (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFra me:(WebFrame *)frame;
341 virtual void DidReceiveTitle(WebView* webview,
342 const std::wstring& title,
343 WebKit::WebFrame* frame) {
344 }
345
346 //
347 // @method webView:didFinishLoadForFrame:
348 // @abstract Notifies the delegate that the committed load of a frame has com pleted
349 // @param webView The WebView sending the message
350 // @param frame The frame that finished loading
351 // @discussion This method is called after the committed data source of a fra me has successfully loaded
352 // and will only be called when all subresources such as images and styleshee ts are done loading.
353 // Plug-In content and JavaScript-requested loads may occur after this method is called.
354 // - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame;
355 virtual void DidFinishLoadForFrame(WebView* webview,
356 WebKit::WebFrame* frame) {
357 }
358
359 //
360 // @method webView:didFailLoadWithError:forFrame:
361 // @abstract Notifies the delegate that the committed load of a frame has fai led
362 // @param webView The WebView sending the message
363 // @param error The error that occurred
364 // @param frame The frame that failed to load
365 // @discussion This method is called after a data source has committed but fa iled to completely load.
366 // - (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error fo rFrame:(WebFrame *)frame;
367 virtual void DidFailLoadWithError(WebView* webview,
368 const WebKit::WebURLError& error,
369 WebKit::WebFrame* forFrame) {
370 }
371
372 // Notifies the delegate of a DOMContentLoaded event.
373 // This is called when the html resource has been loaded, but
374 // not necessarily all subresources (images, stylesheets). So, this is called
375 // before DidFinishLoadForFrame.
376 virtual void DidFinishDocumentLoadForFrame(WebView* webview, WebKit::WebFrame* frame) {
377 }
378
379 // This method is called when we load a resource from an in-memory cache.
380 // A return value of |false| indicates the load should proceed, but WebCore
381 // appears to largely ignore the return value.
382 virtual bool DidLoadResourceFromMemoryCache(
383 WebView* webview,
384 const WebKit::WebURLRequest& request,
385 const WebKit::WebURLResponse& response,
386 WebKit::WebFrame* frame) {
387 return false;
388 }
389
390 // This is called after javascript onload handlers have been fired.
391 virtual void DidHandleOnloadEventsForFrame(WebView* webview, WebKit::WebFrame* frame) {
392 }
393
394 // This method is called when anchors within a page have been clicked.
395 // It is very similar to DidCommitLoadForFrame.
396 virtual void DidChangeLocationWithinPageForFrame(WebView* webview,
397 WebKit::WebFrame* frame,
398 bool is_new_navigation) {
399 }
400
401 // This is called when the favicon for a frame has been received.
402 virtual void DidReceiveIconForFrame(WebView* webview, WebKit::WebFrame* frame) {
403 }
404
405 // Notifies the delegate that a frame will start a client-side redirect. When
406 // this function is called, the redirect has not yet been started (it may
407 // not even be scheduled to happen until some point in the future). When the
408 // redirect has been cancelled or has succeeded, DidStopClientRedirect will
409 // be called.
410 //
411 // WebKit considers meta refreshes, and setting document.location (regardless
412 // of when called) as client redirects (possibly among others).
413 //
414 // This function is intended to continue progress feedback while a
415 // client-side redirect is pending. Watch out: WebKit seems to call us twice
416 // for client redirects, resulting in two calls of this function.
417 virtual void WillPerformClientRedirect(WebView* webview,
418 WebKit::WebFrame* frame,
419 const GURL& src_url,
420 const GURL& dest_url,
421 unsigned int delay_seconds,
422 unsigned int fire_date) {
423 }
424
425 // Notifies the delegate that a pending client-side redirect has been
426 // cancelled (for example, if the frame changes before the timeout) or has
427 // completed successfully. A client-side redirect is the result of setting
428 // document.location, for example, as opposed to a server side redirect
429 // which is the result of HTTP headers (see DidReceiveServerRedirect).
430 //
431 // On success, this will be called when the provisional load that the client
432 // side redirect initiated is committed.
433 //
434 // See the implementation of FrameLoader::clientRedirectCancelledOrFinished.
435 virtual void DidCancelClientRedirect(WebView* webview,
436 WebKit::WebFrame* frame) {
437 }
438
439 // Notifies the delegate that the load about to be committed for the specified
440 // webview and frame was due to a client redirect originating from source URL.
441 // The information/notification obtained from this method is relevant until
442 // the next provisional load is started, at which point it becomes obsolete.
443 virtual void DidCompleteClientRedirect(WebView* webview,
444 WebKit::WebFrame* frame,
445 const GURL& source) {
446 }
447
448 // Notifies the delegate that a form is about to be submitted.
449 virtual void WillSubmitForm(WebView* webview, WebKit::WebFrame* frame,
450 const WebKit::WebForm& form) {
451 }
452
453 //
454 // @method webView:willCloseFrame:
455 // @abstract Notifies the delegate that a frame will be closed
456 // @param webView The WebView sending the message
457 // @param frame The frame that will be closed
458 // @discussion This method is called right before WebKit is done with the fra me
459 // and the objects that it contains.
460 // - (void)webView:(WebView *)sender willCloseFrame:(WebFrame *)frame;
461 virtual void WillCloseFrame(WebView* webview, WebKit::WebFrame* frame) {
462 }
463
464 // ResourceLoadDelegate ----------------------------------------------------
465
466 // Associates the given identifier with the initial resource request.
467 // Resource load callbacks will use the identifier throughout the life of the
468 // request.
469 virtual void AssignIdentifierToRequest(
470 WebKit::WebFrame* webframe,
471 uint32 identifier,
472 const WebKit::WebURLRequest& request) {
473 }
474
475 // Notifies the delegate that a request is about to be sent out, giving the
476 // delegate the opportunity to modify the request. Note that request is
477 // writable here, and changes to the URL, for example, will change the request
478 // made. If this request is the result of a redirect, then redirect_response
479 // will be non-null and contain the response that triggered the redirect.
480 virtual void WillSendRequest(
481 WebKit::WebFrame* webframe,
482 uint32 identifier,
483 WebKit::WebURLRequest* request,
484 const WebKit::WebURLResponse& redirect_response) {
485 }
486
487 virtual void DidReceiveResponse(WebKit::WebFrame* webframe,
488 uint32 identifier,
489 const WebKit::WebURLResponse& response) {
490 }
491
492 // Notifies the delegate that a subresource load has succeeded.
493 virtual void DidFinishLoading(WebKit::WebFrame* webframe, uint32 identifier) {
494 }
495
496 // Notifies the delegate that a subresource load has failed, and why.
497 virtual void DidFailLoadingWithError(WebKit::WebFrame* webframe,
498 uint32 identifier,
499 const WebKit::WebURLError& error) {
500 }
501
502 // ChromeClient ------------------------------------------------------------
503
504 // Appends a line to the application's error console. The message contains
505 // an error description or other information, the line_no provides a line
506 // number (e.g. for a JavaScript error report), and the source_id contains
507 // a URL or other description of the source of the message.
508 virtual void AddMessageToConsole(WebView* webview,
509 const std::wstring& message,
510 unsigned int line_no,
511 const std::wstring& source_id) {
512 }
513
514 // Queries the browser for suggestions to be shown for the form text field
515 // named |field_name|. |text| is the text entered by the user so far and
516 // |node_id| is the id of the node of the input field.
517 virtual void QueryFormFieldAutofill(const std::wstring& field_name,
518 const std::wstring& text,
519 int64 node_id) {
520 }
521
522 // Instructs the browser to remove the autofill entry specified from it DB.
523 virtual void RemoveStoredAutofillEntry(const std::wstring& name,
524 const std::wstring& value) {
525 }
526
527 virtual void DidContentsSizeChange(WebKit::WebWidget* webwidget,
528 int new_width, int new_height) {
529 }
530
531 // Called to retrieve the provider of desktop notifications. Pointer
532 // is owned by the implementation of WebViewDelegate.
533 virtual WebKit::WebNotificationPresenter* GetNotificationPresenter() {
534 return NULL;
535 }
536
537 // UIDelegate --------------------------------------------------------------
538
539 // Displays a JavaScript alert panel associated with the given view. Clients
540 // should visually indicate that this panel comes from JavaScript and some
541 // information about the originating frame (at least the domain). The panel
542 // should have a single OK button.
543 virtual void RunJavaScriptAlert(WebKit::WebFrame* webframe,
544 const std::wstring& message) {
545 }
546
547 // Displays a JavaScript confirm panel associated with the given view.
548 // Clients should visually indicate that this panel comes
549 // from JavaScript. The panel should have two buttons, e.g. "OK" and
550 // "Cancel". Returns true if the user hit OK, or false if the user hit Cancel.
551 virtual bool RunJavaScriptConfirm(WebKit::WebFrame* webframe,
552 const std::wstring& message) {
553 return false;
554 }
555
556 // Displays a JavaScript text input panel associated with the given view.
557 // Clients should visually indicate that this panel comes from JavaScript.
558 // The panel should have two buttons, e.g. "OK" and "Cancel", and an area to
559 // type text. The default_value should appear as the initial text in the
560 // panel when it is shown. If the user hit OK, returns true and fills result
561 // with the text in the box. The value of result is undefined if the user
562 // hit Cancel.
563 virtual bool RunJavaScriptPrompt(WebKit::WebFrame* webframe,
564 const std::wstring& message,
565 const std::wstring& default_value,
566 std::wstring* result) {
567 return false;
568 }
569
570 // Sets the status bar text.
571 virtual void SetStatusbarText(WebView* webview,
572 const std::wstring& message) { }
573
574 // Displays a "before unload" confirm panel associated with the given view.
575 // The panel should have two buttons, e.g. "OK" and "Cancel", where OK means
576 // that the navigation should continue, and Cancel means that the navigation
577 // should be cancelled, leaving the user on the current page. Returns true
578 // if the user hit OK, or false if the user hit Cancel.
579 virtual bool RunBeforeUnloadConfirm(WebKit::WebFrame* webframe,
580 const std::wstring& message) {
581 return true; // OK, continue to navigate away
582 }
583
584 // Tells the client that we're hovering over a link with a given URL,
585 // if the node is not a link, the URL will be an empty GURL.
586 virtual void UpdateTargetURL(WebView* webview,
587 const GURL& url) {
588 }
589
590 // Called to display a file chooser prompt. The prompt should be pre-
591 // populated with the given initial_filename string. The WebViewDelegate
592 // will own the WebFileChooserCallback object and is responsible for
593 // freeing it.
594 virtual void RunFileChooser(bool multi_select,
595 const string16& title,
596 const FilePath& initial_filename,
597 WebFileChooserCallback* file_chooser) {
598 delete file_chooser;
599 }
600
601 // @abstract Shows a context menu with commands relevant to a specific
602 // element on the current page.
603 // @param webview The WebView sending the delegate method.
604 // @param node_type The type of the node(s) the context menu is being
605 // invoked on
606 // @param x The x position of the mouse pointer (relative to the webview)
607 // @param y The y position of the mouse pointer (relative to the webview)
608 // @param link_url The absolute URL of the link that contains the node the
609 // mouse right clicked on
610 // @param image_url The absolute URL of the image that the mouse right
611 // clicked on
612 // @param page_url The URL of the page the mouse right clicked on
613 // @param frame_url The URL of the subframe the mouse right clicked on
614 // @param media_params Extra attributed needed by the context menu for
615 // media elements.
616 // @param selection_text The raw text of the selection that the mouse right
617 // clicked on
618 // @param misspelled_word The editable (possibily) misspelled word
619 // in the Editor on which dictionary lookup for suggestions will be done.
620 // @param edit_flags which edit operations the renderer believes are available
621 // @param security_info
622 // @param frame_charset which indicates the character encoding of
623 // the currently focused frame.
624 virtual void ShowContextMenu(WebView* webview,
625 ContextNodeType node_type,
626 int x,
627 int y,
628 const GURL& link_url,
629 const GURL& image_url,
630 const GURL& page_url,
631 const GURL& frame_url,
632 const ContextMenuMediaParams& media_params,
633 const std::wstring& selection_text,
634 const std::wstring& misspelled_word,
635 int edit_flags,
636 const std::string& security_info,
637 const std::string& frame_charset) {
638 }
639
640 // Starts a drag session with the supplied contextual information.
641 // webview: The WebView sending the delegate method.
642 // drop_data: a WebDropData struct which should contain all the necessary
643 // information for dragging data out of the webview.
644 virtual void StartDragging(WebView* webview,
645 const WebKit::WebDragData& drag_data) {
646 }
647
648 // Returns the focus to the client.
649 // reverse: Whether the focus should go to the previous (if true) or the next
650 // focusable element.
651 virtual void TakeFocus(WebView* webview, bool reverse) {
652 }
653
654 // Displays JS out-of-memory warning in the infobar
655 virtual void JSOutOfMemory() {
656 }
657
658 // Notification that a user metric has occurred.
659 virtual void UserMetricsRecordAction(const std::wstring& action) { }
660
661 // -------------------------------------------------------------------------
662
663 // Notification that a request to download an image has completed. |errored|
664 // indicates if there was a network error. The image is empty if there was
665 // a network error, the contents of the page couldn't by converted to an
666 // image, or the response from the host was not 200.
667 // NOTE: image is empty if the response didn't contain image data.
668 virtual void DidDownloadImage(int id,
669 const GURL& image_url,
670 bool errored,
671 const SkBitmap& image) {
672 }
673
674 // History Related ---------------------------------------------------------
675
676 // Tells the embedder to navigate back or forward in session history by the
677 // given offset (relative to the current position in session history).
678 virtual void NavigateBackForwardSoon(int offset) {
679 }
680
681 // Returns how many entries are in the back and forward lists, respectively.
682 virtual int GetHistoryBackListCount() {
683 return 0;
684 }
685 virtual int GetHistoryForwardListCount() {
686 return 0;
687 }
688
689 // Notification that the form state of an element in the document, scroll
690 // position, or possibly something else has changed that affects session
691 // history (HistoryItem). This function will be called frequently, so the
692 // implementor should not perform intensive operations in this notification.
693 virtual void OnNavStateChanged(WebView* webview) { }
694
695 // -------------------------------------------------------------------------
696
697 // Tell the delegate the tooltip text and its directionality hint for the
698 // current mouse position.
699 virtual void SetTooltipText(WebView* webview,
700 const std::wstring& tooltip_text,
701 WebKit::WebTextDirection text_direction_hint) { }
702
703 // Downloading -------------------------------------------------------------
704
705 virtual void DownloadUrl(const GURL& url, const GURL& referrer) { }
706
707 // InspectorClient ---------------------------------------------------------
708
709 virtual void UpdateInspectorSettings(const std::wstring& raw_settings) { }
710
711 // DevTools ----------------------------------------------------------------
712
713 virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate() {
714 return NULL;
715 }
716
717 // Selection clipboard -----------------------------------------------------
718
719 // Request the text on the selection clipboard be sent back to the webview
720 // so it can be inserted into the current focus area. In response to this call
721 // the delegate should get the text and send it to the WebView via
722 // InsertText().
723 virtual void PasteFromSelectionClipboard() { }
724
725 // Editor Client -----------------------------------------------------------
726
727 // Returns true if the word is spelled correctly. The word may begin or end
728 // with whitespace or punctuation, so the implementor should be sure to handle
729 // these cases.
730 //
731 // If the word is misspelled (returns false), the given first and last
732 // indices (inclusive) will be filled with the offsets of the boundary of the
733 // word within the given buffer. The out pointers must be specified. If the
734 // word is correctly spelled (returns true), they will be set to (0,0).
735 virtual void SpellCheck(const std::wstring& word, int* misspell_location,
736 int* misspell_length) {
737 *misspell_location = *misspell_length = 0;
738 }
739
740 // Computes an auto correct word for a misspelled word. If no word is found,
741 // empty string is computed.
742 virtual std::wstring GetAutoCorrectWord(const std::wstring& misspelled_word) {
743 return std::wstring();
744 }
745
746 // Asks the user to print the page or a specific frame. Called in response to
747 // a window.print() call.
748 virtual void ScriptedPrint(WebKit::WebFrame* frame) { }
749
750 // Called when an item was added to the history
751 virtual void DidAddHistoryItem() { }
752
753 WebViewDelegate() { }
754
755 protected:
756 ~WebViewDelegate() { }
757 };
758
759 #endif // WEBKIT_GLUE_WEBVIEW_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698