OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/extension_pref_store.h" | 10 #include "chrome/browser/extensions/extension_pref_store.h" |
11 #include "chrome/browser/prefs/pref_notifier.h" | 11 #include "chrome/browser/prefs/pref_notifier.h" |
12 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 12 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
16 #include "chrome/common/extensions/url_pattern.h" | 16 #include "chrome/common/extensions/url_pattern.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "content/common/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
19 | 19 |
20 using base::Time; | 20 using base::Time; |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // The number of apps per page. This isn't a hard limit, but new apps installed | 24 // The number of apps per page. This isn't a hard limit, but new apps installed |
25 // from the webstore will overflow onto a new page if this limit is reached. | 25 // from the webstore will overflow onto a new page if this limit is reached. |
26 const int kNaturalAppPageSize = 18; | 26 const int kNaturalAppPageSize = 18; |
27 | 27 |
28 // Additional preferences keys | 28 // Additional preferences keys |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 return false; | 1117 return false; |
1118 } | 1118 } |
1119 | 1119 |
1120 void ExtensionPrefs::SetBrowserActionVisibility(const Extension* extension, | 1120 void ExtensionPrefs::SetBrowserActionVisibility(const Extension* extension, |
1121 bool visible) { | 1121 bool visible) { |
1122 if (GetBrowserActionVisibility(extension) == visible) | 1122 if (GetBrowserActionVisibility(extension) == visible) |
1123 return; | 1123 return; |
1124 | 1124 |
1125 UpdateExtensionPref(extension->id(), kBrowserActionVisible, | 1125 UpdateExtensionPref(extension->id(), kBrowserActionVisible, |
1126 Value::CreateBooleanValue(visible)); | 1126 Value::CreateBooleanValue(visible)); |
1127 NotificationService::current()->Notify( | 1127 content::NotificationService::current()->Notify( |
1128 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, | 1128 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, |
1129 content::Source<ExtensionPrefs>(this), | 1129 content::Source<ExtensionPrefs>(this), |
1130 content::Details<const Extension>(extension)); | 1130 content::Details<const Extension>(extension)); |
1131 } | 1131 } |
1132 | 1132 |
1133 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { | 1133 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { |
1134 const DictionaryValue* extension = GetExtensionPref(extension_id); | 1134 const DictionaryValue* extension = GetExtensionPref(extension_id); |
1135 if (!extension) | 1135 if (!extension) |
1136 return std::string(); | 1136 return std::string(); |
1137 | 1137 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 if (it == page_counts.end() || it->second < kNaturalAppPageSize) | 1451 if (it == page_counts.end() || it->second < kNaturalAppPageSize) |
1452 return i; | 1452 return i; |
1453 } | 1453 } |
1454 } | 1454 } |
1455 | 1455 |
1456 void ExtensionPrefs::SetAppLauncherOrder( | 1456 void ExtensionPrefs::SetAppLauncherOrder( |
1457 const std::vector<std::string>& extension_ids) { | 1457 const std::vector<std::string>& extension_ids) { |
1458 for (size_t i = 0; i < extension_ids.size(); ++i) | 1458 for (size_t i = 0; i < extension_ids.size(); ++i) |
1459 SetAppLaunchIndex(extension_ids.at(i), i); | 1459 SetAppLaunchIndex(extension_ids.at(i), i); |
1460 | 1460 |
1461 NotificationService::current()->Notify( | 1461 content::NotificationService::current()->Notify( |
1462 chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, | 1462 chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, |
1463 content::Source<ExtensionPrefs>(this), | 1463 content::Source<ExtensionPrefs>(this), |
1464 NotificationService::NoDetails()); | 1464 content::NotificationService::NoDetails()); |
1465 } | 1465 } |
1466 | 1466 |
1467 int ExtensionPrefs::GetPageIndex(const std::string& extension_id) { | 1467 int ExtensionPrefs::GetPageIndex(const std::string& extension_id) { |
1468 int value = -1; | 1468 int value = -1; |
1469 ReadExtensionPrefInteger(extension_id, kPrefPageIndex, &value); | 1469 ReadExtensionPrefInteger(extension_id, kPrefPageIndex, &value); |
1470 return value; | 1470 return value; |
1471 } | 1471 } |
1472 | 1472 |
1473 void ExtensionPrefs::SetPageIndex(const std::string& extension_id, int index) { | 1473 void ExtensionPrefs::SetPageIndex(const std::string& extension_id, int index) { |
1474 UpdateExtensionPref(extension_id, kPrefPageIndex, | 1474 UpdateExtensionPref(extension_id, kPrefPageIndex, |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, | 1792 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, |
1793 PrefService::UNSYNCABLE_PREF); | 1793 PrefService::UNSYNCABLE_PREF); |
1794 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, | 1794 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, |
1795 PrefService::UNSYNCABLE_PREF); | 1795 PrefService::UNSYNCABLE_PREF); |
1796 prefs->RegisterListPref(prefs::kExtensionInstallForceList, | 1796 prefs->RegisterListPref(prefs::kExtensionInstallForceList, |
1797 PrefService::UNSYNCABLE_PREF); | 1797 PrefService::UNSYNCABLE_PREF); |
1798 prefs->RegisterStringPref(kWebStoreLogin, | 1798 prefs->RegisterStringPref(kWebStoreLogin, |
1799 std::string() /* default_value */, | 1799 std::string() /* default_value */, |
1800 PrefService::UNSYNCABLE_PREF); | 1800 PrefService::UNSYNCABLE_PREF); |
1801 } | 1801 } |
OLD | NEW |