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

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

Issue 2498463002: RenderWidget/RenderView: encapsulate ViewHostMsg_Show, etc, in a callback (Closed)
Patch Set: Remove RenderWidgetFullscreen Created 4 years, 1 month 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
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_WIDGET_H_ 5 #ifndef CONTENT_RENDERER_RENDER_WIDGET_H_
6 #define CONTENT_RENDERER_RENDER_WIDGET_H_ 6 #define CONTENT_RENDERER_RENDER_WIDGET_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 95
96 namespace content { 96 namespace content {
97 class CompositorDependencies; 97 class CompositorDependencies;
98 class ExternalPopupMenu; 98 class ExternalPopupMenu;
99 class FrameSwapMessageQueue; 99 class FrameSwapMessageQueue;
100 class ImeEventGuard; 100 class ImeEventGuard;
101 class PepperPluginInstanceImpl; 101 class PepperPluginInstanceImpl;
102 class RenderFrameImpl; 102 class RenderFrameImpl;
103 class RenderFrameProxy; 103 class RenderFrameProxy;
104 class RenderViewImpl;
104 class RenderWidgetCompositor; 105 class RenderWidgetCompositor;
105 class RenderWidgetOwnerDelegate; 106 class RenderWidgetOwnerDelegate;
106 class RenderWidgetScreenMetricsEmulator; 107 class RenderWidgetScreenMetricsEmulator;
107 class ResizingModeSelector; 108 class ResizingModeSelector;
108 class TextInputClientObserver; 109 class TextInputClientObserver;
109 struct ContextMenuParams; 110 struct ContextMenuParams;
110 struct ResizeParams; 111 struct ResizeParams;
111 112
112 // RenderWidget provides a communication bridge between a WebWidget and 113 // RenderWidget provides a communication bridge between a WebWidget and
113 // a RenderWidgetHost, the latter of which lives in a different process. 114 // a RenderWidgetHost, the latter of which lives in a different process.
114 // 115 //
115 // RenderWidget is used to implement: 116 // RenderWidget is used to implement:
116 // - RenderViewImpl (deprecated) 117 // - RenderViewImpl (deprecated)
117 // - Fullscreen mode (RenderWidgetFullScreen) 118 // - Fullscreen mode (RenderWidgetFullScreen)
118 // - Popup "menus" (like the color chooser and date picker) 119 // - Popup "menus" (like the color chooser and date picker)
119 // - Widgets for frames (for out-of-process iframe support) 120 // - Widgets for frames (for out-of-process iframe support)
120 class CONTENT_EXPORT RenderWidget 121 class CONTENT_EXPORT RenderWidget
121 : public IPC::Listener, 122 : public IPC::Listener,
122 public IPC::Sender, 123 public IPC::Sender,
123 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient), 124 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
124 public RenderWidgetCompositorDelegate, 125 public RenderWidgetCompositorDelegate,
125 public RenderWidgetInputHandlerDelegate, 126 public RenderWidgetInputHandlerDelegate,
126 public RenderWidgetScreenMetricsEmulatorDelegate, 127 public RenderWidgetScreenMetricsEmulatorDelegate,
127 public base::RefCounted<RenderWidget> { 128 public base::RefCounted<RenderWidget> {
128 public: 129 public:
129 // Creates a new RenderWidget. The opener_id is the routing ID of the 130 // Creates a new RenderWidget for a popup. |opener| is the RenderView that
130 // RenderView that this widget lives inside. 131 // this widget lives inside.
131 static RenderWidget* Create(int32_t opener_id, 132 static RenderWidget* CreateForPopup(RenderViewImpl* opener,
132 CompositorDependencies* compositor_deps, 133 CompositorDependencies* compositor_deps,
133 blink::WebPopupType popup_type, 134 blink::WebPopupType popup_type,
134 const ScreenInfo& screen_info); 135 const ScreenInfo& screen_info);
135 136
136 // Creates a new RenderWidget that will be attached to a RenderFrame. 137 // Creates a new RenderWidget that will be attached to a RenderFrame.
137 static RenderWidget* CreateForFrame(int widget_routing_id, 138 static RenderWidget* CreateForFrame(int widget_routing_id,
138 bool hidden, 139 bool hidden,
139 const ScreenInfo& screen_info, 140 const ScreenInfo& screen_info,
140 CompositorDependencies* compositor_deps, 141 CompositorDependencies* compositor_deps,
141 blink::WebLocalFrame* frame); 142 blink::WebLocalFrame* frame);
142 143
143 // Used by content_layouttest_support to hook into the creation of 144 // Used by content_layouttest_support to hook into the creation of
144 // RenderWidgets. 145 // RenderWidgets.
145 using CreateRenderWidgetFunction = RenderWidget* (*)(int32_t, 146 using CreateRenderWidgetFunction = RenderWidget* (*)(int32_t,
146 CompositorDependencies*, 147 CompositorDependencies*,
147 blink::WebPopupType, 148 blink::WebPopupType,
148 const ScreenInfo&, 149 const ScreenInfo&,
149 bool, 150 bool,
150 bool, 151 bool,
151 bool); 152 bool);
152 using RenderWidgetInitializedCallback = void (*)(RenderWidget*); 153 using RenderWidgetInitializedCallback = void (*)(RenderWidget*);
154 using ShowCallback = base::Callback<void(RenderWidget* widget_to_show,
155 blink::WebNavigationPolicy policy,
156 const gfx::Rect& initial_rect)>;
153 static void InstallCreateHook( 157 static void InstallCreateHook(
154 CreateRenderWidgetFunction create_render_widget, 158 CreateRenderWidgetFunction create_render_widget,
155 RenderWidgetInitializedCallback render_widget_initialized_callback); 159 RenderWidgetInitializedCallback render_widget_initialized_callback);
156 160
157 // Closes a RenderWidget that was created by |CreateForFrame|. 161 // Closes a RenderWidget that was created by |CreateForFrame|.
158 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget. 162 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget.
159 // https://crbug.com/545684 163 // https://crbug.com/545684
160 virtual void CloseForFrame(); 164 virtual void CloseForFrame();
161 165
162 int32_t routing_id() const { return routing_id_; } 166 int32_t routing_id() const { return routing_id_; }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 ~RenderWidget() override; 439 ~RenderWidget() override;
436 440
437 static blink::WebFrameWidget* CreateWebFrameWidget( 441 static blink::WebFrameWidget* CreateWebFrameWidget(
438 RenderWidget* render_widget, 442 RenderWidget* render_widget,
439 blink::WebLocalFrame* frame); 443 blink::WebLocalFrame* frame);
440 444
441 // Creates a WebWidget based on the popup type. 445 // Creates a WebWidget based on the popup type.
442 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget); 446 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
443 447
444 // Called by Create() functions and subclasses to finish initialization. 448 // Called by Create() functions and subclasses to finish initialization.
445 void Init(int32_t opener_id, blink::WebWidget* web_widget); 449 // |show_callback| will be invoked once WebWidgetClient::show() occurs, and
450 // should be null if show() won't be triggered for this widget.
451 void Init(const ShowCallback& show_callback, blink::WebWidget* web_widget);
446 452
447 // Allows the process to exit once the unload handler has finished, if there 453 // Allows the process to exit once the unload handler has finished, if there
448 // are no other active RenderWidgets. 454 // are no other active RenderWidgets.
449 void WasSwappedOut(); 455 void WasSwappedOut();
450 456
451 void DoDeferredClose(); 457 void DoDeferredClose();
452 void NotifyOnClose(); 458 void NotifyOnClose();
453 459
454 gfx::Size GetSizeForWebWidget() const; 460 gfx::Size GetSizeForWebWidget() const;
455 virtual void ResizeWebWidget(); 461 virtual void ResizeWebWidget();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 // We are responsible for destroying this object via its Close method. 620 // We are responsible for destroying this object via its Close method.
615 // May be NULL when the window is closing. 621 // May be NULL when the window is closing.
616 blink::WebWidget* webwidget_internal_; 622 blink::WebWidget* webwidget_internal_;
617 623
618 // The delegate of the owner of this object. 624 // The delegate of the owner of this object.
619 RenderWidgetOwnerDelegate* owner_delegate_; 625 RenderWidgetOwnerDelegate* owner_delegate_;
620 626
621 // This is lazily constructed and must not outlive webwidget_. 627 // This is lazily constructed and must not outlive webwidget_.
622 std::unique_ptr<RenderWidgetCompositor> compositor_; 628 std::unique_ptr<RenderWidgetCompositor> compositor_;
623 629
624 // Set to the ID of the view that initiated creating this view, if any. When
625 // the view was initiated by the browser (the common case), this will be
626 // MSG_ROUTING_NONE. This is used in determining ownership when opening
627 // child tabs. See RenderWidget::createWebViewWithRequest.
628 //
629 // This ID may refer to an invalid view if that view is closed before this
630 // view is.
631 int32_t opener_id_;
632
633 // The rect where this view should be initially shown. 630 // The rect where this view should be initially shown.
634 gfx::Rect initial_rect_; 631 gfx::Rect initial_rect_;
635 632
636 // We store the current cursor object so we can avoid spamming SetCursor 633 // We store the current cursor object so we can avoid spamming SetCursor
637 // messages. 634 // messages.
638 WebCursor current_cursor_; 635 WebCursor current_cursor_;
639 636
640 // The size of the RenderWidget. 637 // The size of the RenderWidget.
641 gfx::Size size_; 638 gfx::Size size_;
642 639
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 795
799 private: 796 private:
800 // Applies/Removes the DevTools device emulation transformation to/from a 797 // Applies/Removes the DevTools device emulation transformation to/from a
801 // window rect. 798 // window rect.
802 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const; 799 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
803 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const; 800 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
804 801
805 // Indicates whether this widget has focus. 802 // Indicates whether this widget has focus.
806 bool has_focus_; 803 bool has_focus_;
807 804
805 // A callback into the creator/opener of this widget, to be executed when
806 // WebWidgetClient::show() occurs.
807 ShowCallback show_callback_;
808
808 #if defined(OS_MACOSX) 809 #if defined(OS_MACOSX)
809 // Responds to IPCs from TextInputClientMac regarding getting string at given 810 // Responds to IPCs from TextInputClientMac regarding getting string at given
810 // position or range as well as finding character index at a given position. 811 // position or range as well as finding character index at a given position.
811 std::unique_ptr<TextInputClientObserver> text_input_client_observer_; 812 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
812 #endif 813 #endif
813 814
814 // This reference is set by the RenderFrame and is used to query the IME- 815 // This reference is set by the RenderFrame and is used to query the IME-
815 // related state from the plugin to later send to the browser. 816 // related state from the plugin to later send to the browser.
816 PepperPluginInstanceImpl* focused_pepper_plugin_; 817 PepperPluginInstanceImpl* focused_pepper_plugin_;
817 818
818 // Stores edit commands associated to the next key event. 819 // Stores edit commands associated to the next key event.
819 // Will be cleared as soon as the next key event is processed. 820 // Will be cleared as soon as the next key event is processed.
820 EditCommands edit_commands_; 821 EditCommands edit_commands_;
821 822
822 // This field stores drag/drop related info for the event that is currently 823 // This field stores drag/drop related info for the event that is currently
823 // being handled. If the current event results in starting a drag/drop 824 // being handled. If the current event results in starting a drag/drop
824 // session, this info is sent to the browser along with other drag/drop info. 825 // session, this info is sent to the browser along with other drag/drop info.
825 DragEventSourceInfo possible_drag_event_info_; 826 DragEventSourceInfo possible_drag_event_info_;
826 827
827 DISALLOW_COPY_AND_ASSIGN(RenderWidget); 828 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
828 }; 829 };
829 830
830 } // namespace content 831 } // namespace content
831 832
832 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ 833 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698