| 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/views/tabs/base_tab.h" | 5 #include "chrome/browser/ui/views/tabs/base_tab.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 private: | 137 private: |
| 138 BaseTab* target_; | 138 BaseTab* target_; |
| 139 | 139 |
| 140 DISALLOW_COPY_AND_ASSIGN(FavIconCrashAnimation); | 140 DISALLOW_COPY_AND_ASSIGN(FavIconCrashAnimation); |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 BaseTab::BaseTab(TabController* controller) | 143 BaseTab::BaseTab(TabController* controller) |
| 144 : controller_(controller), | 144 : controller_(controller), |
| 145 closing_(false), | 145 closing_(false), |
| 146 dragging_(false), | 146 dragging_(false), |
| 147 fav_icon_hiding_offset_(0), | 147 favicon_hiding_offset_(0), |
| 148 loading_animation_frame_(0), | 148 loading_animation_frame_(0), |
| 149 should_display_crashed_favicon_(false), | 149 should_display_crashed_favicon_(false), |
| 150 throbber_disabled_(false), | 150 throbber_disabled_(false), |
| 151 theme_provider_(NULL) { | 151 theme_provider_(NULL) { |
| 152 BaseTab::InitResources(); | 152 BaseTab::InitResources(); |
| 153 | 153 |
| 154 SetID(VIEW_ID_TAB); | 154 SetID(VIEW_ID_TAB); |
| 155 | 155 |
| 156 // Add the Close Button. | 156 // Add the Close Button. |
| 157 close_button_ = new TabCloseButton(this); | 157 close_button_ = new TabCloseButton(this); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 432 |
| 433 int icon_size = frames.height(); | 433 int icon_size = frames.height(); |
| 434 int image_offset = loading_animation_frame_ * icon_size; | 434 int image_offset = loading_animation_frame_ * icon_size; |
| 435 DrawIconCenter(canvas, frames, image_offset, | 435 DrawIconCenter(canvas, frames, image_offset, |
| 436 icon_size, icon_size, bounds, false); | 436 icon_size, icon_size, bounds, false); |
| 437 } else { | 437 } else { |
| 438 canvas->Save(); | 438 canvas->Save(); |
| 439 canvas->ClipRectInt(0, 0, width(), height()); | 439 canvas->ClipRectInt(0, 0, width(), height()); |
| 440 if (should_display_crashed_favicon_) { | 440 if (should_display_crashed_favicon_) { |
| 441 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 441 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 442 SkBitmap crashed_fav_icon(*rb.GetBitmapNamed(IDR_SAD_FAVICON)); | 442 SkBitmap crashed_favicon(*rb.GetBitmapNamed(IDR_SAD_FAVICON)); |
| 443 bounds.set_y(bounds.y() + fav_icon_hiding_offset_); | 443 bounds.set_y(bounds.y() + favicon_hiding_offset_); |
| 444 DrawIconCenter(canvas, crashed_fav_icon, 0, | 444 DrawIconCenter(canvas, crashed_favicon, 0, |
| 445 crashed_fav_icon.width(), | 445 crashed_favicon.width(), |
| 446 crashed_fav_icon.height(), bounds, true); | 446 crashed_favicon.height(), bounds, true); |
| 447 } else { | 447 } else { |
| 448 if (!data().favicon.isNull()) { | 448 if (!data().favicon.isNull()) { |
| 449 // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch | 449 // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch |
| 450 // to using that class to render the favicon). | 450 // to using that class to render the favicon). |
| 451 DrawIconCenter(canvas, data().favicon, 0, | 451 DrawIconCenter(canvas, data().favicon, 0, |
| 452 data().favicon.width(), | 452 data().favicon.width(), |
| 453 data().favicon.height(), | 453 data().favicon.height(), |
| 454 bounds, true); | 454 bounds, true); |
| 455 } | 455 } |
| 456 } | 456 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 } | 507 } |
| 508 | 508 |
| 509 int BaseTab::loading_animation_frame() const { | 509 int BaseTab::loading_animation_frame() const { |
| 510 return loading_animation_frame_; | 510 return loading_animation_frame_; |
| 511 } | 511 } |
| 512 | 512 |
| 513 bool BaseTab::should_display_crashed_favicon() const { | 513 bool BaseTab::should_display_crashed_favicon() const { |
| 514 return should_display_crashed_favicon_; | 514 return should_display_crashed_favicon_; |
| 515 } | 515 } |
| 516 | 516 |
| 517 int BaseTab::fav_icon_hiding_offset() const { | 517 int BaseTab::favicon_hiding_offset() const { |
| 518 return fav_icon_hiding_offset_; | 518 return favicon_hiding_offset_; |
| 519 } | 519 } |
| 520 | 520 |
| 521 void BaseTab::SetFaviconHidingOffset(int offset) { | 521 void BaseTab::SetFaviconHidingOffset(int offset) { |
| 522 fav_icon_hiding_offset_ = offset; | 522 favicon_hiding_offset_ = offset; |
| 523 ScheduleIconPaint(); | 523 ScheduleIconPaint(); |
| 524 } | 524 } |
| 525 | 525 |
| 526 void BaseTab::DisplayCrashedFavIcon() { | 526 void BaseTab::DisplayCrashedFavIcon() { |
| 527 should_display_crashed_favicon_ = true; | 527 should_display_crashed_favicon_ = true; |
| 528 } | 528 } |
| 529 | 529 |
| 530 void BaseTab::ResetCrashedFavIcon() { | 530 void BaseTab::ResetCrashedFavIcon() { |
| 531 should_display_crashed_favicon_ = false; | 531 should_display_crashed_favicon_ = false; |
| 532 } | 532 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 // static | 564 // static |
| 565 void BaseTab::InitResources() { | 565 void BaseTab::InitResources() { |
| 566 static bool initialized = false; | 566 static bool initialized = false; |
| 567 if (!initialized) { | 567 if (!initialized) { |
| 568 initialized = true; | 568 initialized = true; |
| 569 font_ = new gfx::Font( | 569 font_ = new gfx::Font( |
| 570 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont)); | 570 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont)); |
| 571 font_height_ = font_->GetHeight(); | 571 font_height_ = font_->GetHeight(); |
| 572 } | 572 } |
| 573 } | 573 } |
| OLD | NEW |