summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-15 04:30:12 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-15 04:30:12 +0000
commit919ddc8c4928d69c3db02c68c0dbf573ebc54899 (patch)
tree74d8d509008427576fddfcf01282b897df23d261
parent6f317586c5b00ab2196d9f3dbff571bad34b8352 (diff)
downloadchromium_src-919ddc8c4928d69c3db02c68c0dbf573ebc54899.zip
chromium_src-919ddc8c4928d69c3db02c68c0dbf573ebc54899.tar.gz
chromium_src-919ddc8c4928d69c3db02c68c0dbf573ebc54899.tar.bz2
Various minor fixes:
* --load-extension no longer requires --enable-extensions * No longer support chrome:// URLs for user scripts * Remove old unused Greasemonkey test * Enable Greasemonkey API emulation in linux/mac BUG=16720,16007,4476 TEST=Added several unit tests Original review: http://codereview.chromium.org/149619 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20719 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_init.cc10
-rw-r--r--chrome/browser/extensions/extension_startup_unittest.cc152
-rw-r--r--chrome/browser/extensions/extensions_service.cc1
-rw-r--r--chrome/browser/extensions/extensions_service.h1
-rw-r--r--chrome/browser/profile.cc12
-rw-r--r--chrome/chrome.gyp1
-rw-r--r--chrome/common/extensions/url_pattern.cc4
-rw-r--r--chrome/common/extensions/url_pattern.h9
-rw-r--r--chrome/common/extensions/url_pattern_unittest.cc14
-rw-r--r--chrome/renderer/extensions/greasemonkey_api_unittest.cc86
-rw-r--r--chrome/renderer/renderer_resources.grd2
-rw-r--r--chrome/renderer/resources/greasemonkey_api.js68
-rw-r--r--chrome/renderer/user_script_slave.cc9
-rw-r--r--chrome/test/unit/unittests.vcproj4
14 files changed, 117 insertions, 256 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index d3062ef..05d614a 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -733,16 +733,6 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
static_cast<size_t>(expected_tab_count));
}
- // Extension should be loaded from path which is specified by flag
- // |kLoadExtension| once and only when the browser process is starting up.
- if (command_line.HasSwitch(switches::kLoadExtension)) {
- std::wstring path_string =
- command_line.GetSwitchValue(switches::kLoadExtension);
- FilePath path = FilePath::FromWStringHack(path_string);
- profile->GetExtensionsService()->LoadExtension(path);
- profile->GetUserScriptMaster()->AddWatchedPath(path);
- }
-
if (command_line.HasSwitch(switches::kPackExtension)) {
// Input Paths.
FilePath src_dir = FilePath::FromWStringHack(command_line.GetSwitchValue(
diff --git a/chrome/browser/extensions/extension_startup_unittest.cc b/chrome/browser/extensions/extension_startup_unittest.cc
index 540671e..74d40a9 100644
--- a/chrome/browser/extensions/extension_startup_unittest.cc
+++ b/chrome/browser/extensions/extension_startup_unittest.cc
@@ -71,6 +71,11 @@ class ExtensionStartupTestBase
file_util::CopyFile(src_dir.AppendASCII("script2.js"),
user_scripts_dir_.AppendASCII("script2.user.js"));
}
+
+ if (!load_extension_.value().empty()) {
+ command_line->AppendSwitchWithValue(switches::kLoadExtension,
+ load_extension_.ToWStringHack());
+ }
}
// NotificationObserver
@@ -91,11 +96,65 @@ class ExtensionStartupTestBase
file_util::Delete(extensions_dir_, true);
}
+ void WaitForServicesToStart(int num_expected_extensions,
+ bool expect_extensions_enabled) {
+ ExtensionsService* service = browser()->profile()->GetExtensionsService();
+ if (!service->is_ready()) {
+ registrar_.Add(this, NotificationType::EXTENSIONS_READY,
+ NotificationService::AllSources());
+ ui_test_utils::RunMessageLoop();
+ registrar_.Remove(this, NotificationType::EXTENSIONS_READY,
+ NotificationService::AllSources());
+ }
+
+ ASSERT_EQ(static_cast<uint32>(num_expected_extensions),
+ service->extensions()->size());
+ ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled());
+
+ UserScriptMaster* master = browser()->profile()->GetUserScriptMaster();
+ if (!master->ScriptsReady()) {
+ // Wait for UserScriptMaster to finish its scan.
+ registrar_.Add(this, NotificationType::USER_SCRIPTS_UPDATED,
+ NotificationService::AllSources());
+ ui_test_utils::RunMessageLoop();
+ registrar_.Remove(this, NotificationType::USER_SCRIPTS_UPDATED,
+ NotificationService::AllSources());
+ }
+ ASSERT_TRUE(master->ScriptsReady());
+ }
+
+ void TestInjection(bool expect_css, bool expect_script) {
+ // Load a page affected by the content script and test to see the effect.
+ FilePath test_file;
+ PathService::Get(chrome::DIR_TEST_DATA, &test_file);
+ test_file = test_file.AppendASCII("extensions")
+ .AppendASCII("test_file.html");
+
+ ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file));
+
+ bool result = false;
+ ui_test_utils::ExecuteJavaScriptAndExtractBool(
+ browser()->GetSelectedTabContents()->render_view_host(), L"",
+ L"window.domAutomationController.send("
+ L"document.defaultView.getComputedStyle(document.body, null)."
+ L"getPropertyValue('background-color') == 'rgb(245, 245, 220)')",
+ &result);
+ EXPECT_EQ(expect_css, result);
+
+ result = false;
+ ui_test_utils::ExecuteJavaScriptAndExtractBool(
+ browser()->GetSelectedTabContents()->render_view_host(), L"",
+ L"window.domAutomationController.send(document.title == 'Modified')",
+ &result);
+ EXPECT_EQ(expect_script, result);
+ }
+
FilePath preferences_file_;
FilePath extensions_dir_;
FilePath user_scripts_dir_;
bool enable_extensions_;
bool enable_user_scripts_;
+ FilePath load_extension_;
NotificationRegistrar registrar_;
};
@@ -112,58 +171,36 @@ class ExtensionsStartupTest : public ExtensionStartupTestBase {
};
IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, Test) {
- ExtensionsService* service = browser()->profile()->GetExtensionsService();
- if (!service->is_ready()) {
- registrar_.Add(this, NotificationType::EXTENSIONS_READY,
- NotificationService::AllSources());
- ui_test_utils::RunMessageLoop();
- registrar_.Remove(this, NotificationType::EXTENSIONS_READY,
- NotificationService::AllSources());
- }
- ASSERT_EQ(3u, service->extensions()->size());
- ASSERT_TRUE(service->extensions_enabled());
-
- UserScriptMaster* master = browser()->profile()->GetUserScriptMaster();
- if (!master->ScriptsReady()) {
- // Wait for UserScriptMaster to finish its scan.
- registrar_.Add(this, NotificationType::USER_SCRIPTS_UPDATED,
- NotificationService::AllSources());
- ui_test_utils::RunMessageLoop();
- registrar_.Remove(this, NotificationType::USER_SCRIPTS_UPDATED,
- NotificationService::AllSources());
- }
- ASSERT_TRUE(master->ScriptsReady());
+ WaitForServicesToStart(3, true);
+ TestInjection(true, true);
+}
- FilePath test_file;
- PathService::Get(chrome::DIR_TEST_DATA, &test_file);
- test_file = test_file.AppendASCII("extensions")
- .AppendASCII("test_file.html");
- // Now we should be able to load a page affected by the content script and see
- // the effect.
- ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file));
+// ExtensionsLoadTest
+// Ensures that we can startup the browser with --load-extension and see them
+// run.
- // Test that the content script ran.
- bool result = false;
- ui_test_utils::ExecuteJavaScriptAndExtractBool(
- browser()->GetSelectedTabContents()->render_view_host(), L"",
- L"window.domAutomationController.send("
- L"document.defaultView.getComputedStyle(document.body, null)."
- L"getPropertyValue('background-color') == 'rgb(245, 245, 220)')",
- &result);
- EXPECT_TRUE(result);
+class ExtensionsLoadTest : public ExtensionStartupTestBase {
+ public:
+ ExtensionsLoadTest() {
+ PathService::Get(chrome::DIR_TEST_DATA, &load_extension_);
+ load_extension_ = load_extension_
+ .AppendASCII("extensions")
+ .AppendASCII("good")
+ .AppendASCII("Extensions")
+ .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
+ .AppendASCII("1.0.0.0");
+ }
+};
- result = false;
- ui_test_utils::ExecuteJavaScriptAndExtractBool(
- browser()->GetSelectedTabContents()->render_view_host(), L"",
- L"window.domAutomationController.send(document.title == 'Modified')",
- &result);
- EXPECT_TRUE(result);
+IN_PROC_BROWSER_TEST_F(ExtensionsLoadTest, Test) {
+ WaitForServicesToStart(1, false);
+ TestInjection(true, true);
}
// ExtensionsStartupUserScriptTest
-// Tests that we can startup with --enable-user-scripts and run user sripts and
+// Tests that we can startup with --enable-user-scripts and run user scripts and
// see them do basic things.
class ExtensionsStartupUserScriptTest : public ExtensionStartupTestBase {
@@ -174,31 +211,20 @@ class ExtensionsStartupUserScriptTest : public ExtensionStartupTestBase {
};
IN_PROC_BROWSER_TEST_F(ExtensionsStartupUserScriptTest, Test) {
- UserScriptMaster* master = browser()->profile()->GetUserScriptMaster();
- if (!master->ScriptsReady()) {
- // Wait for UserScriptMaster to finish its scan.
- registrar_.Add(this, NotificationType::USER_SCRIPTS_UPDATED,
- NotificationService::AllSources());
- ui_test_utils::RunMessageLoop();
- registrar_.Remove(this, NotificationType::USER_SCRIPTS_UPDATED,
- NotificationService::AllSources());
- }
- ASSERT_TRUE(master->ScriptsReady());
+ WaitForServicesToStart(0, false);
+ TestInjection(false, true);
+}
- FilePath test_file;
- PathService::Get(chrome::DIR_TEST_DATA, &test_file);
- test_file = test_file.AppendASCII("extensions")
- .AppendASCII("test_file.html");
+// Ensure we don't inject into chrome:// URLs
+IN_PROC_BROWSER_TEST_F(ExtensionsStartupUserScriptTest, NoInjectIntoChrome) {
+ WaitForServicesToStart(0, false);
- // Now we should be able to load a page affected by the content script and see
- // the effect.
- ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file));
+ ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab"));
- // Test that the user script ran.
bool result = false;
ui_test_utils::ExecuteJavaScriptAndExtractBool(
browser()->GetSelectedTabContents()->render_view_host(), L"",
L"window.domAutomationController.send(document.title == 'Modified')",
&result);
- EXPECT_TRUE(result);
+ EXPECT_FALSE(result);
}
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 27031d8..17fd390 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -430,6 +430,7 @@ void ExtensionsService::OnExtensionsLoaded(ExtensionList* new_extensions) {
for (ExtensionList::iterator iter = new_extensions->begin();
iter != new_extensions->end(); ++iter) {
if (extensions_enabled() || (*iter)->IsTheme() ||
+ (*iter)->location() == Extension::LOAD ||
(*iter)->location() == Extension::EXTERNAL_REGISTRY) {
Extension* old = GetExtensionById((*iter)->id());
if (old) {
diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h
index 8ae2759..87c0dc7 100644
--- a/chrome/browser/extensions/extensions_service.h
+++ b/chrome/browser/extensions/extensions_service.h
@@ -34,7 +34,6 @@ class Profile;
class ResourceDispatcherHost;
class SkBitmap;
class SiteInstance;
-class UserScriptMaster;
typedef std::vector<Extension*> ExtensionList;
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index 46ba216..72bf157 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -563,6 +563,18 @@ void ProfileImpl::InitExtensions() {
false);
extensions_service_->Init();
+
+ // Load any extensions specified with --load-extension.
+ if (command_line->HasSwitch(switches::kLoadExtension)) {
+ std::wstring path_string =
+ command_line->GetSwitchValue(switches::kLoadExtension);
+ FilePath path = FilePath::FromWStringHack(path_string);
+ extensions_service_->LoadExtension(path);
+
+ // Tell UserScriptMaser to watch this extension's directory for changes so
+ // you can live edit content scripts during development.
+ user_script_master_->AddWatchedPath(path);
+ }
}
void ProfileImpl::InitWebResources() {
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 6cb5e89..3731471 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -3748,7 +3748,6 @@
'common/zip_unittest.cc',
'renderer/audio_message_filter_unittest.cc',
'renderer/extensions/extension_api_client_unittest.cc',
- 'renderer/extensions/greasemonkey_api_unittest.cc',
'renderer/extensions/json_schema_unittest.cc',
'renderer/net/render_dns_master_unittest.cc',
'renderer/net/render_dns_queue_unittest.cc',
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc
index 2fc6f56..7a4f853 100644
--- a/chrome/common/extensions/url_pattern.cc
+++ b/chrome/common/extensions/url_pattern.cc
@@ -15,12 +15,12 @@ static const char* kValidSchemes[] = {
chrome::kHttpsScheme,
chrome::kFileScheme,
chrome::kFtpScheme,
- chrome::kChromeUIScheme,
};
static const char kPathSeparator[] = "/";
-static bool IsValidScheme(const std::string& scheme) {
+// static
+bool URLPattern::IsValidScheme(const std::string& scheme) {
for (size_t i = 0; i < arraysize(kValidSchemes); ++i) {
if (scheme == kValidSchemes[i])
return true;
diff --git a/chrome/common/extensions/url_pattern.h b/chrome/common/extensions/url_pattern.h
index 08d76b0..f69cd7a 100644
--- a/chrome/common/extensions/url_pattern.h
+++ b/chrome/common/extensions/url_pattern.h
@@ -23,7 +23,6 @@
// - http://*/*
// - http://*/foo*
// - https://*.google.com/foo*bar
-// - chrome://foo/bar
// - file://monkey*
// - http://127.0.0.1/*
//
@@ -33,6 +32,7 @@
// - http://foo.*.bar/baz -- * must be first component
// - http:/bar -- scheme separator not found
// - foo://* -- invalid scheme
+// - chrome:// -- we don't support chrome internal URLs
//
// Design rationale:
// * We need to be able to tell users what 'sites' a given URLPattern will
@@ -42,8 +42,7 @@
// patterns to URLPatterns as possible. Greasemonkey @include patterns are
// simple globs, so this won't be perfect.
// * Although we would like to support any scheme, it isn't clear what to tell
-// users about URLPatterns that affect data or javascript URLs, and saying
-// something useful about chrome-extension URLs is more work, so those are
+// users about URLPatterns that affect data or javascript URLs, so those are
// left out for now.
//
// From a 2008-ish crawl of userscripts.org, the following patterns were found
@@ -70,6 +69,10 @@
// than the original glob, which is probably better than nothing.
class URLPattern {
public:
+ // Returns true if the specified scheme can be used in URL patterns, and false
+ // otherwise.
+ static bool IsValidScheme(const std::string& scheme);
+
URLPattern() : match_subdomains_(false) {}
// Initializes this instance by parsing the provided string. On failure, the
diff --git a/chrome/common/extensions/url_pattern_unittest.cc b/chrome/common/extensions/url_pattern_unittest.cc
index 3db623f..f3fec47 100644
--- a/chrome/common/extensions/url_pattern_unittest.cc
+++ b/chrome/common/extensions/url_pattern_unittest.cc
@@ -16,6 +16,7 @@ TEST(URLPatternTest, ParseInvalid) {
"http://foo.*.bar/baz", // must be first component
"http:/bar", // scheme separator not found
"foo://*", // invalid scheme
+ "chrome://*/*", // we don't support internal chrome URLs
};
for (size_t i = 0; i < arraysize(kInvalidPatterns); ++i) {
@@ -67,19 +68,6 @@ TEST(URLPatternTest, Match3) {
EXPECT_FALSE(pattern.MatchesUrl(GURL("http://yahoo.com/foobar")));
}
-// odd schemes and normalization
-TEST(URLPatternTest, Match4) {
- URLPattern pattern;
- EXPECT_TRUE(pattern.Parse("chrome://thinger/*"));
- EXPECT_EQ("chrome", pattern.scheme());
- EXPECT_EQ("thinger", pattern.host());
- EXPECT_FALSE(pattern.match_subdomains());
- EXPECT_EQ("/*", pattern.path());
- EXPECT_TRUE(pattern.MatchesUrl(GURL("chrome://thinger/foobar")));
- EXPECT_TRUE(pattern.MatchesUrl(GURL("CHROME://thinger/")));
- EXPECT_FALSE(pattern.MatchesUrl(GURL("http://thinger/")));
-}
-
// glob escaping
TEST(URLPatternTest, Match5) {
URLPattern pattern;
diff --git a/chrome/renderer/extensions/greasemonkey_api_unittest.cc b/chrome/renderer/extensions/greasemonkey_api_unittest.cc
deleted file mode 100644
index 2687953..0000000
--- a/chrome/renderer/extensions/greasemonkey_api_unittest.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// 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.
-
-#include "app/resource_bundle.h"
-#include "base/file_util.h"
-#include "base/path_service.h"
-#include "base/string_util.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/test/v8_unit_test.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-#include "grit/renderer_resources.h"
-
-// TODO(port)
-#if defined(OS_WIN)
-
-static const char kGreasemonkeyApi[] = "greasemonkey_api.js";
-static const char kGreasemonkeyApiTest[] = "greasemonkey_api_test.js";
-
-class GreasemonkeyApiTest : public V8UnitTest {
- public:
- GreasemonkeyApiTest() {}
-
- virtual void SetUp() {
- V8UnitTest::SetUp();
-
- // Add the greasemonkey api to the context.
- StringPiece api_js =
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_GREASEMONKEY_API_JS);
- ExecuteScriptInContext(api_js, kGreasemonkeyApi);
-
- // Add the test functions to the context.
- std::wstring test_js_file_path;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_js_file_path));
- file_util::AppendToPath(&test_js_file_path, L"extensions");
- file_util::AppendToPath(&test_js_file_path,
- UTF8ToWide(kGreasemonkeyApiTest));
- std::string test_js;
- ASSERT_TRUE(file_util::ReadFileToString(test_js_file_path, &test_js));
- ExecuteScriptInContext(test_js, kGreasemonkeyApiTest);
- }
-};
-
-TEST_F(GreasemonkeyApiTest, GetSetValue) {
- TestFunction("testGetSetValue");
-}
-
-TEST_F(GreasemonkeyApiTest, DeleteValue) {
- TestFunction("testDeleteValue");
-}
-
-TEST_F(GreasemonkeyApiTest, ListValues) {
- TestFunction("testListValues");
-}
-
-TEST_F(GreasemonkeyApiTest, GetResourceURL) {
- TestFunction("testGetResourceURL");
-}
-
-TEST_F(GreasemonkeyApiTest, GetResourceText) {
- TestFunction("testGetResourceText");
-}
-
-TEST_F(GreasemonkeyApiTest, AddStyle) {
- TestFunction("testAddStyle");
-}
-
-TEST_F(GreasemonkeyApiTest, XmlhttpRequest) {
- TestFunction("testXmlhttpRequest");
-}
-
-TEST_F(GreasemonkeyApiTest, RegisterMenuCommand) {
- TestFunction("testRegisterMenuCommand");
-}
-
-TEST_F(GreasemonkeyApiTest, OpenInTab) {
- TestFunction("testOpenInTab");
-}
-
-TEST_F(GreasemonkeyApiTest, Log) {
- TestFunction("testLog");
-}
-
-#endif // #if defined(OSWIN)
diff --git a/chrome/renderer/renderer_resources.grd b/chrome/renderer/renderer_resources.grd
index bdba06d..eb128c7 100644
--- a/chrome/renderer/renderer_resources.grd
+++ b/chrome/renderer/renderer_resources.grd
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This comment is only here because changes to resources are not picked up
-without changes to the corresponding grd file. mp1 -->
+without changes to the corresponding grd file. aa1 -->
<grit latest_public_release="0" current_release="1">
<outputs>
<output filename="grit/renderer_resources.h" type="rc_header">
diff --git a/chrome/renderer/resources/greasemonkey_api.js b/chrome/renderer/resources/greasemonkey_api.js
index 0ad24f0..7b829ad 100644
--- a/chrome/renderer/resources/greasemonkey_api.js
+++ b/chrome/renderer/resources/greasemonkey_api.js
@@ -7,70 +7,9 @@
// have your change take effect.
// -----------------------------------------------------------------------------
-// Implementation of the Greasemonkey API, see:
+// Partial implementation of the Greasemonkey API, see:
// http://wiki.greasespot.net/Greasemonkey_Manual:APIs
-const MIN_INT_32 = -0x80000000;
-const MAX_INT_32 = 0x7FFFFFFF;
-
-// Prefix for user script values that are stored in localStorage.
-const STORAGE_NS = "__userscript__.";
-
-function GM_getValue(name, defaultValue) {
- var value = localStorage.getItem(STORAGE_NS + name);
- return value ? value : defaultValue;
-}
-
-function GM_setValue(name, value) {
- // The values for GM_getValue() and GM_setValue() can only be boolean,
- // strings, or 32 bit integers. See the setPrefs function in:
- // http://greasemonkey.devjavu.com/browser/trunk/src/chrome/chromeFiles/content/prefmanager.js
- var goodType = false;
- switch (typeof(value)) {
- case "string":
- case "boolean":
- goodType = true;
- break;
- case "number":
- // Note that "value % 1 == 0" checks that the number is not a float.
- if (value % 1 == 0 && value >= MIN_INT_32 && value <= MAX_INT_32) {
- goodType = true;
- }
- break;
- }
-
- if (!goodType) {
- throw new Error("Unsupported type for GM_setValue. Supported types " +
- "are: string, bool, and 32 bit integers.");
- }
-
- localStorage.setItem(STORAGE_NS + name, value);
-}
-
-function GM_deleteValue(name) {
- localStorage.removeItem(STORAGE_NS + name);
-}
-
-function GM_listValues() {
- var values = [];
- for (var i = 0; i < localStorage.length; i++) {
- var key = localStorage.key(i);
- if (key.indexOf(STORAGE_NS) == 0) {
- key = key.substring(STORAGE_NS.length);
- values.push(key);
- }
- }
- return values;
-}
-
-function GM_getResourceURL(resourceName) {
- throw new Error("not implemented.");
-}
-
-function GM_getResourceText(resourceName) {
- throw new Error("not implemented.");
-}
-
function GM_addStyle(css) {
var parent = document.getElementsByTagName("head")[0];
if (!parent) {
@@ -121,11 +60,6 @@ function GM_xmlhttpRequest(details) {
xhr.send(details.data ? details.data : null);
}
-function GM_registerMenuCommand(commandName, commandFunc, accelKey,
- accelModifiers, accessKey) {
- throw new Error("not implemented.");
-}
-
function GM_openInTab(url) {
window.open(url, "");
}
diff --git a/chrome/renderer/user_script_slave.cc b/chrome/renderer/user_script_slave.cc
index afd065f..9692736 100644
--- a/chrome/renderer/user_script_slave.cc
+++ b/chrome/renderer/user_script_slave.cc
@@ -36,13 +36,8 @@ UserScriptSlave::UserScriptSlave()
: shared_memory_(NULL),
script_deleter_(&scripts_),
user_script_start_line_(0) {
- // TODO: Only windows supports resources and only windows supports user
- // scrips, so only load the Greasemonkey API on windows. Fix this when
- // better cross platofrm support is available.
-#if defined(OS_WIN)
api_js_ = ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_GREASEMONKEY_API_JS);
-#endif
// Count the number of lines that will be injected before the user script.
StringPiece::size_type pos = 0;
@@ -114,6 +109,10 @@ bool UserScriptSlave::UpdateScripts(base::SharedMemoryHandle shared_memory) {
bool UserScriptSlave::InjectScripts(WebFrame* frame,
UserScript::RunLocation location) {
+ // Don't bother if this is not a URL we inject script into.
+ if (!URLPattern::IsValidScheme(frame->GetURL().scheme()))
+ return true;
+
PerfTimer timer;
int num_matched = 0;
diff --git a/chrome/test/unit/unittests.vcproj b/chrome/test/unit/unittests.vcproj
index c61ca6b..8158588 100644
--- a/chrome/test/unit/unittests.vcproj
+++ b/chrome/test/unit/unittests.vcproj
@@ -942,10 +942,6 @@
>
</File>
<File
- RelativePath="..\..\renderer\extensions\greasemonkey_api_unittest.cc"
- >
- </File>
- <File
RelativePath="..\..\renderer\extensions\json_schema_unittest.cc"
>
</File>