| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 // The dictionary containing the extension's manifest. | 29 // The dictionary containing the extension's manifest. |
| 30 const wchar_t kPrefManifest[] = L"manifest"; | 30 const wchar_t kPrefManifest[] = L"manifest"; |
| 31 | 31 |
| 32 // The version number. | 32 // The version number. |
| 33 const wchar_t kPrefVersion[] = L"manifest.version"; | 33 const wchar_t kPrefVersion[] = L"manifest.version"; |
| 34 | 34 |
| 35 // Indicates if an extension is blacklisted: | 35 // Indicates if an extension is blacklisted: |
| 36 const wchar_t kPrefBlacklist[] = L"blacklist"; | 36 const wchar_t kPrefBlacklist[] = L"blacklist"; |
| 37 | 37 |
| 38 // Indicates whether the toolbar should be shown on app tabs. | |
| 39 const wchar_t kPrefAppTabToolbars[] = L"app_tab_toolbars"; | |
| 40 | |
| 41 // Indicates whether to show an install warning when the user enables. | 38 // Indicates whether to show an install warning when the user enables. |
| 42 const wchar_t kExtensionDidEscalatePermissions[] = L"install_warning_on_enable"; | 39 const wchar_t kExtensionDidEscalatePermissions[] = L"install_warning_on_enable"; |
| 43 | 40 |
| 44 // A preference that tracks extension shelf configuration. This is a list | 41 // A preference that tracks extension shelf configuration. This is a list |
| 45 // object read from the Preferences file, containing a list of toolstrip URLs. | 42 // object read from the Preferences file, containing a list of toolstrip URLs. |
| 46 const wchar_t kExtensionShelf[] = L"extensions.shelf"; | 43 const wchar_t kExtensionShelf[] = L"extensions.shelf"; |
| 47 | 44 |
| 48 // A preference that tracks browser action toolbar configuration. This is a list | 45 // A preference that tracks browser action toolbar configuration. This is a list |
| 49 // object stored in the Preferences file. The extensions are stored by ID. | 46 // object stored in the Preferences file. The extensions are stored by ID. |
| 50 const wchar_t kExtensionToolbar[] = L"extensions.toolbar"; | 47 const wchar_t kExtensionToolbar[] = L"extensions.toolbar"; |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 if (!extension_prefs) | 770 if (!extension_prefs) |
| 774 continue; | 771 continue; |
| 775 | 772 |
| 776 DictionaryValue* info = NULL; | 773 DictionaryValue* info = NULL; |
| 777 if (extension_prefs->GetDictionary(kIdleInstallInfo, &info)) | 774 if (extension_prefs->GetDictionary(kIdleInstallInfo, &info)) |
| 778 result.insert(id); | 775 result.insert(id); |
| 779 } | 776 } |
| 780 return result; | 777 return result; |
| 781 } | 778 } |
| 782 | 779 |
| 783 bool ExtensionPrefs::AreAppTabToolbarsVisible( | |
| 784 const std::string& extension_id) { | |
| 785 // Default to hiding toolbars. | |
| 786 bool show_toolbars = false; | |
| 787 DictionaryValue* pref = GetExtensionPref(extension_id); | |
| 788 if (!pref) | |
| 789 return show_toolbars; | |
| 790 | |
| 791 pref->GetBoolean( | |
| 792 ASCIIToWide(extension_id) + L"." + kPrefAppTabToolbars, &show_toolbars); | |
| 793 return show_toolbars; | |
| 794 } | |
| 795 | |
| 796 void ExtensionPrefs::SetAppTabToolbarVisibility( | |
| 797 const std::string& extension_id, bool value) { | |
| 798 DictionaryValue* pref = GetOrCreateExtensionPref(extension_id); | |
| 799 std::wstring key = ASCIIToWide(extension_id) + L"." + kPrefAppTabToolbars; | |
| 800 | |
| 801 if (value) | |
| 802 pref->SetBoolean(key, true); | |
| 803 else | |
| 804 pref->Remove(key, NULL); // False is the default value. | |
| 805 | |
| 806 prefs_->ScheduleSavePersistentPrefs(); | |
| 807 } | |
| 808 | |
| 809 | 780 |
| 810 // static | 781 // static |
| 811 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { | 782 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { |
| 812 prefs->RegisterDictionaryPref(kExtensionsPref); | 783 prefs->RegisterDictionaryPref(kExtensionsPref); |
| 813 prefs->RegisterListPref(kExtensionShelf); | 784 prefs->RegisterListPref(kExtensionShelf); |
| 814 prefs->RegisterListPref(kExtensionToolbar); | 785 prefs->RegisterListPref(kExtensionToolbar); |
| 815 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); | 786 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); |
| 816 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate); | 787 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate); |
| 817 } | 788 } |
| OLD | NEW |