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

Side by Side Diff: content/renderer/render_frame_impl.h

Issue 130773004: Start moving context menu code to RenderFrame. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 #ifndef CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ 5 #ifndef CONTENT_RENDERER_RENDER_FRAME_IMPL_H_
6 #define CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ 6 #define CONTENT_RENDERER_RENDER_FRAME_IMPL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/id_map.h"
12 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 15 #include "base/observer_list.h"
14 #include "base/process/process_handle.h" 16 #include "base/process/process_handle.h"
15 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
16 #include "content/public/renderer/render_frame.h" 18 #include "content/public/renderer/render_frame.h"
17 #include "content/renderer/renderer_webcookiejar_impl.h" 19 #include "content/renderer/renderer_webcookiejar_impl.h"
18 #include "ipc/ipc_message.h" 20 #include "ipc/ipc_message.h"
19 #include "third_party/WebKit/public/web/WebDataSource.h" 21 #include "third_party/WebKit/public/web/WebDataSource.h"
20 #include "third_party/WebKit/public/web/WebFrameClient.h" 22 #include "third_party/WebKit/public/web/WebFrameClient.h"
21 23
22 class TransportDIB; 24 class TransportDIB;
23 struct FrameMsg_BuffersSwapped_Params; 25 struct FrameMsg_BuffersSwapped_Params;
24 struct FrameMsg_CompositorFrameSwapped_Params; 26 struct FrameMsg_CompositorFrameSwapped_Params;
25 27
26 namespace blink { 28 namespace blink {
27 class WebMouseEvent; 29 class WebMouseEvent;
28 struct WebCompositionUnderline; 30 struct WebCompositionUnderline;
31 struct WebContextMenuData;
29 struct WebCursorInfo; 32 struct WebCursorInfo;
30 } 33 }
31 34
32 namespace gfx { 35 namespace gfx {
36 class Point;
33 class Range; 37 class Range;
34 class Rect; 38 class Rect;
35 } 39 }
36 40
37 namespace content { 41 namespace content {
38 42
39 class ChildFrameCompositingHelper; 43 class ChildFrameCompositingHelper;
40 class PepperPluginInstanceImpl; 44 class PepperPluginInstanceImpl;
41 class RendererPpapiHost; 45 class RendererPpapiHost;
42 class RenderFrameObserver; 46 class RenderFrameObserver;
43 class RenderViewImpl; 47 class RenderViewImpl;
44 class RenderWidget; 48 class RenderWidget;
45 class RenderWidgetFullscreenPepper; 49 class RenderWidgetFullscreenPepper;
50 struct CustomContextMenuContext;
46 51
47 class CONTENT_EXPORT RenderFrameImpl 52 class CONTENT_EXPORT RenderFrameImpl
48 : public RenderFrame, 53 : public RenderFrame,
49 NON_EXPORTED_BASE(public blink::WebFrameClient) { 54 NON_EXPORTED_BASE(public blink::WebFrameClient) {
50 public: 55 public:
51 // Creates a new RenderFrame. |render_view| is the RenderView object that this 56 // Creates a new RenderFrame. |render_view| is the RenderView object that this
52 // frame belongs to. 57 // frame belongs to.
53 // Callers *must* call |SetWebFrame| immediately after creation. 58 // Callers *must* call |SetWebFrame| immediately after creation.
54 // TODO(creis): We should structure this so that |SetWebFrame| isn't needed. 59 // TODO(creis): We should structure this so that |SetWebFrame| isn't needed.
55 static RenderFrameImpl* Create(RenderViewImpl* render_view, int32 routing_id); 60 static RenderFrameImpl* Create(RenderViewImpl* render_view, int32 routing_id);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 blink::WebSecurityOrigin targetOrigin, 312 blink::WebSecurityOrigin targetOrigin,
308 blink::WebDOMMessageEvent event); 313 blink::WebDOMMessageEvent event);
309 virtual blink::WebString userAgentOverride( 314 virtual blink::WebString userAgentOverride(
310 blink::WebFrame* frame, 315 blink::WebFrame* frame,
311 const blink::WebURL& url); 316 const blink::WebURL& url);
312 virtual blink::WebString doNotTrackValue(blink::WebFrame* frame); 317 virtual blink::WebString doNotTrackValue(blink::WebFrame* frame);
313 virtual bool allowWebGL(blink::WebFrame* frame, bool default_value); 318 virtual bool allowWebGL(blink::WebFrame* frame, bool default_value);
314 virtual void didLoseWebGLContext(blink::WebFrame* frame, 319 virtual void didLoseWebGLContext(blink::WebFrame* frame,
315 int arb_robustness_status_code); 320 int arb_robustness_status_code);
316 321
322 // TODO(jam): move this to WebFrameClient
323 virtual void showContextMenu(const blink::WebContextMenuData& data);
324
317 protected: 325 protected:
318 RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id); 326 RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id);
319 327
320 private: 328 private:
321 friend class RenderFrameObserver; 329 friend class RenderFrameObserver;
330 FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest,
331 ShouldUpdateSelectionTextFromContextMenuParams);
322 332
323 // Functions to add and remove observers for this object. 333 // Functions to add and remove observers for this object.
324 void AddObserver(RenderFrameObserver* observer); 334 void AddObserver(RenderFrameObserver* observer);
325 void RemoveObserver(RenderFrameObserver* observer); 335 void RemoveObserver(RenderFrameObserver* observer);
326 336
327 // IPC message handlers ------------------------------------------------------ 337 // IPC message handlers ------------------------------------------------------
328 // 338 //
329 // The documentation for these functions should be in 339 // The documentation for these functions should be in
330 // content/common/*_messages.h for the message that the function is handling. 340 // content/common/*_messages.h for the message that the function is handling.
331 void OnSwapOut(); 341 void OnSwapOut();
332 void OnBuffersSwapped(const FrameMsg_BuffersSwapped_Params& params); 342 void OnBuffersSwapped(const FrameMsg_BuffersSwapped_Params& params);
333 void OnCompositorFrameSwapped(const IPC::Message& message); 343 void OnCompositorFrameSwapped(const IPC::Message& message);
344 void OnShowContextMenu(const gfx::Point& location);
345 void OnContextMenuClosed(const CustomContextMenuContext& custom_context);
346 void OnCustomContextMenuAction(const CustomContextMenuContext& custom_context,
347 unsigned action);
348
349 // Returns whether |params.selection_text| should be synchronized to the
350 // browser before bringing up the context menu. Static for testing.
351 static bool ShouldUpdateSelectionTextFromContextMenuParams(
352 const base::string16& selection_text,
353 size_t selection_text_offset,
354 const gfx::Range& selection_range,
355 const ContextMenuParams& params);
334 356
335 // Stores the WebFrame we are associated with. 357 // Stores the WebFrame we are associated with.
336 blink::WebFrame* frame_; 358 blink::WebFrame* frame_;
337 359
338 base::WeakPtr<RenderViewImpl> render_view_; 360 base::WeakPtr<RenderViewImpl> render_view_;
339 int routing_id_; 361 int routing_id_;
340 bool is_swapped_out_; 362 bool is_swapped_out_;
341 bool is_detaching_; 363 bool is_detaching_;
342 364
343 #if defined(ENABLE_PLUGINS) 365 #if defined(ENABLE_PLUGINS)
344 // Current text input composition text. Empty if no composition is in 366 // Current text input composition text. Empty if no composition is in
345 // progress. 367 // progress.
346 base::string16 pepper_composition_text_; 368 base::string16 pepper_composition_text_;
347 #endif 369 #endif
348 370
349 RendererWebCookieJarImpl cookie_jar_; 371 RendererWebCookieJarImpl cookie_jar_;
350 372
351 // All the registered observers. 373 // All the registered observers.
352 ObserverList<RenderFrameObserver> observers_; 374 ObserverList<RenderFrameObserver> observers_;
353 375
354 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; 376 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_;
355 377
378 // External context menu requests we're waiting for. "Internal"
379 // (WebKit-originated) context menu events will have an ID of 0 and will not
380 // be in this map.
381 //
382 // We don't want to add internal ones since some of the "special" page
383 // handlers in the browser process just ignore the context menu requests so
384 // avoid showing context menus, and so this will cause right clicks to leak
385 // entries in this map. Most users of the custom context menu (e.g. Pepper
386 // plugins) are normally only on "regular" pages and the regular pages will
387 // always respond properly to the request, so we don't have to worry so
388 // much about leaks.
389 IDMap<ContextMenuClient, IDMapExternalPointer> pending_context_menus_;
390
356 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl); 391 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl);
357 }; 392 };
358 393
359 } // namespace content 394 } // namespace content
360 395
361 #endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_ 396 #endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698