OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tabpose_window.h" | 5 #import "chrome/browser/ui/cocoa/tabpose_window.h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
12 #include "base/mac/scoped_cftyperef.h" | 12 #include "base/mac/scoped_cftyperef.h" |
13 #include "base/scoped_callback_factory.h" | 13 #include "base/scoped_callback_factory.h" |
14 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #import "chrome/browser/debugger/devtools_window.h" | 17 #import "chrome/browser/debugger/devtools_window.h" |
18 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/renderer_host/backing_store_mac.h" | 20 #include "chrome/browser/renderer_host/backing_store_mac.h" |
21 #include "chrome/browser/renderer_host/render_view_host.h" | 21 #include "chrome/browser/renderer_host/render_view_host.h" |
22 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" | 22 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" |
23 #include "chrome/browser/tab_contents/tab_contents.h" | 23 #include "chrome/browser/tab_contents/tab_contents.h" |
24 #include "chrome/browser/tab_contents/thumbnail_generator.h" | 24 #include "chrome/browser/tab_contents/thumbnail_generator.h" |
25 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 25 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
26 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 26 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
27 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | |
27 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 28 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
28 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" | 29 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" |
29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 30 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
31 #include "grit/app_resources.h" | 32 #include "grit/app_resources.h" |
32 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
33 #include "skia/ext/skia_utils_mac.h" | 34 #include "skia/ext/skia_utils_mac.h" |
34 #include "third_party/skia/include/utils/mac/SkCGUtils.h" | 35 #include "third_party/skia/include/utils/mac/SkCGUtils.h" |
35 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
36 #include "ui/gfx/scoped_cg_context_state_mac.h" | 37 #include "ui/gfx/scoped_cg_context_state_mac.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 thumbnail_.reset(SkCreateCGImageRefWithColorspace( | 180 thumbnail_.reset(SkCreateCGImageRefWithColorspace( |
180 bitmap, base::mac::GetSystemColorSpace())); | 181 bitmap, base::mac::GetSystemColorSpace())); |
181 loader_ = NULL; | 182 loader_ = NULL; |
182 [self setNeedsDisplay]; | 183 [self setNeedsDisplay]; |
183 } | 184 } |
184 | 185 |
185 - (int)topOffset { | 186 - (int)topOffset { |
186 int topOffset = 0; | 187 int topOffset = 0; |
187 | 188 |
188 // Medium term, we want to show thumbs of the actual info bar views, which | 189 // Medium term, we want to show thumbs of the actual info bar views, which |
189 // means I need to create InfoBarControllers here. At that point, we can get | 190 // means I need to create InfoBarControllers here. |
190 // the height from that controller. Until then, hardcode. :-/ | 191 NSWindow* window = [contents_->GetNativeView() window]; |
191 const int kInfoBarHeight = 31; | 192 NSWindowController* windowController = [window windowController]; |
192 topOffset += contents_->infobar_count() * kInfoBarHeight; | 193 DCHECK(windowController); |
Nico
2011/03/04 07:34:20
I forgot that all background contents don't have a
| |
194 if ([windowController isKindOfClass:[BrowserWindowController class]]) { | |
195 BrowserWindowController* bwc = | |
196 static_cast<BrowserWindowController*>(windowController); | |
197 InfoBarContainerController* infoBarContainer = | |
198 [bwc infoBarContainerController]; | |
199 topOffset += NSHeight([[infoBarContainer view] frame]); | |
200 } | |
193 | 201 |
194 bool always_show_bookmark_bar = | 202 bool always_show_bookmark_bar = |
195 contents_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 203 contents_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
196 bool has_detached_bookmark_bar = | 204 bool has_detached_bookmark_bar = |
197 contents_->ShouldShowBookmarkBar() && !always_show_bookmark_bar; | 205 contents_->ShouldShowBookmarkBar() && !always_show_bookmark_bar; |
198 if (has_detached_bookmark_bar) | 206 if (has_detached_bookmark_bar) |
199 topOffset += bookmarks::kNTPBookmarkBarHeight; | 207 topOffset += bookmarks::kNTPBookmarkBarHeight; |
200 | 208 |
201 return topOffset; | 209 return topOffset; |
202 } | 210 } |
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1646 tile.set_tab_contents(contents->tab_contents()); | 1654 tile.set_tab_contents(contents->tab_contents()); |
1647 ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index]; | 1655 ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index]; |
1648 [thumbLayer setTabContents:contents->tab_contents()]; | 1656 [thumbLayer setTabContents:contents->tab_contents()]; |
1649 } | 1657 } |
1650 | 1658 |
1651 - (void)tabStripModelDeleted { | 1659 - (void)tabStripModelDeleted { |
1652 [self close]; | 1660 [self close]; |
1653 } | 1661 } |
1654 | 1662 |
1655 @end | 1663 @end |
OLD | NEW |