summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension.cc
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-05 22:51:54 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-05 22:51:54 +0000
commitd2a69e2fccc65e8c74b770343cecad7a1136f9fd (patch)
treeefc684e21d7ef65d72dcb31fba6a01184df8407b /chrome/browser/extensions/extension.cc
parenta60551c712b36d6241c234cd81ae2a847f323ec5 (diff)
downloadchromium_src-d2a69e2fccc65e8c74b770343cecad7a1136f9fd.zip
chromium_src-d2a69e2fccc65e8c74b770343cecad7a1136f9fd.tar.gz
chromium_src-d2a69e2fccc65e8c74b770343cecad7a1136f9fd.tar.bz2
Integrate URLPattern with Extension user scripts.
Also refactored the UserScript class in UserScriptSlave and the UserScriptInfo structure in UserScriptMaster into a common location. Review URL: http://codereview.chromium.org/21070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9270 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension.cc')
-rw-r--r--chrome/browser/extensions/extension.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/chrome/browser/extensions/extension.cc b/chrome/browser/extensions/extension.cc
index f932eff..11cab38 100644
--- a/chrome/browser/extensions/extension.cc
+++ b/chrome/browser/extensions/extension.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/string_util.h"
#include "net/base/net_util.h"
+#include "chrome/common/extensions/user_script.h"
const char kExtensionURLScheme[] = "chrome-extension";
const char kUserScriptURLScheme[] = "chrome-user-script";
@@ -262,16 +263,23 @@ bool Extension::InitFromValue(const DictionaryValue& source,
return false;
}
- UserScriptInfo script_info;
+ UserScript script;
for (size_t j = 0; j < matches->GetSize(); ++j) {
- std::string match;
- if (!matches->GetString(j, &match)) {
+ std::string match_str;
+ if (!matches->GetString(j, &match_str)) {
*error = FormatErrorMessage(kInvalidMatchError, IntToString(i),
IntToString(j));
return false;
}
- script_info.matches.push_back(match);
+ URLPattern pattern;
+ if (!pattern.Parse(match_str)) {
+ *error = FormatErrorMessage(kInvalidMatchError, IntToString(i),
+ IntToString(j));
+ return false;
+ }
+
+ script.add_url_pattern(pattern);
}
// TODO(aa): Support multiple files.
@@ -281,10 +289,10 @@ bool Extension::InitFromValue(const DictionaryValue& source,
IntToString(0));
return false;
}
- script_info.path = Extension::GetResourcePath(path(), file);
- script_info.url = Extension::GetResourceURL(url(), file);
+ script.set_path(Extension::GetResourcePath(path(), file));
+ script.set_url(Extension::GetResourceURL(url(), file));
- user_scripts_.push_back(script_info);
+ user_scripts_.push_back(script);
}
}