Chromium Code Reviews| Index: chrome/browser/ui/views/toolbar/toolbar_action_view_controller.h |
| diff --git a/chrome/browser/ui/views/toolbar/toolbar_action_view_controller.h b/chrome/browser/ui/views/toolbar/toolbar_action_view_controller.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2649bc045983d80dc0337760a1c6e9c5812a8aaa |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/toolbar/toolbar_action_view_controller.h |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ |
| +#define CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ |
| + |
| +#include "base/strings/string16.h" |
| +#include "ui/gfx/image/image.h" |
| + |
| +namespace gfx { |
| +class Canvas; |
| +class Rect; |
| +} |
| + |
| +class ToolbarActionViewDelegate; |
| + |
| +// The basic controller class for actions that are shown on the toolbar, |
| +// extension actions (like browser actions) and chrome actions (like |
| +// chromecast). |
| +class ToolbarActionViewController { |
|
sky
2014/10/15 23:52:30
I'm surprised this class doesn't know about the nu
Devlin
2014/10/16 16:46:39
There's one controller per action per view.
|
| + public: |
| + virtual ~ToolbarActionViewController() {} |
| + |
| + // Sets the view delegate, which can handle most of the front-end logic. |
| + virtual void SetDelegate(ToolbarActionViewDelegate* delegate) = 0; |
| + |
| + // Returns the icon to use for the given |tab_id|. |
| + virtual gfx::Image GetIcon(int tab_id) = 0; |
|
sky
2014/10/15 23:52:30
It's not clear at all what |tab_id| is, not why th
Devlin
2014/10/16 16:46:39
There is currently one ToolbarActionViewController
sky
2014/10/16 18:13:39
I'm ok with what you have. What isn't all clear th
Devlin
2014/10/16 22:05:27
Ah, I see. I didn't realize that tab ids weren't
|
| + |
| + // Returns the accessible name to use for the given |tab_id|. |
| + virtual base::string16 GetAccessibleName(int tab_id) const = 0; |
| + |
| + // Returns the tooltip to use for the given |tab_id|. |
| + virtual base::string16 GetTooltip(int tab_id) const = 0; |
| + |
| + // Returns true if the action should be enabled on the given |tab_id|. |
| + virtual bool IsEnabled(int tab_id) const = 0; |
| + |
| + // Returns true if the action has a popup for the given |tab_id|. |
| + virtual bool HasPopup(int tab_id) const = 0; |
| + |
| + // Hides the current popup, if one is visible. |
| + virtual void HidePopup() = 0; |
| + |
| + // Returns true if a menu is currently running for the action. |
| + virtual bool IsMenuRunning() const = 0; |
| + |
| + // Executes the default action (typically showing the popup), and attributes |
| + // the action to a user (thus, only use this for actions that *were* done by |
| + // the user). |
| + virtual void ExecuteActionByUser() = 0; |
| + |
| + // Paints any extra parts of the image (e.g., a badge). |
| + virtual void PaintExtra(gfx::Canvas* canvas, |
| + const gfx::Rect& bounds, |
| + int tab_id) const { |
| + } |
| + |
| + // Registers an accelerator. Called when the view is added to the hierarchy. |
| + // Unregistering any commands is the responsibility of the controller. |
| + virtual void RegisterCommand() { |
| + } |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_ |