diff options
author | georged@chromium.org <georged@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-18 21:26:24 +0000 |
---|---|---|
committer | georged@chromium.org <georged@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-18 21:26:24 +0000 |
commit | 3cfbd0eb2afd2cf0b8b248d6bb97ec39b064cd23 (patch) | |
tree | eaa3eddbc15cf6bac88d04c4766778fd545f95c0 /chrome/browser/extensions/extensions_ui.cc | |
parent | 836827406c7135b0225474d24b9d08dd8edff27a (diff) | |
download | chromium_src-3cfbd0eb2afd2cf0b8b248d6bb97ec39b064cd23.zip chromium_src-3cfbd0eb2afd2cf0b8b248d6bb97ec39b064cd23.tar.gz chromium_src-3cfbd0eb2afd2cf0b8b248d6bb97ec39b064cd23.tar.bz2 |
Review URL: http://codereview.chromium.org/42288
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12016 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extensions_ui.cc')
-rw-r--r-- | chrome/browser/extensions/extensions_ui.cc | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index 3048172..ee273dc 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -85,23 +85,35 @@ void ExtensionsDOMHandler::HandleRequestExtensionsData(const Value* value) { dom_ui_->CallJavascriptFunction(L"returnExtensionsData", results); } +static void CreateScriptFileDetailValue( + const FilePath& extension_path, const UserScript::FileList& scripts, + const wchar_t* key, DictionaryValue* script_data) { + if (scripts.empty()) + return; + + ListValue *list = new ListValue(); + for (size_t i = 0; i < scripts.size(); ++i) { + const UserScript::File &file = scripts[i]; + // We are passing through GURLs to canonicalize the output to a valid + // URL path fragment. + GURL script_url = net::FilePathToFileURL(file.path()); + GURL extension_url = net::FilePathToFileURL(extension_path); + std::string relative_path = + script_url.spec().substr(extension_url.spec().length() + 1); + + list->Append(new StringValue(relative_path)); + } + script_data->Set(key, list); +} + // Static DictionaryValue* ExtensionsDOMHandler::CreateContentScriptDetailValue( const UserScript& script, const FilePath& extension_path) { DictionaryValue* script_data = new DictionaryValue(); - - // TODO(rafaelw): When UserScript supports multiple js, this will have to - // put them all in this list; - ListValue *js_list = new ListValue(); - // We are passing through GURLs to canonicalize the output to a valid - // URL path fragment. - GURL script_url = net::FilePathToFileURL(script.path()); - GURL extension_url = net::FilePathToFileURL(extension_path); - std::string relative_js_path = - script_url.spec().substr(extension_url.spec().length() + 1); - - js_list->Append(new StringValue(relative_js_path)); - script_data->Set(L"js", js_list); + CreateScriptFileDetailValue(extension_path, script.js_scripts(), L"js", + script_data); + CreateScriptFileDetailValue(extension_path, script.css_scripts(), L"css", + script_data); // Get list of glob "matches" strings ListValue *url_pattern_list = new ListValue(); |