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 namespace content { 11 class WebContents; 12 } 13 14 // A class that controls the WebContents view. It manages displaying the 15 // native view for a given WebContents. 16 // Note that just creating the class does not display the view. We defer 17 // inserting it until the box is the correct size to avoid multiple resize 18 // messages to the renderer. You must call |-ensureContentsVisible| to display 19 // the render widget host view. 20 21 @interface TabContentsController : NSViewController { 22 @private 23 content::WebContents* contents_; // weak 24 } 25 @property(readonly, nonatomic) content::WebContents* webContents; 26 27 // Create the contents of a tab represented by |contents|. 28 - (id)initWithContents:(content::WebContents*)contents; 29 30 // Call when the tab contents is about to be replaced with the currently 31 // selected tab contents to do not trigger unnecessary content relayout. 32 - (void)ensureContentsSizeDoesNotChange; 33 34 // Call when the tab view is properly sized and the render widget host view 35 // should be put into the view hierarchy. 36 - (void)ensureContentsVisible; 37 38 // Call to change the underlying web contents object. View is not changed, 39 // call |-ensureContentsVisible| to display the |newContents|'s render widget 40 // host view. 41 - (void)changeWebContents:(content::WebContents*)newContents; 42 43 // Called when the tab contents is the currently selected tab and is about to be 44 // removed from the view hierarchy. 45 - (void)willBecomeUnselectedTab; 46 47 // Called when the tab contents is about to be put into the view hierarchy as 48 // the selected tab. Handles things such as ensuring the toolbar is correctly 49 // enabled. 50 - (void)willBecomeSelectedTab; 51 52 // Called when the tab contents is updated in some non-descript way (the 53 // notification from the model isn't specific). |updatedContents| could reflect 54 // an entirely new tab contents object. 55 - (void)tabDidChange:(content::WebContents*)updatedContents; 56 57 @end 58 59 #endif // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_ 60