Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5301)

Unified Diff: chrome/browser/ui/toolbar/toolbar_action_view_controller.h

Issue 661493004: Add infrastructure for Chrome Actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sky's I Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/toolbar/toolbar_action_view_controller.h
diff --git a/chrome/browser/ui/toolbar/toolbar_action_view_controller.h b/chrome/browser/ui/toolbar/toolbar_action_view_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..c7574a26e330c6a3079e07d43ced396a8d97ca84
--- /dev/null
+++ b/chrome/browser/ui/toolbar/toolbar_action_view_controller.h
@@ -0,0 +1,81 @@
+// 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_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_
+#define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_
+
+#include "base/strings/string16.h"
+#include "ui/gfx/image/image.h"
+
+namespace content {
+class WebContents;
+}
+
+namespace gfx {
+class Canvas;
+class Rect;
+}
+
+class ToolbarActionViewDelegate;
+
+// 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.
+// extension actions (like browser actions) and chrome actions (like
+// chromecast).
+class ToolbarActionViewController {
+ public:
+ // The different types of toolbar actions.
+ enum Type {
+ TYPE_EXTENSION_ACTION,
+ TYPE_COMPONENT_ACTION,
+ };
+
+ virtual ~ToolbarActionViewController() {}
+
+ // Get the type of action the view controller represents.
+ 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.
+
+ // 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(content::WebContents* web_contents) = 0;
+
+ // Returns the accessible name to use for the given |tab_id|.
+ virtual base::string16 GetAccessibleName(content::WebContents* web_contents)
+ const = 0;
+
+ // Returns the tooltip to use for the given |tab_id|.
+ virtual base::string16 GetTooltip(content::WebContents* web_contents)
+ const = 0;
+
+ // Returns true if the action should be enabled on the given |tab_id|.
+ virtual bool IsEnabled(content::WebContents* web_contents) const = 0;
+
+ // Returns true if the action has a popup for the given |tab_id|.
+ virtual bool HasPopup(content::WebContents* web_contents) 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,
+ content::WebContents* web_contents) 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_TOOLBAR_TOOLBAR_ACTION_VIEW_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698