Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / browser / frame_host / render_frame_host_delegate.h
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_DELEGATE_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_DELEGATE_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "base/i18n/rtl.h"
12 #include "content/common/content_export.h"
13 #include "content/common/frame_message_enums.h"
14 #include "content/public/common/javascript_message_type.h"
15 #include "content/public/common/media_stream_request.h"
16 #include "net/http/http_response_headers.h"
17
18 #if defined(OS_WIN)
19 #include "ui/gfx/native_widget_types.h"
20 #endif
21
22 class GURL;
23
24 namespace IPC {
25 class Message;
26 }
27
28 namespace content {
29 class GeolocationServiceContext;
30 class RenderFrameHost;
31 class WebContents;
32 struct AXEventNotificationDetails;
33 struct ContextMenuParams;
34 struct TransitionLayerData;
35
36 // An interface implemented by an object interested in knowing about the state
37 // of the RenderFrameHost.
38 class CONTENT_EXPORT RenderFrameHostDelegate {
39  public:
40   // This is used to give the delegate a chance to filter IPC messages.
41   virtual bool OnMessageReceived(RenderFrameHost* render_frame_host,
42                                  const IPC::Message& message);
43
44   // Gets the last committed URL. See WebContents::GetLastCommittedURL for a
45   // description of the semantics.
46   virtual const GURL& GetMainFrameLastCommittedURL() const;
47
48   // A message was added to to the console.
49   virtual bool AddMessageToConsole(int32 level,
50                                    const base::string16& message,
51                                    int32 line_no,
52                                    const base::string16& source_id);
53
54   // Informs the delegate whenever a RenderFrameHost is created.
55   virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) {}
56
57   // Informs the delegate whenever a RenderFrameHost is deleted.
58   virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) {}
59
60   // The top-level RenderFrame began loading a new page. This corresponds to
61   // Blink's notion of the throbber starting.
62   // |to_different_document| will be true unless the load is a fragment
63   // navigation, or triggered by history.pushState/replaceState.
64   virtual void DidStartLoading(RenderFrameHost* render_frame_host,
65                                bool to_different_document) {}
66
67   // The RenderFrameHost has been swapped out.
68   virtual void SwappedOut(RenderFrameHost* render_frame_host) {}
69
70   // Notification that the navigation on the main frame is blocked waiting
71   // for transition to occur.
72   virtual void DidDeferAfterResponseStarted(
73       const TransitionLayerData& transition_data) {}
74
75   // Used to query whether the navigation transition will be handled.
76   virtual bool WillHandleDeferAfterResponseStarted();
77
78   // Notification that a worker process has crashed.
79   virtual void WorkerCrashed(RenderFrameHost* render_frame_host) {}
80
81   // A context menu should be shown, to be built using the context information
82   // provided in the supplied params.
83   virtual void ShowContextMenu(RenderFrameHost* render_frame_host,
84                                const ContextMenuParams& params) {}
85
86   // A JavaScript message, confirmation or prompt should be shown.
87   virtual void RunJavaScriptMessage(RenderFrameHost* render_frame_host,
88                                     const base::string16& message,
89                                     const base::string16& default_prompt,
90                                     const GURL& frame_url,
91                                     JavaScriptMessageType type,
92                                     IPC::Message* reply_msg) {}
93
94   virtual void RunBeforeUnloadConfirm(RenderFrameHost* render_frame_host,
95                                       const base::string16& message,
96                                       bool is_reload,
97                                       IPC::Message* reply_msg) {}
98
99   // Another page accessed the top-level initial empty document, which means it
100   // is no longer safe to display a pending URL without risking a URL spoof.
101   virtual void DidAccessInitialDocument() {}
102
103   // The frame set its opener to null, disowning it for the lifetime of the
104   // window. Only called for the top-level frame.
105   virtual void DidDisownOpener(RenderFrameHost* render_frame_host) {}
106
107   // The onload handler in the frame has completed. Only called for the top-
108   // level frame.
109   virtual void DocumentOnLoadCompleted(RenderFrameHost* render_frame_host) {}
110
111   // The page's title was changed and should be updated. Only called for the
112   // top-level frame.
113   virtual void UpdateTitle(RenderFrameHost* render_frame_host,
114                            int32 page_id,
115                            const base::string16& title,
116                            base::i18n::TextDirection title_direction) {}
117
118   // The page's encoding was changed and should be updated. Only called for the
119   // top-level frame.
120   virtual void UpdateEncoding(RenderFrameHost* render_frame_host,
121                               const std::string& encoding) {}
122
123   // Return this object cast to a WebContents, if it is one. If the object is
124   // not a WebContents, returns NULL.
125   virtual WebContents* GetAsWebContents();
126
127   // The render frame has requested access to media devices listed in
128   // |request|, and the client should grant or deny that permission by
129   // calling |callback|.
130   virtual void RequestMediaAccessPermission(
131       const MediaStreamRequest& request,
132       const MediaResponseCallback& callback);
133
134   // Checks if we have permission to access the microphone or camera. Note that
135   // this does not query the user. |type| must be MEDIA_DEVICE_AUDIO_CAPTURE
136   // or MEDIA_DEVICE_VIDEO_CAPTURE.
137   virtual bool CheckMediaAccessPermission(const GURL& security_origin,
138                                           MediaStreamType type);
139
140   // Get the accessibility mode for the WebContents that owns this frame.
141   virtual AccessibilityMode GetAccessibilityMode() const;
142
143   // Invoked when an accessibility event is received from the renderer.
144   virtual void AccessibilityEventReceived(
145       const std::vector<AXEventNotificationDetails>& details) {}
146
147   // Find a guest RenderFrameHost by its browser plugin instance id.
148   virtual RenderFrameHost* GetGuestByInstanceID(
149       int browser_plugin_instance_id);
150
151   // Gets the GeolocationServiceContext associated with this delegate.
152   virtual GeolocationServiceContext* GetGeolocationServiceContext();
153
154 #if defined(OS_WIN)
155   // Returns the frame's parent's NativeViewAccessible.
156   virtual gfx::NativeViewAccessible GetParentNativeViewAccessible();
157 #endif
158
159  protected:
160   virtual ~RenderFrameHostDelegate() {}
161 };
162
163 }  // namespace content
164
165 #endif  // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_DELEGATE_H_