Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ | |
| 7 | |
| 8 #include "base/strings/string16.h" | |
| 9 #include "ui/gfx/image/image.h" | |
| 10 | |
| 11 namespace content { | |
| 12 class WebContents; | |
| 13 } | |
| 14 | |
| 15 namespace gfx { | |
| 16 class Canvas; | |
| 17 class Rect; | |
| 18 } | |
| 19 | |
| 20 class ToolbarActionViewDelegate; | |
| 21 | |
| 22 // The basic controller class for actions that are shown on the toolbar, | |
|
sky
2014/10/16 23:03:33
This is a bit misleading. This is the controller f
Devlin
2014/10/17 16:33:32
Right. Rephrased to make that more clear.
| |
| 23 // extension actions (like browser actions) and chrome actions (like | |
| 24 // chromecast). | |
| 25 class ToolbarActionViewController { | |
| 26 public: | |
| 27 // The different types of toolbar actions. | |
| 28 enum Type { | |
| 29 TYPE_EXTENSION_ACTION, | |
| 30 TYPE_COMPONENT_ACTION, | |
| 31 }; | |
| 32 | |
| 33 virtual ~ToolbarActionViewController() {} | |
| 34 | |
| 35 // Get the type of action the view controller represents. | |
| 36 virtual Type GetType() const = 0; | |
|
sky
2014/10/16 23:03:34
Why do you need to expose the type? You seem to us
Devlin
2014/10/17 00:31:20
Sure! As long as you don't mind longer reviews. ;
Finnur
2014/10/17 09:57:01
Understood.
| |
| 37 | |
| 38 // Sets the view delegate, which can handle most of the front-end logic. | |
| 39 virtual void SetDelegate(ToolbarActionViewDelegate* delegate) = 0; | |
| 40 | |
| 41 // Returns the icon to use for the given |tab_id|. | |
| 42 virtual gfx::Image GetIcon(content::WebContents* web_contents) = 0; | |
| 43 | |
| 44 // Returns the accessible name to use for the given |tab_id|. | |
| 45 virtual base::string16 GetAccessibleName(content::WebContents* web_contents) | |
| 46 const = 0; | |
| 47 | |
| 48 // Returns the tooltip to use for the given |tab_id|. | |
| 49 virtual base::string16 GetTooltip(content::WebContents* web_contents) | |
| 50 const = 0; | |
| 51 | |
| 52 // Returns true if the action should be enabled on the given |tab_id|. | |
| 53 virtual bool IsEnabled(content::WebContents* web_contents) const = 0; | |
| 54 | |
| 55 // Returns true if the action has a popup for the given |tab_id|. | |
| 56 virtual bool HasPopup(content::WebContents* web_contents) const = 0; | |
| 57 | |
| 58 // Hides the current popup, if one is visible. | |
| 59 virtual void HidePopup() = 0; | |
| 60 | |
| 61 // Returns true if a menu is currently running for the action. | |
| 62 virtual bool IsMenuRunning() const = 0; | |
| 63 | |
| 64 // Executes the default action (typically showing the popup), and attributes | |
| 65 // the action to a user (thus, only use this for actions that *were* done by | |
| 66 // the user). | |
| 67 virtual void ExecuteActionByUser() = 0; | |
| 68 | |
| 69 // Paints any extra parts of the image (e.g., a badge). | |
| 70 virtual void PaintExtra(gfx::Canvas* canvas, | |
| 71 const gfx::Rect& bounds, | |
| 72 content::WebContents* web_contents) const { | |
| 73 } | |
| 74 | |
| 75 // Registers an accelerator. Called when the view is added to the hierarchy. | |
| 76 // Unregistering any commands is the responsibility of the controller. | |
| 77 virtual void RegisterCommand() { | |
| 78 } | |
| 79 }; | |
| 80 | |
| 81 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ | |
| OLD | NEW |