| 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/gtk/tabs/tab_renderer_gtk.h" | 5 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/defaults.h" | 12 #include "chrome/browser/defaults.h" |
| 13 #include "chrome/browser/extensions/extension_tab_helper.h" | 13 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 14 #include "chrome/browser/favicon/favicon_tab_helper.h" | 14 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 17 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" |
| 18 #include "chrome/browser/ui/gtk/custom_button.h" | 18 #include "chrome/browser/ui/gtk/custom_button.h" |
| 19 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | |
| 20 #include "chrome/browser/ui/gtk/gtk_util.h" | 19 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 20 #include "chrome/browser/ui/gtk/theme_service_gtk.h" |
| 21 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 21 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 23 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 27 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 28 #include "grit/theme_resources_standard.h" | 28 #include "grit/theme_resources_standard.h" |
| 29 #include "grit/ui_resources.h" | 29 #include "grit/ui_resources.h" |
| 30 #include "skia/ext/image_operations.h" | 30 #include "skia/ext/image_operations.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 gtk_widget_get_allocation(widget, &allocation); | 103 gtk_widget_get_allocation(widget, &allocation); |
| 104 | 104 |
| 105 return gfx::Rect(widget_pos.x() - parent_pos.x(), | 105 return gfx::Rect(widget_pos.x() - parent_pos.x(), |
| 106 widget_pos.y() - parent_pos.y(), | 106 widget_pos.y() - parent_pos.y(), |
| 107 allocation.width, allocation.height); | 107 allocation.width, allocation.height); |
| 108 } | 108 } |
| 109 | 109 |
| 110 } // namespace | 110 } // namespace |
| 111 | 111 |
| 112 TabRendererGtk::LoadingAnimation::Data::Data( | 112 TabRendererGtk::LoadingAnimation::Data::Data( |
| 113 GtkThemeService* theme_service) { | 113 ThemeServiceGtk* theme_service) { |
| 114 // The loading animation image is a strip of states. Each state must be | 114 // The loading animation image is a strip of states. Each state must be |
| 115 // square, so the height must divide the width evenly. | 115 // square, so the height must divide the width evenly. |
| 116 SkBitmap* loading_animation_frames = | 116 SkBitmap* loading_animation_frames = |
| 117 theme_service->GetBitmapNamed(IDR_THROBBER); | 117 theme_service->GetBitmapNamed(IDR_THROBBER); |
| 118 DCHECK(loading_animation_frames); | 118 DCHECK(loading_animation_frames); |
| 119 DCHECK_EQ(loading_animation_frames->width() % | 119 DCHECK_EQ(loading_animation_frames->width() % |
| 120 loading_animation_frames->height(), 0); | 120 loading_animation_frames->height(), 0); |
| 121 loading_animation_frame_count = | 121 loading_animation_frame_count = |
| 122 loading_animation_frames->width() / | 122 loading_animation_frames->width() / |
| 123 loading_animation_frames->height(); | 123 loading_animation_frames->height(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 int TabRendererGtk::tab_inactive_l_height_ = 0; | 155 int TabRendererGtk::tab_inactive_l_height_ = 0; |
| 156 gfx::Font* TabRendererGtk::title_font_ = NULL; | 156 gfx::Font* TabRendererGtk::title_font_ = NULL; |
| 157 int TabRendererGtk::title_font_height_ = 0; | 157 int TabRendererGtk::title_font_height_ = 0; |
| 158 int TabRendererGtk::close_button_width_ = 0; | 158 int TabRendererGtk::close_button_width_ = 0; |
| 159 int TabRendererGtk::close_button_height_ = 0; | 159 int TabRendererGtk::close_button_height_ = 0; |
| 160 | 160 |
| 161 //////////////////////////////////////////////////////////////////////////////// | 161 //////////////////////////////////////////////////////////////////////////////// |
| 162 // TabRendererGtk::LoadingAnimation, public: | 162 // TabRendererGtk::LoadingAnimation, public: |
| 163 // | 163 // |
| 164 TabRendererGtk::LoadingAnimation::LoadingAnimation( | 164 TabRendererGtk::LoadingAnimation::LoadingAnimation( |
| 165 GtkThemeService* theme_service) | 165 ThemeServiceGtk* theme_service) |
| 166 : data_(new Data(theme_service)), | 166 : data_(new Data(theme_service)), |
| 167 theme_service_(theme_service), | 167 theme_service_(theme_service), |
| 168 animation_state_(ANIMATION_NONE), | 168 animation_state_(ANIMATION_NONE), |
| 169 animation_frame_(0) { | 169 animation_frame_(0) { |
| 170 registrar_.Add(this, | 170 registrar_.Add(this, |
| 171 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 171 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 172 content::Source<ThemeService>(theme_service_)); | 172 content::Source<ThemeService>(theme_service_)); |
| 173 } | 173 } |
| 174 | 174 |
| 175 TabRendererGtk::LoadingAnimation::LoadingAnimation( | 175 TabRendererGtk::LoadingAnimation::LoadingAnimation( |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 268 |
| 269 private: | 269 private: |
| 270 TabRendererGtk* target_; | 270 TabRendererGtk* target_; |
| 271 | 271 |
| 272 DISALLOW_COPY_AND_ASSIGN(FaviconCrashAnimation); | 272 DISALLOW_COPY_AND_ASSIGN(FaviconCrashAnimation); |
| 273 }; | 273 }; |
| 274 | 274 |
| 275 //////////////////////////////////////////////////////////////////////////////// | 275 //////////////////////////////////////////////////////////////////////////////// |
| 276 // TabRendererGtk, public: | 276 // TabRendererGtk, public: |
| 277 | 277 |
| 278 TabRendererGtk::TabRendererGtk(GtkThemeService* theme_service) | 278 TabRendererGtk::TabRendererGtk(ThemeServiceGtk* theme_service) |
| 279 : showing_icon_(false), | 279 : showing_icon_(false), |
| 280 showing_close_button_(false), | 280 showing_close_button_(false), |
| 281 favicon_hiding_offset_(0), | 281 favicon_hiding_offset_(0), |
| 282 should_display_crashed_favicon_(false), | 282 should_display_crashed_favicon_(false), |
| 283 loading_animation_(theme_service), | 283 loading_animation_(theme_service), |
| 284 background_offset_x_(0), | 284 background_offset_x_(0), |
| 285 background_offset_y_(kInactiveTabBackgroundOffsetY), | 285 background_offset_y_(kInactiveTabBackgroundOffsetY), |
| 286 theme_service_(theme_service), | 286 theme_service_(theme_service), |
| 287 close_button_color_(0), | 287 close_button_color_(0), |
| 288 is_active_(false), | 288 is_active_(false), |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 if (loading_animation_.animation_state() != ANIMATION_NONE) { | 862 if (loading_animation_.animation_state() != ANIMATION_NONE) { |
| 863 PaintLoadingAnimation(widget, cr); | 863 PaintLoadingAnimation(widget, cr); |
| 864 return; | 864 return; |
| 865 } | 865 } |
| 866 | 866 |
| 867 gfx::CairoCachedSurface* to_display = NULL; | 867 gfx::CairoCachedSurface* to_display = NULL; |
| 868 if (should_display_crashed_favicon_) { | 868 if (should_display_crashed_favicon_) { |
| 869 to_display = theme_service_->GetImageNamed(IDR_SAD_FAVICON)->ToCairo(); | 869 to_display = theme_service_->GetImageNamed(IDR_SAD_FAVICON)->ToCairo(); |
| 870 } else if (!data_.favicon.isNull()) { | 870 } else if (!data_.favicon.isNull()) { |
| 871 if (data_.is_default_favicon && theme_service_->UsingNativeTheme()) { | 871 if (data_.is_default_favicon && theme_service_->UsingNativeTheme()) { |
| 872 to_display = GtkThemeService::GetDefaultFavicon(true)->ToCairo(); | 872 to_display = ThemeServiceGtk::GetDefaultFavicon(true)->ToCairo(); |
| 873 } else if (data_.cairo_favicon.valid()) { | 873 } else if (data_.cairo_favicon.valid()) { |
| 874 to_display = &data_.cairo_favicon; | 874 to_display = &data_.cairo_favicon; |
| 875 } | 875 } |
| 876 } | 876 } |
| 877 | 877 |
| 878 if (to_display) { | 878 if (to_display) { |
| 879 to_display->SetSource(cr, | 879 to_display->SetSource(cr, |
| 880 widget, | 880 widget, |
| 881 favicon_bounds_.x(), | 881 favicon_bounds_.x(), |
| 882 favicon_bounds_.y() + favicon_hiding_offset_); | 882 favicon_bounds_.y() + favicon_hiding_offset_); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 | 1122 |
| 1123 close_button_width_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->width(); | 1123 close_button_width_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->width(); |
| 1124 close_button_height_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->height(); | 1124 close_button_height_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->height(); |
| 1125 | 1125 |
| 1126 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); | 1126 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); |
| 1127 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1127 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
| 1128 title_font_height_ = title_font_->GetHeight(); | 1128 title_font_height_ = title_font_->GetHeight(); |
| 1129 | 1129 |
| 1130 initialized_ = true; | 1130 initialized_ = true; |
| 1131 } | 1131 } |
| OLD | NEW |