| 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 #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/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/defaults.h" | 11 #include "chrome/browser/defaults.h" |
| 12 #include "chrome/browser/extensions/extension_tab_helper.h" | 12 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 13 #include "chrome/browser/favicon_tab_helper.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 16 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" |
| 16 #include "chrome/browser/ui/gtk/custom_button.h" | 17 #include "chrome/browser/ui/gtk/custom_button.h" |
| 17 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 18 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 18 #include "chrome/browser/ui/gtk/gtk_util.h" | 19 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 20 #include "content/browser/tab_contents/tab_contents.h" | 21 #include "content/browser/tab_contents/tab_contents.h" |
| 21 #include "content/common/notification_service.h" | 22 #include "content/common/notification_service.h" |
| 22 #include "grit/app_resources.h" | 23 #include "grit/app_resources.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 for (BitmapCache::iterator it = cached_bitmaps_.begin(); | 280 for (BitmapCache::iterator it = cached_bitmaps_.begin(); |
| 280 it != cached_bitmaps_.end(); ++it) { | 281 it != cached_bitmaps_.end(); ++it) { |
| 281 delete it->second.bitmap; | 282 delete it->second.bitmap; |
| 282 } | 283 } |
| 283 } | 284 } |
| 284 | 285 |
| 285 void TabRendererGtk::UpdateData(TabContents* contents, | 286 void TabRendererGtk::UpdateData(TabContents* contents, |
| 286 bool app, | 287 bool app, |
| 287 bool loading_only) { | 288 bool loading_only) { |
| 288 DCHECK(contents); | 289 DCHECK(contents); |
| 290 TabContentsWrapper* wrapper = |
| 291 TabContentsWrapper::GetCurrentWrapperForContents(contents); |
| 289 theme_service_ = GtkThemeService::GetFrom(contents->profile()); | 292 theme_service_ = GtkThemeService::GetFrom(contents->profile()); |
| 290 | 293 |
| 291 if (!loading_only) { | 294 if (!loading_only) { |
| 292 data_.title = contents->GetTitle(); | 295 data_.title = contents->GetTitle(); |
| 293 data_.incognito = contents->profile()->IsOffTheRecord(); | 296 data_.incognito = contents->profile()->IsOffTheRecord(); |
| 294 data_.crashed = contents->is_crashed(); | 297 data_.crashed = contents->is_crashed(); |
| 295 | 298 |
| 296 SkBitmap* app_icon = | 299 SkBitmap* app_icon = |
| 297 TabContentsWrapper::GetCurrentWrapperForContents(contents)-> | 300 TabContentsWrapper::GetCurrentWrapperForContents(contents)-> |
| 298 extension_tab_helper()->GetExtensionAppIcon(); | 301 extension_tab_helper()->GetExtensionAppIcon(); |
| 299 if (app_icon) | 302 if (app_icon) |
| 300 data_.favicon = *app_icon; | 303 data_.favicon = *app_icon; |
| 301 else | 304 else |
| 302 data_.favicon = contents->GetFavicon(); | 305 data_.favicon = wrapper->favicon_tab_helper()->GetFavicon(); |
| 303 | 306 |
| 304 data_.app = app; | 307 data_.app = app; |
| 305 // This is kind of a hacky way to determine whether our icon is the default | 308 // This is kind of a hacky way to determine whether our icon is the default |
| 306 // favicon. But the plumbing that would be necessary to do it right would | 309 // favicon. But the plumbing that would be necessary to do it right would |
| 307 // be a good bit of work and would sully code for other platforms which | 310 // be a good bit of work and would sully code for other platforms which |
| 308 // don't care to custom-theme the favicon. Hopefully the default favicon | 311 // don't care to custom-theme the favicon. Hopefully the default favicon |
| 309 // will eventually be chromium-themable and this code will go away. | 312 // will eventually be chromium-themable and this code will go away. |
| 310 data_.is_default_favicon = | 313 data_.is_default_favicon = |
| 311 (data_.favicon.pixelRef() == | 314 (data_.favicon.pixelRef() == |
| 312 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 315 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 313 IDR_DEFAULT_FAVICON)->pixelRef()); | 316 IDR_DEFAULT_FAVICON)->pixelRef()); |
| 314 } | 317 } |
| 315 | 318 |
| 316 // Loading state also involves whether we show the favicon, since that's where | 319 // Loading state also involves whether we show the favicon, since that's where |
| 317 // we display the throbber. | 320 // we display the throbber. |
| 318 data_.loading = contents->is_loading(); | 321 data_.loading = contents->is_loading(); |
| 319 data_.show_icon = contents->ShouldDisplayFavicon(); | 322 data_.show_icon = wrapper->favicon_tab_helper()->ShouldDisplayFavicon(); |
| 320 } | 323 } |
| 321 | 324 |
| 322 void TabRendererGtk::UpdateFromModel() { | 325 void TabRendererGtk::UpdateFromModel() { |
| 323 // Force a layout, since the tab may have grown a favicon. | 326 // Force a layout, since the tab may have grown a favicon. |
| 324 Layout(); | 327 Layout(); |
| 325 SchedulePaint(); | 328 SchedulePaint(); |
| 326 | 329 |
| 327 if (data_.crashed) { | 330 if (data_.crashed) { |
| 328 if (!should_display_crashed_favicon_ && !IsPerformingCrashAnimation()) | 331 if (!should_display_crashed_favicon_ && !IsPerformingCrashAnimation()) |
| 329 StartCrashAnimation(); | 332 StartCrashAnimation(); |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 | 1086 |
| 1084 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1087 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 1085 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); | 1088 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); |
| 1086 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1089 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
| 1087 title_font_height_ = title_font_->GetHeight(); | 1090 title_font_height_ = title_font_->GetHeight(); |
| 1088 | 1091 |
| 1089 crashed_favicon = rb.GetBitmapNamed(IDR_SAD_FAVICON); | 1092 crashed_favicon = rb.GetBitmapNamed(IDR_SAD_FAVICON); |
| 1090 | 1093 |
| 1091 initialized_ = true; | 1094 initialized_ = true; |
| 1092 } | 1095 } |
| OLD | NEW |