| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/tabs/base_tab.h" | 5 #include "chrome/browser/views/tabs/base_tab.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "app/animation_container.h" | 9 #include "app/animation_container.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // The loading animation image is a strip of states. Each state must be | 501 // The loading animation image is a strip of states. Each state must be |
| 502 // square, so the height must divide the width evenly. | 502 // square, so the height must divide the width evenly. |
| 503 loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER); | 503 loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER); |
| 504 loading_animation_size_ = loading_animation_frames->height(); | 504 loading_animation_size_ = loading_animation_frames->height(); |
| 505 DCHECK(loading_animation_frames); | 505 DCHECK(loading_animation_frames); |
| 506 DCHECK(loading_animation_frames->width() % | 506 DCHECK(loading_animation_frames->width() % |
| 507 loading_animation_frames->height() == 0); | 507 loading_animation_frames->height() == 0); |
| 508 loading_animation_frame_count = | 508 loading_animation_frame_count = |
| 509 loading_animation_frames->width() / loading_animation_frames->height(); | 509 loading_animation_frames->width() / loading_animation_frames->height(); |
| 510 | 510 |
| 511 // We get a DIV0 further down when the throbber is replaced by an image which | |
| 512 // is taller than wide. In this case we cannot deduce an animation sequence | |
| 513 // from it since we assume that each animation frame has the width of the | |
| 514 // image's height. | |
| 515 if (loading_animation_frame_count == 0) { | |
| 516 #ifdef WIN32 | |
| 517 // TODO(idanan): Remove this when we have a way to handle theme errors. | |
| 518 // See: http://code.google.com/p/chromium/issues/detail?id=12531 For now, | |
| 519 // this is Windows-specific because some users have downloaded a DLL from | |
| 520 // outside of Google to override the theme. | |
| 521 std::wstring text = l10n_util::GetString(IDS_RESOURCE_ERROR); | |
| 522 std::wstring caption = l10n_util::GetString(IDS_RESOURCE_ERROR_CAPTION); | |
| 523 UINT flags = MB_OK | MB_ICONWARNING | MB_TOPMOST; | |
| 524 win_util::MessageBox(NULL, text, caption, flags); | |
| 525 #endif | |
| 526 CHECK(loading_animation_frame_count) << | |
| 527 "Invalid throbber size. Width = " << | |
| 528 loading_animation_frames->width() << ", height = " << | |
| 529 loading_animation_frames->height(); | |
| 530 } | |
| 531 | |
| 532 waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING); | 511 waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING); |
| 533 DCHECK(waiting_animation_frames); | 512 DCHECK(waiting_animation_frames); |
| 534 DCHECK(waiting_animation_frames->width() % | 513 DCHECK(waiting_animation_frames->width() % |
| 535 waiting_animation_frames->height() == 0); | 514 waiting_animation_frames->height() == 0); |
| 536 waiting_animation_frame_count = | 515 waiting_animation_frame_count = |
| 537 waiting_animation_frames->width() / waiting_animation_frames->height(); | 516 waiting_animation_frames->width() / waiting_animation_frames->height(); |
| 538 | 517 |
| 539 waiting_to_loading_frame_count_ratio = | 518 waiting_to_loading_frame_count_ratio = |
| 540 waiting_animation_frame_count / loading_animation_frame_count; | 519 waiting_animation_frame_count / loading_animation_frame_count; |
| 541 // TODO(beng): eventually remove this when we have a proper themeing system. | |
| 542 // themes not supporting IDR_THROBBER_WAITING are causing this | |
| 543 // value to be 0 which causes DIV0 crashes. The value of 5 | |
| 544 // matches the current bitmaps in our source. | |
| 545 if (waiting_to_loading_frame_count_ratio == 0) | |
| 546 waiting_to_loading_frame_count_ratio = 5; | |
| 547 | 520 |
| 548 font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); | 521 font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont)); |
| 549 font_height_ = font_->height(); | 522 font_height_ = font_->height(); |
| 550 } | 523 } |
| 551 | 524 |
| 552 // static | 525 // static |
| 553 void BaseTab::LoadThemeImages() { | 526 void BaseTab::LoadThemeImages() { |
| 554 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 527 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 555 loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER); | 528 loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER); |
| 556 waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING); | 529 waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING); |
| 557 loading_animation_size_ = loading_animation_frames->height(); | 530 loading_animation_size_ = loading_animation_frames->height(); |
| 558 } | 531 } |
| OLD | NEW |