1ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be
3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file.
4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
572a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#ifndef CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
672a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once
8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <Cocoa/Cocoa.h>
10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
11ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/memory/scoped_ptr.h"
124a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch
13c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass TabContents;
144a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdochclass TabContentsNotificationBridge;
154a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch@class TabContentsController;
164a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch
174a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch// The interface for the tab contents view controller's delegate.
184a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch
194a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch@protocol TabContentsControllerDelegate
204a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch
214a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch// Tells the delegate when the tab contents view's frame is about to change.
224a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch- (void)tabContentsViewFrameWillChange:(TabContentsController*)source
234a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch                             frameRect:(NSRect)frameRect;
244a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch
254a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch@end
26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
274a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch// A class that controls the TabContents view. It manages displaying the
283345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// native view for a given TabContents.
293345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// Note that just creating the class does not display the view. We defer
303345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// inserting it until the box is the correct size to avoid multiple resize
313345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// messages to the renderer. You must call |-ensureContentsVisible| to display
323345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick// the render widget host view.
33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@interface TabContentsController : NSViewController {
35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch @private
36c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  TabContents* contents_;  // weak
374a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch  // Delegate to be notified about size changes.
384a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch  id<TabContentsControllerDelegate> delegate_;  // weak
394a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch  scoped_ptr<TabContentsNotificationBridge> tabContentsBridge_;
40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}
413345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick@property(readonly, nonatomic) TabContents* tabContents;
42c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
434a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch- (id)initWithContents:(TabContents*)contents
444a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch              delegate:(id<TabContentsControllerDelegate>)delegate;
454a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch
464a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch// Call when the tab contents is about to be replaced with the currently
474a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch// selected tab contents to do not trigger unnecessary content relayout.
484a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch- (void)ensureContentsSizeDoesNotChange;
494a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch
504a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch// Call when the tab view is properly sized and the render widget host view
514a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch// should be put into the view hierarchy.
524a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch- (void)ensureContentsVisible;
534a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch
544a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch// Call to change the underlying tab contents object. View is not changed,
554a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch// call |-ensureContentsVisible| to display the |newContents|'s render widget
564a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch// host view.
574a5e2dc747d50c653511c68ccb2cfbfb740bd5a7Ben Murdoch- (void)changeTabContents:(TabContents*)newContents;
58c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
59c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Called when the tab contents is the currently selected tab and is about to be
60c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// removed from the view hierarchy.
61c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)willBecomeUnselectedTab;
62c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
63c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Called when the tab contents is about to be put into the view hierarchy as
64c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// the selected tab. Handles things such as ensuring the toolbar is correctly
65c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// enabled.
66c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)willBecomeSelectedTab;
67c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
68c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Called when the tab contents is updated in some non-descript way (the
69c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// notification from the model isn't specific). |updatedContents| could reflect
70c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// an entirely new tab contents object.
71c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)tabDidChange:(TabContents*)updatedContents;
72c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
73c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@end
74c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
7572a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#endif  // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
76