| 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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 134 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 135 close_button_->SetImage(views::CustomButton::BS_NORMAL, | 135 close_button_->SetImage(views::CustomButton::BS_NORMAL, |
| 136 rb.GetBitmapNamed(IDR_TAB_CLOSE)); | 136 rb.GetBitmapNamed(IDR_TAB_CLOSE)); |
| 137 close_button_->SetImage(views::CustomButton::BS_HOT, | 137 close_button_->SetImage(views::CustomButton::BS_HOT, |
| 138 rb.GetBitmapNamed(IDR_TAB_CLOSE_H)); | 138 rb.GetBitmapNamed(IDR_TAB_CLOSE_H)); |
| 139 close_button_->SetImage(views::CustomButton::BS_PUSHED, | 139 close_button_->SetImage(views::CustomButton::BS_PUSHED, |
| 140 rb.GetBitmapNamed(IDR_TAB_CLOSE_P)); | 140 rb.GetBitmapNamed(IDR_TAB_CLOSE_P)); |
| 141 close_button_->SetTooltipText( | 141 close_button_->SetTooltipText( |
| 142 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_CLOSE_TAB))); | 142 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_CLOSE_TAB))); |
| 143 close_button_->SetAccessibleName( | 143 close_button_->SetAccessibleName( |
| 144 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE))); | 144 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); |
| 145 // Disable animation so that the red danger sign shows up immediately | 145 // Disable animation so that the red danger sign shows up immediately |
| 146 // to help avoid mis-clicks. | 146 // to help avoid mis-clicks. |
| 147 close_button_->SetAnimationDuration(0); | 147 close_button_->SetAnimationDuration(0); |
| 148 AddChildView(close_button_); | 148 AddChildView(close_button_); |
| 149 | 149 |
| 150 SetContextMenuController(this); | 150 SetContextMenuController(this); |
| 151 } | 151 } |
| 152 | 152 |
| 153 BaseTab::~BaseTab() { | 153 BaseTab::~BaseTab() { |
| 154 } | 154 } |
| 155 | 155 |
| 156 void BaseTab::SetData(const TabRendererData& data) { | 156 void BaseTab::SetData(const TabRendererData& data) { |
| 157 TabRendererData old(data_); | 157 TabRendererData old(data_); |
| 158 data_ = data; | 158 data_ = data; |
| 159 | 159 |
| 160 if (data_.crashed) { | 160 if (data_.crashed) { |
| 161 if (!should_display_crashed_favicon_ && !IsPerformingCrashAnimation()) | 161 if (!should_display_crashed_favicon_ && !IsPerformingCrashAnimation()) |
| 162 StartCrashAnimation(); | 162 StartCrashAnimation(); |
| 163 } else { | 163 } else { |
| 164 if (IsPerformingCrashAnimation()) | 164 if (IsPerformingCrashAnimation()) |
| 165 StopCrashAnimation(); | 165 StopCrashAnimation(); |
| 166 ResetCrashedFavIcon(); | 166 ResetCrashedFavIcon(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 // Sets the accessible name for the tab. | 169 // Sets the accessible name for the tab. |
| 170 SetAccessibleName(UTF16ToWide(data_.title)); | 170 SetAccessibleName(data_.title); |
| 171 | 171 |
| 172 DataChanged(old); | 172 DataChanged(old); |
| 173 | 173 |
| 174 Layout(); | 174 Layout(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void BaseTab::UpdateLoadingAnimation(TabRendererData::NetworkState state) { | 177 void BaseTab::UpdateLoadingAnimation(TabRendererData::NetworkState state) { |
| 178 // If this is an extension app and a command line flag is set, | 178 // If this is an extension app and a command line flag is set, |
| 179 // then disable the throbber. | 179 // then disable the throbber. |
| 180 throbber_disabled_ = data().app && | 180 throbber_disabled_ = data().app && |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 // static | 468 // static |
| 469 void BaseTab::InitResources() { | 469 void BaseTab::InitResources() { |
| 470 static bool initialized = false; | 470 static bool initialized = false; |
| 471 if (!initialized) { | 471 if (!initialized) { |
| 472 initialized = true; | 472 initialized = true; |
| 473 font_ = new gfx::Font( | 473 font_ = new gfx::Font( |
| 474 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont)); | 474 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont)); |
| 475 font_height_ = font_->GetHeight(); | 475 font_height_ = font_->GetHeight(); |
| 476 } | 476 } |
| 477 } | 477 } |
| OLD | NEW |