Chromium Code Reviews| 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" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 } | 282 } |
| 283 | 283 |
| 284 void TabRendererGtk::UpdateData(TabContents* contents, | 284 void TabRendererGtk::UpdateData(TabContents* contents, |
| 285 bool app, | 285 bool app, |
| 286 bool loading_only) { | 286 bool loading_only) { |
| 287 DCHECK(contents); | 287 DCHECK(contents); |
| 288 theme_provider_ = GtkThemeProvider::GetFrom(contents->profile()); | 288 theme_provider_ = GtkThemeProvider::GetFrom(contents->profile()); |
| 289 | 289 |
| 290 if (!loading_only) { | 290 if (!loading_only) { |
| 291 data_.title = contents->GetTitle(); | 291 data_.title = contents->GetTitle(); |
| 292 data_.off_the_record = contents->profile()->IsOffTheRecord(); | 292 data_.incognito = contents->profile()->IsOffTheRecord(); |
| 293 data_.crashed = contents->is_crashed(); | 293 data_.crashed = contents->is_crashed(); |
| 294 | 294 |
| 295 SkBitmap* app_icon = contents->GetExtensionAppIcon(); | 295 SkBitmap* app_icon = contents->GetExtensionAppIcon(); |
| 296 if (app_icon) | 296 if (app_icon) |
| 297 data_.favicon = *app_icon; | 297 data_.favicon = *app_icon; |
| 298 else | 298 else |
| 299 data_.favicon = contents->GetFavIcon(); | 299 data_.favicon = contents->GetFavIcon(); |
| 300 | 300 |
| 301 data_.app = app; | 301 data_.app = app; |
| 302 // This is kind of a hacky way to determine whether our icon is the default | 302 // This is kind of a hacky way to determine whether our icon is the default |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 // The actual paint methods expect 0, 0 to be the tab top left (see | 379 // The actual paint methods expect 0, 0 to be the tab top left (see |
| 380 // PaintTab). | 380 // PaintTab). |
| 381 canvas.TranslateInt(x(), y()); | 381 canvas.TranslateInt(x(), y()); |
| 382 | 382 |
| 383 // Paint the background behind the favicon. | 383 // Paint the background behind the favicon. |
| 384 int theme_id; | 384 int theme_id; |
| 385 int offset_y = 0; | 385 int offset_y = 0; |
| 386 if (IsSelected()) { | 386 if (IsSelected()) { |
| 387 theme_id = IDR_THEME_TOOLBAR; | 387 theme_id = IDR_THEME_TOOLBAR; |
| 388 } else { | 388 } else { |
| 389 if (!data_.off_the_record) { | 389 if (!data_.incognito) { |
| 390 theme_id = IDR_THEME_TAB_BACKGROUND; | 390 theme_id = IDR_THEME_TAB_BACKGROUND; |
| 391 } else { | 391 } else { |
| 392 theme_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO; | 392 theme_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO; |
| 393 } | 393 } |
| 394 if (!theme_provider_->HasCustomImage(theme_id)) | 394 if (!theme_provider_->HasCustomImage(theme_id)) |
| 395 offset_y = background_offset_y_; | 395 offset_y = background_offset_y_; |
| 396 } | 396 } |
| 397 SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(theme_id); | 397 SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(theme_id); |
| 398 canvas.TileImageInt(*tab_bg, | 398 canvas.TileImageInt(*tab_bg, |
| 399 x() + favicon_bounds_.x(), offset_y + favicon_bounds_.y(), | 399 x() + favicon_bounds_.x(), offset_y + favicon_bounds_.y(), |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 882 gfx::Rect(width(), height())); | 882 gfx::Rect(width(), height())); |
| 883 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, | 883 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, |
| 884 SkXfermode::kClear_Mode); | 884 SkXfermode::kClear_Mode); |
| 885 PaintActiveTabBackground(canvas); | 885 PaintActiveTabBackground(canvas); |
| 886 canvas->Restore(); | 886 canvas->Restore(); |
| 887 } | 887 } |
| 888 } | 888 } |
| 889 } | 889 } |
| 890 | 890 |
| 891 void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) { | 891 void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) { |
| 892 bool is_otr = data_.off_the_record; | 892 bool is_incognito = data_.incognito; |
|
msw
2011/03/12 19:45:55
You may as well remove this local bool, and use |d
| |
| 893 | 893 |
| 894 // The tab image needs to be lined up with the background image | 894 // The tab image needs to be lined up with the background image |
| 895 // so that it feels partially transparent. | 895 // so that it feels partially transparent. |
| 896 int offset_x = background_offset_x_; | 896 int offset_x = background_offset_x_; |
| 897 | 897 |
| 898 int tab_id = is_otr ? | 898 int tab_id = is_incognito ? |
| 899 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; | 899 IDR_THEME_TAB_BACKGROUND_INCOGNITO : IDR_THEME_TAB_BACKGROUND; |
| 900 | 900 |
| 901 SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(tab_id); | 901 SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(tab_id); |
| 902 | 902 |
| 903 // If the theme is providing a custom background image, then its top edge | 903 // If the theme is providing a custom background image, then its top edge |
| 904 // should be at the top of the tab. Otherwise, we assume that the background | 904 // should be at the top of the tab. Otherwise, we assume that the background |
| 905 // image is a composited foreground + frame image. | 905 // image is a composited foreground + frame image. |
| 906 int offset_y = theme_provider_->HasCustomImage(tab_id) ? | 906 int offset_y = theme_provider_->HasCustomImage(tab_id) ? |
| 907 0 : background_offset_y_; | 907 0 : background_offset_y_; |
| 908 | 908 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1081 | 1081 |
| 1082 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1082 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 1083 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); | 1083 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); |
| 1084 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1084 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
| 1085 title_font_height_ = title_font_->GetHeight(); | 1085 title_font_height_ = title_font_->GetHeight(); |
| 1086 | 1086 |
| 1087 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); | 1087 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); |
| 1088 | 1088 |
| 1089 initialized_ = true; | 1089 initialized_ = true; |
| 1090 } | 1090 } |
| OLD | NEW |