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/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/common/badge_util.h" | 10 #include "chrome/common/badge_util.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 268 } |
269 | 269 |
270 bool ExtensionAction::SetAppearance(int tab_id, Appearance new_appearance) { | 270 bool ExtensionAction::SetAppearance(int tab_id, Appearance new_appearance) { |
271 const Appearance old_appearance = GetValue(&appearance_, tab_id); | 271 const Appearance old_appearance = GetValue(&appearance_, tab_id); |
272 | 272 |
273 if (old_appearance == new_appearance) | 273 if (old_appearance == new_appearance) |
274 return false; | 274 return false; |
275 | 275 |
276 SetValue(&appearance_, tab_id, new_appearance); | 276 SetValue(&appearance_, tab_id, new_appearance); |
277 | 277 |
278 // When showing a badge for the first time on a web page, fade it | 278 // When showing a script badge for the first time on a web page, fade it in. |
279 // in. Other transitions happen instantly. | 279 // Other transitions happen instantly. |
280 if (old_appearance == INVISIBLE && tab_id != kDefaultTabId) { | 280 if (old_appearance == INVISIBLE && tab_id != kDefaultTabId && |
| 281 action_type_ == TYPE_SCRIPT_BADGE) { |
281 RunIconAnimation(tab_id); | 282 RunIconAnimation(tab_id); |
282 } | 283 } |
283 | 284 |
284 return true; | 285 return true; |
285 } | 286 } |
286 | 287 |
287 void ExtensionAction::ClearAllValuesForTab(int tab_id) { | 288 void ExtensionAction::ClearAllValuesForTab(int tab_id) { |
288 popup_url_.erase(tab_id); | 289 popup_url_.erase(tab_id); |
289 title_.erase(tab_id); | 290 title_.erase(tab_id); |
290 icon_.erase(tab_id); | 291 icon_.erase(tab_id); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 return orig; | 423 return orig; |
423 return gfx::Image(wrapper->animation()->Apply(*orig.ToSkBitmap())); | 424 return gfx::Image(wrapper->animation()->Apply(*orig.ToSkBitmap())); |
424 } | 425 } |
425 | 426 |
426 void ExtensionAction::RunIconAnimation(int tab_id) { | 427 void ExtensionAction::RunIconAnimation(int tab_id) { |
427 IconAnimationWrapper* icon_animation = | 428 IconAnimationWrapper* icon_animation = |
428 new IconAnimationWrapper(); | 429 new IconAnimationWrapper(); |
429 icon_animation_[tab_id] = icon_animation->AsWeakPtr(); | 430 icon_animation_[tab_id] = icon_animation->AsWeakPtr(); |
430 icon_animation->animation()->Start(); | 431 icon_animation->animation()->Start(); |
431 } | 432 } |
OLD | NEW |