| 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" |
| 19 #include "chrome/browser/ui/gtk/gtk_util.h" | 20 #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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 gtk_widget_get_allocation(widget, &allocation); | 104 gtk_widget_get_allocation(widget, &allocation); |
| 105 | 105 |
| 106 return gfx::Rect(widget_pos.x() - parent_pos.x(), | 106 return gfx::Rect(widget_pos.x() - parent_pos.x(), |
| 107 widget_pos.y() - parent_pos.y(), | 107 widget_pos.y() - parent_pos.y(), |
| 108 allocation.width, allocation.height); | 108 allocation.width, allocation.height); |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace | 111 } // namespace |
| 112 | 112 |
| 113 TabRendererGtk::LoadingAnimation::Data::Data( | 113 TabRendererGtk::LoadingAnimation::Data::Data( |
| 114 ThemeServiceGtk* theme_service) { | 114 GtkThemeService* theme_service) { |
| 115 // The loading animation image is a strip of states. Each state must be | 115 // The loading animation image is a strip of states. Each state must be |
| 116 // square, so the height must divide the width evenly. | 116 // square, so the height must divide the width evenly. |
| 117 SkBitmap* loading_animation_frames = | 117 SkBitmap* loading_animation_frames = |
| 118 theme_service->GetBitmapNamed(IDR_THROBBER); | 118 theme_service->GetBitmapNamed(IDR_THROBBER); |
| 119 DCHECK(loading_animation_frames); | 119 DCHECK(loading_animation_frames); |
| 120 DCHECK_EQ(loading_animation_frames->width() % | 120 DCHECK_EQ(loading_animation_frames->width() % |
| 121 loading_animation_frames->height(), 0); | 121 loading_animation_frames->height(), 0); |
| 122 loading_animation_frame_count = | 122 loading_animation_frame_count = |
| 123 loading_animation_frames->width() / | 123 loading_animation_frames->width() / |
| 124 loading_animation_frames->height(); | 124 loading_animation_frames->height(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 int TabRendererGtk::tab_inactive_l_height_ = 0; | 156 int TabRendererGtk::tab_inactive_l_height_ = 0; |
| 157 gfx::Font* TabRendererGtk::title_font_ = NULL; | 157 gfx::Font* TabRendererGtk::title_font_ = NULL; |
| 158 int TabRendererGtk::title_font_height_ = 0; | 158 int TabRendererGtk::title_font_height_ = 0; |
| 159 int TabRendererGtk::close_button_width_ = 0; | 159 int TabRendererGtk::close_button_width_ = 0; |
| 160 int TabRendererGtk::close_button_height_ = 0; | 160 int TabRendererGtk::close_button_height_ = 0; |
| 161 | 161 |
| 162 //////////////////////////////////////////////////////////////////////////////// | 162 //////////////////////////////////////////////////////////////////////////////// |
| 163 // TabRendererGtk::LoadingAnimation, public: | 163 // TabRendererGtk::LoadingAnimation, public: |
| 164 // | 164 // |
| 165 TabRendererGtk::LoadingAnimation::LoadingAnimation( | 165 TabRendererGtk::LoadingAnimation::LoadingAnimation( |
| 166 ThemeServiceGtk* theme_service) | 166 GtkThemeService* theme_service) |
| 167 : data_(new Data(theme_service)), | 167 : data_(new Data(theme_service)), |
| 168 theme_service_(theme_service), | 168 theme_service_(theme_service), |
| 169 animation_state_(ANIMATION_NONE), | 169 animation_state_(ANIMATION_NONE), |
| 170 animation_frame_(0) { | 170 animation_frame_(0) { |
| 171 registrar_.Add(this, | 171 registrar_.Add(this, |
| 172 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 172 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 173 content::Source<ThemeService>(theme_service_)); | 173 content::Source<ThemeService>(theme_service_)); |
| 174 } | 174 } |
| 175 | 175 |
| 176 TabRendererGtk::LoadingAnimation::LoadingAnimation( | 176 TabRendererGtk::LoadingAnimation::LoadingAnimation( |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 private: | 270 private: |
| 271 TabRendererGtk* target_; | 271 TabRendererGtk* target_; |
| 272 | 272 |
| 273 DISALLOW_COPY_AND_ASSIGN(FaviconCrashAnimation); | 273 DISALLOW_COPY_AND_ASSIGN(FaviconCrashAnimation); |
| 274 }; | 274 }; |
| 275 | 275 |
| 276 //////////////////////////////////////////////////////////////////////////////// | 276 //////////////////////////////////////////////////////////////////////////////// |
| 277 // TabRendererGtk, public: | 277 // TabRendererGtk, public: |
| 278 | 278 |
| 279 TabRendererGtk::TabRendererGtk(ThemeServiceGtk* theme_service) | 279 TabRendererGtk::TabRendererGtk(GtkThemeService* theme_service) |
| 280 : showing_icon_(false), | 280 : showing_icon_(false), |
| 281 showing_close_button_(false), | 281 showing_close_button_(false), |
| 282 favicon_hiding_offset_(0), | 282 favicon_hiding_offset_(0), |
| 283 should_display_crashed_favicon_(false), | 283 should_display_crashed_favicon_(false), |
| 284 loading_animation_(theme_service), | 284 loading_animation_(theme_service), |
| 285 background_offset_x_(0), | 285 background_offset_x_(0), |
| 286 background_offset_y_(kInactiveTabBackgroundOffsetY), | 286 background_offset_y_(kInactiveTabBackgroundOffsetY), |
| 287 theme_service_(theme_service), | 287 theme_service_(theme_service), |
| 288 close_button_color_(0), | 288 close_button_color_(0), |
| 289 is_active_(false), | 289 is_active_(false), |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 if (loading_animation_.animation_state() != ANIMATION_NONE) { | 863 if (loading_animation_.animation_state() != ANIMATION_NONE) { |
| 864 PaintLoadingAnimation(widget, cr); | 864 PaintLoadingAnimation(widget, cr); |
| 865 return; | 865 return; |
| 866 } | 866 } |
| 867 | 867 |
| 868 gfx::CairoCachedSurface* to_display = NULL; | 868 gfx::CairoCachedSurface* to_display = NULL; |
| 869 if (should_display_crashed_favicon_) { | 869 if (should_display_crashed_favicon_) { |
| 870 to_display = theme_service_->GetImageNamed(IDR_SAD_FAVICON)->ToCairo(); | 870 to_display = theme_service_->GetImageNamed(IDR_SAD_FAVICON)->ToCairo(); |
| 871 } else if (!data_.favicon.isNull()) { | 871 } else if (!data_.favicon.isNull()) { |
| 872 if (data_.is_default_favicon && theme_service_->UsingNativeTheme()) { | 872 if (data_.is_default_favicon && theme_service_->UsingNativeTheme()) { |
| 873 to_display = ThemeServiceGtk::GetDefaultFavicon(true)->ToCairo(); | 873 to_display = GtkThemeService::GetDefaultFavicon(true)->ToCairo(); |
| 874 } else if (data_.cairo_favicon.valid()) { | 874 } else if (data_.cairo_favicon.valid()) { |
| 875 to_display = &data_.cairo_favicon; | 875 to_display = &data_.cairo_favicon; |
| 876 } | 876 } |
| 877 } | 877 } |
| 878 | 878 |
| 879 if (to_display) { | 879 if (to_display) { |
| 880 to_display->SetSource(cr, | 880 to_display->SetSource(cr, |
| 881 widget, | 881 widget, |
| 882 favicon_bounds_.x(), | 882 favicon_bounds_.x(), |
| 883 favicon_bounds_.y() + favicon_hiding_offset_); | 883 favicon_bounds_.y() + favicon_hiding_offset_); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); | 1123 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); |
| 1124 close_button_width_ = gdk_pixbuf_get_width(tab_close); | 1124 close_button_width_ = gdk_pixbuf_get_width(tab_close); |
| 1125 close_button_height_ = gdk_pixbuf_get_height(tab_close); | 1125 close_button_height_ = gdk_pixbuf_get_height(tab_close); |
| 1126 | 1126 |
| 1127 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); | 1127 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); |
| 1128 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1128 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
| 1129 title_font_height_ = title_font_->GetHeight(); | 1129 title_font_height_ = title_font_->GetHeight(); |
| 1130 | 1130 |
| 1131 initialized_ = true; | 1131 initialized_ = true; |
| 1132 } | 1132 } |
| OLD | NEW |