| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/extensions/extension_action.h" | 5 #include "chrome/common/extensions/extension_action.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 if (icon_width != 0 && (badge_width % 2 != icon_width % 2)) | 421 if (icon_width != 0 && (badge_width % 2 != icon_width % 2)) |
| 422 badge_width += 1; | 422 badge_width += 1; |
| 423 badge_width = std::max(kBadgeHeight, badge_width); | 423 badge_width = std::max(kBadgeHeight, badge_width); |
| 424 | 424 |
| 425 // Paint the badge background color in the right location. It is usually | 425 // Paint the badge background color in the right location. It is usually |
| 426 // right-aligned, but it can also be center-aligned if it is large. | 426 // right-aligned, but it can also be center-aligned if it is large. |
| 427 int rect_height = kBadgeHeight; | 427 int rect_height = kBadgeHeight; |
| 428 int rect_y = bounds.bottom() - kBottomMargin - kBadgeHeight; | 428 int rect_y = bounds.bottom() - kBottomMargin - kBadgeHeight; |
| 429 int rect_width = badge_width; | 429 int rect_width = badge_width; |
| 430 int rect_x = (badge_width >= kCenterAlignThreshold) ? | 430 int rect_x = (badge_width >= kCenterAlignThreshold) ? |
| 431 (bounds.x() + bounds.width() - badge_width) / 2 : | 431 bounds.x() + (bounds.width() - badge_width) / 2 : |
| 432 bounds.right() - badge_width; | 432 bounds.right() - badge_width; |
| 433 gfx::Rect rect(rect_x, rect_y, rect_width, rect_height); | 433 gfx::Rect rect(rect_x, rect_y, rect_width, rect_height); |
| 434 | 434 |
| 435 SkPaint rect_paint; | 435 SkPaint rect_paint; |
| 436 rect_paint.setStyle(SkPaint::kFill_Style); | 436 rect_paint.setStyle(SkPaint::kFill_Style); |
| 437 rect_paint.setAntiAlias(true); | 437 rect_paint.setAntiAlias(true); |
| 438 rect_paint.setColor(background_color); | 438 rect_paint.setColor(background_color); |
| 439 canvas->DrawRoundRect(rect, 2, rect_paint); | 439 canvas->DrawRoundRect(rect, 2, rect_paint); |
| 440 | 440 |
| 441 // Overlay the gradient. It is stretchy, so we do this in three parts. | 441 // Overlay the gradient. It is stretchy, so we do this in three parts. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 icon_animation->Start(); | 513 icon_animation->Start(); |
| 514 // After the icon is finished fading in (plus some padding to handle random | 514 // After the icon is finished fading in (plus some padding to handle random |
| 515 // timer delays), destroy it. We use a delayed task so that the Animation is | 515 // timer delays), destroy it. We use a delayed task so that the Animation is |
| 516 // deleted even if it hasn't finished by the time the MessageLoop is | 516 // deleted even if it hasn't finished by the time the MessageLoop is |
| 517 // destroyed. | 517 // destroyed. |
| 518 MessageLoop::current()->PostDelayedTask( | 518 MessageLoop::current()->PostDelayedTask( |
| 519 FROM_HERE, | 519 FROM_HERE, |
| 520 base::Bind(&DestroyIconAnimation, base::Passed(icon_animation.Pass())), | 520 base::Bind(&DestroyIconAnimation, base::Passed(icon_animation.Pass())), |
| 521 base::TimeDelta::FromMilliseconds(kIconFadeInDurationMs * 2)); | 521 base::TimeDelta::FromMilliseconds(kIconFadeInDurationMs * 2)); |
| 522 } | 522 } |
| OLD | NEW |