summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_browser_actions_api.h
blob: 7853d0925360d6c0dbb76bb344a0aa345e2a3f36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) 2009 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_EXTENSIONS_EXTENSION_BROWSER_ACTIONS_API_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_ACTIONS_API_H_

#include "chrome/browser/extensions/extension_function.h"
#include "chrome/common/extensions/extension_action.h"

class ExtensionAction;
class ExtensionActionState;

class BrowserActionFunction : public SyncExtensionFunction {
 protected:
  BrowserActionFunction() : tab_id_(ExtensionAction::kDefaultTabId) {}
  virtual ~BrowserActionFunction() {}
  virtual bool RunImpl();
  virtual bool RunBrowserAction() = 0;

  // All the browser action APIs take a single argument called details that is
  // a dictionary.
  const DictionaryValue* details_;

  // The tab id the browser action function should apply to, if any, or
  // kDefaultTabId if none was specified.
  int tab_id_;

  // The browser action for the current extension.
  ExtensionAction* browser_action_;
};

class BrowserActionSetIconFunction : public BrowserActionFunction {
  ~BrowserActionSetIconFunction() {}
  virtual bool RunBrowserAction();
  DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setIcon")
};

class BrowserActionSetTitleFunction : public BrowserActionFunction {
  ~BrowserActionSetTitleFunction() {}
  virtual bool RunBrowserAction();
  DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setTitle")
};

class BrowserActionSetBadgeTextFunction : public BrowserActionFunction {
  ~BrowserActionSetBadgeTextFunction() {}
  virtual bool RunBrowserAction();
  DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setBadgeText")
};

class BrowserActionSetBadgeBackgroundColorFunction
    : public BrowserActionFunction {
  ~BrowserActionSetBadgeBackgroundColorFunction() {}
  virtual bool RunBrowserAction();
  DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setBadgeBackgroundColor")
};

#endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_ACTIONS_API_H_