• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2009 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_PAGE_ACTIONS_MODULE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PAGE_ACTIONS_MODULE_H_
7 #pragma once
8 
9 #include "chrome/browser/extensions/extension_function.h"
10 
11 class TabContentsWrapper;
12 class ExtensionAction;
13 
14 // Base class for page action APIs.
15 class PageActionFunction : public SyncExtensionFunction {
16  protected:
~PageActionFunction()17   virtual ~PageActionFunction() {}
18   bool SetPageActionEnabled(bool enable);
19 
20   bool InitCommon(int tab_id);
21   bool SetVisible(bool visible);
22 
23   ExtensionAction* page_action_;
24   TabContentsWrapper* contents_;
25 };
26 
27 // Implement chrome.pageActions.enableForTab().
28 class EnablePageActionFunction : public PageActionFunction {
~EnablePageActionFunction()29   ~EnablePageActionFunction() {}
30   virtual bool RunImpl();
31   DECLARE_EXTENSION_FUNCTION_NAME("pageActions.enableForTab")
32 };
33 
34 // Implement chrome.pageActions.disableForTab().
35 class DisablePageActionFunction : public PageActionFunction {
~DisablePageActionFunction()36   ~DisablePageActionFunction() {}
37   virtual bool RunImpl();
38   DECLARE_EXTENSION_FUNCTION_NAME("pageActions.disableForTab")
39 };
40 
41 // Implement chrome.pageActions.show().
42 class PageActionShowFunction : public PageActionFunction {
~PageActionShowFunction()43   ~PageActionShowFunction() {}
44   virtual bool RunImpl();
45   DECLARE_EXTENSION_FUNCTION_NAME("pageAction.show")
46 };
47 
48 // Implement chrome.pageActions.hide().
49 class PageActionHideFunction : public PageActionFunction {
~PageActionHideFunction()50   ~PageActionHideFunction() {}
51   virtual bool RunImpl();
52   DECLARE_EXTENSION_FUNCTION_NAME("pageAction.hide")
53 };
54 
55 // Implement chrome.pageActions.setIcon().
56 class PageActionSetIconFunction : public PageActionFunction {
~PageActionSetIconFunction()57   ~PageActionSetIconFunction() {}
58   virtual bool RunImpl();
59   DECLARE_EXTENSION_FUNCTION_NAME("pageAction.setIcon")
60 };
61 
62 // Implement chrome.pageActions.setTitle().
63 class PageActionSetTitleFunction : public PageActionFunction {
~PageActionSetTitleFunction()64   ~PageActionSetTitleFunction() {}
65   virtual bool RunImpl();
66   DECLARE_EXTENSION_FUNCTION_NAME("pageAction.setTitle")
67 };
68 
69 // Implement chrome.pageActions.setPopup().
70 class PageActionSetPopupFunction : public PageActionFunction {
~PageActionSetPopupFunction()71   ~PageActionSetPopupFunction() {}
72   virtual bool RunImpl();
73   DECLARE_EXTENSION_FUNCTION_NAME("pageAction.setPopup")
74 };
75 
76 // Implement chrome.pageActions.setBadgeBackgroundColor().
77 class PageActionSetBadgeBackgroundColorFunction : public PageActionFunction {
~PageActionSetBadgeBackgroundColorFunction()78   ~PageActionSetBadgeBackgroundColorFunction() {}
79   virtual bool RunImpl();
80   DECLARE_EXTENSION_FUNCTION_NAME("pageAction.setBadgeBackgroundColor")
81 };
82 
83 // Implement chrome.pageActions.setBadgeTextColor().
84 class PageActionSetBadgeTextColorFunction : public PageActionFunction {
~PageActionSetBadgeTextColorFunction()85   ~PageActionSetBadgeTextColorFunction() {}
86   virtual bool RunImpl();
87   DECLARE_EXTENSION_FUNCTION_NAME("pageAction.setBadgeTextColor")
88 };
89 
90 // Implement chrome.pageActions.setBadgeText().
91 class PageActionSetBadgeTextFunction : public PageActionFunction {
~PageActionSetBadgeTextFunction()92   ~PageActionSetBadgeTextFunction() {}
93   virtual bool RunImpl();
94   DECLARE_EXTENSION_FUNCTION_NAME("pageAction.setBadgeText")
95 };
96 
97 #endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_PAGE_ACTIONS_MODULE_H_
98