OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 Value* value; | 264 Value* value; |
265 std::wstring relative; | 265 std::wstring relative; |
266 if (!js->Get(script_index, &value) || !value->GetAsString(&relative)) { | 266 if (!js->Get(script_index, &value) || !value->GetAsString(&relative)) { |
267 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidJs, | 267 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidJs, |
268 IntToString(definition_index), IntToString(script_index)); | 268 IntToString(definition_index), IntToString(script_index)); |
269 return false; | 269 return false; |
270 } | 270 } |
271 // TODO(georged): Make GetResourceURL accept wstring too | 271 // TODO(georged): Make GetResourceURL accept wstring too |
272 GURL url = GetResourceURL(WideToUTF8(relative)); | 272 GURL url = GetResourceURL(WideToUTF8(relative)); |
273 ExtensionResource resource = GetResource(WideToUTF8(relative)); | 273 ExtensionResource resource = GetResource(WideToUTF8(relative)); |
274 result->js_scripts().push_back(UserScript::File(resource, url)); | 274 result->js_scripts().push_back(UserScript::File( |
| 275 resource.extension_root(), resource.relative_path(), url)); |
275 } | 276 } |
276 } | 277 } |
277 | 278 |
278 if (css) { | 279 if (css) { |
279 for (size_t script_index = 0; script_index < css->GetSize(); | 280 for (size_t script_index = 0; script_index < css->GetSize(); |
280 ++script_index) { | 281 ++script_index) { |
281 Value* value; | 282 Value* value; |
282 std::wstring relative; | 283 std::wstring relative; |
283 if (!css->Get(script_index, &value) || !value->GetAsString(&relative)) { | 284 if (!css->Get(script_index, &value) || !value->GetAsString(&relative)) { |
284 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidCss, | 285 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidCss, |
285 IntToString(definition_index), IntToString(script_index)); | 286 IntToString(definition_index), IntToString(script_index)); |
286 return false; | 287 return false; |
287 } | 288 } |
288 // TODO(georged): Make GetResourceURL accept wstring too | 289 // TODO(georged): Make GetResourceURL accept wstring too |
289 GURL url = GetResourceURL(WideToUTF8(relative)); | 290 GURL url = GetResourceURL(WideToUTF8(relative)); |
290 ExtensionResource resource = GetResource(WideToUTF8(relative)); | 291 ExtensionResource resource = GetResource(WideToUTF8(relative)); |
291 result->css_scripts().push_back(UserScript::File(resource, url)); | 292 result->css_scripts().push_back(UserScript::File( |
| 293 resource.extension_root(), resource.relative_path(), url)); |
292 } | 294 } |
293 } | 295 } |
294 | 296 |
295 return true; | 297 return true; |
296 } | 298 } |
297 | 299 |
298 // Helper method that loads a PageAction or BrowserAction object from a | 300 // Helper method that loads a PageAction or BrowserAction object from a |
299 // dictionary in the page_actions list or browser_action key of the manifest. | 301 // dictionary in the page_actions list or browser_action key of the manifest. |
300 ExtensionAction* Extension::LoadExtensionActionHelper( | 302 ExtensionAction* Extension::LoadExtensionActionHelper( |
301 const DictionaryValue* page_action, std::string* error, | 303 const DictionaryValue* page_action, std::string* error, |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 UserScript::PatternList::const_iterator pattern = | 1174 UserScript::PatternList::const_iterator pattern = |
1173 content_script->url_patterns().begin(); | 1175 content_script->url_patterns().begin(); |
1174 for (; pattern != content_script->url_patterns().end(); ++pattern) { | 1176 for (; pattern != content_script->url_patterns().end(); ++pattern) { |
1175 if (pattern->match_subdomains() && pattern->host().empty()) | 1177 if (pattern->match_subdomains() && pattern->host().empty()) |
1176 return true; | 1178 return true; |
1177 } | 1179 } |
1178 } | 1180 } |
1179 | 1181 |
1180 return false; | 1182 return false; |
1181 } | 1183 } |
OLD | NEW |