summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_test_api.cc
diff options
context:
space:
mode:
authoryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-09 20:08:51 +0000
committeryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-09 20:08:51 +0000
commit0a724b214d8c644bf65fd86a45447f6a868c05c5 (patch)
treeebdfb74c4ff93edc8ced221baf74c1f53a408965 /chrome/browser/extensions/extension_test_api.cc
parent772baef77e74bc7bd50f6380dee2283839d7351a (diff)
downloadchromium_src-0a724b214d8c644bf65fd86a45447f6a868c05c5.zip
chromium_src-0a724b214d8c644bf65fd86a45447f6a868c05c5.tar.gz
chromium_src-0a724b214d8c644bf65fd86a45447f6a868c05c5.tar.bz2
Make chrome.test functions only accessible to tests.
BUG=103867 TEST=Inspect an extension and try to call chrome.test functions; they should fail. Review URL: http://codereview.chromium.org/9124027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116904 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_test_api.cc')
-rw-r--r--chrome/browser/extensions/extension_test_api.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/chrome/browser/extensions/extension_test_api.cc b/chrome/browser/extensions/extension_test_api.cc
index a8f85fc..2991708 100644
--- a/chrome/browser/extensions/extension_test_api.cc
+++ b/chrome/browser/extensions/extension_test_api.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -6,6 +6,7 @@
#include <string>
+#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
@@ -13,6 +14,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/chrome_switches.h"
#include "content/public/browser/notification_service.h"
namespace {
@@ -23,8 +25,22 @@ namespace {
// in test set up.
const char kNoTestConfigDataError[] = "Test configuration was not set.";
+const char kNotTestProcessError[] =
+ "The chrome.test namespace is only available in tests.";
+
} // namespace
+TestExtensionFunction::~TestExtensionFunction() {}
+
+void TestExtensionFunction::Run() {
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) {
+ error_ = kNotTestProcessError;
+ SendResponse(false);
+ return;
+ }
+ SendResponse(RunImpl());
+}
+
ExtensionTestPassFunction::~ExtensionTestPassFunction() {}
bool ExtensionTestPassFunction::RunImpl() {