OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_DELEGATE_HELPER_H_ | |
6 #define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_DELEGATE_HELPER_H_ | |
7 #pragma once | |
8 | |
9 #include <map> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/compiler_specific.h" | |
13 #include "content/public/browser/notification_observer.h" | |
14 #include "content/public/browser/notification_registrar.h" | |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" | |
16 #include "webkit/glue/window_open_disposition.h" | |
17 | |
18 class RenderWidgetHostView; | |
19 class TabContents; | |
20 struct ViewHostMsg_CreateWindow_Params; | |
21 | |
22 namespace content { | |
23 class WebContents; | |
24 } | |
25 | |
26 namespace gfx { | |
27 class Rect; | |
28 } | |
29 | |
30 // TODO(avi): Once all the TabContentsViews implementations are in content (I'm | |
31 // looking at you, TabContentsViewViews...) then change the parameters to take | |
32 // WebContentsImpl rather than WebContents. | |
33 | |
34 // Provides helper methods that provide common implementations of some | |
35 // TabContentsView methods. | |
36 class RenderViewHostDelegateViewHelper : public content::NotificationObserver { | |
37 public: | |
38 RenderViewHostDelegateViewHelper(); | |
39 virtual ~RenderViewHostDelegateViewHelper(); | |
40 | |
41 // Creates a new window; call |ShowCreatedWindow| below to show it. | |
42 TabContents* CreateNewWindow(content::WebContents* web_contents, | |
43 int route_id, | |
44 const ViewHostMsg_CreateWindow_Params& params); | |
45 | |
46 // Creates a new popup or fullscreen widget; call |ShowCreatedWidget| below to | |
47 // show it. If |is_fullscreen| is true it is a fullscreen widget, if not then | |
48 // a pop-up. |popup_type| is only meaningful for a pop-up. | |
49 RenderWidgetHostView* CreateNewWidget(content::WebContents* web_contents, | |
50 int route_id, | |
51 bool is_fullscreen, | |
52 WebKit::WebPopupType popup_type); | |
53 | |
54 // Shows a window created with |CreateNewWindow| above. | |
55 TabContents* ShowCreatedWindow(content::WebContents* web_contents, | |
56 int route_id, | |
57 WindowOpenDisposition disposition, | |
58 const gfx::Rect& initial_pos, | |
59 bool user_gesture); | |
60 | |
61 // Shows a widget created with |CreateNewWidget| above. |initial_pos| is only | |
62 // meaningful for non-fullscreen widgets. | |
63 RenderWidgetHostView* ShowCreatedWidget(content::WebContents* web_contents, | |
64 int route_id, | |
65 bool is_fullscreen, | |
66 const gfx::Rect& initial_pos); | |
67 | |
68 private: | |
69 // content::NotificationObserver implementation | |
70 virtual void Observe(int type, | |
71 const content::NotificationSource& source, | |
72 const content::NotificationDetails& details) OVERRIDE; | |
73 | |
74 // Finds the new RenderWidgetHost and returns it. Note that this can only be | |
75 // called once as this call also removes it from the internal map. | |
76 RenderWidgetHostView* GetCreatedWidget(int route_id); | |
77 | |
78 // Finds the new TabContents by route_id, initializes it for | |
79 // renderer-initiated creation, and returns it. Note that this can only be | |
80 // called once as this call also removes it from the internal map. | |
81 TabContents* GetCreatedWindow(int route_id); | |
82 | |
83 // Tracks created RenderViewHost objects that have not been shown yet. | |
84 // They are identified by the route ID passed to CreateNewWindow. | |
85 typedef std::map<int, TabContents*> PendingContents; | |
86 PendingContents pending_contents_; | |
87 | |
88 // These maps hold on to the widgets that we created on behalf of the | |
89 // renderer that haven't shown yet. | |
90 typedef std::map<int, RenderWidgetHostView*> PendingWidgetViews; | |
91 PendingWidgetViews pending_widget_views_; | |
92 | |
93 // Registers and unregisters us for notifications. | |
94 content::NotificationRegistrar registrar_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(RenderViewHostDelegateViewHelper); | |
97 }; | |
98 | |
99 #endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_DELEGATE_HELPER_H_ | |
OLD | NEW |