1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CHROME_BROWSER_RENDER_VIEW_HOST_DELEGATE_H__
#define CHROME_BROWSER_RENDER_VIEW_HOST_DELEGATE_H__
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "chrome/common/render_messages.h"
#include "webkit/glue/webpreferences.h"
class NavigationEntry;
class Profile;
class RenderProcessHost;
class RenderViewHost;
class SkBitmap;
class WebContents;
struct WebDropData;
enum WindowOpenDisposition;
namespace IPC {
class Message;
}
namespace gfx {
class Rect;
}
namespace net {
enum LoadState;
}
//
// RenderViewHostDelegate
//
// An interface implemented by an object interested in knowing about the state
// of the RenderViewHost.
//
// This interface currently encompasses every type of message that was
// previously being sent by WebContents itself. Some of these notifications
// may not be relevant to all users of RenderViewHost and we should consider
// exposing a more generic Send function on RenderViewHost and a response
// listener here to serve that need.
//
class RenderViewHostDelegate {
public:
// Retrieves the profile to be used.
virtual Profile* GetProfile() const = 0;
// The page is trying to open a new page (e.g. a popup window).
virtual void CreateView(int route_id, HANDLE modal_dialog_event) { }
// The page is trying to open a new widget (e.g. a select popup).
virtual void CreateWidget(int route_id) { }
// Show the newly created page with the specified disposition and bounds.
virtual void ShowView(int route_id,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
bool user_gesture) { }
// Show the newly created widget with the specified bounds.
virtual void ShowWidget(int route_id, const gfx::Rect& initial_pos) { }
// The RenderView is being constructed (message sent to the renderer process
// to construct a RenderView). Now is a good time to send other setup events
// to the RenderView. This precedes any other commands to the RenderView.
virtual void RendererCreated(RenderViewHost* render_view_host) { }
// The RenderView has been constructed.
virtual void RendererReady(RenderViewHost* render_view_host) { }
// The RenderView died somehow (crashed or was killed by the user).
virtual void RendererGone(RenderViewHost* render_view_host) { }
// The RenderView was navigated to a different page.
virtual void DidNavigate(RenderViewHost* render_view_host,
const ViewHostMsg_FrameNavigate_Params& params) { }
// The state for the page changed and should be updated.
virtual void UpdateState(RenderViewHost* render_view_host,
int32 page_id,
const GURL& url,
const std::wstring& title,
const std::string& state) { }
// The page's title was changed and should be updated.
virtual void UpdateTitle(RenderViewHost* render_view_host,
int32 page_id,
const std::wstring& title) { }
// The page's encoding was changed and should be updated.
virtual void UpdateEncoding(RenderViewHost* render_view_host,
const std::wstring& encoding_name) { }
// The destination URL has changed should be updated
virtual void UpdateTargetURL(int32 page_id, const GURL& url) { }
// The thumbnail representation of the page changed and should be updated.
virtual void UpdateThumbnail(const GURL& url,
const SkBitmap& bitmap,
const ThumbnailScore& score) { }
// The page is trying to close the RenderView's representation in the client.
virtual void Close(RenderViewHost* render_view_host) { }
// The page is trying to move the RenderView's representation in the client.
virtual void RequestMove(const gfx::Rect& new_bounds) { }
// The RenderView began loading a new page.
virtual void DidStartLoading(RenderViewHost* render_view_host,
int32 page_id) { }
// The RenderView stopped loading a page.
virtual void DidStopLoading(RenderViewHost* render_view_host,
int32 page_id) { }
// The RenderView is starting a provisional load.
virtual void DidStartProvisionalLoadForFrame(RenderViewHost* render_view_host,
bool is_main_frame,
const GURL& url) { }
// Sent when a provisional load is redirected.
virtual void DidRedirectProvisionalLoad(int32 page_id,
const GURL& source_url,
const GURL& target_url) { }
// The RenderView loaded a resource from an in-memory cache.
// |security_info| contains the security info if this resource was originally
// loaded over a secure connection.
virtual void DidLoadResourceFromMemoryCache(const GURL& url,
const std::string& security_info) { }
// The RenderView failed a provisional load with an error.
virtual void DidFailProvisionalLoadWithError(
RenderViewHost* render_view_host,
bool is_main_frame,
int error_code,
const GURL& url,
bool showing_repost_interstitial) { }
// A find operation in the current page completed.
virtual void FindReply(int request_id,
int number_of_matches,
const gfx::Rect& selection_rect,
int active_match_ordinal,
bool final_update) { }
// The URL for the FavIcon of a page has changed.
virtual void UpdateFavIconURL(RenderViewHost* render_view_host,
int32 page_id, const GURL& icon_url) { }
// The FavIcon for a page needs to be downloaded.
virtual void DownloadFavIcon(RenderViewHost* render_view_host,
int32 page_id) { }
// An image that was requested to be downloaded by DownloadImage has
// completed.
virtual void DidDownloadImage(RenderViewHost* render_view_host,
int id,
const GURL& image_url,
bool errored,
const SkBitmap& image) { }
// A context menu should be shown, to be built using the context information
// provided in the supplied params.
virtual void ShowContextMenu(const ViewHostMsg_ContextMenu_Params& params) {
}
// The user started dragging content of the specified type within the
// RenderView. Contextual information about the dragged content is supplied
// by WebDropData.
virtual void StartDragging(const WebDropData& drop_data) { }
// The page wants to update the mouse cursor during a drag & drop operation.
// |is_drop_target| is true if the mouse is over a valid drop target.
virtual void UpdateDragCursor(bool is_drop_target) { }
// The page wants to open a URL with the specified disposition.
virtual void RequestOpenURL(const GURL& url,
WindowOpenDisposition disposition) { }
// A DOM automation operation completed. The result of the operation is
// expressed in a json string.
virtual void DomOperationResponse(const std::string& json_string,
int automation_id) { }
// A message was sent from HTML-based UI.
// By default we ignore such messages.
virtual void ProcessDOMUIMessage(const std::string& message,
const std::string& content) { }
// Navigate to the history entry for the given offset from the current
// position within the NavigationController. Makes no change if offset is
// not valid.
virtual void GoToEntryAtOffset(int offset) { }
// The page requests the size of the back and forward lists
// within the NavigationController.
virtual void GetHistoryListCount(int* back_list_count,
int* forward_list_count) { }
// The page wants to open a plugin to display the given URL, of a certain
// content type. |reply_msg| contains the name of the plugin.
virtual void OpenChannelToPlugin(const GURL& url,
const std::string& mime_type,
IPC::Message* reply_msg) { }
// A file chooser should be shown.
virtual void RunFileChooser(const std::wstring& default_file) { }
// A javascript message, confirmation or prompt should be shown.
virtual void RunJavaScriptMessage(const std::wstring& message,
const std::wstring& default_prompt,
const int flags,
IPC::Message* reply_msg) { }
virtual void RunBeforeUnloadConfirm(const std::wstring& message,
IPC::Message* reply_msg) { }
// Display this RenderViewHost in a modal fashion.
virtual void RunModal(IPC::Message* reply_msg) { }
virtual void ShowModalHTMLDialog(const GURL& url, int width, int height,
const std::string& json_arguments,
IPC::Message* reply_msg) { }
// Password forms have been detected in the page.
virtual void PasswordFormsSeen(const std::vector<PasswordForm>& forms) { }
// Callback to inform the browser it should take back focus. If reverse is
// true, it means the focus was retrieved by doing a Shift-Tab.
virtual void TakeFocus(bool reverse) { }
// Notification that the page has an OpenSearch description document.
virtual void PageHasOSDD(RenderViewHost* render_view_host,
int32 page_id, const GURL& doc_url,
bool autodetected) { }
// Notification that the inspect element window has been opened
virtual void InspectElementReply(int num_resources) { }
// Notification that the render view has calculated the number of printed
// pages.
virtual void DidGetPrintedPagesCount(int cookie, int number_pages) {
NOTREACHED();
}
// Notification that the render view is done rendering one printed page. This
// call is synchronous, the renderer is waiting on us because of the EMF
// memory mapped data.
virtual void DidPrintPage(const ViewHostMsg_DidPrintPage_Params& params) {
NOTREACHED();
}
// Callback to inform the browser that the renderer did not process the
// specified events. This gives an opportunity to the browser to process the
// event (used for keyboard shortcuts).
virtual void HandleKeyboardEvent(const WebKeyboardEvent& event) { }
// |url| is assigned to a server that can provide alternate error pages. If
// unchanged, just use the error pages built into our webkit.
virtual GURL GetAlternateErrorPageURL() const {
return GURL();
}
// Returns a WebPreferences object that will be used by the renderer
// associated with the owning render view host.
virtual WebPreferences GetWebkitPrefs() {
NOTREACHED();
return WebPreferences();
}
// Notification when default plugin updates status of the missing plugin.
virtual void OnMissingPluginStatus(int status) { }
// Notification from the renderer that a plugin instance has crashed.
virtual void OnCrashedPlugin(const std::wstring& plugin_path) { }
// Notification from the renderer that JS runs out of memory.
virtual void OnJSOutOfMemory() { }
// Notification that we get when we receive all savable links of
// sub-resources for the current page, their referrers and list of frames
// (include main frame and sub frames).
virtual void OnReceivedSavableResourceLinksForCurrentPage(
const std::vector<GURL>& resources_list,
const std::vector<GURL>& referrers_list,
const std::vector<GURL>& frames_list) { }
// Notification that we get when we receive serialized html content data of a
// specified web page from render process. The parameter frame_url specifies
// what frame the data belongs. The parameter data contains the available
// data for sending. The parameter status indicates the serialization status,
// See webkit_glue::DomSerializerDelegate::PageSavingSerializationStatus for
// the detail meaning of status.
virtual void OnReceivedSerializedHtmlData(const GURL& frame_url,
const std::string& data,
int32 status) { }
// Notification whether we should close the page, after an explicit call to
// AttemptToClosePage. This is called before a cross-site request or before
// a tab/window is closed, to allow the appropriate renderer to approve or
// deny the request. |proceed| indicates whether the user chose to proceed.
virtual void ShouldClosePage(bool proceed) { }
// Called by ResourceDispatcherHost when a response for a pending cross-site
// request is received. The ResourceDispatcherHost will pause the response
// until the onunload handler of the previous renderer is run.
virtual void OnCrossSiteResponse(int new_render_process_host_id,
int new_request_id) { }
// Whether this object can be blurred through a javascript
// obj.blur() call. ConstrainedWindows shouldn't be able to be
// blurred.
virtual bool CanBlur() const { return true; }
// Notification that the renderer has become unresponsive. The
// delegate can use this notification to show a warning to the user.
virtual void RendererUnresponsive(RenderViewHost* render_view_host) { }
// Notification that a previously unresponsive renderer has become
// responsive again. The delegate can use this notification to end the
// warning shown to the user.
virtual void RendererResponsive(RenderViewHost* render_view_host) { }
// Notification that the RenderViewHost's load state changed.
virtual void LoadStateChanged(const GURL& url, net::LoadState load_state) { }
// Notification that a request for install info has completed.
virtual void OnDidGetApplicationInfo(
int32 page_id,
const webkit_glue::WebApplicationInfo& app_info) { }
};
#endif // CHROME_BROWSER_RENDER_VIEW_HOST_DELEGATE_H__
|