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