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/browser/extensions/extension_action.h" | 5 #include "chrome/browser/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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 453 |
454 // Paint the badge background color in the right location. It is usually | 454 // Paint the badge background color in the right location. It is usually |
455 // right-aligned, but it can also be center-aligned if it is large. | 455 // right-aligned, but it can also be center-aligned if it is large. |
456 int rect_height = kBadgeHeight; | 456 int rect_height = kBadgeHeight; |
457 int bottom_margin = | 457 int bottom_margin = |
458 action_type == extensions::Extension::ActionInfo::TYPE_BROWSER ? | 458 action_type == extensions::Extension::ActionInfo::TYPE_BROWSER ? |
459 kBottomMarginBrowserAction : kBottomMarginPageAction; | 459 kBottomMarginBrowserAction : kBottomMarginPageAction; |
460 int rect_y = bounds.bottom() - bottom_margin - kBadgeHeight; | 460 int rect_y = bounds.bottom() - bottom_margin - kBadgeHeight; |
461 int rect_width = badge_width; | 461 int rect_width = badge_width; |
462 int rect_x = (badge_width >= kCenterAlignThreshold) ? | 462 int rect_x = (badge_width >= kCenterAlignThreshold) ? |
463 (bounds.x() + bounds.width() - badge_width) / 2 : | 463 bounds.x() + (bounds.width() - badge_width) / 2 : |
464 bounds.right() - badge_width; | 464 bounds.right() - badge_width; |
465 gfx::Rect rect(rect_x, rect_y, rect_width, rect_height); | 465 gfx::Rect rect(rect_x, rect_y, rect_width, rect_height); |
466 | 466 |
467 SkPaint rect_paint; | 467 SkPaint rect_paint; |
468 rect_paint.setStyle(SkPaint::kFill_Style); | 468 rect_paint.setStyle(SkPaint::kFill_Style); |
469 rect_paint.setAntiAlias(true); | 469 rect_paint.setAntiAlias(true); |
470 rect_paint.setColor(background_color); | 470 rect_paint.setColor(background_color); |
471 canvas->DrawRoundRect(rect, 2, rect_paint); | 471 canvas->DrawRoundRect(rect, 2, rect_paint); |
472 | 472 |
473 // Overlay the gradient. It is stretchy, so we do this in three parts. | 473 // 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... |
545 icon_animation->Start(); | 545 icon_animation->Start(); |
546 // After the icon is finished fading in (plus some padding to handle random | 546 // After the icon is finished fading in (plus some padding to handle random |
547 // timer delays), destroy it. We use a delayed task so that the Animation is | 547 // timer delays), destroy it. We use a delayed task so that the Animation is |
548 // deleted even if it hasn't finished by the time the MessageLoop is | 548 // deleted even if it hasn't finished by the time the MessageLoop is |
549 // destroyed. | 549 // destroyed. |
550 MessageLoop::current()->PostDelayedTask( | 550 MessageLoop::current()->PostDelayedTask( |
551 FROM_HERE, | 551 FROM_HERE, |
552 base::Bind(&DestroyIconAnimation, base::Passed(icon_animation.Pass())), | 552 base::Bind(&DestroyIconAnimation, base::Passed(icon_animation.Pass())), |
553 base::TimeDelta::FromMilliseconds(kIconFadeInDurationMs * 2)); | 553 base::TimeDelta::FromMilliseconds(kIconFadeInDurationMs * 2)); |
554 } | 554 } |
OLD | NEW |