1// Copyright (c) 2010 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_EXTENSIONS_EXTENSION_BROWSER_ACTIONS_API_H_
6#define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_ACTIONS_API_H_
7#pragma once
8
9#include "chrome/browser/extensions/extension_function.h"
10#include "chrome/common/extensions/extension_action.h"
11
12class DictionaryValue;
13class ExtensionAction;
14
15// Base class for chrome.browserAction.* APIs.
16class BrowserActionFunction : public SyncExtensionFunction {
17 protected:
18  BrowserActionFunction()
19      : details_(NULL),
20        tab_id_(ExtensionAction::kDefaultTabId),
21        browser_action_(NULL) {}
22  virtual ~BrowserActionFunction() {}
23  virtual bool RunImpl();
24  virtual bool RunBrowserAction() = 0;
25
26  // All the browser action APIs take a single argument called details that is
27  // a dictionary.
28  DictionaryValue* details_;
29
30  // The tab id the browser action function should apply to, if any, or
31  // kDefaultTabId if none was specified.
32  int tab_id_;
33
34  // The browser action for the current extension.
35  ExtensionAction* browser_action_;
36};
37
38// Implement chrome.browserAction.setIcon().
39class BrowserActionSetIconFunction : public BrowserActionFunction {
40  ~BrowserActionSetIconFunction() {}
41  virtual bool RunBrowserAction();
42  DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setIcon")
43};
44
45// Implement chrome.browserAction.setTitle().
46class BrowserActionSetTitleFunction : public BrowserActionFunction {
47  ~BrowserActionSetTitleFunction() {}
48  virtual bool RunBrowserAction();
49  DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setTitle")
50};
51
52// Implement chrome.browserActions.setPopup().
53class BrowserActionSetPopupFunction : public BrowserActionFunction {
54  ~BrowserActionSetPopupFunction() {}
55  virtual bool RunBrowserAction();
56  DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setPopup")
57};
58
59// Implement chrome.browserAction.setBadgeText().
60class BrowserActionSetBadgeTextFunction : public BrowserActionFunction {
61  ~BrowserActionSetBadgeTextFunction() {}
62  virtual bool RunBrowserAction();
63  DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setBadgeText")
64};
65
66// Implement chrome.browserAction.setBadgeBackgroundColor().
67class BrowserActionSetBadgeBackgroundColorFunction
68    : public BrowserActionFunction {
69  ~BrowserActionSetBadgeBackgroundColorFunction() {}
70  virtual bool RunBrowserAction();
71  DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setBadgeBackgroundColor")
72};
73
74#endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_ACTIONS_API_H_
75