155fd43f90913676682487f89f27c756adb827f66Devang Patel// Copyright (c) 2011 The Chromium Authors. All rights reserved. 255fd43f90913676682487f89f27c756adb827f66Devang Patel// Use of this source code is governed by a BSD-style license that can be 355fd43f90913676682487f89f27c756adb827f66Devang Patel// found in the LICENSE file. 455fd43f90913676682487f89f27c756adb827f66Devang Patel 5c67c938de2097f26dba71d9436e4707dd8a5012dDevang Patel#ifndef CHROME_BROWSER_UI_COCOA_SIDEBAR_CONTROLLER_H_ 655fd43f90913676682487f89f27c756adb827f66Devang Patel#define CHROME_BROWSER_UI_COCOA_SIDEBAR_CONTROLLER_H_ 755fd43f90913676682487f89f27c756adb827f66Devang Patel#pragma once 855fd43f90913676682487f89f27c756adb827f66Devang Patel 955fd43f90913676682487f89f27c756adb827f66Devang Patel#import <Foundation/Foundation.h> 1055fd43f90913676682487f89f27c756adb827f66Devang Patel 1155fd43f90913676682487f89f27c756adb827f66Devang Patel#include "base/memory/scoped_nsobject.h" 1255fd43f90913676682487f89f27c756adb827f66Devang Patel#import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" 1355fd43f90913676682487f89f27c756adb827f66Devang Patel 1455fd43f90913676682487f89f27c756adb827f66Devang Patel@class NSSplitView; 15ab7752c1496c2913793305ba4b989a551c5617e1Devang Patel@class NSView; 1645dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel 17c874eb54ecf57f493c49934a327e0e4e49f0ff10Devang Patelclass TabContents; 1855fd43f90913676682487f89f27c756adb827f66Devang Patel 193799f97d539f6c288d169063e1b335917fafcffbDevang Patel// A class that handles updates of the sidebar view within a browser window. 208f487662869d10c866b9ebdccb8f6a7509d3ab56Bill Wendling// It swaps in the relevant sidebar contents for a given TabContents or removes 218e58a1b17bb57e6ffa187a0ec758f9a1bed7685bDevang Patel// the vew, if there's no sidebar contents to show. 2285d344b0c68048527f1ac46ba22bbc950870d3c5Devang Patel@interface SidebarController : NSObject { 23b899eed1bc0a64f96fa7aff8d7c6f999cf85bdfeDevang Patel @private 24c2ff962bf97761a54c94d2dadb555060403d49c6Devang Patel // A view hosting sidebar contents. 25ab7752c1496c2913793305ba4b989a551c5617e1Devang Patel scoped_nsobject<NSSplitView> splitView_; 26e77242c3d5843a5a6484794254623c8552dc6a4fDevang Patel 2745dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel // Manages currently displayed sidebar contents. 2845dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel scoped_nsobject<TabContentsController> contentsController_; 2945dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel} 3045dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel 3145dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel- (id)initWithDelegate:(id<TabContentsControllerDelegate>)delegate; 3245dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel 3345dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel// This controller's view. 3445dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel- (NSSplitView*)view; 3545dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel 36e8ff1ce7343c697ff90d940c8c5fa8fccc09220dDevang Patel// The compiler seems to have trouble handling a function named "view" that 37e8ff1ce7343c697ff90d940c8c5fa8fccc09220dDevang Patel// returns an NSSplitView, so provide a differently-named method. 38e8ff1ce7343c697ff90d940c8c5fa8fccc09220dDevang Patel- (NSSplitView*)splitView; 39e8ff1ce7343c697ff90d940c8c5fa8fccc09220dDevang Patel 40e8ff1ce7343c697ff90d940c8c5fa8fccc09220dDevang Patel// Depending on |contents|'s state, decides whether the sidebar 4145dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel// should be shown or hidden and adjusts its width (|delegate_| handles 4226426949f33e5a77fbd2fa330f7df5626e8b177dDevang Patel// the actual resize). 4345dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel- (void)updateSidebarForTabContents:(TabContents*)contents; 4445dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel 45e8ff1ce7343c697ff90d940c8c5fa8fccc09220dDevang Patel// Call when the sidebar view is properly sized and the render widget host view 46e8ff1ce7343c697ff90d940c8c5fa8fccc09220dDevang Patel// should be put into the view hierarchy. 47e8ff1ce7343c697ff90d940c8c5fa8fccc09220dDevang Patel- (void)ensureContentsVisible; 48e8ff1ce7343c697ff90d940c8c5fa8fccc09220dDevang Patel 49e8ff1ce7343c697ff90d940c8c5fa8fccc09220dDevang Patel@end 5045dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel 5145dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel#endif // CHROME_BROWSER_UI_COCOA_SIDEBAR_CONTROLLER_H_ 5245dc02d6f97447785ee7ffe08c36a34bc8921b0bDevang Patel