[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 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_RENDERER_RENDER_FRAME_IMPL_H_ |
| 6 | #define CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ |
| 7 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 10 | #include "base/basictypes.h" |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 11 | #include "base/files/file_path.h" |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 12 | #include "base/gtest_prod_util.h" |
| 13 | #include "base/id_map.h" |
[email protected] | abc501e | 2014-01-27 19:27:26 | [diff] [blame] | 14 | #include "base/memory/weak_ptr.h" |
[email protected] | 2e2d963 | 2013-12-03 00:55:26 | [diff] [blame] | 15 | #include "base/observer_list.h" |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 16 | #include "base/process/process_handle.h" |
[email protected] | 65920f33 | 2014-03-04 21:14:18 | [diff] [blame] | 17 | #include "content/public/common/referrer.h" |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 18 | #include "content/public/renderer/render_frame.h" |
[email protected] | f3add92 | 2013-12-20 23:17:16 | [diff] [blame] | 19 | #include "content/renderer/renderer_webcookiejar_impl.h" |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 20 | #include "ipc/ipc_message.h" |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 21 | #include "third_party/WebKit/public/web/WebDataSource.h" |
| 22 | #include "third_party/WebKit/public/web/WebFrameClient.h" |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 23 | #include "ui/gfx/range/range.h" |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 24 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 25 | class TransportDIB; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 26 | struct FrameMsg_BuffersSwapped_Params; |
| 27 | struct FrameMsg_CompositorFrameSwapped_Params; |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 28 | struct FrameMsg_Navigate_Params; |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 29 | |
| 30 | namespace blink { |
[email protected] | 5cdd8fd8 | 2014-02-05 20:12:12 | [diff] [blame] | 31 | class WebInputEvent; |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 32 | class WebMouseEvent; |
[email protected] | 82ce5b9 | 2014-03-22 05:15:26 | [diff] [blame] | 33 | class WebContentDecryptionModule; |
| 34 | class WebSecurityOrigin; |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 35 | struct WebCompositionUnderline; |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 36 | struct WebContextMenuData; |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 37 | struct WebCursorInfo; |
| 38 | } |
| 39 | |
| 40 | namespace gfx { |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 41 | class Point; |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 42 | class Range; |
| 43 | class Rect; |
| 44 | } |
| 45 | |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 46 | namespace content { |
| 47 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 48 | class ChildFrameCompositingHelper; |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 49 | class PepperPluginInstanceImpl; |
| 50 | class RendererPpapiHost; |
[email protected] | 2e2d963 | 2013-12-03 00:55:26 | [diff] [blame] | 51 | class RenderFrameObserver; |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 52 | class RenderViewImpl; |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 53 | class RenderWidget; |
| 54 | class RenderWidgetFullscreenPepper; |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 55 | struct CustomContextMenuContext; |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 56 | |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 57 | class CONTENT_EXPORT RenderFrameImpl |
| 58 | : public RenderFrame, |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 59 | NON_EXPORTED_BASE(public blink::WebFrameClient) { |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 60 | public: |
[email protected] | 2f61bdd | 2013-07-02 18:38:47 | [diff] [blame] | 61 | // Creates a new RenderFrame. |render_view| is the RenderView object that this |
| 62 | // frame belongs to. |
[email protected] | b70da4c | 2014-01-06 19:57:09 | [diff] [blame] | 63 | // Callers *must* call |SetWebFrame| immediately after creation. |
| 64 | // TODO(creis): We should structure this so that |SetWebFrame| isn't needed. |
[email protected] | 2f61bdd | 2013-07-02 18:38:47 | [diff] [blame] | 65 | static RenderFrameImpl* Create(RenderViewImpl* render_view, int32 routing_id); |
| 66 | |
[email protected] | a5ac6dc | 2014-01-15 07:02:14 | [diff] [blame] | 67 | // Just like RenderFrame::FromWebFrame but returns the implementation. |
| 68 | static RenderFrameImpl* FromWebFrame(blink::WebFrame* web_frame); |
[email protected] | b70da4c | 2014-01-06 19:57:09 | [diff] [blame] | 69 | |
[email protected] | 2f61bdd | 2013-07-02 18:38:47 | [diff] [blame] | 70 | // Used by content_layouttest_support to hook into the creation of |
| 71 | // RenderFrameImpls. |
| 72 | static void InstallCreateHook( |
| 73 | RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)); |
| 74 | |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 75 | virtual ~RenderFrameImpl(); |
| 76 | |
[email protected] | b70da4c | 2014-01-06 19:57:09 | [diff] [blame] | 77 | bool is_swapped_out() const { |
| 78 | return is_swapped_out_; |
| 79 | } |
| 80 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 81 | // Out-of-process child frames receive a signal from RenderWidgetCompositor |
| 82 | // when a compositor frame has committed. |
| 83 | void DidCommitCompositorFrame(); |
| 84 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 85 | // TODO(jam): this is a temporary getter until all the code is transitioned |
| 86 | // to using RenderFrame instead of RenderView. |
[email protected] | abc501e | 2014-01-27 19:27:26 | [diff] [blame] | 87 | RenderViewImpl* render_view() { return render_view_.get(); } |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 88 | |
[email protected] | f3add92 | 2013-12-20 23:17:16 | [diff] [blame] | 89 | RendererWebCookieJarImpl* cookie_jar() { return &cookie_jar_; } |
| 90 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 91 | // Returns the RenderWidget associated with this frame. |
| 92 | RenderWidget* GetRenderWidget(); |
| 93 | |
[email protected] | a5ac6dc | 2014-01-15 07:02:14 | [diff] [blame] | 94 | // This is called right after creation with the WebFrame for this RenderFrame. |
[email protected] | b70da4c | 2014-01-06 19:57:09 | [diff] [blame] | 95 | void SetWebFrame(blink::WebFrame* web_frame); |
| 96 | |
[email protected] | 5815cf5 | 2014-01-29 17:45:05 | [diff] [blame] | 97 | // Notification from RenderView. |
| 98 | virtual void OnStop(); |
| 99 | |
[email protected] | 723971b | 2014-02-12 11:08:25 | [diff] [blame] | 100 | // Start/Stop loading notifications. |
| 101 | // TODO(nasko): Those are page-level methods at this time and come from |
| 102 | // WebViewClient. We should move them to be WebFrameClient calls and put |
| 103 | // logic in the browser side to balance starts/stops. |
[email protected] | e3b10d1 | 2014-03-28 16:06:09 | [diff] [blame] | 104 | // |to_different_document| will be true unless the load is a fragment |
| 105 | // navigation, or triggered by history.pushState/replaceState. |
[email protected] | 6dd5c32 | 2014-03-12 07:58:46 | [diff] [blame] | 106 | virtual void didStartLoading(bool to_different_document); |
| 107 | virtual void didStopLoading(); |
| 108 | virtual void didChangeLoadProgress(double load_progress); |
[email protected] | 723971b | 2014-02-12 11:08:25 | [diff] [blame] | 109 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 110 | #if defined(ENABLE_PLUGINS) |
[email protected] | 271ff579 | 2013-12-04 22:29:31 | [diff] [blame] | 111 | // Notification that a PPAPI plugin has been created. |
| 112 | void PepperPluginCreated(RendererPpapiHost* host); |
| 113 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 114 | // Notifies that |instance| has changed the cursor. |
| 115 | // This will update the cursor appearance if it is currently over the plugin |
| 116 | // instance. |
| 117 | void PepperDidChangeCursor(PepperPluginInstanceImpl* instance, |
| 118 | const blink::WebCursorInfo& cursor); |
| 119 | |
| 120 | // Notifies that |instance| has received a mouse event. |
| 121 | void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl* instance); |
| 122 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 123 | // Informs the render view that a PPAPI plugin has changed text input status. |
| 124 | void PepperTextInputTypeChanged(PepperPluginInstanceImpl* instance); |
| 125 | void PepperCaretPositionChanged(PepperPluginInstanceImpl* instance); |
| 126 | |
| 127 | // Cancels current composition. |
| 128 | void PepperCancelComposition(PepperPluginInstanceImpl* instance); |
| 129 | |
| 130 | // Informs the render view that a PPAPI plugin has changed selection. |
| 131 | void PepperSelectionChanged(PepperPluginInstanceImpl* instance); |
| 132 | |
| 133 | // Creates a fullscreen container for a pepper plugin instance. |
| 134 | RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer( |
| 135 | PepperPluginInstanceImpl* plugin); |
| 136 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 137 | bool IsPepperAcceptingCompositionEvents() const; |
| 138 | |
| 139 | // Notification that the given plugin has crashed. |
| 140 | void PluginCrashed(const base::FilePath& plugin_path, |
| 141 | base::ProcessId plugin_pid); |
| 142 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 143 | // Simulates IME events for testing purpose. |
| 144 | void SimulateImeSetComposition( |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 145 | const base::string16& text, |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 146 | const std::vector<blink::WebCompositionUnderline>& underlines, |
| 147 | int selection_start, |
| 148 | int selection_end); |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 149 | void SimulateImeConfirmComposition(const base::string16& text, |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 150 | const gfx::Range& replacement_range); |
| 151 | |
| 152 | // TODO(jam): remove these once the IPC handler moves from RenderView to |
| 153 | // RenderFrame. |
| 154 | void OnImeSetComposition( |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 155 | const base::string16& text, |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 156 | const std::vector<blink::WebCompositionUnderline>& underlines, |
| 157 | int selection_start, |
| 158 | int selection_end); |
| 159 | void OnImeConfirmComposition( |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 160 | const base::string16& text, |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 161 | const gfx::Range& replacement_range, |
| 162 | bool keep_selection); |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 163 | #endif // ENABLE_PLUGINS |
| 164 | |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 165 | // IPC::Sender |
| 166 | virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 167 | |
| 168 | // IPC::Listener |
| 169 | virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 170 | |
[email protected] | 271ff579 | 2013-12-04 22:29:31 | [diff] [blame] | 171 | // RenderFrame implementation: |
[email protected] | b849847b | 2013-12-10 21:57:58 | [diff] [blame] | 172 | virtual RenderView* GetRenderView() OVERRIDE; |
[email protected] | 60eca4eb | 2013-12-06 00:02:16 | [diff] [blame] | 173 | virtual int GetRoutingID() OVERRIDE; |
[email protected] | a5ac6dc | 2014-01-15 07:02:14 | [diff] [blame] | 174 | virtual blink::WebFrame* GetWebFrame() OVERRIDE; |
[email protected] | d019e1a38 | 2013-12-11 17:52:06 | [diff] [blame] | 175 | virtual WebPreferences& GetWebkitPreferences() OVERRIDE; |
| 176 | virtual int ShowContextMenu(ContextMenuClient* client, |
| 177 | const ContextMenuParams& params) OVERRIDE; |
| 178 | virtual void CancelContextMenu(int request_id) OVERRIDE; |
[email protected] | 1a6d011 | 2014-03-10 19:08:41 | [diff] [blame] | 179 | virtual blink::WebNode GetContextMenuNode() const OVERRIDE; |
[email protected] | 271ff579 | 2013-12-04 22:29:31 | [diff] [blame] | 180 | virtual blink::WebPlugin* CreatePlugin( |
| 181 | blink::WebFrame* frame, |
| 182 | const WebPluginInfo& info, |
| 183 | const blink::WebPluginParams& params) OVERRIDE; |
[email protected] | d019e1a38 | 2013-12-11 17:52:06 | [diff] [blame] | 184 | virtual void LoadURLExternally( |
| 185 | blink::WebFrame* frame, |
| 186 | const blink::WebURLRequest& request, |
| 187 | blink::WebNavigationPolicy policy) OVERRIDE; |
[email protected] | db3be76f | 2014-03-25 02:27:47 | [diff] [blame] | 188 | virtual void ExecuteJavaScript(const base::string16& javascript) OVERRIDE; |
[email protected] | 271ff579 | 2013-12-04 22:29:31 | [diff] [blame] | 189 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 190 | // blink::WebFrameClient implementation ------------------------------------- |
| 191 | virtual blink::WebPlugin* createPlugin( |
| 192 | blink::WebFrame* frame, |
| 193 | const blink::WebPluginParams& params); |
| 194 | virtual blink::WebMediaPlayer* createMediaPlayer( |
| 195 | blink::WebFrame* frame, |
| 196 | const blink::WebURL& url, |
| 197 | blink::WebMediaPlayerClient* client); |
[email protected] | 82ce5b9 | 2014-03-22 05:15:26 | [diff] [blame] | 198 | virtual blink::WebContentDecryptionModule* createContentDecryptionModule( |
| 199 | blink::WebFrame* frame, |
| 200 | const blink::WebSecurityOrigin& security_origin, |
| 201 | const blink::WebString& key_system); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 202 | virtual blink::WebApplicationCacheHost* createApplicationCacheHost( |
| 203 | blink::WebFrame* frame, |
| 204 | blink::WebApplicationCacheHostClient* client); |
| 205 | virtual blink::WebWorkerPermissionClientProxy* |
| 206 | createWorkerPermissionClientProxy(blink::WebFrame* frame); |
| 207 | virtual blink::WebCookieJar* cookieJar(blink::WebFrame* frame); |
| 208 | virtual blink::WebServiceWorkerProvider* createServiceWorkerProvider( |
[email protected] | 7e11315 | 2014-02-26 20:01:14 | [diff] [blame] | 209 | blink::WebFrame* frame); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 210 | virtual void didAccessInitialDocument(blink::WebFrame* frame); |
| 211 | virtual blink::WebFrame* createChildFrame(blink::WebFrame* parent, |
| 212 | const blink::WebString& name); |
| 213 | virtual void didDisownOpener(blink::WebFrame* frame); |
| 214 | virtual void frameDetached(blink::WebFrame* frame); |
[email protected] | 9c9343b | 2014-03-08 02:56:07 | [diff] [blame] | 215 | virtual void frameFocused(); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 216 | virtual void willClose(blink::WebFrame* frame); |
| 217 | virtual void didChangeName(blink::WebFrame* frame, |
| 218 | const blink::WebString& name); |
[email protected] | f5b6dd112 | 2013-10-04 02:42:50 | [diff] [blame] | 219 | virtual void didMatchCSS( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 220 | blink::WebFrame* frame, |
| 221 | const blink::WebVector<blink::WebString>& newly_matching_selectors, |
| 222 | const blink::WebVector<blink::WebString>& stopped_matching_selectors); |
| 223 | virtual void loadURLExternally(blink::WebFrame* frame, |
| 224 | const blink::WebURLRequest& request, |
| 225 | blink::WebNavigationPolicy policy); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 226 | virtual void loadURLExternally( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 227 | blink::WebFrame* frame, |
| 228 | const blink::WebURLRequest& request, |
| 229 | blink::WebNavigationPolicy policy, |
| 230 | const blink::WebString& suggested_name); |
[email protected] | 1a4e975 | 2013-12-31 20:10:58 | [diff] [blame] | 231 | // The WebDataSource::ExtraData* is assumed to be a DocumentState* subclass. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 232 | virtual blink::WebNavigationPolicy decidePolicyForNavigation( |
| 233 | blink::WebFrame* frame, |
| 234 | blink::WebDataSource::ExtraData* extra_data, |
| 235 | const blink::WebURLRequest& request, |
| 236 | blink::WebNavigationType type, |
| 237 | blink::WebNavigationPolicy default_policy, |
[email protected] | f6ae17fc | 2013-08-19 22:56:17 | [diff] [blame] | 238 | bool is_redirect); |
| 239 | // DEPRECATED |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 240 | virtual blink::WebNavigationPolicy decidePolicyForNavigation( |
| 241 | blink::WebFrame* frame, |
| 242 | const blink::WebURLRequest& request, |
| 243 | blink::WebNavigationType type, |
| 244 | blink::WebNavigationPolicy default_policy, |
[email protected] | 255eea09 | 2013-06-28 17:19:14 | [diff] [blame] | 245 | bool is_redirect); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 246 | virtual void willSendSubmitEvent(blink::WebFrame* frame, |
| 247 | const blink::WebFormElement& form); |
| 248 | virtual void willSubmitForm(blink::WebFrame* frame, |
| 249 | const blink::WebFormElement& form); |
| 250 | virtual void didCreateDataSource(blink::WebFrame* frame, |
| 251 | blink::WebDataSource* datasource); |
| 252 | virtual void didStartProvisionalLoad(blink::WebFrame* frame); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 253 | virtual void didReceiveServerRedirectForProvisionalLoad( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 254 | blink::WebFrame* frame); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 255 | virtual void didFailProvisionalLoad( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 256 | blink::WebFrame* frame, |
| 257 | const blink::WebURLError& error); |
| 258 | virtual void didCommitProvisionalLoad(blink::WebFrame* frame, |
[email protected] | 255eea09 | 2013-06-28 17:19:14 | [diff] [blame] | 259 | bool is_new_navigation); |
[email protected] | c4f80f7 | 2014-01-13 11:24:12 | [diff] [blame] | 260 | virtual void didClearWindowObject(blink::WebFrame* frame, int world_id); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 261 | virtual void didCreateDocumentElement(blink::WebFrame* frame); |
| 262 | virtual void didReceiveTitle(blink::WebFrame* frame, |
| 263 | const blink::WebString& title, |
| 264 | blink::WebTextDirection direction); |
| 265 | virtual void didChangeIcon(blink::WebFrame* frame, |
| 266 | blink::WebIconURL::Type icon_type); |
| 267 | virtual void didFinishDocumentLoad(blink::WebFrame* frame); |
| 268 | virtual void didHandleOnloadEvents(blink::WebFrame* frame); |
| 269 | virtual void didFailLoad(blink::WebFrame* frame, |
| 270 | const blink::WebURLError& error); |
| 271 | virtual void didFinishLoad(blink::WebFrame* frame); |
| 272 | virtual void didNavigateWithinPage(blink::WebFrame* frame, |
[email protected] | 255eea09 | 2013-06-28 17:19:14 | [diff] [blame] | 273 | bool is_new_navigation); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 274 | virtual void didUpdateCurrentHistoryItem(blink::WebFrame* frame); |
[email protected] | c3f2c70 | 2014-03-19 23:39:48 | [diff] [blame] | 275 | virtual void didChangeSelection(bool is_empty_selection); |
[email protected] | 12cc511 | 2014-03-03 17:01:10 | [diff] [blame] | 276 | virtual void showContextMenu(const blink::WebContextMenuData& data); |
[email protected] | 9107034 | 2014-03-07 00:29:02 | [diff] [blame] | 277 | virtual void clearContextMenu(); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 278 | virtual void willRequestAfterPreconnect(blink::WebFrame* frame, |
| 279 | blink::WebURLRequest& request); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 280 | virtual void willSendRequest( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 281 | blink::WebFrame* frame, |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 282 | unsigned identifier, |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 283 | blink::WebURLRequest& request, |
| 284 | const blink::WebURLResponse& redirect_response); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 285 | virtual void didReceiveResponse( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 286 | blink::WebFrame* frame, |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 287 | unsigned identifier, |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 288 | const blink::WebURLResponse& response); |
| 289 | virtual void didFinishResourceLoad(blink::WebFrame* frame, |
[email protected] | 255eea09 | 2013-06-28 17:19:14 | [diff] [blame] | 290 | unsigned identifier); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 291 | virtual void didLoadResourceFromMemoryCache( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 292 | blink::WebFrame* frame, |
| 293 | const blink::WebURLRequest& request, |
| 294 | const blink::WebURLResponse& response); |
| 295 | virtual void didDisplayInsecureContent(blink::WebFrame* frame); |
| 296 | virtual void didRunInsecureContent(blink::WebFrame* frame, |
| 297 | const blink::WebSecurityOrigin& origin, |
| 298 | const blink::WebURL& target); |
| 299 | virtual void didAbortLoading(blink::WebFrame* frame); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 300 | virtual void didCreateScriptContext(blink::WebFrame* frame, |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 301 | v8::Handle<v8::Context> context, |
| 302 | int extension_group, |
[email protected] | 255eea09 | 2013-06-28 17:19:14 | [diff] [blame] | 303 | int world_id); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 304 | virtual void willReleaseScriptContext(blink::WebFrame* frame, |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 305 | v8::Handle<v8::Context> context, |
[email protected] | 255eea09 | 2013-06-28 17:19:14 | [diff] [blame] | 306 | int world_id); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 307 | virtual void didFirstVisuallyNonEmptyLayout(blink::WebFrame* frame); |
| 308 | virtual void didChangeContentsSize(blink::WebFrame* frame, |
| 309 | const blink::WebSize& size); |
| 310 | virtual void didChangeScrollOffset(blink::WebFrame* frame); |
| 311 | virtual void willInsertBody(blink::WebFrame* frame); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 312 | virtual void reportFindInPageMatchCount(int request_id, |
| 313 | int count, |
[email protected] | 255eea09 | 2013-06-28 17:19:14 | [diff] [blame] | 314 | bool final_update); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 315 | virtual void reportFindInPageSelection(int request_id, |
| 316 | int active_match_ordinal, |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 317 | const blink::WebRect& sel); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 318 | virtual void requestStorageQuota( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 319 | blink::WebFrame* frame, |
| 320 | blink::WebStorageQuotaType type, |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 321 | unsigned long long requested_size, |
[email protected] | 45868f07 | 2014-02-06 11:58:59 | [diff] [blame] | 322 | blink::WebStorageQuotaCallbacks callbacks); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 323 | virtual void willOpenSocketStream( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 324 | blink::WebSocketStreamHandle* handle); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 325 | virtual void willStartUsingPeerConnectionHandler( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 326 | blink::WebFrame* frame, |
| 327 | blink::WebRTCPeerConnectionHandler* handler); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 328 | virtual bool willCheckAndDispatchMessageEvent( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 329 | blink::WebFrame* sourceFrame, |
| 330 | blink::WebFrame* targetFrame, |
| 331 | blink::WebSecurityOrigin targetOrigin, |
| 332 | blink::WebDOMMessageEvent event); |
| 333 | virtual blink::WebString userAgentOverride( |
| 334 | blink::WebFrame* frame, |
| 335 | const blink::WebURL& url); |
| 336 | virtual blink::WebString doNotTrackValue(blink::WebFrame* frame); |
| 337 | virtual bool allowWebGL(blink::WebFrame* frame, bool default_value); |
| 338 | virtual void didLoseWebGLContext(blink::WebFrame* frame, |
[email protected] | 255eea09 | 2013-06-28 17:19:14 | [diff] [blame] | 339 | int arb_robustness_status_code); |
[email protected] | 5cdd8fd8 | 2014-02-05 20:12:12 | [diff] [blame] | 340 | virtual void forwardInputEvent(const blink::WebInputEvent* event); |
[email protected] | 9ef43adc | 2014-02-19 08:02:15 | [diff] [blame] | 341 | virtual void initializeChildFrame(const blink::WebRect& frame_rect, |
| 342 | float scale_factor); |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 343 | |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 344 | // TODO(nasko): Make all tests in RenderViewImplTest friends and then move |
| 345 | // this back to private member. |
| 346 | void OnNavigate(const FrameMsg_Navigate_Params& params); |
| 347 | |
[email protected] | 2f61bdd | 2013-07-02 18:38:47 | [diff] [blame] | 348 | protected: |
| 349 | RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id); |
| 350 | |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 351 | private: |
[email protected] | 2e2d963 | 2013-12-03 00:55:26 | [diff] [blame] | 352 | friend class RenderFrameObserver; |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 353 | FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest, |
| 354 | ShouldUpdateSelectionTextFromContextMenuParams); |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 355 | FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, |
| 356 | OnExtendSelectionAndDelete); |
| 357 | FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, |
| 358 | SetEditableSelectionAndComposition); |
[email protected] | 2e2d963 | 2013-12-03 00:55:26 | [diff] [blame] | 359 | |
[email protected] | 37567b43 | 2014-02-12 01:12:22 | [diff] [blame] | 360 | typedef std::map<GURL, double> HostZoomLevels; |
| 361 | |
[email protected] | 2e2d963 | 2013-12-03 00:55:26 | [diff] [blame] | 362 | // Functions to add and remove observers for this object. |
| 363 | void AddObserver(RenderFrameObserver* observer); |
| 364 | void RemoveObserver(RenderFrameObserver* observer); |
[email protected] | 1c2052f | 2013-08-28 08:24:34 | [diff] [blame] | 365 | |
[email protected] | 37567b43 | 2014-02-12 01:12:22 | [diff] [blame] | 366 | void UpdateURL(blink::WebFrame* frame); |
| 367 | |
[email protected] | 9c9343b | 2014-03-08 02:56:07 | [diff] [blame] | 368 | // Gets the focused element. If no such element exists then the element will |
| 369 | // be NULL. |
| 370 | blink::WebElement GetFocusedElement(); |
| 371 | |
[email protected] | b70da4c | 2014-01-06 19:57:09 | [diff] [blame] | 372 | // IPC message handlers ------------------------------------------------------ |
| 373 | // |
| 374 | // The documentation for these functions should be in |
| 375 | // content/common/*_messages.h for the message that the function is handling. |
[email protected] | f76f3223 | 2014-03-11 17:36:17 | [diff] [blame] | 376 | void OnBeforeUnload(); |
[email protected] | b70da4c | 2014-01-06 19:57:09 | [diff] [blame] | 377 | void OnSwapOut(); |
[email protected] | f49722f | 2014-01-30 17:54:50 | [diff] [blame] | 378 | void OnChildFrameProcessGone(); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 379 | void OnBuffersSwapped(const FrameMsg_BuffersSwapped_Params& params); |
| 380 | void OnCompositorFrameSwapped(const IPC::Message& message); |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 381 | void OnShowContextMenu(const gfx::Point& location); |
| 382 | void OnContextMenuClosed(const CustomContextMenuContext& custom_context); |
| 383 | void OnCustomContextMenuAction(const CustomContextMenuContext& custom_context, |
| 384 | unsigned action); |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 385 | void OnUndo(); |
| 386 | void OnRedo(); |
[email protected] | 9c9343b | 2014-03-08 02:56:07 | [diff] [blame] | 387 | void OnCut(); |
| 388 | void OnCopy(); |
| 389 | void OnPaste(); |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 390 | void OnPasteAndMatchStyle(); |
| 391 | void OnDelete(); |
| 392 | void OnSelectAll(); |
| 393 | void OnSelectRange(const gfx::Point& start, const gfx::Point& end); |
| 394 | void OnUnselect(); |
[email protected] | e31b8ebb | 2014-03-07 17:59:34 | [diff] [blame] | 395 | void OnCSSInsertRequest(const std::string& css); |
[email protected] | f13ab89 | 2014-03-12 06:48:52 | [diff] [blame] | 396 | void OnJavaScriptExecuteRequest(const base::string16& javascript, |
| 397 | int id, |
| 398 | bool notify_result); |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 399 | void OnSetEditableSelectionOffsets(int start, int end); |
[email protected] | e5e438d6 | 2014-03-27 21:47:16 | [diff] [blame] | 400 | void OnSetCompositionFromExistingText( |
| 401 | int start, int end, |
| 402 | const std::vector<blink::WebCompositionUnderline>& underlines); |
| 403 | void OnExtendSelectionAndDelete(int before, int after); |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 404 | #if defined(OS_MACOSX) |
| 405 | void OnCopyToFindPboard(); |
| 406 | #endif |
[email protected] | 9c9343b | 2014-03-08 02:56:07 | [diff] [blame] | 407 | |
[email protected] | 65920f33 | 2014-03-04 21:14:18 | [diff] [blame] | 408 | // Virtual since overridden by WebTestProxy for layout tests. |
| 409 | virtual blink::WebNavigationPolicy DecidePolicyForNavigation( |
| 410 | RenderFrame* render_frame, |
| 411 | blink::WebFrame* frame, |
| 412 | blink::WebDataSource::ExtraData* extraData, |
| 413 | const blink::WebURLRequest& request, |
| 414 | blink::WebNavigationType type, |
| 415 | blink::WebNavigationPolicy default_policy, |
| 416 | bool is_redirect); |
| 417 | void OpenURL(blink::WebFrame* frame, |
| 418 | const GURL& url, |
| 419 | const Referrer& referrer, |
| 420 | blink::WebNavigationPolicy policy); |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 421 | |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 422 | // Dispatches the current state of selection on the webpage to the browser if |
| 423 | // it has changed. |
| 424 | // TODO(varunjain): delete this method once we figure out how to keep |
| 425 | // selection handles in sync with the webpage. |
| 426 | void SyncSelectionIfRequired(); |
| 427 | |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 428 | // Returns whether |params.selection_text| should be synchronized to the |
| 429 | // browser before bringing up the context menu. Static for testing. |
| 430 | static bool ShouldUpdateSelectionTextFromContextMenuParams( |
| 431 | const base::string16& selection_text, |
| 432 | size_t selection_text_offset, |
| 433 | const gfx::Range& selection_range, |
| 434 | const ContextMenuParams& params); |
[email protected] | b70da4c | 2014-01-06 19:57:09 | [diff] [blame] | 435 | |
[email protected] | a5ac6dc | 2014-01-15 07:02:14 | [diff] [blame] | 436 | // Stores the WebFrame we are associated with. |
[email protected] | b70da4c | 2014-01-06 19:57:09 | [diff] [blame] | 437 | blink::WebFrame* frame_; |
| 438 | |
[email protected] | abc501e | 2014-01-27 19:27:26 | [diff] [blame] | 439 | base::WeakPtr<RenderViewImpl> render_view_; |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 440 | int routing_id_; |
[email protected] | 6dd5c32 | 2014-03-12 07:58:46 | [diff] [blame] | 441 | bool is_loading_; |
[email protected] | 1c2052f | 2013-08-28 08:24:34 | [diff] [blame] | 442 | bool is_swapped_out_; |
| 443 | bool is_detaching_; |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 444 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 445 | #if defined(ENABLE_PLUGINS) |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 446 | // Current text input composition text. Empty if no composition is in |
| 447 | // progress. |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 448 | base::string16 pepper_composition_text_; |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 449 | #endif |
| 450 | |
[email protected] | f3add92 | 2013-12-20 23:17:16 | [diff] [blame] | 451 | RendererWebCookieJarImpl cookie_jar_; |
| 452 | |
[email protected] | 2e2d963 | 2013-12-03 00:55:26 | [diff] [blame] | 453 | // All the registered observers. |
| 454 | ObserverList<RenderFrameObserver> observers_; |
| 455 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 456 | scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; |
| 457 | |
[email protected] | 4ecee35 | 2014-03-11 21:12:19 | [diff] [blame] | 458 | // The node that the context menu was pressed over. |
| 459 | blink::WebNode context_menu_node_; |
| 460 | |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 461 | // External context menu requests we're waiting for. "Internal" |
| 462 | // (WebKit-originated) context menu events will have an ID of 0 and will not |
| 463 | // be in this map. |
| 464 | // |
| 465 | // We don't want to add internal ones since some of the "special" page |
| 466 | // handlers in the browser process just ignore the context menu requests so |
| 467 | // avoid showing context menus, and so this will cause right clicks to leak |
| 468 | // entries in this map. Most users of the custom context menu (e.g. Pepper |
| 469 | // plugins) are normally only on "regular" pages and the regular pages will |
| 470 | // always respond properly to the request, so we don't have to worry so |
| 471 | // much about leaks. |
| 472 | IDMap<ContextMenuClient, IDMapExternalPointer> pending_context_menus_; |
| 473 | |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 474 | // The text selection the last time DidChangeSelection got called. May contain |
| 475 | // additional characters before and after the selected text, for IMEs. The |
| 476 | // portion of this string that is the actual selected text starts at index |
| 477 | // |selection_range_.GetMin() - selection_text_offset_| and has length |
| 478 | // |selection_range_.length()|. |
| 479 | base::string16 selection_text_; |
| 480 | // The offset corresponding to the start of |selection_text_| in the document. |
| 481 | size_t selection_text_offset_; |
| 482 | // Range over the document corresponding to the actual selected text (which |
| 483 | // could correspond to a substring of |selection_text_|; see above). |
| 484 | gfx::Range selection_range_; |
| 485 | // Used to inform didChangeSelection() when it is called in the context |
| 486 | // of handling a InputMsg_SelectRange IPC. |
| 487 | bool handling_select_range_; |
| 488 | |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 489 | DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl); |
| 490 | }; |
| 491 | |
| 492 | } // namespace content |
| 493 | |
[email protected] | 85d85fd | 2013-06-19 00:57:41 | [diff] [blame] | 494 | #endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ |