summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-05 23:20:30 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-05 23:20:30 +0000
commitd284a5fd91186becd0091b35219710735b9cbf74 (patch)
tree1c7f029d16e5d1c6b0dce45b133d64763a5f3929
parente39bc5e7891b2b2bb4bc6f08e4579da4b1d11fb8 (diff)
downloadchromium_src-d284a5fd91186becd0091b35219710735b9cbf74.zip
chromium_src-d284a5fd91186becd0091b35219710735b9cbf74.tar.gz
chromium_src-d284a5fd91186becd0091b35219710735b9cbf74.tar.bz2
Mac: Make devtools window dockable.
xib change: Deleted NSBox, added NSSplitView instead (with a thin divider and without any child views). I added the devtools tabcontents to TabContentsController; windows and linux instead add it to the browser window and switch it on every tab change. What I've done makes more sense to me and might work better with a) dragging a tab with docked devtools into a new window and b) toggling fullscreen. BUG=17368 TEST= * Inspect element, click the "attach" item in the lower left corner. Devtools should attach to the tab. Click it again, should detach. Re-attach, switch tabs. Should only be in the tab it was attached to. Open another devtools window in another tab, should be attached there. Drag tab with attached devtools into a new window, should work. * Inspect element with docked devtools, close devtools, inspect another element. devtools should open with the same size it had when it was closed, and should still be docked. * Hover link with docked devtools. Status bubble should not overlap devtools. * Go to http://www.pagetutor.com/keeper/http_authentication/index.html and make sure the http auth sheet still shows up Review URL: http://codereview.chromium.org/526001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35576 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/nibs/TabContents.xib101
-rw-r--r--chrome/browser/cocoa/browser_window_cocoa.mm3
-rw-r--r--chrome/browser/cocoa/browser_window_controller.h4
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm9
-rw-r--r--chrome/browser/cocoa/tab_contents_controller.h22
-rw-r--r--chrome/browser/cocoa/tab_contents_controller.mm76
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.h22
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.mm49
-rw-r--r--chrome/browser/debugger/devtools_manager.cc5
-rw-r--r--chrome/browser/debugger/devtools_window.cc4
-rw-r--r--ipc/ipc_message.cc2
-rw-r--r--webkit/glue/devtools/js/devtools.js6
12 files changed, 196 insertions, 107 deletions
diff --git a/chrome/app/nibs/TabContents.xib b/chrome/app/nibs/TabContents.xib
index cf88b9c..2d45690 100644
--- a/chrome/app/nibs/TabContents.xib
+++ b/chrome/app/nibs/TabContents.xib
@@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">9J61</string>
+ <string key="IBDocument.SystemVersion">9L31a</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
- <string key="IBDocument.AppKitVersion">949.46</string>
+ <string key="IBDocument.AppKitVersion">949.54</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="94"/>
+ <integer value="195"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -55,50 +55,12 @@
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSBox" id="753762894">
+ <object class="NSSplitView" id="89435107">
<reference key="NSNextResponder" ref="675542922"/>
- <int key="NSvFlags">18</int>
- <object class="NSMutableArray" key="NSSubviews">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSView" id="250835567">
- <reference key="NSNextResponder" ref="753762894"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrameSize">{480, 360}</string>
- <reference key="NSSuperview" ref="753762894"/>
- </object>
- </object>
+ <int key="NSvFlags">274</int>
<string key="NSFrameSize">{480, 360}</string>
<reference key="NSSuperview" ref="675542922"/>
- <string key="NSOffsets">{0, 0}</string>
- <object class="NSTextFieldCell" key="NSTitleCell">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Box</string>
- <object class="NSFont" key="NSSupport">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">1.100000e+01</double>
- <int key="NSfFlags">3100</int>
- </object>
- <object class="NSColor" key="NSBackgroundColor">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">textBackgroundColor</string>
- <object class="NSColor" key="NSColor" id="524635398">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MQA</bytes>
- </object>
- </object>
- <object class="NSColor" key="NSTextColor">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
- </object>
- </object>
- <reference key="NSContentView" ref="250835567"/>
- <int key="NSBorderType">0</int>
- <int key="NSBoxType">4</int>
- <int key="NSTitlePosition">0</int>
- <bool key="NSTransparent">NO</bool>
- <reference key="NSFillColor2" ref="524635398"/>
+ <int key="NSDividerStyle">2</int>
</object>
</object>
<string key="NSFrameSize">{480, 360}</string>
@@ -122,11 +84,11 @@
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
- <string key="label">contentsBox_</string>
+ <string key="label">contentsContainer_</string>
<reference key="source" ref="326691890"/>
- <reference key="destination" ref="753762894"/>
+ <reference key="destination" ref="89435107"/>
</object>
- <int key="connectionID">169</int>
+ <int key="connectionID">200</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
@@ -167,7 +129,7 @@
<reference key="object" ref="675542922"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="753762894"/>
+ <reference ref="89435107"/>
</object>
<reference key="parent" ref="886393115"/>
</object>
@@ -178,8 +140,8 @@
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
- <int key="objectID">164</int>
- <reference key="object" ref="753762894"/>
+ <int key="objectID">195</int>
+ <reference key="object" ref="89435107"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
@@ -194,7 +156,7 @@
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
- <string>164.IBPluginDependency</string>
+ <string>195.IBPluginDependency</string>
<string>93.IBEditorWindowLastContentRect</string>
<string>93.IBViewEditorWindowController.showingLayoutRectangles</string>
<string>93.IBWindowTemplateEditedContentRect</string>
@@ -210,9 +172,9 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{769, 496}, {480, 360}}</string>
+ <string>{{283, 496}, {480, 360}}</string>
<boolean value="YES" id="5"/>
- <string>{{769, 496}, {480, 360}}</string>
+ <string>{{283, 496}, {480, 360}}</string>
<reference ref="5"/>
<reference ref="5"/>
<string>{480, 360}</string>
@@ -240,7 +202,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">194</int>
+ <int key="maxID">200</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -258,11 +220,10 @@
</object>
</object>
<object class="IBPartialClassDescription">
- <string key="className">GrowBoxView</string>
- <string key="superclassName">NSView</string>
+ <string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
- <string key="minorKey">browser/cocoa/grow_box_view.h</string>
+ <string key="minorKey">browser/cocoa/status_bubble_mac.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
@@ -273,24 +234,18 @@
</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>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">TabContentsController</string>
<string key="superclassName">NSViewController</string>
- <object class="NSMutableDictionary" key="actions">
- <string key="NS.key.0">fullScreen:</string>
- <string key="NS.object.0">id</string>
- </object>
<object class="NSMutableDictionary" key="outlets">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>contentsBox_</string>
- <string>growBox_</string>
- </object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>NSBox</string>
- <string>GrowBoxView</string>
- </object>
+ <string key="NS.key.0">contentsContainer_</string>
+ <string key="NS.object.0">NSSplitView</string>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
@@ -300,7 +255,7 @@
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
- <string key="IBDocument.LastKnownRelativeProjectPath">../../../chrome.xcodeproj</string>
+ <string key="IBDocument.LastKnownRelativeProjectPath">../../chrome.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>
diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm
index c25a32e..8e1df28 100644
--- a/chrome/browser/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/cocoa/browser_window_cocoa.mm
@@ -144,7 +144,8 @@ void BrowserWindowCocoa::ShelfVisibilityChanged() {
}
void BrowserWindowCocoa::UpdateDevTools() {
- NOTIMPLEMENTED();
+ [controller_ updateDevToolsForContents:
+ browser_->tabstrip_model()->GetSelectedTabContents()];
}
void BrowserWindowCocoa::FocusDevTools() {
diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h
index 5e2014f..623104a 100644
--- a/chrome/browser/cocoa/browser_window_controller.h
+++ b/chrome/browser/cocoa/browser_window_controller.h
@@ -35,7 +35,6 @@ class ConstrainedWindowMac;
class LocationBar;
class StatusBubbleMac;
class TabContents;
-@class TabContentsController;
@class TabStripController;
class TabStripModelObserverBridge;
@class TabStripView;
@@ -215,6 +214,9 @@ class TabStripModelObserverBridge;
// tab's sheet queue.
- (void)removeConstrainedWindow:(ConstrainedWindowMac*)window;
+// Shows or hides the docked web inspector depending on |contents|'s state.
+- (void)updateDevToolsForContents:(TabContents*)contents;
+
@end
// Methods which are either only for testing, or only public for testing.
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index a7417bb..d36456c 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -39,6 +39,7 @@
#import "chrome/browser/cocoa/infobar_container_controller.h"
#import "chrome/browser/cocoa/sad_tab_controller.h"
#import "chrome/browser/cocoa/status_bubble_mac.h"
+#import "chrome/browser/cocoa/tab_contents_controller.h"
#import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h"
#import "chrome/browser/cocoa/tab_strip_view.h"
#import "chrome/browser/cocoa/tab_strip_controller.h"
@@ -392,6 +393,10 @@ willPositionSheet:(NSWindow*)sheet
[tabStripController_ removeConstrainedWindow:window];
}
+- (void)updateDevToolsForContents:(TabContents*)contents {
+ [tabStripController_ updateDevToolsForContents: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
@@ -884,7 +889,8 @@ willPositionSheet:(NSWindow*)sheet
// StatusBubble delegate method: tell the status bubble how far above the bottom
// of the window it should position itself.
- (float)verticalOffsetForStatusBubble {
- return verticalOffsetForStatusBubble_;
+ return verticalOffsetForStatusBubble_ +
+ [[tabStripController_ activeTabContentsController] devToolsHeight];
}
- (GTMWindowSheetController*)sheetController {
@@ -1086,7 +1092,6 @@ willPositionSheet:(NSWindow*)sheet
return controller;
}
-
- (void)insertPlaceholderForTab:(TabView*)tab
frame:(NSRect)frame
yStretchiness:(CGFloat)yStretchiness {
diff --git a/chrome/browser/cocoa/tab_contents_controller.h b/chrome/browser/cocoa/tab_contents_controller.h
index 4182705..e3c27c1 100644
--- a/chrome/browser/cocoa/tab_contents_controller.h
+++ b/chrome/browser/cocoa/tab_contents_controller.h
@@ -12,18 +12,19 @@ class TabContentsCommandObserver;
class TabStripModel;
// A class that controls the web contents of a tab. It manages displaying the
-// native view for a given TabContents in |contentsBox_|. Note that just
-// creating the class does not display the view in |contentsBox_|. We defer
-// inserting it until the box is the correct size to avoid multiple resize
-// messages to the renderer. You must call |-ensureContentsVisible| to display
-// the render widget host view.
+// native view for a given TabContents and optionally its docked devtools in
+// |contentsContainer_|.
+// Note that just creating the class does not display the view in
+// |contentsContainer_|. We defer inserting it until the box is the correct size
+// to avoid multiple resize messages to the renderer. You must call
+// |-ensureContentsVisible| to display the render widget host view.
@interface TabContentsController : NSViewController {
@private
TabContentsCommandObserver* observer_; // nil if |commands_| is nil
TabContents* contents_; // weak
- IBOutlet NSBox* contentsBox_;
+ IBOutlet NSSplitView* contentsContainer_;
}
// Create the contents of a tab represented by |contents| and loaded from the
@@ -49,6 +50,15 @@ class TabStripModel;
// an entirely new tab contents object.
- (void)tabDidChange:(TabContents*)updatedContents;
+// Shows |devToolsContents| in a split view, or removes the bottom view in the
+// split viewif |devToolsContents| is NULL.
+// TODO(thakis): Either move this to tab_window or move infobar handling to here
+// too -- http://crbug.com/31633 .
+- (void)showDevToolsContents:(TabContents*)devToolsContents;
+
+// Returns the height required by devtools and divider, or 0 if no devtools are
+// docked to the tab.
+- (CGFloat)devToolsHeight;
@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 8072683..70daa32 100644
--- a/chrome/browser/cocoa/tab_contents_controller.mm
+++ b/chrome/browser/cocoa/tab_contents_controller.mm
@@ -6,8 +6,19 @@
#include "base/mac_util.h"
#include "base/sys_string_conversions.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
+
+// Default offset of the contents splitter in pixels.
+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;
+
@implementation TabContentsController
@@ -29,7 +40,12 @@
// Call when the tab view is properly sized and the render widget host view
// should be put into the view hierarchy.
- (void)ensureContentsVisible {
- [contentsBox_ setContentView:contents_->GetNativeView()];
+ NSArray* subviews = [contentsContainer_ subviews];
+ if ([subviews count] == 0)
+ [contentsContainer_ addSubview:contents_->GetNativeView()];
+ else if ([subviews objectAtIndex:0] != contents_->GetNativeView())
+ [contentsContainer_ replaceSubview:[subviews objectAtIndex:0]
+ with:contents_->GetNativeView()];
}
// Returns YES if the tab represented by this controller is the front-most.
@@ -57,8 +73,64 @@
// the view is different.
if (contents_ != updatedContents) {
contents_ = updatedContents;
- [contentsBox_ setContentView:contents_->GetNativeView()];
+ [self ensureContentsVisible];
}
}
+- (void)showDevToolsContents:(TabContents*)devToolsContents {
+ NSArray* subviews = [contentsContainer_ subviews];
+ if (devToolsContents) {
+ DCHECK_GE([subviews count], 1u);
+ if ([subviews count] == 1) {
+ [contentsContainer_ addSubview:devToolsContents->GetNativeView()];
+ } else {
+ DCHECK_EQ([subviews count], 2u);
+ [contentsContainer_ replaceSubview:[subviews objectAtIndex:1]
+ with:devToolsContents->GetNativeView()];
+ }
+ // Restore split offset.
+ CGFloat splitOffset = g_browser_process->local_state()->GetInteger(
+ prefs::kDevToolsSplitLocation);
+ if (splitOffset == -1) {
+ // Initial load, set to default value.
+ splitOffset = kDefaultContentsSplitOffset;
+ }
+ splitOffset = MIN(splitOffset,
+ NSHeight([contentsContainer_ frame]) - kMinWebHeight);
+ DCHECK_GE(splitOffset, 0) << "kMinWebHeight needs to be smaller than "
+ << "smallest available tab contents space.";
+ splitOffset = MAX(0, splitOffset);
+
+ // 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 devtools.
+ NSRect devtoolsFrame = [devToolsContents->GetNativeView() frame];
+ devtoolsFrame.size.height = splitOffset;
+ [devToolsContents->GetNativeView() setFrame:devtoolsFrame];
+
+ NSRect webFrame = [[subviews objectAtIndex:0] frame];
+ webFrame.size.height = NSHeight([contentsContainer_ frame]) -
+ [self devToolsHeight];
+ [[subviews objectAtIndex:0] setFrame:webFrame];
+
+ [contentsContainer_ adjustSubviews];
+ } else {
+ if ([subviews count] > 1) {
+ NSView* oldDevToolsContentsView = [subviews objectAtIndex:1];
+ // Store split offset when hiding devtools window only.
+ int splitOffset = NSHeight([oldDevToolsContentsView frame]);
+ g_browser_process->local_state()->SetInteger(
+ prefs::kDevToolsSplitLocation, splitOffset);
+ [oldDevToolsContentsView removeFromSuperview];
+ }
+ }
+}
+
+- (CGFloat)devToolsHeight {
+ NSArray* subviews = [contentsContainer_ subviews];
+ if ([subviews count] < 2)
+ return 0;
+ return NSHeight([[subviews objectAtIndex:1] frame]) +
+ [contentsContainer_ dividerThickness];
+}
+
@end
diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h
index 838c00a..f5f8d9d 100644
--- a/chrome/browser/cocoa/tab_strip_controller.h
+++ b/chrome/browser/cocoa/tab_strip_controller.h
@@ -16,6 +16,7 @@
#import "chrome/browser/cocoa/url_drop_target.h"
#import "third_party/GTM/AppKit/GTMWindowSheetController.h"
+@class TabContentsController;
@class TabView;
@class TabStripView;
@@ -36,7 +37,6 @@ class ToolbarModel;
// then handles replacing the contentView of the window. As tabs are switched,
// the single child of the contentView is swapped around to hold the contents
// (toolbar and all) representing that tab.
-
@interface TabStripController :
NSObject<TabControllerTarget,
URLDropTargetController,
@@ -53,13 +53,19 @@ class ToolbarModel;
scoped_ptr<TabStripModelObserverBridge> bridge_;
Browser* browser_; // weak
TabStripModel* tabStripModel_; // weak
+
// Access to the TabContentsControllers (which own the parent view
- // for the toolbar and associated tab contents) given an index. This needs
- // to be kept in the same order as the tab strip's model as we will be
- // using its index from the TabStripModelObserver calls.
+ // for the toolbar and associated tab contents) given an index. Call
+ // |indexFromModelIndex:| to convert a |tabStripModel_| index to a
+ // |tabContentsArray_| index. Do NOT assume that the indices of
+ // |tabStripModel_| and this array are identical, this is e.g. not true while
+ // tabs are animating closed (closed tabs are removed from |tabStripModel_|
+ // immediately, but from |tabContentsArray_| only after their close animation
+ // has completed).
scoped_nsobject<NSMutableArray> tabContentsArray_;
- // An array of TabControllers which manage the actual tab views. As above,
- // this is kept in the same order as the tab strip model.
+ // An array of TabControllers which manage the actual tab views. See note
+ // above |tabContentsArray_|. |tabContentsArray_| and |tabArray_| always
+ // contain objects belonging to the same tabs at the same indices.
scoped_nsobject<NSMutableArray> tabArray_;
// Set of TabControllers that are currently animating closed.
@@ -183,10 +189,14 @@ class ToolbarModel;
// for the per-tab sheets.
- (GTMWindowSheetController*)sheetController;
+// Returns the currently active TabContentsController.
+- (TabContentsController*)activeTabContentsController;
+
// See comments in browser_window_controller.h for documentation about these
// functions.
- (BOOL)attachConstrainedWindow:(ConstrainedWindowMac*)window;
- (void)removeConstrainedWindow:(ConstrainedWindowMac*)window;
+- (void)updateDevToolsForContents:(TabContents*)contents;
@end
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index b3a1e87..4253aa7 100644
--- a/chrome/browser/cocoa/tab_strip_controller.mm
+++ b/chrome/browser/cocoa/tab_strip_controller.mm
@@ -28,6 +28,7 @@
#import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h"
#import "chrome/browser/cocoa/tab_view.h"
#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/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
@@ -461,10 +462,15 @@ private:
}
// Given an index into the tab model, returns the index into the tab controller
-// array accounting for tabs that are currently closing. For example, if there
-// are two tabs in the process of closing before |index|, this returns
-// |index| + 2. If there are no closing tabs, this will return |index|.
+// or tab contents controller array accounting for tabs that are currently
+// closing. For example, if there are two tabs in the process of closing before
+// |index|, this returns |index| + 2. If there are no closing tabs, this will
+// return |index|.
- (NSInteger)indexFromModelIndex:(NSInteger)index {
+ DCHECK(index >= 0);
+ if (index < 0)
+ return index;
+
NSInteger i = 0;
for (TabController* controller in tabArray_.get()) {
if ([closingControllers_ containsObject:controller]) {
@@ -937,6 +943,7 @@ private:
// Swap in the contents for the new tab.
[self swapInTabAtIndex:modelIndex];
+ [self updateDevToolsForContents:newContents];
if (newContents) {
newContents->DidBecomeSelected();
@@ -1042,6 +1049,9 @@ private:
[self removeTab:tab];
}
+ // Does nothing, purely for consistency with the windows/linux code.
+ [self updateDevToolsForContents:NULL];
+
// Send a broadcast that the number of tabs have changed.
[[NSNotificationCenter defaultCenter]
postNotificationName:kTabStripNumberOfTabsChanged
@@ -1612,6 +1622,17 @@ private:
return sheetController_.get();
}
+- (TabContentsController*)activeTabContentsController {
+ int modelIndex = tabStripModel_->selected_index();
+ if (modelIndex < 0)
+ return nil;
+ NSInteger index = [self indexFromModelIndex:modelIndex];
+ if (index < 0 ||
+ index >= (NSInteger)[tabContentsArray_ count])
+ return nil;
+ return [tabContentsArray_ objectAtIndex:index];
+}
+
- (void)gtm_systemRequestsVisibilityForView:(NSView*)view {
// This implementation is required by GTMWindowSheetController.
@@ -1632,7 +1653,7 @@ private:
// View hierarchy of the contents view:
// NSView -- switchView, same for all tabs
// +- NSView -- TabContentsController's view
- // +- NSBox
+ // +- NSSplitView
// +- TabContentsViewCocoa
// We use the TabContentsController's view in |swapInTabAtIndex|, so we have
// to pass it to the sheet controller here.
@@ -1706,4 +1727,24 @@ private:
}
}
+- (void)updateDevToolsForContents:(TabContents*)contents {
+ int modelIndex = tabStripModel_->GetIndexOfTabContents(contents);
+
+ // This happens e.g. if one hits cmd-q with a docked devtools window open.
+ 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* devtoolsContents = contents ?
+ DevToolsWindow::GetDevToolsContents(contents) : NULL;
+ [tabController showDevToolsContents:devtoolsContents];
+}
+
@end
diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc
index b8fb65d..4bf9825 100644
--- a/chrome/browser/debugger/devtools_manager.cc
+++ b/chrome/browser/debugger/devtools_manager.cc
@@ -342,13 +342,8 @@ void DevToolsManager::ToggleDevToolsWindow(RenderViewHost* inspected_rvh,
bool do_open = force_open;
DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh);
if (!host) {
-#if defined OS_MACOSX
- // TODO(pfeldman): Implement dock on Mac OS.
- bool docked = false;
-#else
bool docked = inspected_rvh->process()->profile()->GetPrefs()->
GetBoolean(prefs::kDevToolsOpenDocked);
-#endif
host = new DevToolsWindow(
inspected_rvh->site_instance()->browsing_instance()->profile(),
inspected_rvh,
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc
index 0eaccdd..9127c6c 100644
--- a/chrome/browser/debugger/devtools_window.cc
+++ b/chrome/browser/debugger/devtools_window.cc
@@ -31,6 +31,10 @@ TabContents* DevToolsWindow::GetDevToolsContents(TabContents* inspected_tab) {
if (!inspected_tab) {
return NULL;
}
+
+ if (!DevToolsManager::GetInstance())
+ return NULL; // Happens only in tests.
+
DevToolsClientHost* client_host = DevToolsManager::GetInstance()->
GetDevToolsClientHostFor(inspected_tab->render_view_host());
if (!client_host) {
diff --git a/ipc/ipc_message.cc b/ipc/ipc_message.cc
index a532a8d..703588d0 100644
--- a/ipc/ipc_message.cc
+++ b/ipc/ipc_message.cc
@@ -123,4 +123,4 @@ void Message::EnsureFileDescriptorSet() {
#endif
-} // namespace IPC \ No newline at end of file
+} // namespace IPC
diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js
index 1984f94..c4cb247 100644
--- a/webkit/glue/devtools/js/devtools.js
+++ b/webkit/glue/devtools/js/devtools.js
@@ -176,12 +176,6 @@ WebInspector.loaded = function() {
Preferences.heapProfilerPresent = true;
oldLoaded.call(this);
- // Hide dock button on Mac OS.
- // TODO(pfeldman): remove once Mac OS docking is implemented.
- if (InspectorFrontendHost.platform().indexOf('mac') == 0) {
- document.getElementById('dock-status-bar-item').addStyleClass('hidden');
- }
-
InspectorFrontendHost.loaded();
};