| 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "chrome/common/extensions/api/extension_action/action_info.h" | 18 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 19 #include "chrome/common/extensions/extension_icon_set.h" | 19 #include "chrome/common/extensions/extension_icon_set.h" |
| 20 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
| 21 // TODO(robertphillips): change this to "class SkBaseDevice;" | 21 // TODO(robertphillips): change this to "class SkBaseDevice;" |
| 22 #include "third_party/skia/include/core/SkDevice.h" | 22 #include "third_party/skia/include/core/SkDevice.h" |
| 23 #include "ui/base/animation/linear_animation.h" | 23 #include "ui/gfx/animation/linear_animation.h" |
| 24 | 24 |
| 25 class GURL; | 25 class GURL; |
| 26 class SkBitmap; | 26 class SkBitmap; |
| 27 | 27 |
| 28 namespace gfx { | 28 namespace gfx { |
| 29 class Canvas; | 29 class Canvas; |
| 30 class Image; | 30 class Image; |
| 31 class ImageSkia; | 31 class ImageSkia; |
| 32 class Rect; | 32 class Rect; |
| 33 class Size; | 33 class Size; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 47 // The action icon is hidden. | 47 // The action icon is hidden. |
| 48 INVISIBLE, | 48 INVISIBLE, |
| 49 // The action is trying to get the user's attention but isn't yet | 49 // The action is trying to get the user's attention but isn't yet |
| 50 // running on the page. Currently only used for script badges. | 50 // running on the page. Currently only used for script badges. |
| 51 WANTS_ATTENTION, | 51 WANTS_ATTENTION, |
| 52 // The action icon is visible with its normal appearance. | 52 // The action icon is visible with its normal appearance. |
| 53 ACTIVE, | 53 ACTIVE, |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // A fade-in animation. | 56 // A fade-in animation. |
| 57 class IconAnimation : public ui::LinearAnimation { | 57 class IconAnimation : public gfx::LinearAnimation { |
| 58 public: | 58 public: |
| 59 // Observes changes to icon animation state. | 59 // Observes changes to icon animation state. |
| 60 class Observer { | 60 class Observer { |
| 61 public: | 61 public: |
| 62 virtual void OnIconChanged() = 0; | 62 virtual void OnIconChanged() = 0; |
| 63 | 63 |
| 64 protected: | 64 protected: |
| 65 virtual ~Observer() {} | 65 virtual ~Observer() {} |
| 66 }; | 66 }; |
| 67 | 67 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 93 void AddObserver(Observer* observer); | 93 void AddObserver(Observer* observer); |
| 94 void RemoveObserver(Observer* observer); | 94 void RemoveObserver(Observer* observer); |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 // Construct using ExtensionAction::RunIconAnimation(). | 97 // Construct using ExtensionAction::RunIconAnimation(). |
| 98 friend class ExtensionAction; | 98 friend class ExtensionAction; |
| 99 IconAnimation(); | 99 IconAnimation(); |
| 100 | 100 |
| 101 base::WeakPtr<IconAnimation> AsWeakPtr(); | 101 base::WeakPtr<IconAnimation> AsWeakPtr(); |
| 102 | 102 |
| 103 // ui::LinearAnimation implementation. | 103 // gfx::LinearAnimation implementation. |
| 104 virtual void AnimateToState(double state) OVERRIDE; | 104 virtual void AnimateToState(double state) OVERRIDE; |
| 105 | 105 |
| 106 // Device we use to paint icons to. | 106 // Device we use to paint icons to. |
| 107 mutable scoped_ptr<SkBaseDevice> device_; | 107 mutable scoped_ptr<SkBaseDevice> device_; |
| 108 | 108 |
| 109 ObserverList<Observer> observers_; | 109 ObserverList<Observer> observers_; |
| 110 | 110 |
| 111 base::WeakPtrFactory<IconAnimation> weak_ptr_factory_; | 111 base::WeakPtrFactory<IconAnimation> weak_ptr_factory_; |
| 112 | 112 |
| 113 DISALLOW_COPY_AND_ASSIGN(IconAnimation); | 113 DISALLOW_COPY_AND_ASSIGN(IconAnimation); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 }; | 369 }; |
| 370 | 370 |
| 371 template<> | 371 template<> |
| 372 struct ExtensionAction::ValueTraits<int> { | 372 struct ExtensionAction::ValueTraits<int> { |
| 373 static int CreateEmpty() { | 373 static int CreateEmpty() { |
| 374 return -1; | 374 return -1; |
| 375 } | 375 } |
| 376 }; | 376 }; |
| 377 | 377 |
| 378 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_ | 378 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_ |
| OLD | NEW |