OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/extensions_ui.h" | 5 #include "chrome/browser/extensions/extensions_ui.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/thread.h" | 10 #include "base/thread.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 232 } |
233 | 233 |
234 static void CreateScriptFileDetailValue( | 234 static void CreateScriptFileDetailValue( |
235 const FilePath& extension_path, const UserScript::FileList& scripts, | 235 const FilePath& extension_path, const UserScript::FileList& scripts, |
236 const wchar_t* key, DictionaryValue* script_data) { | 236 const wchar_t* key, DictionaryValue* script_data) { |
237 if (scripts.empty()) | 237 if (scripts.empty()) |
238 return; | 238 return; |
239 | 239 |
240 ListValue *list = new ListValue(); | 240 ListValue *list = new ListValue(); |
241 for (size_t i = 0; i < scripts.size(); ++i) { | 241 for (size_t i = 0; i < scripts.size(); ++i) { |
242 const UserScript::File &file = scripts[i]; | 242 const UserScript::File& file = scripts[i]; |
243 // We are passing through GURLs to canonicalize the output to a valid | 243 // TODO(cira): this information is not used on extension page yet. We |
244 // URL path fragment. | 244 // may want to display actual resource that got loaded, not default. |
245 GURL script_url = net::FilePathToFileURL(file.path()); | 245 list->Append( |
246 GURL extension_url = net::FilePathToFileURL(extension_path); | 246 new StringValue(file.resource().relative_path().value())); |
247 std::string relative_path = | |
248 script_url.spec().substr(extension_url.spec().length() + 1); | |
249 | |
250 list->Append(new StringValue(relative_path)); | |
251 } | 247 } |
252 script_data->Set(key, list); | 248 script_data->Set(key, list); |
253 } | 249 } |
254 | 250 |
255 // Static | 251 // Static |
256 DictionaryValue* ExtensionsDOMHandler::CreateContentScriptDetailValue( | 252 DictionaryValue* ExtensionsDOMHandler::CreateContentScriptDetailValue( |
257 const UserScript& script, const FilePath& extension_path) { | 253 const UserScript& script, const FilePath& extension_path) { |
258 DictionaryValue* script_data = new DictionaryValue(); | 254 DictionaryValue* script_data = new DictionaryValue(); |
259 CreateScriptFileDetailValue(extension_path, script.js_scripts(), L"js", | 255 CreateScriptFileDetailValue(extension_path, script.js_scripts(), L"js", |
260 script_data); | 256 script_data); |
(...skipping 24 matching lines...) Expand all Loading... |
285 extension_data->SetString(L"name", extension->name()); | 281 extension_data->SetString(L"name", extension->name()); |
286 extension_data->SetString(L"description", extension->description()); | 282 extension_data->SetString(L"description", extension->description()); |
287 extension_data->SetString(L"version", extension->version()->GetString()); | 283 extension_data->SetString(L"version", extension->version()->GetString()); |
288 extension_data->SetBoolean(L"enabled", enabled); | 284 extension_data->SetBoolean(L"enabled", enabled); |
289 | 285 |
290 // Add list of content_script detail DictionaryValues | 286 // Add list of content_script detail DictionaryValues |
291 ListValue *content_script_list = new ListValue(); | 287 ListValue *content_script_list = new ListValue(); |
292 UserScriptList content_scripts = extension->content_scripts(); | 288 UserScriptList content_scripts = extension->content_scripts(); |
293 for (UserScriptList::const_iterator script = content_scripts.begin(); | 289 for (UserScriptList::const_iterator script = content_scripts.begin(); |
294 script != content_scripts.end(); ++script) { | 290 script != content_scripts.end(); ++script) { |
295 content_script_list->Append(CreateContentScriptDetailValue(*script, | 291 content_script_list->Append( |
296 extension->path())); | 292 CreateContentScriptDetailValue(*script, extension->path())); |
297 } | 293 } |
298 extension_data->Set(L"content_scripts", content_script_list); | 294 extension_data->Set(L"content_scripts", content_script_list); |
299 | 295 |
300 // Add permissions | 296 // Add permissions |
301 ListValue *permission_list = new ListValue; | 297 ListValue *permission_list = new ListValue; |
302 std::vector<URLPattern> permissions = extension->host_permissions(); | 298 std::vector<URLPattern> permissions = extension->host_permissions(); |
303 for (std::vector<URLPattern>::iterator permission = permissions.begin(); | 299 for (std::vector<URLPattern>::iterator permission = permissions.begin(); |
304 permission != permissions.end(); ++permission) { | 300 permission != permissions.end(); ++permission) { |
305 permission_list->Append(Value::CreateStringValue( | 301 permission_list->Append(Value::CreateStringValue( |
306 permission->GetAsString())); | 302 permission->GetAsString())); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 AddMessageHandler(handler); | 351 AddMessageHandler(handler); |
356 handler->Attach(this); | 352 handler->Attach(this); |
357 | 353 |
358 ExtensionsUIHTMLSource* html_source = new ExtensionsUIHTMLSource(); | 354 ExtensionsUIHTMLSource* html_source = new ExtensionsUIHTMLSource(); |
359 | 355 |
360 // Set up the chrome://extensions/ source. | 356 // Set up the chrome://extensions/ source. |
361 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 357 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
362 NewRunnableMethod(&chrome_url_data_manager, | 358 NewRunnableMethod(&chrome_url_data_manager, |
363 &ChromeURLDataManager::AddDataSource, html_source)); | 359 &ChromeURLDataManager::AddDataSource, html_source)); |
364 } | 360 } |
OLD | NEW |