Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1373)

Unified Diff: chrome/browser/cocoa/tab_strip_controller.mm

Issue 526001: Mac: Make devtools window dockable. (Closed)
Patch Set: copyediting Created 10 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/tab_strip_controller.h ('k') | chrome/browser/debugger/devtools_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/tab_strip_controller.mm
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index 31a38efbac126bf7a5e86cd046d61022615823ef..e4cb6a4d71e85b3a9339557c0ef54e5e3ec589d2 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();
@@ -1036,6 +1043,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
@@ -1606,6 +1616,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.
@@ -1626,7 +1647,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.
@@ -1700,4 +1721,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
« no previous file with comments | « chrome/browser/cocoa/tab_strip_controller.h ('k') | chrome/browser/debugger/devtools_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698