summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension_action.h
blob: 445f98eea2892b76ec78717b0e84cb72cc08966f (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// 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_COMMON_EXTENSIONS_EXTENSION_ACTION_H_
#define CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_

#include <map>
#include <string>
#include <vector>

#include "base/basictypes.h"

class ExtensionAction {
 public:
  ExtensionAction();
  virtual ~ExtensionAction();

  typedef enum {
    PAGE_ACTION = 0,
    BROWSER_ACTION = 1,
  } ExtensionActionType;

  std::string id() const { return id_; }
  void set_id(const std::string& id) { id_ = id; }

  ExtensionActionType type() const { return type_; }
  void set_type(ExtensionActionType type) { type_ = type; }

  std::string extension_id() const { return extension_id_; }
  void set_extension_id(const std::string& extension_id) {
    extension_id_ = extension_id;
  }

  std::string name() const { return name_; }
  void set_name(const std::string& name) { name_ = name; }

  const std::vector<std::string>& icon_paths() const { return icon_paths_; }
  void AddIconPath(const std::string& icon_path) {
    icon_paths_.push_back(icon_path);
  }

 private:
  // The id for the ExtensionAction, for example: "RssPageAction".
  // For BrowserActions this is blank.
  std::string id_;

  // The type of the ExtensionAction, either PageAction or BrowserAction.
  ExtensionActionType type_;

  // The id for the extension this ExtensionAction belongs to (as defined in
  // the extension manifest).
  std::string extension_id_;

  // The name of the ExtensionAction.
  std::string name_;

  // The paths to the icons that this PageIcon can show.
  std::vector<std::string> icon_paths_;
};

typedef std::map<std::string, ExtensionAction*> ExtensionActionMap;

// This class keeps track of what values each tab uses to override the default
// values of the ExtensionAction.
class ExtensionActionState {
 public:
  ExtensionActionState(std::string title, int icon_index)
    : title_(title), icon_index_(icon_index) {
  }

  std::string title() const { return title_; }
  int icon_index() const { return icon_index_; }

 private:
  // The title to use.
  std::string title_;

  // The icon to use.
  int icon_index_;

  DISALLOW_COPY_AND_ASSIGN(ExtensionActionState);
};

#endif  // CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_