| 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 "base/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "chrome/browser/extensions/extension_prefs.h" | 6 #include "chrome/browser/extensions/extension_prefs.h" |
| 7 #include "chrome/common/extensions/extension.h" | 7 #include "chrome/common/extensions/extension.h" |
| 8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
| 9 | 9 |
| 10 using base::Time; | 10 using base::Time; |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 UpdateExtensionPref(id, kPrefPath, Value::CreateStringValue(path)); | 378 UpdateExtensionPref(id, kPrefPath, Value::CreateStringValue(path)); |
| 379 // We store prefs about LOAD extensions, but don't cache their manifest | 379 // We store prefs about LOAD extensions, but don't cache their manifest |
| 380 // since it may change on disk. | 380 // since it may change on disk. |
| 381 if (extension->location() != Extension::LOAD) { | 381 if (extension->location() != Extension::LOAD) { |
| 382 UpdateExtensionPref(id, kPrefManifest, | 382 UpdateExtensionPref(id, kPrefManifest, |
| 383 extension->manifest_value()->DeepCopy()); | 383 extension->manifest_value()->DeepCopy()); |
| 384 } | 384 } |
| 385 prefs_->SavePersistentPrefs(); | 385 prefs_->SavePersistentPrefs(); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void ExtensionPrefs::OnExtensionUninstalled(const Extension* extension, | 388 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, |
| 389 const Extension::Location& location, |
| 389 bool external_uninstall) { | 390 bool external_uninstall) { |
| 390 // For external extensions, we save a preference reminding ourself not to try | 391 // For external extensions, we save a preference reminding ourself not to try |
| 391 // and install the extension anymore (except when |external_uninstall| is | 392 // and install the extension anymore (except when |external_uninstall| is |
| 392 // true, which signifies that the registry key was deleted or the pref file | 393 // true, which signifies that the registry key was deleted or the pref file |
| 393 // no longer lists the extension). | 394 // no longer lists the extension). |
| 394 if (!external_uninstall && | 395 if (!external_uninstall && Extension::IsExternalLocation(location)) { |
| 395 Extension::IsExternalLocation(extension->location())) { | 396 UpdateExtensionPref(extension_id, kPrefState, |
| 396 UpdateExtensionPref(extension->id(), kPrefState, | |
| 397 Value::CreateIntegerValue(Extension::KILLBIT)); | 397 Value::CreateIntegerValue(Extension::KILLBIT)); |
| 398 prefs_->ScheduleSavePersistentPrefs(); | 398 prefs_->ScheduleSavePersistentPrefs(); |
| 399 } else { | 399 } else { |
| 400 DeleteExtensionPrefs(extension->id()); | 400 DeleteExtensionPrefs(extension_id); |
| 401 } | 401 } |
| 402 } | 402 } |
| 403 | 403 |
| 404 Extension::State ExtensionPrefs::GetExtensionState( | 404 Extension::State ExtensionPrefs::GetExtensionState( |
| 405 const std::string& extension_id) { | 405 const std::string& extension_id) { |
| 406 DictionaryValue* extension = GetExtensionPref(extension_id); | 406 DictionaryValue* extension = GetExtensionPref(extension_id); |
| 407 | 407 |
| 408 // If the extension doesn't have a pref, it's a --load-extension. | 408 // If the extension doesn't have a pref, it's a --load-extension. |
| 409 if (!extension) | 409 if (!extension) |
| 410 return Extension::ENABLED; | 410 return Extension::ENABLED; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 return NULL; | 599 return NULL; |
| 600 } | 600 } |
| 601 | 601 |
| 602 // static | 602 // static |
| 603 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { | 603 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { |
| 604 prefs->RegisterDictionaryPref(kExtensionsPref); | 604 prefs->RegisterDictionaryPref(kExtensionsPref); |
| 605 prefs->RegisterListPref(kExtensionShelf); | 605 prefs->RegisterListPref(kExtensionShelf); |
| 606 prefs->RegisterListPref(kExtensionToolbar); | 606 prefs->RegisterListPref(kExtensionToolbar); |
| 607 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); | 607 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); |
| 608 } | 608 } |
| OLD | NEW |