From 3cfbd0eb2afd2cf0b8b248d6bb97ec39b064cd23 Mon Sep 17 00:00:00 2001 From: "georged@chromium.org" <georged@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> Date: Wed, 18 Mar 2009 21:26:24 +0000 Subject: Review URL: http://codereview.chromium.org/42288 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12016 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/extensions/extensions_ui.cc | 38 ++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'chrome/browser/extensions/extensions_ui.cc') 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(); -- cgit v1.1