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 an action that is shown on the toolbar - | |
23 // an extension action (like browser actions) or a component action (like | |
24 // chromecast). | |
25 class ToolbarActionViewController { | |
sky
2014/10/20 22:51:09
Would a better name for this be BrowserActionViewC
Devlin
2014/10/21 00:02:33
Confusingly, not necessarily. In a fairly short a
Finnur
2014/10/21 09:34:12
Yeah, I'm with Devlin here. We need a name that en
| |
26 public: | |
27 virtual ~ToolbarActionViewController() {} | |
28 | |
29 // Returns the unique ID of this particular action. For extensions, this is | |
30 // the extension id; for component actions, this is the name of the component. | |
31 virtual const std::string& GetId() const = 0; | |
32 | |
33 // Sets the view delegate, which can handle most of the front-end logic. | |
34 virtual void SetDelegate(ToolbarActionViewDelegate* delegate) = 0; | |
35 | |
36 // Returns the icon to use for the given |web_contents|. | |
37 virtual gfx::Image GetIcon(content::WebContents* web_contents) = 0; | |
38 | |
39 // Returns the icon and the badge, if any, for the current tab. | |
40 virtual gfx::ImageSkia GetIconWithBadge() = 0; | |
41 | |
42 // Returns the accessible name to use for the given |web_contents|. | |
43 virtual base::string16 GetAccessibleName(content::WebContents* web_contents) | |
44 const = 0; | |
45 | |
46 // Returns the tooltip to use for the given |web_contents|. | |
47 virtual base::string16 GetTooltip(content::WebContents* web_contents) | |
48 const = 0; | |
49 | |
50 // Returns true if the action should be enabled on the given |web_contents|. | |
51 virtual bool IsEnabled(content::WebContents* web_contents) const = 0; | |
52 | |
53 // Returns true if the action has a popup for the given |web_contents|. | |
54 virtual bool HasPopup(content::WebContents* web_contents) const = 0; | |
55 | |
56 // Hides the current popup, if one is visible. | |
57 virtual void HidePopup() = 0; | |
58 | |
59 // Returns the native view for the popup, if one is active. | |
60 virtual gfx::NativeView GetPopupNativeView() = 0; | |
61 | |
62 // Returns true if a menu is currently running for the action. | |
63 virtual bool IsMenuRunning() const = 0; | |
64 | |
65 // Returns true if this view can be dragged. This should only be true for | |
66 // extensions right now, since they are the only ones the model currently | |
67 // supports. | |
68 // TODO(devlin): Tweak the model so that it supports generic actions. | |
69 virtual bool CanDrag() const = 0; | |
70 | |
71 // Executes the default action (which is typically showing the popup). If | |
72 // |by_user| is true, then this was through a direct user action (as oppposed | |
73 // to, e.g., an API call). | |
74 // Returns true if a popup is shown. | |
75 virtual bool ExecuteAction(bool by_user) = 0; | |
76 | |
77 // Paints any extra parts of the image (e.g., a badge). | |
78 virtual void PaintExtra(gfx::Canvas* canvas, | |
79 const gfx::Rect& bounds, | |
80 content::WebContents* web_contents) const { | |
81 } | |
82 | |
83 // Registers an accelerator. Called when the view is added to the hierarchy. | |
84 // Unregistering any commands is the responsibility of the controller. | |
85 virtual void RegisterCommand() { | |
86 } | |
87 }; | |
88 | |
89 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ | |
OLD | NEW |