| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_VIEWS_BROWSER_ACTIONS_PANEL_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_PANEL_H_ |
| 6 #define CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_PANEL_H_ | 6 #define CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_PANEL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| 11 #include "chrome/browser/extensions/image_loading_tracker.h" | 11 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 12 #include "chrome/browser/views/browser_bubble.h" | 12 #include "chrome/browser/views/browser_bubble.h" |
| 13 #include "chrome/common/notification_observer.h" | 13 #include "chrome/common/notification_observer.h" |
| 14 #include "chrome/common/notification_registrar.h" | 14 #include "chrome/common/notification_registrar.h" |
| 15 #include "views/controls/button/menu_button.h" | 15 #include "views/controls/button/menu_button.h" |
| 16 #include "views/view.h" | 16 #include "views/view.h" |
| 17 | 17 |
| 18 class BrowserActionsContainer; | 18 class BrowserActionsContainer; |
| 19 class Extension; | 19 class Extension; |
| 20 class ExtensionAction2; | 20 class ExtensionAction; |
| 21 class ExtensionPopup; | 21 class ExtensionPopup; |
| 22 class Profile; | 22 class Profile; |
| 23 class ToolbarView; | 23 class ToolbarView; |
| 24 | 24 |
| 25 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
| 26 // BrowserActionButton | 26 // BrowserActionButton |
| 27 | 27 |
| 28 // The BrowserActionButton is a specialization of the MenuButton class. | 28 // The BrowserActionButton is a specialization of the MenuButton class. |
| 29 // It acts on a ExtensionAction2, in this case a BrowserAction and handles | 29 // It acts on a ExtensionAction, in this case a BrowserAction and handles |
| 30 // loading the image for the button asynchronously on the file thread to | 30 // loading the image for the button asynchronously on the file thread to |
| 31 class BrowserActionButton : public views::MenuButton, | 31 class BrowserActionButton : public views::MenuButton, |
| 32 public views::ButtonListener, | 32 public views::ButtonListener, |
| 33 public ImageLoadingTracker::Observer, | 33 public ImageLoadingTracker::Observer, |
| 34 public NotificationObserver { | 34 public NotificationObserver { |
| 35 public: | 35 public: |
| 36 BrowserActionButton(Extension* extension, BrowserActionsContainer* panel); | 36 BrowserActionButton(Extension* extension, BrowserActionsContainer* panel); |
| 37 ~BrowserActionButton(); | 37 ~BrowserActionButton(); |
| 38 | 38 |
| 39 ExtensionAction2* browser_action() const { return browser_action_; } | 39 ExtensionAction* browser_action() const { return browser_action_; } |
| 40 Extension* extension() { return extension_; } | 40 Extension* extension() { return extension_; } |
| 41 | 41 |
| 42 // Called to update the display to match the browser action's state. | 42 // Called to update the display to match the browser action's state. |
| 43 void UpdateState(); | 43 void UpdateState(); |
| 44 | 44 |
| 45 // Overriden from views::View. Return a 0-inset so the icon can draw all the | 45 // Overriden from views::View. Return a 0-inset so the icon can draw all the |
| 46 // way to the edge of the view if it wants. | 46 // way to the edge of the view if it wants. |
| 47 virtual gfx::Insets GetInsets() const; | 47 virtual gfx::Insets GetInsets() const; |
| 48 | 48 |
| 49 // Overridden from views::ButtonListener: | 49 // Overridden from views::ButtonListener: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 72 virtual bool IsPopup(); | 72 virtual bool IsPopup(); |
| 73 | 73 |
| 74 // Notifications when the popup is hidden or shown by the container. | 74 // Notifications when the popup is hidden or shown by the container. |
| 75 virtual void PopupDidShow(); | 75 virtual void PopupDidShow(); |
| 76 virtual void PopupDidHide(); | 76 virtual void PopupDidHide(); |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 // If the image from the browser action needs to be loaded, load it. | 79 // If the image from the browser action needs to be loaded, load it. |
| 80 void LoadImage(); | 80 void LoadImage(); |
| 81 | 81 |
| 82 // The browser action this view represents. The ExtensionAction2 is not owned | 82 // The browser action this view represents. The ExtensionAction is not owned |
| 83 // by this class. | 83 // by this class. |
| 84 ExtensionAction2* browser_action_; | 84 ExtensionAction* browser_action_; |
| 85 | 85 |
| 86 // The extension associated with the browser action we're displaying. | 86 // The extension associated with the browser action we're displaying. |
| 87 Extension* extension_; | 87 Extension* extension_; |
| 88 | 88 |
| 89 // The icons representing different states for the browser action. | 89 // The icons representing different states for the browser action. |
| 90 std::vector<SkBitmap> browser_action_icons_; | 90 std::vector<SkBitmap> browser_action_icons_; |
| 91 | 91 |
| 92 // The object that is waiting for the image loading to complete | 92 // The object that is waiting for the image loading to complete |
| 93 // asynchronously. This object can potentially outlive the BrowserActionView, | 93 // asynchronously. This object can potentially outlive the BrowserActionView, |
| 94 // and takes care of deleting itself. | 94 // and takes care of deleting itself. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // The button that triggered the current popup (just a reference to a button | 220 // The button that triggered the current popup (just a reference to a button |
| 221 // from browser_action_views_). | 221 // from browser_action_views_). |
| 222 BrowserActionButton* popup_button_; | 222 BrowserActionButton* popup_button_; |
| 223 | 223 |
| 224 ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_; | 224 ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_; |
| 225 | 225 |
| 226 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); | 226 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 #endif // CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_PANEL_H_ | 229 #endif // CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_PANEL_H_ |
| OLD | NEW |