Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2393)

Unified Diff: chrome/browser/extensions/location_bar_controller.h

Issue 10559054: Animate the script badges. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: really sending for review... Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/location_bar_controller.h
diff --git a/chrome/browser/extensions/location_bar_controller.h b/chrome/browser/extensions/location_bar_controller.h
index 68048b0b0f42bbb5a8243808119f37a0a7b70ab7..e12f0f8d9d27b8d536e480fa41ff2f38a751c7af 100644
--- a/chrome/browser/extensions/location_bar_controller.h
+++ b/chrome/browser/extensions/location_bar_controller.h
@@ -10,7 +10,19 @@
#include <string>
#include <vector>
+#include "base/observer_list.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "ui/base/animation/linear_animation.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
class ExtensionAction;
+class SkDevice;
+
+namespace ui {
+class Animation;
+class AnimationDelegate;
+}
namespace extensions {
@@ -26,15 +38,59 @@ class LocationBarController {
ACTION_SHOW_CONTEXT_MENU,
};
- virtual ~LocationBarController() {}
+ // A fade-in animation for the items that appear in the locaion bar. These
Yoyo Zhou 2012/06/22 00:50:29 typo: location
not at google - send to devlin 2012/06/26 07:30:47 Done.
+ // are designed to be owned by a LocationBarController (with a tab lifespan),
+ // but used by objects with an unprecictable lifespan in the UI, hence
Yoyo Zhou 2012/06/22 00:50:29 typo: unpredictable
not at google - send to devlin 2012/06/26 07:30:47 Done.
not at google - send to devlin 2012/06/26 07:30:47 Done.
+ // the weak reference support.
+ class IconAnimation : public ui::LinearAnimation,
+ public base::SupportsWeakPtr<IconAnimation> {
+ public:
+ // Observes changes to icon animation state.
+ class Observer {
+ public:
+ virtual void OnIconChanged(const IconAnimation& animation,
+ LocationBarController* location_bar) = 0;
+
+ protected:
+ virtual ~Observer() {}
+ };
+
+ // It's only useful to construct these from LocationBarController
+ // implementations. Use LocationBarController::GetIconAnimation.
+ IconAnimation(LocationBarController* owner,
+ ui::AnimationDelegate* delegate);
+ virtual ~IconAnimation();
+
+ // Returns the icon derived from the current animation state applied to
+ // |icon|. Ownership remains with this.
+ const SkBitmap& Apply(const SkBitmap& icon) const;
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ private:
+ // ui::LinearAnimation implementation.
+ virtual void AnimateToState(double state) OVERRIDE;
- // Utility to add any actions to |out| which aren't present in |actions|.
- static void AddMissingActions(
- const std::set<ExtensionAction*>& actions,
- std::vector<ExtensionAction*>* out);
+ // Owning LocationBarController to give to observers.
+ LocationBarController* owner_;
+
+ // Device we use to paint icons to.
+ mutable scoped_ptr<SkDevice> device_;
+
+ ObserverList<Observer> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(IconAnimation);
+ };
+
+ virtual ~LocationBarController() {}
// Gets the action data for all extensions.
- virtual std::vector<ExtensionAction*> GetCurrentActions() = 0;
+ virtual std::vector<ExtensionAction*> GetCurrentActions() const = 0;
+
+ // Gets the icon animation for an ExtensionAction, if there is one.
+ virtual base::WeakPtr<IconAnimation> GetIconAnimation(
+ const ExtensionAction* action) const = 0;
// Notifies this that the badge for an extension has been clicked with some
// mouse button (1 for left, 2 for middle, and 3 for right click), and

Powered by Google App Engine
This is Rietveld 408576698