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.
5 #ifndef CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
8 #include <Cocoa/Cocoa.h>
10 #include "base/memory/scoped_ptr.h"
12 class FullscreenObserver;
18 // A class that controls the WebContents view. It manages displaying the
19 // native view for a given WebContents.
20 // Note that just creating the class does not display the view. We defer
21 // inserting it until the box is the correct size to avoid multiple resize
22 // messages to the renderer. You must call |-ensureContentsVisible| to display
23 // the render widget host view.
25 @interface TabContentsController : NSViewController {
27 content::WebContents* contents_; // weak
28 // When |fullscreenObserver_| not-NULL, TabContentsController monitors for
29 // and auto-embeds fullscreen widgets as a subview.
30 scoped_ptr<FullscreenObserver> fullscreenObserver_;
31 // Set to true while TabContentsController is embedding a fullscreen widget
32 // view as a subview instead of the normal WebContentsView render view.
33 BOOL isEmbeddingFullscreenWidget_;
35 @property(readonly, nonatomic) content::WebContents* webContents;
37 // Create the contents of a tab represented by |contents|. When
38 // |enableEmbeddedFullscreen| is true, the WebContents view will automatically
39 // be swapped with a fullscreen render widget owned by the current WebContents.
40 - (id)initWithContents:(content::WebContents*)contents
41 andAutoEmbedFullscreen:(BOOL)enableEmbeddedFullscreen;
43 // Call when the tab contents is about to be replaced with the currently
44 // selected tab contents to do not trigger unnecessary content relayout.
45 - (void)ensureContentsSizeDoesNotChange;
47 // Call when the tab view is properly sized and the render widget host view
48 // should be put into the view hierarchy.
49 - (void)ensureContentsVisible;
51 // Call to change the underlying web contents object. View is not changed,
52 // call |-ensureContentsVisible| to display the |newContents|'s render widget
54 - (void)changeWebContents:(content::WebContents*)newContents;
56 // Called when the tab contents is the currently selected tab and is about to be
57 // removed from the view hierarchy.
58 - (void)willBecomeUnselectedTab;
60 // Called when the tab contents is about to be put into the view hierarchy as
61 // the selected tab. Handles things such as ensuring the toolbar is correctly
63 - (void)willBecomeSelectedTab;
65 // Called when the tab contents is updated in some non-descript way (the
66 // notification from the model isn't specific). |updatedContents| could reflect
67 // an entirely new tab contents object.
68 - (void)tabDidChange:(content::WebContents*)updatedContents;
70 // Called to switch the container's subview to the WebContents-owned fullscreen
71 // widget or back to WebContentsView's widget.
72 - (void)toggleFullscreenWidget:(BOOL)enterFullscreen;
76 #endif // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_