Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Side by Side Diff: chrome/browser/extensions/extension_prefs.cc

Issue 3129003: remove toolstrips (Closed)
Patch Set: merge Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "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 "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
(...skipping 23 matching lines...) Expand all
34 34
35 // The version number. 35 // The version number.
36 const char kPrefVersion[] = "manifest.version"; 36 const char kPrefVersion[] = "manifest.version";
37 37
38 // Indicates if an extension is blacklisted: 38 // Indicates if an extension is blacklisted:
39 const char kPrefBlacklist[] = "blacklist"; 39 const char kPrefBlacklist[] = "blacklist";
40 40
41 // Indicates whether to show an install warning when the user enables. 41 // Indicates whether to show an install warning when the user enables.
42 const char kExtensionDidEscalatePermissions[] = "install_warning_on_enable"; 42 const char kExtensionDidEscalatePermissions[] = "install_warning_on_enable";
43 43
44 // A preference that tracks extension shelf configuration. This is a list
45 // object read from the Preferences file, containing a list of toolstrip URLs.
46 const char kExtensionShelf[] = "extensions.shelf";
47
48 // A preference that tracks admin policy regarding which extensions the user 44 // A preference that tracks admin policy regarding which extensions the user
49 // can and can not install. This preference is a list object, containing 45 // can and can not install. This preference is a list object, containing
50 // strings that list extension ids. Denylist can contain "*" meaning all 46 // strings that list extension ids. Denylist can contain "*" meaning all
51 // extensions. 47 // extensions.
52 const char kExtensionInstallAllowList[] = "extensions.install.allowlist"; 48 const char kExtensionInstallAllowList[] = "extensions.install.allowlist";
53 const char kExtensionInstallDenyList[] = "extensions.install.denylist"; 49 const char kExtensionInstallDenyList[] = "extensions.install.denylist";
54 50
55 // A preference that tracks browser action toolbar configuration. This is a list 51 // A preference that tracks browser action toolbar configuration. This is a list
56 // object stored in the Preferences file. The extensions are stored by ID. 52 // object stored in the Preferences file. The extensions are stored by ID.
57 const char kExtensionToolbar[] = "extensions.toolbar"; 53 const char kExtensionToolbar[] = "extensions.toolbar";
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 427
432 // Check to see if the extension has been killed. 428 // Check to see if the extension has been killed.
433 int state; 429 int state;
434 if (extension->GetInteger(kPrefState, &state) && 430 if (extension->GetInteger(kPrefState, &state) &&
435 state == static_cast<int>(Extension::KILLBIT)) { 431 state == static_cast<int>(Extension::KILLBIT)) {
436 killed_ids->insert(StringToLowerASCII(key_name)); 432 killed_ids->insert(StringToLowerASCII(key_name));
437 } 433 }
438 } 434 }
439 } 435 }
440 436
441 ExtensionPrefs::URLList ExtensionPrefs::GetShelfToolstripOrder() {
442 URLList urls;
443 const ListValue* toolstrip_urls = prefs_->GetList(kExtensionShelf);
444 if (toolstrip_urls) {
445 for (size_t i = 0; i < toolstrip_urls->GetSize(); ++i) {
446 std::string url;
447 if (toolstrip_urls->GetString(i, &url))
448 urls.push_back(GURL(url));
449 }
450 }
451 return urls;
452 }
453
454 void ExtensionPrefs::SetShelfToolstripOrder(const URLList& urls) {
455 ListValue* toolstrip_urls = prefs_->GetMutableList(kExtensionShelf);
456 toolstrip_urls->Clear();
457 for (size_t i = 0; i < urls.size(); ++i) {
458 GURL url = urls[i];
459 toolstrip_urls->Append(new StringValue(url.spec()));
460 }
461 prefs_->ScheduleSavePersistentPrefs();
462 }
463
464 std::vector<std::string> ExtensionPrefs::GetToolbarOrder() { 437 std::vector<std::string> ExtensionPrefs::GetToolbarOrder() {
465 std::vector<std::string> extension_ids; 438 std::vector<std::string> extension_ids;
466 const ListValue* toolbar_order = prefs_->GetList(kExtensionToolbar); 439 const ListValue* toolbar_order = prefs_->GetList(kExtensionToolbar);
467 if (toolbar_order) { 440 if (toolbar_order) {
468 for (size_t i = 0; i < toolbar_order->GetSize(); ++i) { 441 for (size_t i = 0; i < toolbar_order->GetSize(); ++i) {
469 std::string extension_id; 442 std::string extension_id;
470 if (toolbar_order->GetString(i, &extension_id)) 443 if (toolbar_order->GetString(i, &extension_id))
471 extension_ids.push_back(extension_id); 444 extension_ids.push_back(extension_id);
472 } 445 }
473 } 446 }
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 if (extension_prefs->GetDictionary(kIdleInstallInfo, &info)) 787 if (extension_prefs->GetDictionary(kIdleInstallInfo, &info))
815 result.insert(id); 788 result.insert(id);
816 } 789 }
817 return result; 790 return result;
818 } 791 }
819 792
820 793
821 // static 794 // static
822 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { 795 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) {
823 prefs->RegisterDictionaryPref(kExtensionsPref); 796 prefs->RegisterDictionaryPref(kExtensionsPref);
824 prefs->RegisterListPref(kExtensionShelf);
825 prefs->RegisterListPref(kExtensionToolbar); 797 prefs->RegisterListPref(kExtensionToolbar);
826 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); 798 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1);
827 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate); 799 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate);
828 prefs->RegisterListPref(kExtensionInstallAllowList); 800 prefs->RegisterListPref(kExtensionInstallAllowList);
829 prefs->RegisterListPref(kExtensionInstallDenyList); 801 prefs->RegisterListPref(kExtensionInstallDenyList);
830 } 802 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_popup_apitest.cc ('k') | chrome/browser/extensions/extension_process_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698