| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // When showing a script badge for the first time on a web page, fade it in. | 265 // When showing a script badge for the first time on a web page, fade it in. |
| 266 // Other transitions happen instantly. | 266 // Other transitions happen instantly. |
| 267 if (old_appearance == INVISIBLE && tab_id != kDefaultTabId && | 267 if (old_appearance == INVISIBLE && tab_id != kDefaultTabId && |
| 268 action_type_ == extensions::ActionInfo::TYPE_SCRIPT_BADGE) { | 268 action_type_ == extensions::ActionInfo::TYPE_SCRIPT_BADGE) { |
| 269 RunIconAnimation(tab_id); | 269 RunIconAnimation(tab_id); |
| 270 } | 270 } |
| 271 | 271 |
| 272 return true; | 272 return true; |
| 273 } | 273 } |
| 274 | 274 |
| 275 void ExtensionAction::DeclarativeShow(int tab_id) { |
| 276 DCHECK_NE(tab_id, kDefaultTabId); |
| 277 ++declarative_show_count_[tab_id]; // Use default initialization to 0. |
| 278 } |
| 279 |
| 280 void ExtensionAction::UndoDeclarativeShow(int tab_id) { |
| 281 int& show_count = declarative_show_count_[tab_id]; |
| 282 DCHECK_GT(show_count, 0); |
| 283 if (--show_count == 0) |
| 284 declarative_show_count_.erase(tab_id); |
| 285 } |
| 286 |
| 275 void ExtensionAction::ClearAllValuesForTab(int tab_id) { | 287 void ExtensionAction::ClearAllValuesForTab(int tab_id) { |
| 276 popup_url_.erase(tab_id); | 288 popup_url_.erase(tab_id); |
| 277 title_.erase(tab_id); | 289 title_.erase(tab_id); |
| 278 icon_.erase(tab_id); | 290 icon_.erase(tab_id); |
| 279 badge_text_.erase(tab_id); | 291 badge_text_.erase(tab_id); |
| 280 badge_text_color_.erase(tab_id); | 292 badge_text_color_.erase(tab_id); |
| 281 badge_background_color_.erase(tab_id); | 293 badge_background_color_.erase(tab_id); |
| 282 appearance_.erase(tab_id); | 294 appearance_.erase(tab_id); |
| 295 // TODO(jyasskin): Erase the element from declarative_show_count_ |
| 296 // when the tab's closed. There's a race between the |
| 297 // PageActionController and the ContentRulesRegistry on navigation, |
| 298 // which prevents me from cleaning everything up now. |
| 283 icon_animation_.erase(tab_id); | 299 icon_animation_.erase(tab_id); |
| 284 } | 300 } |
| 285 | 301 |
| 286 void ExtensionAction::PaintBadge(gfx::Canvas* canvas, | 302 void ExtensionAction::PaintBadge(gfx::Canvas* canvas, |
| 287 const gfx::Rect& bounds, | 303 const gfx::Rect& bounds, |
| 288 int tab_id) { | 304 int tab_id) { |
| 289 badge_util::PaintBadge( | 305 badge_util::PaintBadge( |
| 290 canvas, | 306 canvas, |
| 291 bounds, | 307 bounds, |
| 292 GetBadgeText(tab_id), | 308 GetBadgeText(tab_id), |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 icon_animation->Start(); | 391 icon_animation->Start(); |
| 376 // After the icon is finished fading in (plus some padding to handle random | 392 // After the icon is finished fading in (plus some padding to handle random |
| 377 // timer delays), destroy it. We use a delayed task so that the Animation is | 393 // timer delays), destroy it. We use a delayed task so that the Animation is |
| 378 // deleted even if it hasn't finished by the time the MessageLoop is | 394 // deleted even if it hasn't finished by the time the MessageLoop is |
| 379 // destroyed. | 395 // destroyed. |
| 380 MessageLoop::current()->PostDelayedTask( | 396 MessageLoop::current()->PostDelayedTask( |
| 381 FROM_HERE, | 397 FROM_HERE, |
| 382 base::Bind(&DestroyIconAnimation, base::Passed(icon_animation.Pass())), | 398 base::Bind(&DestroyIconAnimation, base::Passed(icon_animation.Pass())), |
| 383 base::TimeDelta::FromMilliseconds(kIconFadeInDurationMs * 2)); | 399 base::TimeDelta::FromMilliseconds(kIconFadeInDurationMs * 2)); |
| 384 } | 400 } |
| OLD | NEW |