[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / tab_contents / tab_contents_controller.h
blobaefdc2376bf76ded342b910fa5bad4a3a0614825
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;
14 namespace content {
15 class WebContents;
18 // A class that controls the WebContents view. It internally creates a container
19 // view (the NSView accessed by calling |-view|) which manages the layout and
20 // display of the WebContents view.
22 // Client code that inserts [controller view] into the view hierarchy needs to
23 // beforehand call the |-ensureContentsSizeDoesNotChange| method. This will
24 // avoid multiple resize messages being sent to the renderer and triggering
25 // redundant and costly layouts. After the view has been inserted, client code
26 // calls |-ensureContentsVisible| to display the WebContents view.
28 // AutoEmbedFullscreen mode: When enabled, TabContentsController will observe
29 // for WebContents fullscreen changes and automatically swap the normal
30 // WebContents view with the fullscreen view (if different). In addition, if a
31 // WebContents is being screen-captured, the view will be centered within the
32 // container view, sized to the aspect ratio of the capture video resolution,
33 // and scaling will be avoided whenever possible.
34 @interface TabContentsController : NSViewController {
35 @private
36 content::WebContents* contents_; // weak
37 // When |fullscreenObserver_| is not-NULL, TabContentsController monitors for
38 // and auto-embeds fullscreen widgets as a subview.
39 scoped_ptr<FullscreenObserver> fullscreenObserver_;
40 // Set to true while TabContentsController is embedding a fullscreen widget
41 // view as a subview instead of the normal WebContentsView render view. Note:
42 // This will be false in the case of non-Flash fullscreen.
43 BOOL isEmbeddingFullscreenWidget_;
45 @property(readonly, nonatomic) content::WebContents* webContents;
47 // Create the contents of a tab represented by |contents|. When
48 // |enableEmbeddedFullscreen| is true, the WebContents view will automatically
49 // be swapped with a fullscreen render widget owned by the current WebContents.
50 - (id)initWithContents:(content::WebContents*)contents
51 andAutoEmbedFullscreen:(BOOL)enableEmbeddedFullscreen;
53 // Call when the container view owned by TabContentsController is about to be
54 // resized and inserted into the view hierarchy, so as to not trigger
55 // unnecessary content re-layout.
56 - (void)ensureContentsSizeDoesNotChange;
58 // Call after the container view is inserted into the view hierarchy and
59 // properly sized. Then, this method will select either the WebContents view or
60 // the fullscreen view and swap it into the view hierarchy for display.
61 - (void)ensureContentsVisible;
63 // Call to change the underlying web contents object. View is not changed,
64 // call |-ensureContentsVisible| to display the |newContents|'s render widget
65 // host view.
66 - (void)changeWebContents:(content::WebContents*)newContents;
68 // Called when the tab contents is the currently selected tab and is about to be
69 // removed from the view hierarchy.
70 - (void)willBecomeUnselectedTab;
72 // Called when the tab contents is about to be put into the view hierarchy as
73 // the selected tab. Handles things such as ensuring the toolbar is correctly
74 // enabled.
75 - (void)willBecomeSelectedTab;
77 // Called when the tab contents is updated in some non-descript way (the
78 // notification from the model isn't specific). |updatedContents| could reflect
79 // an entirely new tab contents object.
80 - (void)tabDidChange:(content::WebContents*)updatedContents;
82 // Called to switch the container's subview to the WebContents-owned fullscreen
83 // widget or back to WebContentsView's widget.
84 - (void)toggleFullscreenWidget:(BOOL)enterFullscreen;
86 @end
88 #endif // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_