summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-22 17:26:38 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-22 17:26:38 +0000
commitf9b1a7b9185c0889238305d088de150d88731775 (patch)
tree10af27f4189c2d431b6fbd70127a893b7ba0a3b7 /chrome/browser/extensions
parentfbc97c595085bd98b432963b9a627610f5294052 (diff)
downloadchromium_src-f9b1a7b9185c0889238305d088de150d88731775.zip
chromium_src-f9b1a7b9185c0889238305d088de150d88731775.tar.gz
chromium_src-f9b1a7b9185c0889238305d088de150d88731775.tar.bz2
Adding the ability to remove page actions.BUG=NoneTEST=unit test.
Review URL: http://codereview.chromium.org/131003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18910 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc2
-rw-r--r--chrome/browser/extensions/extension_page_actions_module.cc14
-rw-r--r--chrome/browser/extensions/extension_page_actions_module.h11
-rwxr-xr-xchrome/browser/extensions/extension_page_actions_module_constants.cc1
-rwxr-xr-xchrome/browser/extensions/extension_page_actions_module_constants.h1
5 files changed, 25 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 6e560e16..7b873a5 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -102,6 +102,8 @@ void FactoryRegistry::ResetFunctions() {
// Page Actions.
factories_[page_actions::kEnablePageActionFunction] =
&NewExtensionFunction<EnablePageActionFunction>;
+ factories_[page_actions::kDisablePageActionFunction] =
+ &NewExtensionFunction<DisablePageActionFunction>;
// Bookmarks.
factories_[bookmarks::kGetBookmarksFunction] =
diff --git a/chrome/browser/extensions/extension_page_actions_module.cc b/chrome/browser/extensions/extension_page_actions_module.cc
index ffc5aa2..09d2c47 100644
--- a/chrome/browser/extensions/extension_page_actions_module.cc
+++ b/chrome/browser/extensions/extension_page_actions_module.cc
@@ -17,7 +17,7 @@
namespace keys = extension_page_actions_module_constants;
-bool EnablePageActionFunction::RunImpl() {
+bool PageActionFunction::SetPageActionEnabled(bool enable) {
EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST));
const ListValue* args = static_cast<const ListValue*>(args_);
@@ -64,9 +64,17 @@ bool EnablePageActionFunction::RunImpl() {
return false;
}
- // Set visible and broadcast notifications that the UI should be updated.
- contents->EnablePageAction(page_action);
+ // Set visibility and broadcast notifications that the UI should be updated.
+ contents->SetPageActionEnabled(page_action, enable);
contents->NotifyNavigationStateChanged(TabContents::INVALIDATE_PAGE_ACTIONS);
return true;
}
+
+bool EnablePageActionFunction::RunImpl() {
+ return SetPageActionEnabled(true);
+}
+
+bool DisablePageActionFunction::RunImpl() {
+ return SetPageActionEnabled(false);
+}
diff --git a/chrome/browser/extensions/extension_page_actions_module.h b/chrome/browser/extensions/extension_page_actions_module.h
index b6e9d87..48ed414 100644
--- a/chrome/browser/extensions/extension_page_actions_module.h
+++ b/chrome/browser/extensions/extension_page_actions_module.h
@@ -7,7 +7,16 @@
#include "chrome/browser/extensions/extension_function.h"
-class EnablePageActionFunction : public SyncExtensionFunction {
+class PageActionFunction : public SyncExtensionFunction {
+ protected:
+ bool SetPageActionEnabled(bool enable);
+};
+
+class EnablePageActionFunction : public PageActionFunction {
+ virtual bool RunImpl();
+};
+
+class DisablePageActionFunction : public PageActionFunction {
virtual bool RunImpl();
};
diff --git a/chrome/browser/extensions/extension_page_actions_module_constants.cc b/chrome/browser/extensions/extension_page_actions_module_constants.cc
index 5471483..e58264b 100755
--- a/chrome/browser/extensions/extension_page_actions_module_constants.cc
+++ b/chrome/browser/extensions/extension_page_actions_module_constants.cc
@@ -15,5 +15,6 @@ const char kNoPageActionError[] = "No PageAction with id: *.";
const char kUrlNotActiveError[] = "This url is no longer active: *.";
const char kEnablePageActionFunction[] = "EnablePageAction";
+const char kDisablePageActionFunction[] = "DisablePageAction";
} // namespace extension_page_actions_module_constants
diff --git a/chrome/browser/extensions/extension_page_actions_module_constants.h b/chrome/browser/extensions/extension_page_actions_module_constants.h
index a3ce33c..bf28b9f 100755
--- a/chrome/browser/extensions/extension_page_actions_module_constants.h
+++ b/chrome/browser/extensions/extension_page_actions_module_constants.h
@@ -21,6 +21,7 @@ extern const char kUrlNotActiveError[];
// Function names.
extern const char kEnablePageActionFunction[];
+extern const char kDisablePageActionFunction[];
}; // namespace extension_page_actions_module_constants