OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" | 5 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include <Cocoa/Cocoa.h> | 9 #include <Cocoa/Cocoa.h> |
10 | 10 |
11 #import "base/mac/foundation_util.h" | 11 #import "base/mac/foundation_util.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #import "chrome/browser/ui/cocoa/view_id_util.h" | 15 #import "chrome/browser/ui/cocoa/view_id_util.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/browser/web_contents_view.h" |
18 | 19 |
19 using content::WebContents; | 20 using content::WebContents; |
20 | 21 |
21 @interface GraySplitView : NSSplitView { | 22 @interface GraySplitView : NSSplitView { |
22 CGFloat topContentOffset_; | 23 CGFloat topContentOffset_; |
23 } | 24 } |
24 | 25 |
25 @property(assign, nonatomic) CGFloat topContentOffset; | 26 @property(assign, nonatomic) CGFloat topContentOffset; |
26 | 27 |
27 - (NSColor*)dividerColor; | 28 - (NSColor*)dividerColor; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 136 } |
136 | 137 |
137 - (void)showDevToolsContainer { | 138 - (void)showDevToolsContainer { |
138 NSArray* subviews = [splitView_ subviews]; | 139 NSArray* subviews = [splitView_ subviews]; |
139 DCHECK_EQ([subviews count], 1u); | 140 DCHECK_EQ([subviews count], 1u); |
140 WebContents* devToolsContents = devToolsWindow_->web_contents(); | 141 WebContents* devToolsContents = devToolsWindow_->web_contents(); |
141 | 142 |
142 // |devToolsView| is a TabContentsViewCocoa object, whose ViewID was | 143 // |devToolsView| is a TabContentsViewCocoa object, whose ViewID was |
143 // set to VIEW_ID_TAB_CONTAINER initially, so we need to change it to | 144 // set to VIEW_ID_TAB_CONTAINER initially, so we need to change it to |
144 // VIEW_ID_DEV_TOOLS_DOCKED here. | 145 // VIEW_ID_DEV_TOOLS_DOCKED here. |
145 NSView* devToolsView = devToolsContents->GetNativeView(); | 146 NSView* devToolsView = devToolsContents->GetView()->GetNativeView(); |
146 view_id_util::SetID(devToolsView, VIEW_ID_DEV_TOOLS_DOCKED); | 147 view_id_util::SetID(devToolsView, VIEW_ID_DEV_TOOLS_DOCKED); |
147 [devToolsView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; | 148 [devToolsView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
148 | 149 |
149 NSRect containerRect = NSMakeRect(0, 0, 100, 100); | 150 NSRect containerRect = NSMakeRect(0, 0, 100, 100); |
150 scoped_nsobject<NSView> devToolsContainerView( | 151 scoped_nsobject<NSView> devToolsContainerView( |
151 [[NSView alloc] initWithFrame:containerRect]); | 152 [[NSView alloc] initWithFrame:containerRect]); |
152 [devToolsContainerView addSubview:devToolsView]; | 153 [devToolsContainerView addSubview:devToolsView]; |
153 [splitView_ addSubview:devToolsContainerView]; | 154 [splitView_ addSubview:devToolsContainerView]; |
154 [self updateDevToolsViewFrame]; | 155 [self updateDevToolsViewFrame]; |
155 | 156 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 192 } |
192 | 193 |
193 [[splitView_ window] disableScreenUpdatesUntilFlush]; | 194 [[splitView_ window] disableScreenUpdatesUntilFlush]; |
194 [webView setFrame:webFrame]; | 195 [webView setFrame:webFrame]; |
195 [devToolsView setFrame:devToolsFrame]; | 196 [devToolsView setFrame:devToolsFrame]; |
196 | 197 |
197 [splitView_ adjustSubviews]; | 198 [splitView_ adjustSubviews]; |
198 } | 199 } |
199 | 200 |
200 - (void)updateDevToolsViewFrame { | 201 - (void)updateDevToolsViewFrame { |
201 NSView* devToolsView = devToolsWindow_->web_contents()->GetNativeView(); | 202 NSView* devToolsView = |
| 203 devToolsWindow_->web_contents()->GetView()->GetNativeView(); |
202 NSRect devToolsRect = [[devToolsView superview] bounds]; | 204 NSRect devToolsRect = [[devToolsView superview] bounds]; |
203 if (devToolsWindow_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) | 205 if (devToolsWindow_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) |
204 devToolsRect.size.height -= [splitView_ topContentOffset]; | 206 devToolsRect.size.height -= [splitView_ topContentOffset]; |
205 [devToolsView setFrame:devToolsRect]; | 207 [devToolsView setFrame:devToolsRect]; |
206 } | 208 } |
207 | 209 |
208 // NSSplitViewDelegate protocol. | 210 // NSSplitViewDelegate protocol. |
209 - (BOOL)splitView:(NSSplitView *)splitView | 211 - (BOOL)splitView:(NSSplitView *)splitView |
210 shouldAdjustSizeOfSubview:(NSView *)subview { | 212 shouldAdjustSizeOfSubview:(NSView *)subview { |
211 // Return NO for the devTools view to indicate that it should not be resized | 213 // Return NO for the devTools view to indicate that it should not be resized |
(...skipping 13 matching lines...) Expand all Loading... |
225 return [splitView_ topContentOffset]; | 227 return [splitView_ topContentOffset]; |
226 } | 228 } |
227 return proposedPosition; | 229 return proposedPosition; |
228 } | 230 } |
229 | 231 |
230 -(void)splitViewWillResizeSubviews:(NSNotification *)notification { | 232 -(void)splitViewWillResizeSubviews:(NSNotification *)notification { |
231 [[splitView_ window] disableScreenUpdatesUntilFlush]; | 233 [[splitView_ window] disableScreenUpdatesUntilFlush]; |
232 } | 234 } |
233 | 235 |
234 @end | 236 @end |
OLD | NEW |