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
This commit is contained in:
chrome
app
nibs
browser
ipc
webkit/glue/devtools/js
@ -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">
|
||||
@ -272,25 +233,19 @@
|
||||
<string key="minorKey">browser/cocoa/tab_strip_model_observer_bridge.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>
|
||||
</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>
|
||||
|
@ -144,7 +144,8 @@ void BrowserWindowCocoa::ShelfVisibilityChanged() {
|
||||
}
|
||||
|
||||
void BrowserWindowCocoa::UpdateDevTools() {
|
||||
NOTIMPLEMENTED();
|
||||
[controller_ updateDevToolsForContents:
|
||||
browser_->tabstrip_model()->GetSelectedTabContents()];
|
||||
}
|
||||
|
||||
void BrowserWindowCocoa::FocusDevTools() {
|
||||
|
@ -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.
|
||||
|
@ -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 {
|
||||
|
@ -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_
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
@ -123,4 +123,4 @@ void Message::EnsureFileDescriptorSet() {
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace IPC
|
||||
} // namespace IPC
|
||||
|
@ -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();
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user