| 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_theme_service.h" |
| 20 #include "chrome/browser/ui/gtk/gtk_util.h" | 20 #include "chrome/browser/ui/gtk/gtk_util.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.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 "grit/ui_resources_standard.h" | 30 #include "grit/ui_resources_standard.h" |
| 31 #include "skia/ext/image_operations.h" | 31 #include "skia/ext/image_operations.h" |
| 32 #include "ui/base/animation/slide_animation.h" | 32 #include "ui/base/animation/slide_animation.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 selected_title_color_ = | 320 selected_title_color_ = |
| 321 theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT); | 321 theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT); |
| 322 unselected_title_color_ = | 322 unselected_title_color_ = |
| 323 theme_service_->GetColor(ThemeService::COLOR_BACKGROUND_TAB_TEXT); | 323 theme_service_->GetColor(ThemeService::COLOR_BACKGROUND_TAB_TEXT); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void TabRendererGtk::UpdateData(WebContents* contents, | 326 void TabRendererGtk::UpdateData(WebContents* contents, |
| 327 bool app, | 327 bool app, |
| 328 bool loading_only) { | 328 bool loading_only) { |
| 329 DCHECK(contents); | 329 DCHECK(contents); |
| 330 TabContentsWrapper* wrapper = | 330 TabContents* tab_contents = TabContents::FromWebContents(contents); |
| 331 TabContentsWrapper::GetCurrentWrapperForContents(contents); | |
| 332 | 331 |
| 333 if (!loading_only) { | 332 if (!loading_only) { |
| 334 data_.title = contents->GetTitle(); | 333 data_.title = contents->GetTitle(); |
| 335 data_.incognito = contents->GetBrowserContext()->IsOffTheRecord(); | 334 data_.incognito = contents->GetBrowserContext()->IsOffTheRecord(); |
| 336 data_.crashed = contents->IsCrashed(); | 335 data_.crashed = contents->IsCrashed(); |
| 337 | 336 |
| 338 SkBitmap* app_icon = | 337 SkBitmap* app_icon = |
| 339 TabContentsWrapper::GetCurrentWrapperForContents(contents)-> | 338 tab_contents->extension_tab_helper()->GetExtensionAppIcon(); |
| 340 extension_tab_helper()->GetExtensionAppIcon(); | |
| 341 if (app_icon) { | 339 if (app_icon) { |
| 342 data_.favicon = *app_icon; | 340 data_.favicon = *app_icon; |
| 343 } else { | 341 } else { |
| 344 data_.favicon = wrapper->favicon_tab_helper()->GetFavicon(); | 342 data_.favicon = tab_contents->favicon_tab_helper()->GetFavicon(); |
| 345 } | 343 } |
| 346 | 344 |
| 347 data_.app = app; | 345 data_.app = app; |
| 348 | 346 |
| 349 // Make a cairo cached version of the favicon. | 347 // Make a cairo cached version of the favicon. |
| 350 if (!data_.favicon.isNull()) { | 348 if (!data_.favicon.isNull()) { |
| 351 // Instead of resizing the icon during each frame, create our resized | 349 // Instead of resizing the icon during each frame, create our resized |
| 352 // icon resource now, send it to the xserver and use that each frame | 350 // icon resource now, send it to the xserver and use that each frame |
| 353 // instead. | 351 // instead. |
| 354 | 352 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // will eventually be chromium-themable and this code will go away. | 396 // will eventually be chromium-themable and this code will go away. |
| 399 data_.is_default_favicon = | 397 data_.is_default_favicon = |
| 400 (data_.favicon.pixelRef() == | 398 (data_.favicon.pixelRef() == |
| 401 ui::ResourceBundle::GetSharedInstance().GetBitmapNamed( | 399 ui::ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 402 IDR_DEFAULT_FAVICON)->pixelRef()); | 400 IDR_DEFAULT_FAVICON)->pixelRef()); |
| 403 } | 401 } |
| 404 | 402 |
| 405 // Loading state also involves whether we show the favicon, since that's where | 403 // Loading state also involves whether we show the favicon, since that's where |
| 406 // we display the throbber. | 404 // we display the throbber. |
| 407 data_.loading = contents->IsLoading(); | 405 data_.loading = contents->IsLoading(); |
| 408 data_.show_icon = wrapper->favicon_tab_helper()->ShouldDisplayFavicon(); | 406 data_.show_icon = tab_contents->favicon_tab_helper()->ShouldDisplayFavicon(); |
| 409 } | 407 } |
| 410 | 408 |
| 411 void TabRendererGtk::UpdateFromModel() { | 409 void TabRendererGtk::UpdateFromModel() { |
| 412 // Force a layout, since the tab may have grown a favicon. | 410 // Force a layout, since the tab may have grown a favicon. |
| 413 Layout(); | 411 Layout(); |
| 414 SchedulePaint(); | 412 SchedulePaint(); |
| 415 | 413 |
| 416 if (data_.crashed) { | 414 if (data_.crashed) { |
| 417 if (!should_display_crashed_favicon_ && !IsPerformingCrashAnimation()) | 415 if (!should_display_crashed_favicon_ && !IsPerformingCrashAnimation()) |
| 418 StartCrashAnimation(); | 416 StartCrashAnimation(); |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); | 1122 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); |
| 1125 close_button_width_ = gdk_pixbuf_get_width(tab_close); | 1123 close_button_width_ = gdk_pixbuf_get_width(tab_close); |
| 1126 close_button_height_ = gdk_pixbuf_get_height(tab_close); | 1124 close_button_height_ = gdk_pixbuf_get_height(tab_close); |
| 1127 | 1125 |
| 1128 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); | 1126 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); |
| 1129 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1127 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
| 1130 title_font_height_ = title_font_->GetHeight(); | 1128 title_font_height_ = title_font_->GetHeight(); |
| 1131 | 1129 |
| 1132 initialized_ = true; | 1130 initialized_ = true; |
| 1133 } | 1131 } |
| OLD | NEW |