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/browser/extensions/extension_prefs.h" | 5 #include "chrome/browser/extensions/extension_prefs.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } | 382 } |
383 | 383 |
384 return version; | 384 return version; |
385 } | 385 } |
386 | 386 |
387 void ExtensionPrefs::MigrateToPrefs(Extension* extension) { | 387 void ExtensionPrefs::MigrateToPrefs(Extension* extension) { |
388 UpdateExtensionPref(extension->id(), kPrefManifest, | 388 UpdateExtensionPref(extension->id(), kPrefManifest, |
389 extension->manifest_value()->DeepCopy()); | 389 extension->manifest_value()->DeepCopy()); |
390 } | 390 } |
391 | 391 |
| 392 FilePath ExtensionPrefs::GetExtensionPath(const std::string& extension_id) { |
| 393 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref); |
| 394 if (!dict || dict->GetSize() == 0) |
| 395 return FilePath(); |
| 396 |
| 397 std::wstring path; |
| 398 if (!dict->GetString(ASCIIToWide(extension_id) + L"." + kPrefPath, &path)) |
| 399 return FilePath(); |
| 400 |
| 401 return install_directory_.Append(FilePath::FromWStringHack(path)); |
| 402 } |
| 403 |
392 bool ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id, | 404 bool ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id, |
393 const std::wstring& key, | 405 const std::wstring& key, |
394 Value* data_value) { | 406 Value* data_value) { |
395 DictionaryValue* extension = GetOrCreateExtensionPref(extension_id); | 407 DictionaryValue* extension = GetOrCreateExtensionPref(extension_id); |
396 if (!extension->Set(key, data_value)) { | 408 if (!extension->Set(key, data_value)) { |
397 NOTREACHED() << "Cannot modify key: '" << key.c_str() | 409 NOTREACHED() << "Cannot modify key: '" << key.c_str() |
398 << "' for extension: '" << extension_id.c_str() << "'"; | 410 << "' for extension: '" << extension_id.c_str() << "'"; |
399 return false; | 411 return false; |
400 } | 412 } |
401 return true; | 413 return true; |
(...skipping 22 matching lines...) Expand all Loading... |
424 } | 436 } |
425 | 437 |
426 DictionaryValue* ExtensionPrefs::GetExtensionPref( | 438 DictionaryValue* ExtensionPrefs::GetExtensionPref( |
427 const std::string& extension_id) { | 439 const std::string& extension_id) { |
428 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref); | 440 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref); |
429 DictionaryValue* extension = NULL; | 441 DictionaryValue* extension = NULL; |
430 std::wstring id = ASCIIToWide(extension_id); | 442 std::wstring id = ASCIIToWide(extension_id); |
431 dict->GetDictionary(id, &extension); | 443 dict->GetDictionary(id, &extension); |
432 return extension; | 444 return extension; |
433 } | 445 } |
OLD | NEW |