diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-30 20:31:54 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-30 20:31:54 +0000 |
commit | c45a61ca508f3beba4a9f23dd6468b6f488820d7 (patch) | |
tree | 3ff1a2d09cbbc84c4d92fe5f21f8283f75ecc266 /chrome | |
parent | 809d04236179a9bfa7231e3fccddc96027529064 (diff) | |
download | chromium_src-c45a61ca508f3beba4a9f23dd6468b6f488820d7.zip chromium_src-c45a61ca508f3beba4a9f23dd6468b6f488820d7.tar.gz chromium_src-c45a61ca508f3beba4a9f23dd6468b6f488820d7.tar.bz2 |
Sidebar view, Mac implementation (common sidebar code and Windows version is already submitted).
TabContents.xib changes: it was converted to the latest IB version and vertical NSSplitView was added to it
as a child for existing horizontal NSSplitView hosting devTools; new one hosts page content and sidebar content.
BrowserWindowCocoa instance listen to SIDEBAR_CHANGED notification and updates sidebar content view according
to the sidebar state linked to the current tab (adds or removes the corresponding view).
Sidebar API design doc: http://www.chromium.org/developers/design-documents/extensions/sidebar-extension-api.
BUG=51084
TEST=Run browser_tests and interactive_ui_tests.
Review URL: http://codereview.chromium.org/3228003
Patch from Aleksey Shlyapnikov <alekseys@chromium.org>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57898 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/nibs/TabContents.xib | 798 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.mm | 14 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.h | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.h | 13 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.mm | 88 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.mm | 45 | ||||
-rw-r--r-- | chrome/browser/cocoa/view_id_util_browsertest.mm | 18 |
10 files changed, 936 insertions, 50 deletions
diff --git a/chrome/app/nibs/TabContents.xib b/chrome/app/nibs/TabContents.xib index 2d45690..d93dcbb 100644 --- a/chrome/app/nibs/TabContents.xib +++ b/chrome/app/nibs/TabContents.xib @@ -1,14 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> -<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> +<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9L31a</string> - <string key="IBDocument.InterfaceBuilderVersion">677</string> - <string key="IBDocument.AppKitVersion">949.54</string> - <string key="IBDocument.HIToolboxVersion">353.00</string> + <string key="IBDocument.SystemVersion">10F569</string> + <string key="IBDocument.InterfaceBuilderVersion">788</string> + <string key="IBDocument.AppKitVersion">1038.29</string> + <string key="IBDocument.HIToolboxVersion">461.00</string> + <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="NS.object.0">788</string> + </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="195"/> + <integer value="213"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -16,7 +20,7 @@ </object> <object class="NSMutableDictionary" key="IBDocument.Metadata"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys" id="0"> <bool key="EncodedWithXMLCoder">YES</bool> </object> <object class="NSMutableArray" key="dict.values"> @@ -48,7 +52,7 @@ <object class="NSMutableString" key="NSViewClass"> <characters key="NS.bytes">View</characters> </object> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSWindowContentMinSize">{480, 360}</string> <object class="NSView" key="NSWindowView" id="675542922"> <reference key="NSNextResponder"/> @@ -58,6 +62,17 @@ <object class="NSSplitView" id="89435107"> <reference key="NSNextResponder" ref="675542922"/> <int key="NSvFlags">274</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSSplitView" id="901624045"> + <reference key="NSNextResponder" ref="89435107"/> + <int key="NSvFlags">268</int> + <string key="NSFrameSize">{480, 360}</string> + <reference key="NSSuperview" ref="89435107"/> + <bool key="NSIsVertical">YES</bool> + <int key="NSDividerStyle">2</int> + </object> + </object> <string key="NSFrameSize">{480, 360}</string> <reference key="NSSuperview" ref="675542922"/> <int key="NSDividerStyle">2</int> @@ -68,7 +83,7 @@ </object> <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string> <string key="NSMinSize">{480, 382}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> + <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> </object> </object> <object class="IBObjectContainer" key="IBDocument.Objects"> @@ -84,11 +99,19 @@ </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> - <string key="label">contentsContainer_</string> + <string key="label">devToolsContainer_</string> <reference key="source" ref="326691890"/> <reference key="destination" ref="89435107"/> </object> - <int key="connectionID">200</int> + <int key="connectionID">212</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">contentsContainer_</string> + <reference key="source" ref="326691890"/> + <reference key="destination" ref="901624045"/> + </object> + <int key="connectionID">216</int> </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> @@ -96,9 +119,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBObjectRecord"> <int key="objectID">0</int> - <object class="NSArray" key="object" id="0"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> + <reference key="object" ref="0"/> <reference key="children" ref="1012502457"/> <nil key="parent"/> </object> @@ -106,7 +127,7 @@ <int key="objectID">-2</int> <reference key="object" ref="326691890"/> <reference key="parent" ref="0"/> - <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string> + <string key="objectName">File's Owner</string> </object> <object class="IBObjectRecord"> <int key="objectID">-1</int> @@ -144,20 +165,29 @@ <reference key="object" ref="89435107"/> <object class="NSMutableArray" key="children"> <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="901624045"/> </object> <reference key="parent" ref="675542922"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">213</int> + <reference key="object" ref="901624045"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + <reference key="parent" ref="89435107"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>-1.IBPluginDependency</string> - <string>-2.IBPluginDependency</string> <string>-3.IBPluginDependency</string> <string>195.IBPluginDependency</string> + <string>213.IBPluginDependency</string> <string>93.IBEditorWindowLastContentRect</string> + <string>93.IBPluginDependency</string> <string>93.IBViewEditorWindowController.showingLayoutRectangles</string> <string>93.IBWindowTemplateEditedContentRect</string> <string>93.ImportedFromIB2</string> @@ -171,22 +201,20 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>{{529, 843}, {480, 360}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{283, 496}, {480, 360}}</string> - <boolean value="YES" id="5"/> - <string>{{283, 496}, {480, 360}}</string> - <reference ref="5"/> - <reference ref="5"/> + <boolean value="YES"/> + <string>{{529, 843}, {480, 360}}</string> + <boolean value="YES"/> + <boolean value="YES"/> <string>{480, 360}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <reference ref="5"/> + <boolean value="YES"/> </object> </object> <object class="NSMutableDictionary" key="unlocalizedProperties"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> + <reference key="dict.sortedKeys" ref="0"/> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> </object> @@ -194,15 +222,13 @@ <nil key="activeLocalization"/> <object class="NSMutableDictionary" key="localizations"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> + <reference key="dict.sortedKeys" ref="0"/> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> </object> </object> <nil key="sourceID"/> - <int key="maxID">200</int> + <int key="maxID">216</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -214,6 +240,13 @@ <string key="NS.key.0">commandDispatch:</string> <string key="NS.object.0">id</string> </object> + <object class="NSMutableDictionary" key="actionInfosByName"> + <string key="NS.key.0">commandDispatch:</string> + <object class="IBActionInfo" key="NS.object.0"> + <string key="name">commandDispatch:</string> + <string key="candidateClassName">id</string> + </object> + </object> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBUserSource</string> <string key="minorKey"/> @@ -223,6 +256,20 @@ <string key="className">NSObject</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> + <string key="minorKey">../third_party/GTM/Foundation/GTMNSObject+KeyValueObserving.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/objc_zombie.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> <string key="minorKey">browser/cocoa/status_bubble_mac.h</string> </object> </object> @@ -234,18 +281,60 @@ </object> </object> <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/view_id_util.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSWindow</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/chrome_browser_window.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">NSWindow</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/cocoa/nswindow_local_state.h</string> + <string key="minorKey">browser/cocoa/themed_window.h</string> </object> </object> <object class="IBPartialClassDescription"> <string key="className">TabContentsController</string> <string key="superclassName">NSViewController</string> <object class="NSMutableDictionary" key="outlets"> - <string key="NS.key.0">contentsContainer_</string> - <string key="NS.object.0">NSSplitView</string> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>contentsContainer_</string> + <string>devToolsContainer_</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSSplitView</string> + <string>NSSplitView</string> + </object> + </object> + <object class="NSMutableDictionary" key="toOneOutletInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>contentsContainer_</string> + <string>devToolsContainer_</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBToOneOutletInfo"> + <string key="name">contentsContainer_</string> + <string key="candidateClassName">NSSplitView</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">devToolsContainer_</string> + <string key="candidateClassName">NSSplitView</string> + </object> + </object> </object> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> @@ -253,8 +342,649 @@ </object> </object> </object> + <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <string key="superclassName">NSResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="666638363"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSApplication.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="338636985"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSApplicationScripting.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="611088932"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSColorPanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSHelpManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSPageLayout.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSMenu</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="828006429"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSMenu.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AddressBook.framework/Headers/ABActions.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSAccessibility.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSAlert.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSAnimation.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="666638363"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="338636985"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSBrowser.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="611088932"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSComboBox.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSComboBoxCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSControl.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSDatePickerCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSDictionaryController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSDragging.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="278014344"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSDrawer.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSFontManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSFontPanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSImage.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSKeyValueBinding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="828006429"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSNibLoading.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSOutlineView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSPasteboard.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSRuleEditor.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSSavePanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSSound.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSSpeechRecognizer.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSSpeechSynthesizer.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="702397801"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSSplitView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTabView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTableView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSText.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTextStorage.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTextView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTokenField.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTokenFieldCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSToolbar.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSToolbarItem.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="916226890"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="1006359016"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSWindow.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSArchiver.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSClassDescription.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSConnection.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSError.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSMetadata.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSNetServices.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSObject.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSObjectScripting.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSPort.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSPortCoder.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptClassDescription.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptKeyValueCoding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptObjectSpecifiers.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptWhoseTests.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSSpellServer.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSStream.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSThread.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURL.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURLDownload.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSXMLParser.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Print.framework/Headers/PDEPluginInterface.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">QuartzCore.framework/Headers/CAAnimation.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">QuartzCore.framework/Headers/CALayer.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">QuartzCore.framework/Headers/CIImageProvider.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">SecurityInterface.framework/Headers/SFAuthorizationView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">SecurityInterface.framework/Headers/SFCertificatePanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">SecurityInterface.framework/Headers/SFChooseIdentityPanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSInterfaceStyle.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSResponder</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSResponder.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSSplitView</string> + <string key="superclassName">NSView</string> + <reference key="sourceIdentifier" ref="702397801"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSClipView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSMenuItem.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSRulerView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <string key="superclassName">NSResponder</string> + <reference key="sourceIdentifier" ref="916226890"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSViewController</string> + <string key="superclassName">NSResponder</string> + <object class="NSMutableDictionary" key="outlets"> + <string key="NS.key.0">view</string> + <string key="NS.object.0">NSView</string> + </object> + <object class="NSMutableDictionary" key="toOneOutletInfosByName"> + <string key="NS.key.0">view</string> + <object class="IBToOneOutletInfo" key="NS.object.0"> + <string key="name">view</string> + <string key="candidateClassName">NSView</string> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSViewController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSWindow</string> + <reference key="sourceIdentifier" ref="278014344"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSWindow</string> + <string key="superclassName">NSResponder</string> + <reference key="sourceIdentifier" ref="1006359016"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSWindow</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSWindowScripting.h</string> + </object> + </object> + </object> </object> <int key="IBDocument.localizationMode">0</int> + <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string> + <integer value="1050" key="NS.object.0"/> + </object> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string> + <integer value="1050" key="NS.object.0"/> + </object> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string> + <integer value="3000" key="NS.object.0"/> + </object> + <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> <string key="IBDocument.LastKnownRelativeProjectPath">../../chrome.xcodeproj</string> <int key="IBDocument.defaultPropertyAccessControl">3</int> </data> diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h index 354b9d5..10b9fd3 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.h +++ b/chrome/browser/cocoa/browser_window_cocoa.h @@ -125,6 +125,7 @@ class BrowserWindowCocoa : public BrowserWindow, int GetCommandId(const NativeWebKeyboardEvent& event); bool HandleKeyboardEventInternal(NSEvent* event); NSWindow* window() const; // Accessor for the (current) |NSWindow|. + void UpdateSidebarForContents(TabContents* tab_contents); NotificationRegistrar registrar_; Browser* browser_; // weak, owned by controller diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index a89421f..fa9d6c6 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -37,6 +37,8 @@ #include "chrome/browser/global_keyboard_shortcuts_mac.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profile.h" +#include "chrome/browser/sidebar/sidebar_container.h" +#include "chrome/browser/sidebar/sidebar_manager.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/native_web_keyboard_event.h" @@ -55,6 +57,8 @@ BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser, // This pref applies to all windows, so all must watch for it. registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, NotificationService::AllSources()); + registrar_.Add(this, NotificationType::SIDEBAR_CHANGED, + NotificationService::AllSources()); } BrowserWindowCocoa::~BrowserWindowCocoa() { @@ -569,6 +573,10 @@ void BrowserWindowCocoa::Observe(NotificationType type, case NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: [controller_ updateBookmarkBarVisibilityWithAnimation:YES]; break; + case NotificationType::SIDEBAR_CHANGED: + UpdateSidebarForContents( + Details<SidebarContainer>(details)->tab_contents()); + break; default: NOTREACHED(); // we don't ask for anything else! break; @@ -585,3 +593,9 @@ void BrowserWindowCocoa::DestroyBrowser() { NSWindow* BrowserWindowCocoa::window() const { return [controller_ window]; } + +void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { + if (tab_contents == browser_->tabstrip_model()->GetSelectedTabContents()) { + [controller_ updateSidebarForContents:tab_contents]; + } +} diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h index d4fe820..c971777 100644 --- a/chrome/browser/cocoa/browser_window_controller.h +++ b/chrome/browser/cocoa/browser_window_controller.h @@ -235,6 +235,10 @@ class TabStripModelObserverBridge; // Shows or hides the docked web inspector depending on |contents|'s state. - (void)updateDevToolsForContents:(TabContents*)contents; +// Displays the active sidebar linked to the |contents| or hides sidebar UI, +// if there's no such sidebar. +- (void)updateSidebarForContents:(TabContents*)contents; + // Gets the current theme provider. - (ThemeProvider*)themeProvider; diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 0e18570..e4fc9ce 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -399,6 +399,10 @@ [tabStripController_ updateDevToolsForContents:contents]; } +- (void)updateSidebarForContents:(TabContents*)contents { + [tabStripController_ updateSidebarForContents:contents]; +} + // Called when the user wants to close a window or from the shutdown process. // The Browser object is in control of whether or not we're allowed to close. It // may defer closing due to several states, such as onUnload handlers needing to diff --git a/chrome/browser/cocoa/tab_contents_controller.h b/chrome/browser/cocoa/tab_contents_controller.h index 548007a..ce156c0 100644 --- a/chrome/browser/cocoa/tab_contents_controller.h +++ b/chrome/browser/cocoa/tab_contents_controller.h @@ -24,8 +24,10 @@ class TabStripModel; @private TabContentsCommandObserver* observer_; // nil if |commands_| is nil TabContents* contents_; // weak + TabContents* sidebarContents_; // weak IBOutlet NSSplitView* contentsContainer_; + IBOutlet NSSplitView* devToolsContainer_; } // Create the contents of a tab represented by |contents| and loaded from the @@ -60,6 +62,17 @@ class TabStripModel; // Returns the height required by devtools and divider, or 0 if no devtools are // docked to the tab. - (CGFloat)devToolsHeight; + +// Shows |sidebarContents| in a split view, or removes the right view in the +// split view if |sidebarContents| is NULL. +// TODO(thakis): Either move this to tab_window or move infobar handling to here +// too -- http://crbug.com/31633 . +- (void)showSidebarContents:(TabContents*)sidebarContents; + +// Returns contents of the currently displayed sidebar; returns NULL if there +// isn't any. +- (TabContents*)sidebarContents; + @end #endif // CHROME_BROWSER_COCOA_TAB_CONTENTS_CONTROLLER_H_ diff --git a/chrome/browser/cocoa/tab_contents_controller.mm b/chrome/browser/cocoa/tab_contents_controller.mm index 9bd1643..545d6f1 100644 --- a/chrome/browser/cocoa/tab_contents_controller.mm +++ b/chrome/browser/cocoa/tab_contents_controller.mm @@ -19,8 +19,9 @@ static const int kDefaultContentsSplitOffset = 400; // Never make the web part of the tab contents smaller than this (needed if the -// window is only a few pixels high). -static const int kMinWebHeight = 50; +// window is only a few pixels high/wide). +const int kMinWebHeight = 50; +const int kMinWebWidth = 50; @implementation TabContentsController @@ -31,6 +32,7 @@ static const int kMinWebHeight = 50; bundle:mac_util::MainAppBundle()])) { contents_ = contents; } + sidebarContents_ = NULL; return self; } @@ -84,7 +86,7 @@ static const int kMinWebHeight = 50; } - (void)showDevToolsContents:(TabContents*)devToolsContents { - NSArray* subviews = [contentsContainer_ subviews]; + NSArray* subviews = [devToolsContainer_ subviews]; if (devToolsContents) { DCHECK_GE([subviews count], 1u); @@ -103,10 +105,10 @@ static const int kMinWebHeight = 50; NSView* devtoolsView = devToolsContents->GetNativeView(); view_id_util::SetID(devtoolsView, VIEW_ID_DEV_TOOLS_DOCKED); if ([subviews count] == 1) { - [contentsContainer_ addSubview:devtoolsView]; + [devToolsContainer_ addSubview:devtoolsView]; } else { DCHECK_EQ([subviews count], 2u); - [contentsContainer_ replaceSubview:[subviews objectAtIndex:1] + [devToolsContainer_ replaceSubview:[subviews objectAtIndex:1] with:devToolsContents->GetNativeView()]; // If devtools are already visible, keep the current size. splitOffset = NSHeight([devtoolsView frame]); @@ -114,7 +116,7 @@ static const int kMinWebHeight = 50; // Make sure |splitOffset| isn't too large or too small. splitOffset = MIN(splitOffset, - NSHeight([contentsContainer_ frame]) - kMinWebHeight); + NSHeight([devToolsContainer_ frame]) - kMinWebHeight); DCHECK_GE(splitOffset, 0) << "kMinWebHeight needs to be smaller than " << "smallest available tab contents space."; splitOffset = MAX(0, splitOffset); @@ -126,11 +128,11 @@ static const int kMinWebHeight = 50; [devtoolsView setFrame:devtoolsFrame]; NSRect webFrame = [[subviews objectAtIndex:0] frame]; - webFrame.size.height = NSHeight([contentsContainer_ frame]) - + webFrame.size.height = NSHeight([devToolsContainer_ frame]) - [self devToolsHeight]; [[subviews objectAtIndex:0] setFrame:webFrame]; - [contentsContainer_ adjustSubviews]; + [devToolsContainer_ adjustSubviews]; } else { if ([subviews count] > 1) { NSView* oldDevToolsContentsView = [subviews objectAtIndex:1]; @@ -144,11 +146,77 @@ static const int kMinWebHeight = 50; } - (CGFloat)devToolsHeight { - NSArray* subviews = [contentsContainer_ subviews]; + NSArray* subviews = [devToolsContainer_ subviews]; if ([subviews count] < 2) return 0; return NSHeight([[subviews objectAtIndex:1] frame]) + - [contentsContainer_ dividerThickness]; + [devToolsContainer_ dividerThickness]; +} + +// This function is very similar to showDevToolsContents. +// TODO(alekseys): refactor and move both to browser window. +// I (alekseys) intend to do it very soon. +- (void)showSidebarContents:(TabContents*)sidebarContents { + sidebarContents_ = sidebarContents; + NSArray* subviews = [contentsContainer_ subviews]; + if (sidebarContents) { + DCHECK_GE([subviews count], 1u); + + // Load the default split offset. + CGFloat sidebarWidth = g_browser_process->local_state()->GetInteger( + prefs::kExtensionSidebarWidth); + if (sidebarWidth == -1) { + // Initial load, set to default value. + sidebarWidth = NSWidth([contentsContainer_ frame]) / 7; + } + + // |sidebarView| is a TabContentsViewCocoa object, whose ViewID was + // set to VIEW_ID_TAB_CONTAINER initially, so we need to change it to + // VIEW_ID_SIDE_BAR_CONTAINER here. + NSView* sidebarView = sidebarContents->GetNativeView(); + view_id_util::SetID(sidebarView, VIEW_ID_SIDE_BAR_CONTAINER); + if ([subviews count] == 1) { + [contentsContainer_ addSubview:sidebarView]; + } else { + DCHECK_EQ([subviews count], 2u); + sidebarWidth = NSWidth([[subviews objectAtIndex:1] frame]); + [contentsContainer_ replaceSubview:[subviews objectAtIndex:1] + with:sidebarContents->GetNativeView()]; + } + + // Make sure |sidebarWidth| isn't too large or too small. + sidebarWidth = MIN(sidebarWidth, + NSWidth([contentsContainer_ frame]) - kMinWebWidth); + DCHECK_GE(sidebarWidth, 0) << "kMinWebWidth needs to be smaller than " + << "smallest available tab contents space."; + sidebarWidth = MAX(0, sidebarWidth); + + // It seems as if |-setPosition:ofDividerAtIndex:| should do what's needed, + // but I can't figure out how to use it. Manually resize web and sidebar. + NSRect sidebarFrame = [sidebarView frame]; + sidebarFrame.size.width = sidebarWidth; + [sidebarView setFrame:sidebarFrame]; + + NSRect webFrame = [[subviews objectAtIndex:0] frame]; + webFrame.size.width = NSWidth([contentsContainer_ frame]) - + ([contentsContainer_ dividerThickness] + sidebarWidth); + [[subviews objectAtIndex:0] setFrame:webFrame]; + + [contentsContainer_ adjustSubviews]; + } else { + if ([subviews count] > 1) { + NSView* oldSidebarContentsView = [subviews objectAtIndex:1]; + // Store split offset when hiding sidebar window only. + int sidebarWidth = NSWidth([oldSidebarContentsView frame]); + g_browser_process->local_state()->SetInteger( + prefs::kExtensionSidebarWidth, sidebarWidth); + [oldSidebarContentsView removeFromSuperview]; + } + } +} + +- (TabContents*)sidebarContents { + return sidebarContents_; } @end diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h index 054f2cb..1751a15 100644 --- a/chrome/browser/cocoa/tab_strip_controller.h +++ b/chrome/browser/cocoa/tab_strip_controller.h @@ -223,6 +223,7 @@ class ToolbarModel; - (void)attachConstrainedWindow:(ConstrainedWindowMac*)window; - (void)removeConstrainedWindow:(ConstrainedWindowMac*)window; - (void)updateDevToolsForContents:(TabContents*)contents; +- (void)updateSidebarForContents:(TabContents*)contents; @end diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index 2bc8730..2aed440 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -31,6 +31,8 @@ #import "chrome/browser/cocoa/throbber_view.h" #include "chrome/browser/debugger/devtools_window.h" #include "chrome/browser/net/url_fixer_upper.h" +#include "chrome/browser/sidebar/sidebar_container.h" +#include "chrome/browser/sidebar/sidebar_manager.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -1046,6 +1048,7 @@ private: // Swap in the contents for the new tab. [self swapInTabAtIndex:modelIndex]; + [self updateSidebarForContents:newContents]; [self updateDevToolsForContents:newContents]; if (newContents) { @@ -1153,6 +1156,7 @@ private: } // Does nothing, purely for consistency with the windows/linux code. + [self updateSidebarForContents:NULL]; [self updateDevToolsForContents:NULL]; // Send a broadcast that the number of tabs have changed. @@ -1788,11 +1792,12 @@ private: // NSView -- switchView, same for all tabs // +- NSView -- TabContentsController's view // +- NSSplitView - // +- TabContentsViewCocoa + // +- NSSplitView + // +- TabContentsViewCocoa // We use the TabContentsController's view in |swapInTabAtIndex|, so we have // to pass it to the sheet controller here. NSView* tabContentsView = - [[window->owner()->GetNativeView() superview] superview]; + [[[window->owner()->GetNativeView() superview] superview] superview]; window->delegate()->RunSheet([self sheetController], tabContentsView); // TODO(avi, thakis): GTMWindowSheetController has no api to move tabsheets @@ -1811,7 +1816,7 @@ private: - (void)removeConstrainedWindow:(ConstrainedWindowMac*)window { NSView* tabContentsView = - [[window->owner()->GetNativeView() superview] superview]; + [[[window->owner()->GetNativeView() superview] superview] superview]; // TODO(avi, thakis): GTMWindowSheetController has no api to move tabsheets // between windows. Until then, we have to prevent having to move a tabsheet @@ -1846,4 +1851,38 @@ private: [tabController showDevToolsContents:devtoolsContents]; } +// This function is very similar to updateDevToolsContents. +// TODO(alekseys): refactor and move both to browser window. +// I (alekseys) intend to do it very soon. +- (void)updateSidebarForContents:(TabContents*)contents { + if (SidebarManager::GetInstance() == NULL) // Happens in tests. + return; + + int modelIndex = tabStripModel_->GetIndexOfTabContents(contents); + + // This happens e.g. if one hits cmd-q with sidebar expanded. + if (modelIndex == TabStripModel::kNoTab) + return; + + NSInteger index = [self indexFromModelIndex:modelIndex]; + DCHECK_GE(index, 0); + DCHECK_LT(index, (NSInteger)[tabContentsArray_ count]); + if (index < 0 || index >= (NSInteger)[tabContentsArray_ count]) + return; + + TabContentsController* tabController = + [tabContentsArray_ objectAtIndex:index]; + TabContents* sidebar_contents = NULL; + if (contents && SidebarManager::IsSidebarAllowed()) { + SidebarContainer* active_sidebar = + SidebarManager::GetInstance()->GetActiveSidebarContainerFor(contents); + if (active_sidebar) + sidebar_contents = active_sidebar->sidebar_contents(); + } + TabContents* old_sidebar_contents = [tabController sidebarContents]; + [tabController showSidebarContents:sidebar_contents]; + SidebarManager::GetInstance()->NotifyStateChanges( + old_sidebar_contents, sidebar_contents); +} + @end diff --git a/chrome/browser/cocoa/view_id_util_browsertest.mm b/chrome/browser/cocoa/view_id_util_browsertest.mm index 2582bbd..f6fa0c3 100644 --- a/chrome/browser/cocoa/view_id_util_browsertest.mm +++ b/chrome/browser/cocoa/view_id_util_browsertest.mm @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/command_line.h" #include "base/logging.h" #include "base/utf_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -10,6 +11,8 @@ #include "chrome/browser/cocoa/view_id_util.h" #include "chrome/browser/download/download_shelf.h" #include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/sidebar/sidebar_manager.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "chrome/test/in_process_browser_test.h" @@ -18,7 +21,10 @@ // Basic sanity check of ViewID use on the mac. class ViewIDTest : public InProcessBrowserTest { public: - ViewIDTest() : root_window_(nil) {} + ViewIDTest() : root_window_(nil) { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableExperimentalExtensionApis); + } void CheckViewID(ViewID view_id, bool should_have) { if (!root_window_) @@ -34,6 +40,13 @@ class ViewIDTest : public InProcessBrowserTest { // VIEW_ID_FIND_IN_PAGE_TEXT_FIELD and VIEW_ID_FIND_IN_PAGE. browser()->ShowFindBar(); + // Make sure sidebar is created to test VIEW_ID_SIDE_BAR_CONTAINER. + const char sidebar_content_id[] = "test_content_id"; + SidebarManager::GetInstance()->ShowSidebar( + browser()->GetSelectedTabContents(), sidebar_content_id); + SidebarManager::GetInstance()->ExpandSidebar( + browser()->GetSelectedTabContents(), sidebar_content_id); + // Make sure docked devtools is created to test VIEW_ID_DEV_TOOLS_DOCKED browser()->profile()->GetPrefs()->SetBoolean(prefs::kDevToolsOpenDocked, true); @@ -57,7 +70,6 @@ class ViewIDTest : public InProcessBrowserTest { if (i == VIEW_ID_STAR_BUTTON || i == VIEW_ID_AUTOCOMPLETE || i == VIEW_ID_CONTENTS_SPLIT || - i == VIEW_ID_SIDE_BAR_CONTAINER || i == VIEW_ID_SIDE_BAR_SPLIT) { continue; } @@ -78,7 +90,7 @@ IN_PROC_BROWSER_TEST_F(ViewIDTest, Basic) { ASSERT_NO_FATAL_FAILURE(DoTest()); } -IN_PROC_BROWSER_TEST_F(ViewIDTest, FAILS_Fullscreen) { +IN_PROC_BROWSER_TEST_F(ViewIDTest, Fullscreen) { browser()->window()->SetFullscreen(true); ASSERT_NO_FATAL_FAILURE(DoTest()); } |