| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "ui/gfx/image/image.h" | 9 #include "ui/gfx/image/image.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 class WebContents; | 12 class WebContents; |
| 13 } | 13 } |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 class Canvas; | 16 class Size; |
| 17 class Rect; | |
| 18 } | 17 } |
| 19 | 18 |
| 20 namespace ui { | 19 namespace ui { |
| 21 class MenuModel; | 20 class MenuModel; |
| 22 } | 21 } |
| 23 | 22 |
| 24 class ToolbarActionViewDelegate; | 23 class ToolbarActionViewDelegate; |
| 25 | 24 |
| 26 // The basic controller class for an action that is shown on the toolbar - | 25 // The basic controller class for an action that is shown on the toolbar - |
| 27 // an extension action (like browser actions) or a component action (like | 26 // an extension action (like browser actions) or a component action (like |
| 28 // chromecast). | 27 // chromecast). |
| 29 class ToolbarActionViewController { | 28 class ToolbarActionViewController { |
| 30 public: | 29 public: |
| 31 virtual ~ToolbarActionViewController() {} | 30 virtual ~ToolbarActionViewController() {} |
| 32 | 31 |
| 33 // Returns the unique ID of this particular action. For extensions, this is | 32 // Returns the unique ID of this particular action. For extensions, this is |
| 34 // the extension id; for component actions, this is the name of the component. | 33 // the extension id; for component actions, this is the name of the component. |
| 35 virtual const std::string& GetId() const = 0; | 34 virtual const std::string& GetId() const = 0; |
| 36 | 35 |
| 37 // Sets the view delegate, which can handle most of the front-end logic. | 36 // Sets the view delegate, which can handle most of the front-end logic. |
| 38 virtual void SetDelegate(ToolbarActionViewDelegate* delegate) = 0; | 37 virtual void SetDelegate(ToolbarActionViewDelegate* delegate) = 0; |
| 39 | 38 |
| 40 // Returns the icon to use for the given |web_contents|. | 39 // Returns the icon to use for the given |web_contents| and |size|. |
| 41 virtual gfx::Image GetIcon(content::WebContents* web_contents) = 0; | 40 virtual gfx::Image GetIcon(content::WebContents* web_contents, |
| 42 | 41 const gfx::Size& size) = 0; |
| 43 // Returns the icon and the badge, if any, for the current tab. | |
| 44 virtual gfx::ImageSkia GetIconWithBadge() = 0; | |
| 45 | 42 |
| 46 // Returns the name of the action, which can be separate from the accessible | 43 // Returns the name of the action, which can be separate from the accessible |
| 47 // name or name for the tooltip. | 44 // name or name for the tooltip. |
| 48 virtual base::string16 GetActionName() const = 0; | 45 virtual base::string16 GetActionName() const = 0; |
| 49 | 46 |
| 50 // Returns the accessible name to use for the given |web_contents|. | 47 // Returns the accessible name to use for the given |web_contents|. |
| 51 virtual base::string16 GetAccessibleName(content::WebContents* web_contents) | 48 virtual base::string16 GetAccessibleName(content::WebContents* web_contents) |
| 52 const = 0; | 49 const = 0; |
| 53 | 50 |
| 54 // Returns the tooltip to use for the given |web_contents|. | 51 // Returns the tooltip to use for the given |web_contents|. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 83 |
| 87 // Executes the default action (which is typically showing the popup). If | 84 // Executes the default action (which is typically showing the popup). If |
| 88 // |by_user| is true, then this was through a direct user action (as oppposed | 85 // |by_user| is true, then this was through a direct user action (as oppposed |
| 89 // to, e.g., an API call). | 86 // to, e.g., an API call). |
| 90 // Returns true if a popup is shown. | 87 // Returns true if a popup is shown. |
| 91 virtual bool ExecuteAction(bool by_user) = 0; | 88 virtual bool ExecuteAction(bool by_user) = 0; |
| 92 | 89 |
| 93 // Updates the current state of the action. | 90 // Updates the current state of the action. |
| 94 virtual void UpdateState() = 0; | 91 virtual void UpdateState() = 0; |
| 95 | 92 |
| 96 // Paints any extra parts of the image (e.g., a badge). | |
| 97 virtual void PaintExtra(gfx::Canvas* canvas, | |
| 98 const gfx::Rect& bounds, | |
| 99 content::WebContents* web_contents) const { | |
| 100 } | |
| 101 | |
| 102 // Registers an accelerator. Called when the view is added to the hierarchy. | 93 // Registers an accelerator. Called when the view is added to the hierarchy. |
| 103 // Unregistering any commands is the responsibility of the controller. | 94 // Unregistering any commands is the responsibility of the controller. |
| 104 virtual void RegisterCommand() { | 95 virtual void RegisterCommand() { |
| 105 } | 96 } |
| 106 }; | 97 }; |
| 107 | 98 |
| 108 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ | 99 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ |
| OLD | NEW |