summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_page_actions_module.cc
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 06:05:40 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 06:05:40 +0000
commitf93914857eb403a7aecf9154d14efae2703077e9 (patch)
tree816be10bf84bf1e7dca953092b23975ada90eb59 /chrome/browser/extensions/extension_page_actions_module.cc
parentab49e2e3c7f3fef9ebbf9749e8bf06765f644c21 (diff)
downloadchromium_src-f93914857eb403a7aecf9154d14efae2703077e9.zip
chromium_src-f93914857eb403a7aecf9154d14efae2703077e9.tar.gz
chromium_src-f93914857eb403a7aecf9154d14efae2703077e9.tar.bz2
Separate out the string constants used for extension API function
names, function parameter keys, error messages and event names so that they can be reused when writing extension UI tests. Original review: http://codereview.chromium.org/113771 Review URL: http://codereview.chromium.org/113831 Patch from Joi Sigurdsson <joi.sigurdsson@gmail.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16867 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_page_actions_module.cc')
-rw-r--r--chrome/browser/extensions/extension_page_actions_module.cc22
1 files changed, 9 insertions, 13 deletions
diff --git a/chrome/browser/extensions/extension_page_actions_module.cc b/chrome/browser/extensions/extension_page_actions_module.cc
index d1fa723..fb686d8 100644
--- a/chrome/browser/extensions/extension_page_actions_module.cc
+++ b/chrome/browser/extensions/extension_page_actions_module.cc
@@ -9,17 +9,12 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/extensions/extension.h"
#include "chrome/browser/extensions/extension_error_utils.h"
+#include "chrome/browser/extensions/extension_page_actions_module_constants.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
-namespace {
- // Error messages.
- const char* kNoExtensionError = "No extension with id: *.";
- const char* kNoTabError = "No tab with id: *.";
- const char* kNoPageActionError = "No PageAction with id: *.";
- const char* kUrlNotActiveError = "This url is no longer active: *.";
-}
+namespace keys = extension_page_actions_module_constants;
bool EnablePageActionFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST));
@@ -31,22 +26,23 @@ bool EnablePageActionFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(args->GetDictionary(1, &action));
int tab_id;
- EXTENSION_FUNCTION_VALIDATE(action->GetInteger(L"tabId", &tab_id));
+ EXTENSION_FUNCTION_VALIDATE(action->GetInteger(keys::kTabIdKey, &tab_id));
std::string url;
- EXTENSION_FUNCTION_VALIDATE(action->GetString(L"url", &url));
+ EXTENSION_FUNCTION_VALIDATE(action->GetString(keys::kUrlKey, &url));
// Find the TabContents that contains this tab id.
TabContents* contents = NULL;
ExtensionTabUtil::GetTabById(tab_id, profile(), NULL, NULL, &contents, NULL);
if (!contents) {
- error_ = ExtensionErrorUtils::FormatErrorMessage(kNoTabError,
+ error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoTabError,
IntToString(tab_id));
return false;
}
// Make sure the URL hasn't changed.
if (url != contents->controller().GetActiveEntry()->url().spec()) {
- error_ = ExtensionErrorUtils::FormatErrorMessage(kUrlNotActiveError, url);
+ error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kUrlNotActiveError,
+ url);
return false;
}
@@ -55,14 +51,14 @@ bool EnablePageActionFunction::RunImpl() {
ExtensionsService* service = profile()->GetExtensionsService();
extension = service->GetExtensionByID(extension_id());
if (!extension) {
- error_ = ExtensionErrorUtils::FormatErrorMessage(kNoExtensionError,
+ error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoExtensionError,
extension_id());
return false;
}
const PageAction* page_action = extension->GetPageAction(page_action_id);
if (!page_action) {
- error_ = ExtensionErrorUtils::FormatErrorMessage(kNoPageActionError,
+ error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoPageActionError,
page_action_id);
return false;
}