| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_UI_VIEWS_TOOLBAR_BROWSER_ACTION_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTION_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTION_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTION_VIEW_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/ui/views/extensions/extension_action_view_controller.h" | 8 #include "chrome/browser/ui/views/extensions/extension_action_view_controller.h" |
| 9 #include "chrome/browser/ui/views/extensions/extension_action_view_delegate.h" | 9 #include "chrome/browser/ui/views/extensions/extension_action_view_delegate.h" |
| 10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 icon_observer_ = icon_observer; | 102 icon_observer_ = icon_observer; |
| 103 } | 103 } |
| 104 | 104 |
| 105 // Called to update the display to match the browser action's state. | 105 // Called to update the display to match the browser action's state. |
| 106 void UpdateState(); | 106 void UpdateState(); |
| 107 | 107 |
| 108 // Does this button's action have a popup? | 108 // Does this button's action have a popup? |
| 109 bool IsPopup(); | 109 bool IsPopup(); |
| 110 | 110 |
| 111 // Overridden from views::View: | 111 // Overridden from views::View: |
| 112 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 112 virtual void GetAccessibleState(ui::AXViewState* state) override; |
| 113 | 113 |
| 114 // Overridden from views::ButtonListener: | 114 // Overridden from views::ButtonListener: |
| 115 virtual void ButtonPressed(views::Button* sender, | 115 virtual void ButtonPressed(views::Button* sender, |
| 116 const ui::Event& event) OVERRIDE; | 116 const ui::Event& event) override; |
| 117 | 117 |
| 118 // Overridden from content::NotificationObserver: | 118 // Overridden from content::NotificationObserver: |
| 119 virtual void Observe(int type, | 119 virtual void Observe(int type, |
| 120 const content::NotificationSource& source, | 120 const content::NotificationSource& source, |
| 121 const content::NotificationDetails& details) OVERRIDE; | 121 const content::NotificationDetails& details) override; |
| 122 | 122 |
| 123 // MenuButton behavior overrides. These methods all default to LabelButton | 123 // MenuButton behavior overrides. These methods all default to LabelButton |
| 124 // behavior unless this button is a popup. In that case, it uses MenuButton | 124 // behavior unless this button is a popup. In that case, it uses MenuButton |
| 125 // behavior. MenuButton has the notion of a child popup being shown where the | 125 // behavior. MenuButton has the notion of a child popup being shown where the |
| 126 // button will stay in the pushed state until the "menu" (a popup in this | 126 // button will stay in the pushed state until the "menu" (a popup in this |
| 127 // case) is dismissed. | 127 // case) is dismissed. |
| 128 virtual bool Activate() OVERRIDE; | 128 virtual bool Activate() override; |
| 129 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 129 virtual bool OnMousePressed(const ui::MouseEvent& event) override; |
| 130 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 130 virtual void OnMouseReleased(const ui::MouseEvent& event) override; |
| 131 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 131 virtual void OnMouseExited(const ui::MouseEvent& event) override; |
| 132 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; | 132 virtual bool OnKeyReleased(const ui::KeyEvent& event) override; |
| 133 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 133 virtual void OnGestureEvent(ui::GestureEvent* event) override; |
| 134 virtual scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const | 134 virtual scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const |
| 135 OVERRIDE; | 135 override; |
| 136 | 136 |
| 137 // Whether the browser action is enabled on this tab. Note that we cannot use | 137 // Whether the browser action is enabled on this tab. Note that we cannot use |
| 138 // the built-in views enabled/SetEnabled because disabled views do not | 138 // the built-in views enabled/SetEnabled because disabled views do not |
| 139 // receive drag events. | 139 // receive drag events. |
| 140 bool IsEnabled(int tab_id) const; | 140 bool IsEnabled(int tab_id) const; |
| 141 | 141 |
| 142 // Gets the icon of this button and its badge. | 142 // Gets the icon of this button and its badge. |
| 143 gfx::ImageSkia GetIconWithBadge(); | 143 gfx::ImageSkia GetIconWithBadge(); |
| 144 | 144 |
| 145 // Returns button icon so it can be accessed during tests. | 145 // Returns button icon so it can be accessed during tests. |
| 146 gfx::ImageSkia GetIconForTest(); | 146 gfx::ImageSkia GetIconForTest(); |
| 147 | 147 |
| 148 private: | 148 private: |
| 149 // Overridden from views::View: | 149 // Overridden from views::View: |
| 150 virtual void ViewHierarchyChanged( | 150 virtual void ViewHierarchyChanged( |
| 151 const ViewHierarchyChangedDetails& details) OVERRIDE; | 151 const ViewHierarchyChangedDetails& details) override; |
| 152 virtual void OnDragDone() OVERRIDE; | 152 virtual void OnDragDone() override; |
| 153 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 153 virtual gfx::Size GetPreferredSize() const override; |
| 154 virtual void PaintChildren(gfx::Canvas* canvas, | 154 virtual void PaintChildren(gfx::Canvas* canvas, |
| 155 const views::CullSet& cull_set) OVERRIDE; | 155 const views::CullSet& cull_set) override; |
| 156 | 156 |
| 157 // ExtensionActionViewDelegate: | 157 // ExtensionActionViewDelegate: |
| 158 virtual views::View* GetAsView() OVERRIDE; | 158 virtual views::View* GetAsView() override; |
| 159 virtual bool IsShownInMenu() OVERRIDE; | 159 virtual bool IsShownInMenu() override; |
| 160 virtual views::FocusManager* GetFocusManagerForAccelerator() OVERRIDE; | 160 virtual views::FocusManager* GetFocusManagerForAccelerator() override; |
| 161 virtual views::Widget* GetParentForContextMenu() OVERRIDE; | 161 virtual views::Widget* GetParentForContextMenu() override; |
| 162 virtual ExtensionActionViewController* GetPreferredPopupViewController() | 162 virtual ExtensionActionViewController* GetPreferredPopupViewController() |
| 163 OVERRIDE; | 163 override; |
| 164 virtual views::View* GetReferenceViewForPopup() OVERRIDE; | 164 virtual views::View* GetReferenceViewForPopup() override; |
| 165 virtual views::MenuButton* GetContextMenuButton() OVERRIDE; | 165 virtual views::MenuButton* GetContextMenuButton() override; |
| 166 virtual content::WebContents* GetCurrentWebContents() OVERRIDE; | 166 virtual content::WebContents* GetCurrentWebContents() override; |
| 167 virtual void HideActivePopup() OVERRIDE; | 167 virtual void HideActivePopup() override; |
| 168 virtual void OnIconUpdated() OVERRIDE; | 168 virtual void OnIconUpdated() override; |
| 169 virtual void OnPopupShown(bool grant_tab_permissions) OVERRIDE; | 169 virtual void OnPopupShown(bool grant_tab_permissions) override; |
| 170 virtual void CleanupPopup() OVERRIDE; | 170 virtual void CleanupPopup() override; |
| 171 | 171 |
| 172 // A lock to keep the MenuButton pressed when a menu or popup is visible. | 172 // A lock to keep the MenuButton pressed when a menu or popup is visible. |
| 173 // This needs to be destroyed after |view_controller_|, because | 173 // This needs to be destroyed after |view_controller_|, because |
| 174 // |view_controller_|'s destructor can call CleanupPopup(), which uses this | 174 // |view_controller_|'s destructor can call CleanupPopup(), which uses this |
| 175 // object. | 175 // object. |
| 176 scoped_ptr<views::MenuButton::PressedLock> pressed_lock_; | 176 scoped_ptr<views::MenuButton::PressedLock> pressed_lock_; |
| 177 | 177 |
| 178 // The controller for this ExtensionAction view. | 178 // The controller for this ExtensionAction view. |
| 179 scoped_ptr<ExtensionActionViewController> view_controller_; | 179 scoped_ptr<ExtensionActionViewController> view_controller_; |
| 180 | 180 |
| 181 // Delegate that usually represents a container for BrowserActionView. | 181 // Delegate that usually represents a container for BrowserActionView. |
| 182 BrowserActionView::Delegate* delegate_; | 182 BrowserActionView::Delegate* delegate_; |
| 183 | 183 |
| 184 // Used to make sure we only register the command once. | 184 // Used to make sure we only register the command once. |
| 185 bool called_registered_extension_command_; | 185 bool called_registered_extension_command_; |
| 186 | 186 |
| 187 content::NotificationRegistrar registrar_; | 187 content::NotificationRegistrar registrar_; |
| 188 | 188 |
| 189 // The observer that we need to notify when the icon of the button has been | 189 // The observer that we need to notify when the icon of the button has been |
| 190 // updated. | 190 // updated. |
| 191 IconObserver* icon_observer_; | 191 IconObserver* icon_observer_; |
| 192 | 192 |
| 193 DISALLOW_COPY_AND_ASSIGN(BrowserActionView); | 193 DISALLOW_COPY_AND_ASSIGN(BrowserActionView); |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTION_VIEW_H_ | 196 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTION_VIEW_H_ |
| OLD | NEW |