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

Side by Side Diff: public/webpage/WebViewClient.h

Issue 17186002: Move public/webpage to public/web (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | « public/webpage/WebViewBenchmarkSupport.h ('k') | public/webpage/WebWidget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef WebViewClient_h
32 #define WebViewClient_h
33
34 #include "../platform/WebColor.h"
35 #include "../platform/WebGraphicsContext3D.h"
36 #include "../platform/WebString.h"
37 #include "WebAccessibilityNotification.h"
38 #include "WebContentDetectionResult.h"
39 #include "WebDragOperation.h"
40 #include "WebEditingAction.h"
41 #include "WebFileChooserCompletion.h"
42 #include "WebFileChooserParams.h"
43 #include "WebPageVisibilityState.h"
44 #include "WebPopupType.h"
45 #include "WebTextAffinity.h"
46 #include "WebTextDirection.h"
47 #include "WebWidgetClient.h"
48
49 namespace WebKit {
50
51 class WebAccessibilityObject;
52 class WebColorChooser;
53 class WebColorChooserClient;
54 class WebCompositorOutputSurface;
55 class WebDateTimeChooserCompletion;
56 class WebDeviceOrientationClient;
57 class WebDragData;
58 class WebElement;
59 class WebExternalPopupMenu;
60 class WebExternalPopupMenuClient;
61 class WebFileChooserCompletion;
62 class WebFrame;
63 class WebGeolocationClient;
64 class WebGeolocationService;
65 class WebGestureEvent;
66 class WebHelperPlugin;
67 class WebHitTestResult;
68 class WebIconLoadingCompletion;
69 class WebImage;
70 class WebInputElement;
71 class WebKeyboardEvent;
72 class WebNode;
73 class WebNotificationPresenter;
74 class WebRange;
75 class WebSpeechInputController;
76 class WebSpeechInputListener;
77 class WebSpeechRecognizer;
78 class WebStorageNamespace;
79 class WebURL;
80 class WebURLRequest;
81 class WebUserMediaClient;
82 class WebView;
83 class WebWidget;
84 struct WebConsoleMessage;
85 struct WebContextMenuData;
86 struct WebDateTimeChooserParams;
87 struct WebPoint;
88 struct WebPopupMenuInfo;
89 struct WebRect;
90 struct WebSize;
91 struct WebWindowFeatures;
92
93 // Since a WebView is a WebWidget, a WebViewClient is a WebWidgetClient.
94 // Virtual inheritance allows an implementation of WebWidgetClient to be
95 // easily reused as part of an implementation of WebViewClient.
96 class WebViewClient : virtual public WebWidgetClient {
97 public:
98 // Factory methods -----------------------------------------------------
99
100 // Create a new related WebView. This method must clone its session storage
101 // so any subsequent calls to createSessionStorageNamespace conform to the
102 // WebStorage specification.
103 // The request parameter is only for the client to check if the request
104 // could be fulfilled. The client should not load the request.
105 // The policy parameter indicates how the new view will be displayed in
106 // WebWidgetClient::show.
107 virtual WebView* createView(WebFrame* creator,
108 const WebURLRequest& request,
109 const WebWindowFeatures& features,
110 const WebString& name,
111 WebNavigationPolicy policy) {
112 return 0;
113 }
114
115 // Create a new WebPopupMenu. In the second form, the client is
116 // responsible for rendering the contents of the popup menu.
117 virtual WebWidget* createPopupMenu(WebPopupType) { return 0; }
118 virtual WebWidget* createPopupMenu(const WebPopupMenuInfo&) { return 0; }
119 virtual WebExternalPopupMenu* createExternalPopupMenu(
120 const WebPopupMenuInfo&, WebExternalPopupMenuClient*) { return 0; }
121
122 // Create a session storage namespace object associated with this WebView.
123 virtual WebStorageNamespace* createSessionStorageNamespace(unsigned quota) { return 0; }
124
125
126 // Misc ----------------------------------------------------------------
127
128 // A new message was added to the console.
129 virtual void didAddMessageToConsole(
130 const WebConsoleMessage&, const WebString& sourceName, unsigned sourceLi ne) { }
131
132 // Called when script in the page calls window.print(). If frame is
133 // non-null, then it selects a particular frame, including its
134 // children, to print. Otherwise, the main frame and its children
135 // should be printed.
136 virtual void printPage(WebFrame*) { }
137
138 // Called to retrieve the provider of desktop notifications.
139 virtual WebNotificationPresenter* notificationPresenter() { return 0; }
140
141 // Called to request an icon for the specified filenames.
142 // The icon is shown in a file upload control.
143 virtual bool queryIconForFiles(const WebVector<WebString>& filenames, WebIco nLoadingCompletion*) { return false; }
144
145 // This method enumerates all the files in the path. It returns immediately
146 // and asynchronously invokes the WebFileChooserCompletion with all the
147 // files in the directory. Returns false if the WebFileChooserCompletion
148 // will never be called.
149 virtual bool enumerateChosenDirectory(const WebString& path, WebFileChooserC ompletion*) { return false; }
150
151 // Creates the main WebFrame for the specified WebHelperPlugin.
152 // Called by WebHelperPlugin to provide the WebFrameClient interface for the WebFrame.
153 virtual void initializeHelperPluginWebFrame(WebHelperPlugin*) { }
154
155
156 // Navigational --------------------------------------------------------
157
158 // These notifications bracket any loading that occurs in the WebView.
159 virtual void didStartLoading() { }
160 virtual void didStopLoading() { }
161
162 // Notification that some progress was made loading the current page.
163 // loadProgress is a value between 0 (nothing loaded) and 1.0 (frame fully
164 // loaded).
165 virtual void didChangeLoadProgress(WebFrame*, double loadProgress) { }
166
167 // Editing -------------------------------------------------------------
168
169 // These methods allow the client to intercept and overrule editing
170 // operations.
171 virtual bool shouldBeginEditing(const WebRange&) { return true; }
172 virtual bool shouldEndEditing(const WebRange&) { return true; }
173 virtual bool shouldInsertNode(
174 const WebNode&, const WebRange&, WebEditingAction) { return true; }
175 virtual bool shouldInsertText(
176 const WebString&, const WebRange&, WebEditingAction) { return true; }
177 virtual bool shouldChangeSelectedRange(
178 const WebRange& from, const WebRange& to, WebTextAffinity,
179 bool stillSelecting) { return true; }
180 virtual bool shouldDeleteRange(const WebRange&) { return true; }
181 virtual bool shouldApplyStyle(const WebString& style, const WebRange&) { ret urn true; }
182
183 virtual void didBeginEditing() { }
184 virtual void didCancelCompositionOnSelectionChange() { }
185 virtual void didChangeSelection(bool isSelectionEmpty) { }
186 virtual void didChangeContents() { }
187 virtual void didExecuteCommand(const WebString& commandName) { }
188 virtual void didEndEditing() { }
189 virtual void didChangeFormState(const WebNode&) { }
190
191 // This method is called in response to WebView's handleInputEvent()
192 // when the default action for the current keyboard event is not
193 // suppressed by the page, to give the embedder a chance to handle
194 // the keyboard event specially.
195 //
196 // Returns true if the keyboard event was handled by the embedder,
197 // indicating that the default action should be suppressed.
198 virtual bool handleCurrentKeyboardEvent() { return false; }
199
200 // Dialogs -------------------------------------------------------------
201
202 // This method opens the color chooser and returns a new WebColorChooser
203 // instance. If there is a WebColorChooser already from the last time this
204 // was called, it ends the color chooser by calling endChooser, and replaces
205 // it with the new one.
206 virtual WebColorChooser* createColorChooser(WebColorChooserClient*,
207 const WebColor&) { return 0; }
208
209 // This method returns immediately after showing the dialog. When the
210 // dialog is closed, it should call the WebFileChooserCompletion to
211 // pass the results of the dialog. Returns false if
212 // WebFileChooseCompletion will never be called.
213 virtual bool runFileChooser(const WebFileChooserParams&,
214 WebFileChooserCompletion*) { return false; }
215
216 // Ask users to choose date/time for the specified parameters. When a user
217 // chooses a value, an implementation of this function should call
218 // WebDateTimeChooserCompletion::didChooseValue or didCancelChooser. If the
219 // implementation opened date/time chooser UI successfully, it should return
220 // true. This function is used only if ExternalDateTimeChooser is used.
221 virtual bool openDateTimeChooser(const WebDateTimeChooserParams&, WebDateTim eChooserCompletion*) { return false; }
222
223 // Displays a modal alert dialog containing the given message. Returns
224 // once the user dismisses the dialog.
225 virtual void runModalAlertDialog(
226 WebFrame*, const WebString& message) { }
227
228 // Displays a modal confirmation dialog with the given message as
229 // description and OK/Cancel choices. Returns true if the user selects
230 // 'OK' or false otherwise.
231 virtual bool runModalConfirmDialog(
232 WebFrame*, const WebString& message) { return false; }
233
234 // Displays a modal input dialog with the given message as description
235 // and OK/Cancel choices. The input field is pre-filled with
236 // defaultValue. Returns true if the user selects 'OK' or false
237 // otherwise. Upon returning true, actualValue contains the value of
238 // the input field.
239 virtual bool runModalPromptDialog(
240 WebFrame*, const WebString& message, const WebString& defaultValue,
241 WebString* actualValue) { return false; }
242
243 // Displays a modal confirmation dialog containing the given message as
244 // description and OK/Cancel choices, where 'OK' means that it is okay
245 // to proceed with closing the view. Returns true if the user selects
246 // 'OK' or false otherwise.
247 virtual bool runModalBeforeUnloadDialog(
248 WebFrame*, const WebString& message) { return true; }
249
250
251 // UI ------------------------------------------------------------------
252
253 // Called when script modifies window.status
254 virtual void setStatusText(const WebString&) { }
255
256 // Called when hovering over an anchor with the given URL.
257 virtual void setMouseOverURL(const WebURL&) { }
258
259 // Called when keyboard focus switches to an anchor with the given URL.
260 virtual void setKeyboardFocusURL(const WebURL&) { }
261
262 // Shows a context menu with commands relevant to a specific element on
263 // the given frame. Additional context data is supplied.
264 virtual void showContextMenu(WebFrame*, const WebContextMenuData&) { }
265
266 // Called when a drag-n-drop operation should begin.
267 virtual void startDragging(WebFrame*, const WebDragData&, WebDragOperationsM ask, const WebImage&, const WebPoint& dragImageOffset) { }
268
269 // Called to determine if drag-n-drop operations may initiate a page
270 // navigation.
271 virtual bool acceptsLoadDrops() { return true; }
272
273 // Take focus away from the WebView by focusing an adjacent UI element
274 // in the containing window.
275 virtual void focusNext() { }
276 virtual void focusPrevious() { }
277
278 // Called when a new node gets focused.
279 virtual void focusedNodeChanged(const WebNode&) { }
280
281 virtual void numberOfWheelEventHandlersChanged(unsigned) { }
282
283 // Indicates two things:
284 // 1) This view may have a new layout now.
285 // 2) Calling layout() is a no-op.
286 // After calling WebWidget::layout(), expect to get this notification
287 // unless the view did not need a layout.
288 virtual void didUpdateLayout() { }
289
290 // Return true to swallow the input event if the embedder will start a disam biguation popup
291 virtual bool didTapMultipleTargets(const WebGestureEvent&, const WebVector<W ebRect>& targetRects) { return false; }
292
293 // Returns comma separated list of accept languages.
294 virtual WebString acceptLanguages() { return WebString(); }
295
296 // Session history -----------------------------------------------------
297
298 // Tells the embedder to navigate back or forward in session history by
299 // the given offset (relative to the current position in session
300 // history).
301 virtual void navigateBackForwardSoon(int offset) { }
302
303 // Returns the number of history items before/after the current
304 // history item.
305 virtual int historyBackListCount() { return 0; }
306 virtual int historyForwardListCount() { return 0; }
307
308 // Called to notify the embedder when a new history item is added.
309 virtual void didAddHistoryItem() { }
310
311
312 // Accessibility -------------------------------------------------------
313
314 // Notifies embedder about an accessibility notification.
315 virtual void postAccessibilityNotification(const WebAccessibilityObject&, We bAccessibilityNotification) { }
316
317
318 // Developer tools -----------------------------------------------------
319
320 // Called to notify the client that the inspector's settings were
321 // changed and should be saved. See WebView::inspectorSettings.
322 virtual void didUpdateInspectorSettings() { }
323
324 virtual void didUpdateInspectorSetting(const WebString& key, const WebString & value) { }
325
326 // Geolocation ---------------------------------------------------------
327
328 // Access the embedder API for (client-based) geolocation client .
329 virtual WebGeolocationClient* geolocationClient() { return 0; }
330 // Access the embedder API for (non-client-based) geolocation services.
331 virtual WebGeolocationService* geolocationService() { return 0; }
332
333 // Speech --------------------------------------------------------------
334
335 // Access the embedder API for speech input services.
336 virtual WebSpeechInputController* speechInputController(
337 WebSpeechInputListener*) { return 0; }
338
339 // Access the embedder API for speech recognition services.
340 virtual WebSpeechRecognizer* speechRecognizer() { return 0; }
341
342 // Device Orientation --------------------------------------------------
343
344 // Access the embedder API for device orientation services.
345 virtual WebDeviceOrientationClient* deviceOrientationClient() { return 0; }
346
347 // Zoom ----------------------------------------------------------------
348
349 // Informs the browser that the zoom levels for this frame have changed from
350 // the default values.
351 virtual void zoomLimitsChanged(double minimumLevel, double maximumLevel) { }
352
353 // Informs the browser that the zoom level has changed as a result of an
354 // action that wasn't initiated by the client.
355 virtual void zoomLevelChanged() { }
356
357 // Registers a new URL handler for the given protocol.
358 virtual void registerProtocolHandler(const WebString& scheme,
359 const WebString& baseUrl,
360 const WebString& url,
361 const WebString& title) { }
362
363 // Visibility -----------------------------------------------------------
364
365 // Returns the current visibility of the WebView.
366 virtual WebPageVisibilityState visibilityState() const
367 {
368 return WebPageVisibilityStateVisible;
369 }
370
371 // Media Streams -------------------------------------------------------
372
373 virtual WebUserMediaClient* userMediaClient() { return 0; }
374
375
376 // Content detection ----------------------------------------------------
377
378 // Retrieves detectable content (e.g., email addresses, phone numbers)
379 // around a hit test result. The embedder should use platform-specific
380 // content detectors to analyze the region around the hit test result.
381 virtual WebContentDetectionResult detectContentAround(const WebHitTestResult &) { return WebContentDetectionResult(); }
382
383 // Schedules a new content intent with the provided url.
384 virtual void scheduleContentIntent(const WebURL&) { }
385
386 // Cancels any previously scheduled content intents that have not yet launch ed.
387 virtual void cancelScheduledContentIntents() { }
388
389 // Draggable regions ----------------------------------------------------
390
391 // Informs the browser that the draggable regions have been updated.
392 virtual void draggableRegionsChanged() { }
393
394 protected:
395 ~WebViewClient() { }
396 };
397
398 } // namespace WebKit
399
400 #endif
OLDNEW
« no previous file with comments | « public/webpage/WebViewBenchmarkSupport.h ('k') | public/webpage/WebWidget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698