| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 } | 312 } |
| 313 | 313 |
| 314 bool ExtensionAction::SetAppearance(int tab_id, Appearance new_appearance) { | 314 bool ExtensionAction::SetAppearance(int tab_id, Appearance new_appearance) { |
| 315 const Appearance old_appearance = GetValue(&appearance_, tab_id); | 315 const Appearance old_appearance = GetValue(&appearance_, tab_id); |
| 316 | 316 |
| 317 if (old_appearance == new_appearance) | 317 if (old_appearance == new_appearance) |
| 318 return false; | 318 return false; |
| 319 | 319 |
| 320 SetValue(&appearance_, tab_id, new_appearance); | 320 SetValue(&appearance_, tab_id, new_appearance); |
| 321 | 321 |
| 322 // When showing a badge for the first time on a web page, fade it | 322 // When showing a script badge for the first time on a web page, fade it in. |
| 323 // in. Other transitions happen instantly. | 323 // Other transitions happen instantly. |
| 324 if (old_appearance == INVISIBLE && tab_id != kDefaultTabId) { | 324 if (old_appearance == INVISIBLE && tab_id != kDefaultTabId && |
| 325 action_type_ == TYPE_SCRIPT_BADGE) { |
| 325 RunIconAnimation(tab_id); | 326 RunIconAnimation(tab_id); |
| 326 } | 327 } |
| 327 | 328 |
| 328 return true; | 329 return true; |
| 329 } | 330 } |
| 330 | 331 |
| 331 void ExtensionAction::ClearAllValuesForTab(int tab_id) { | 332 void ExtensionAction::ClearAllValuesForTab(int tab_id) { |
| 332 popup_url_.erase(tab_id); | 333 popup_url_.erase(tab_id); |
| 333 title_.erase(tab_id); | 334 title_.erase(tab_id); |
| 334 icon_.erase(tab_id); | 335 icon_.erase(tab_id); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 icon_animation->Start(); | 513 icon_animation->Start(); |
| 513 // 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 |
| 514 // 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 |
| 515 // 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 |
| 516 // destroyed. | 517 // destroyed. |
| 517 MessageLoop::current()->PostDelayedTask( | 518 MessageLoop::current()->PostDelayedTask( |
| 518 FROM_HERE, | 519 FROM_HERE, |
| 519 base::Bind(&DestroyIconAnimation, base::Passed(icon_animation.Pass())), | 520 base::Bind(&DestroyIconAnimation, base::Passed(icon_animation.Pass())), |
| 520 base::TimeDelta::FromMilliseconds(kIconFadeInDurationMs * 2)); | 521 base::TimeDelta::FromMilliseconds(kIconFadeInDurationMs * 2)); |
| 521 } | 522 } |
| OLD | NEW |