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 #include "chrome/browser/ui/views/tabs/tab.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 const gfx::Rect& bounds, | 171 const gfx::Rect& bounds, |
172 bool filter, | 172 bool filter, |
173 const SkPaint& paint) { | 173 const SkPaint& paint) { |
174 // Center the image within bounds. | 174 // Center the image within bounds. |
175 int dst_x = bounds.x() - (icon_width - bounds.width()) / 2; | 175 int dst_x = bounds.x() - (icon_width - bounds.width()) / 2; |
176 int dst_y = bounds.y() - (icon_height - bounds.height()) / 2; | 176 int dst_y = bounds.y() - (icon_height - bounds.height()) / 2; |
177 DrawIconAtLocation(canvas, image, image_offset, dst_x, dst_y, icon_width, | 177 DrawIconAtLocation(canvas, image, image_offset, dst_x, dst_y, icon_width, |
178 icon_height, filter, paint); | 178 icon_height, filter, paint); |
179 } | 179 } |
180 | 180 |
181 chrome::HostDesktopType GetHostDesktopType(views::View* view) { | 181 ui::HostDesktopType GetHostDesktopType(views::View* view) { |
182 // Widget is NULL when tabs are detached. | 182 // Widget is NULL when tabs are detached. |
183 views::Widget* widget = view->GetWidget(); | 183 views::Widget* widget = view->GetWidget(); |
184 return chrome::GetHostDesktopTypeForNativeView( | 184 return chrome::GetHostDesktopTypeForNativeView( |
185 widget ? widget->GetNativeView() : NULL); | 185 widget ? widget->GetNativeView() : NULL); |
186 } | 186 } |
187 | 187 |
188 // Stop()s |animation| and then deletes it. We do this rather than just deleting | 188 // Stop()s |animation| and then deletes it. We do this rather than just deleting |
189 // so that the delegate is notified before the destruction. | 189 // so that the delegate is notified before the destruction. |
190 void StopAndDeleteAnimation(scoped_ptr<gfx::Animation> animation) { | 190 void StopAndDeleteAnimation(scoped_ptr<gfx::Animation> animation) { |
191 if (animation) | 191 if (animation) |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 } | 1179 } |
1180 } | 1180 } |
1181 | 1181 |
1182 void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { | 1182 void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { |
1183 int tab_id; | 1183 int tab_id; |
1184 int frame_id; | 1184 int frame_id; |
1185 views::Widget* widget = GetWidget(); | 1185 views::Widget* widget = GetWidget(); |
1186 GetTabIdAndFrameId(widget, &tab_id, &frame_id); | 1186 GetTabIdAndFrameId(widget, &tab_id, &frame_id); |
1187 | 1187 |
1188 // Explicitly map the id so we cache correctly. | 1188 // Explicitly map the id so we cache correctly. |
1189 const chrome::HostDesktopType host_desktop_type = GetHostDesktopType(this); | 1189 const ui::HostDesktopType host_desktop_type = GetHostDesktopType(this); |
1190 tab_id = chrome::MapThemeImage(host_desktop_type, tab_id); | 1190 tab_id = chrome::MapThemeImage(host_desktop_type, tab_id); |
1191 | 1191 |
1192 // HasCustomImage() is only true if the theme provides the image. However, | 1192 // HasCustomImage() is only true if the theme provides the image. However, |
1193 // even if the theme does not provide a tab background, the theme machinery | 1193 // even if the theme does not provide a tab background, the theme machinery |
1194 // will make one if given a frame image. | 1194 // will make one if given a frame image. |
1195 ui::ThemeProvider* theme_provider = GetThemeProvider(); | 1195 ui::ThemeProvider* theme_provider = GetThemeProvider(); |
1196 const bool theme_provided_image = theme_provider->HasCustomImage(tab_id) || | 1196 const bool theme_provided_image = theme_provider->HasCustomImage(tab_id) || |
1197 (frame_id != 0 && theme_provider->HasCustomImage(frame_id)); | 1197 (frame_id != 0 && theme_provider->HasCustomImage(frame_id)); |
1198 | 1198 |
1199 const bool can_cache = !theme_provided_image && | 1199 const bool can_cache = !theme_provided_image && |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1650 const gfx::ImageSkia& image) { | 1650 const gfx::ImageSkia& image) { |
1651 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1651 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
1652 ImageCacheEntry entry; | 1652 ImageCacheEntry entry; |
1653 entry.resource_id = resource_id; | 1653 entry.resource_id = resource_id; |
1654 entry.scale_factor = scale_factor; | 1654 entry.scale_factor = scale_factor; |
1655 entry.image = image; | 1655 entry.image = image; |
1656 image_cache_->push_front(entry); | 1656 image_cache_->push_front(entry); |
1657 if (image_cache_->size() > kMaxImageCacheSize) | 1657 if (image_cache_->size() > kMaxImageCacheSize) |
1658 image_cache_->pop_back(); | 1658 image_cache_->pop_back(); |
1659 } | 1659 } |
OLD | NEW |