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" |
11 #include "app/theme_provider.h" | |
12 #include "base/command_line.h" | 11 #include "base/command_line.h" |
13 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
15 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/view_ids.h" | 15 #include "chrome/browser/ui/view_ids.h" |
17 #include "chrome/browser/ui/views/tabs/tab_controller.h" | 16 #include "chrome/browser/ui/views/tabs/tab_controller.h" |
18 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
19 #include "gfx/canvas_skia.h" | 18 #include "gfx/canvas_skia.h" |
20 #include "gfx/favicon_size.h" | 19 #include "gfx/favicon_size.h" |
21 #include "gfx/font.h" | 20 #include "gfx/font.h" |
22 #include "grit/app_resources.h" | 21 #include "grit/app_resources.h" |
23 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
24 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
25 #include "ui/base/animation/slide_animation.h" | 24 #include "ui/base/animation/slide_animation.h" |
26 #include "ui/base/animation/throb_animation.h" | 25 #include "ui/base/animation/throb_animation.h" |
| 26 #include "ui/base/theme_provider.h" |
27 #include "views/controls/button/image_button.h" | 27 #include "views/controls/button/image_button.h" |
28 | 28 |
29 // How long the pulse throb takes. | 29 // How long the pulse throb takes. |
30 static const int kPulseDurationMs = 200; | 30 static const int kPulseDurationMs = 200; |
31 | 31 |
32 // How long the hover state takes. | 32 // How long the hover state takes. |
33 static const int kHoverDurationMs = 400; | 33 static const int kHoverDurationMs = 400; |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 *tooltip = UTF16ToWide(data_.title); | 298 *tooltip = UTF16ToWide(data_.title); |
299 return true; | 299 return true; |
300 } | 300 } |
301 return false; | 301 return false; |
302 } | 302 } |
303 | 303 |
304 AccessibilityTypes::Role BaseTab::GetAccessibleRole() { | 304 AccessibilityTypes::Role BaseTab::GetAccessibleRole() { |
305 return AccessibilityTypes::ROLE_PAGETAB; | 305 return AccessibilityTypes::ROLE_PAGETAB; |
306 } | 306 } |
307 | 307 |
308 ThemeProvider* BaseTab::GetThemeProvider() { | 308 ui::ThemeProvider* BaseTab::GetThemeProvider() { |
309 ThemeProvider* tp = View::GetThemeProvider(); | 309 ui::ThemeProvider* tp = View::GetThemeProvider(); |
310 return tp ? tp : theme_provider_; | 310 return tp ? tp : theme_provider_; |
311 } | 311 } |
312 | 312 |
313 void BaseTab::AdvanceLoadingAnimation(TabRendererData::NetworkState old_state, | 313 void BaseTab::AdvanceLoadingAnimation(TabRendererData::NetworkState old_state, |
314 TabRendererData::NetworkState state) { | 314 TabRendererData::NetworkState state) { |
315 static bool initialized = false; | 315 static bool initialized = false; |
316 static int loading_animation_frame_count = 0; | 316 static int loading_animation_frame_count = 0; |
317 static int waiting_animation_frame_count = 0; | 317 static int waiting_animation_frame_count = 0; |
318 static int waiting_to_loading_frame_count_ratio = 0; | 318 static int waiting_to_loading_frame_count_ratio = 0; |
319 if (!initialized) { | 319 if (!initialized) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 if (base::i18n::IsRTL()) { | 352 if (base::i18n::IsRTL()) { |
353 x = width() - x - | 353 x = width() - x - |
354 (data().favicon.isNull() ? kFavIconSize : data().favicon.width()); | 354 (data().favicon.isNull() ? kFavIconSize : data().favicon.width()); |
355 } | 355 } |
356 | 356 |
357 int favicon_x = x; | 357 int favicon_x = x; |
358 if (!data().favicon.isNull() && data().favicon.width() != kFavIconSize) | 358 if (!data().favicon.isNull() && data().favicon.width() != kFavIconSize) |
359 favicon_x += (data().favicon.width() - kFavIconSize) / 2; | 359 favicon_x += (data().favicon.width() - kFavIconSize) / 2; |
360 | 360 |
361 if (data().network_state != TabRendererData::NETWORK_STATE_NONE) { | 361 if (data().network_state != TabRendererData::NETWORK_STATE_NONE) { |
362 ThemeProvider* tp = GetThemeProvider(); | 362 ui::ThemeProvider* tp = GetThemeProvider(); |
363 SkBitmap frames(*tp->GetBitmapNamed( | 363 SkBitmap frames(*tp->GetBitmapNamed( |
364 (data().network_state == TabRendererData::NETWORK_STATE_WAITING) ? | 364 (data().network_state == TabRendererData::NETWORK_STATE_WAITING) ? |
365 IDR_THROBBER_WAITING : IDR_THROBBER)); | 365 IDR_THROBBER_WAITING : IDR_THROBBER)); |
366 int image_size = frames.height(); | 366 int image_size = frames.height(); |
367 int image_offset = loading_animation_frame_ * image_size; | 367 int image_offset = loading_animation_frame_ * image_size; |
368 int dst_y = (height() - image_size) / 2; | 368 int dst_y = (height() - image_size) / 2; |
369 canvas->DrawBitmapInt(frames, image_offset, 0, image_size, | 369 canvas->DrawBitmapInt(frames, image_offset, 0, image_size, |
370 image_size, favicon_x, dst_y, image_size, image_size, | 370 image_size, favicon_x, dst_y, image_size, image_size, |
371 false); | 371 false); |
372 } else { | 372 } else { |
(...skipping 95 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 |