| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/tabs/tab_renderer_gtk.h" | 5 #include "chrome/browser/gtk/tabs/tab_renderer_gtk.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas_paint.h" | 7 #include "app/gfx/canvas_paint.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 hover_animation_->SetSlideDuration(kHoverDurationMs); | 189 hover_animation_->SetSlideDuration(kHoverDurationMs); |
| 190 } | 190 } |
| 191 | 191 |
| 192 TabRendererGtk::~TabRendererGtk() { | 192 TabRendererGtk::~TabRendererGtk() { |
| 193 tab_.Destroy(); | 193 tab_.Destroy(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void TabRendererGtk::UpdateData(TabContents* contents, bool loading_only) { | 196 void TabRendererGtk::UpdateData(TabContents* contents, bool loading_only) { |
| 197 DCHECK(contents); | 197 DCHECK(contents); |
| 198 if (!loading_only) { | 198 if (!loading_only) { |
| 199 data_.title = UTF16ToWideHack(contents->GetTitle()); | 199 data_.title = contents->GetTitle(); |
| 200 data_.off_the_record = contents->profile()->IsOffTheRecord(); | 200 data_.off_the_record = contents->profile()->IsOffTheRecord(); |
| 201 data_.crashed = contents->is_crashed(); | 201 data_.crashed = contents->is_crashed(); |
| 202 data_.favicon = contents->GetFavIcon(); | 202 data_.favicon = contents->GetFavIcon(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 // Loading state also involves whether we show the favicon, since that's where | 205 // Loading state also involves whether we show the favicon, since that's where |
| 206 // we display the throbber. | 206 // we display the throbber. |
| 207 data_.loading = contents->is_loading(); | 207 data_.loading = contents->is_loading(); |
| 208 data_.show_icon = contents->ShouldDisplayFavIcon(); | 208 data_.show_icon = contents->ShouldDisplayFavIcon(); |
| 209 | 209 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 void TabRendererGtk::SetBounds(const gfx::Rect& bounds) { | 315 void TabRendererGtk::SetBounds(const gfx::Rect& bounds) { |
| 316 gtk_widget_set_size_request(tab_.get(), bounds.width(), bounds.height()); | 316 gtk_widget_set_size_request(tab_.get(), bounds.width(), bounds.height()); |
| 317 bounds_ = bounds; | 317 bounds_ = bounds; |
| 318 Layout(); | 318 Layout(); |
| 319 } | 319 } |
| 320 | 320 |
| 321 //////////////////////////////////////////////////////////////////////////////// | 321 //////////////////////////////////////////////////////////////////////////////// |
| 322 // TabRendererGtk, protected: | 322 // TabRendererGtk, protected: |
| 323 | 323 |
| 324 std::wstring TabRendererGtk::GetTitle() const { | 324 std::wstring TabRendererGtk::GetTitle() const { |
| 325 return data_.title; | 325 return UTF16ToWideHack(data_.title); |
| 326 } | 326 } |
| 327 | 327 |
| 328 /////////////////////////////////////////////////////////////////////////////// | 328 /////////////////////////////////////////////////////////////////////////////// |
| 329 // TabRendererGtk, AnimationDelegate implementation: | 329 // TabRendererGtk, AnimationDelegate implementation: |
| 330 | 330 |
| 331 void TabRendererGtk::AnimationProgressed(const Animation* animation) { | 331 void TabRendererGtk::AnimationProgressed(const Animation* animation) { |
| 332 gtk_widget_queue_draw(tab_.get()); | 332 gtk_widget_queue_draw(tab_.get()); |
| 333 } | 333 } |
| 334 | 334 |
| 335 void TabRendererGtk::AnimationCanceled(const Animation* animation) { | 335 void TabRendererGtk::AnimationCanceled(const Animation* animation) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 favicon_bounds_.y() + fav_icon_hiding_offset_, | 413 favicon_bounds_.y() + fav_icon_hiding_offset_, |
| 414 kFavIconSize, kFavIconSize, | 414 kFavIconSize, kFavIconSize, |
| 415 true); | 415 true); |
| 416 } | 416 } |
| 417 } | 417 } |
| 418 canvas->restore(); | 418 canvas->restore(); |
| 419 } | 419 } |
| 420 } | 420 } |
| 421 | 421 |
| 422 // Paint the Title. | 422 // Paint the Title. |
| 423 std::wstring title = data_.title; | 423 string16 title = data_.title; |
| 424 if (title.empty()) { | 424 if (title.empty()) { |
| 425 if (data_.loading) { | 425 if (data_.loading) { |
| 426 title = l10n_util::GetString(IDS_TAB_LOADING_TITLE); | 426 title = l10n_util::GetStringUTF16(IDS_TAB_LOADING_TITLE); |
| 427 } else { | 427 } else { |
| 428 title = l10n_util::GetString(IDS_TAB_UNTITLED_TITLE); | 428 title = l10n_util::GetStringUTF16(IDS_TAB_UNTITLED_TITLE); |
| 429 } | 429 } |
| 430 } else { | 430 } else { |
| 431 Browser::FormatTitleForDisplay(&title); | 431 Browser::FormatTitleForDisplay(&title); |
| 432 } | 432 } |
| 433 | 433 |
| 434 SkColor title_color = IsSelected() ? selected_title_color_ | 434 SkColor title_color = IsSelected() ? selected_title_color_ |
| 435 : unselected_title_color_; | 435 : unselected_title_color_; |
| 436 canvas->DrawStringInt(title, *title_font_, title_color, title_bounds_.x(), | 436 canvas->DrawStringInt(UTF16ToWideHack(title), *title_font_, title_color, |
| 437 title_bounds_.y(), title_bounds_.width(), | 437 title_bounds_.x(), title_bounds_.y(), |
| 438 title_bounds_.height()); | 438 title_bounds_.width(), title_bounds_.height()); |
| 439 } | 439 } |
| 440 | 440 |
| 441 SkBitmap TabRendererGtk::PaintBitmap() { | 441 SkBitmap TabRendererGtk::PaintBitmap() { |
| 442 gfx::Canvas canvas(width(), height(), false); | 442 gfx::Canvas canvas(width(), height(), false); |
| 443 Paint(&canvas); | 443 Paint(&canvas); |
| 444 return canvas.ExtractBitmap(); | 444 return canvas.ExtractBitmap(); |
| 445 } | 445 } |
| 446 | 446 |
| 447 void TabRendererGtk::SchedulePaint() { | 447 void TabRendererGtk::SchedulePaint() { |
| 448 gtk_widget_queue_draw(tab_.get()); | 448 gtk_widget_queue_draw(tab_.get()); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 gfx::Font base_font = rb.GetFont(ResourceBundle::BaseFont); | 756 gfx::Font base_font = rb.GetFont(ResourceBundle::BaseFont); |
| 757 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 10)); | 757 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 10)); |
| 758 title_font_height_ = title_font_->height(); | 758 title_font_height_ = title_font_->height(); |
| 759 | 759 |
| 760 InitializeLoadingAnimationData(&rb, &loading_animation_data); | 760 InitializeLoadingAnimationData(&rb, &loading_animation_data); |
| 761 | 761 |
| 762 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); | 762 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); |
| 763 | 763 |
| 764 initialized_ = true; | 764 initialized_ = true; |
| 765 } | 765 } |
| OLD | NEW |