- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / tab_contents / tab_contents_controller.h
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_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
7
8 #include <Cocoa/Cocoa.h>
9
10 #include "base/memory/scoped_ptr.h"
11
12 class FullscreenObserver;
13
14 namespace content {
15 class WebContents;
16 }
17
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.
24
25 @interface TabContentsController : NSViewController {
26  @private
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_;
34 }
35 @property(readonly, nonatomic) content::WebContents* webContents;
36
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;
42
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;
46
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;
50
51 // Call to change the underlying web contents object. View is not changed,
52 // call |-ensureContentsVisible| to display the |newContents|'s render widget
53 // host view.
54 - (void)changeWebContents:(content::WebContents*)newContents;
55
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;
59
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
62 // enabled.
63 - (void)willBecomeSelectedTab;
64
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;
69
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;
73
74 @end
75
76 #endif  // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_