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

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

Issue 8205001: (Owner approval for) Delay network requests on startup if any webRequest ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
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"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 const char kPrefIncognitoEnabled[] = "incognito"; 77 const char kPrefIncognitoEnabled[] = "incognito";
78 78
79 // A preference to control whether an extension is allowed to inject script in 79 // A preference to control whether an extension is allowed to inject script in
80 // pages with file URLs. 80 // pages with file URLs.
81 const char kPrefAllowFileAccess[] = "newAllowFileAccess"; 81 const char kPrefAllowFileAccess[] = "newAllowFileAccess";
82 // TODO(jstritar): As part of fixing http://crbug.com/91577, we revoked all 82 // TODO(jstritar): As part of fixing http://crbug.com/91577, we revoked all
83 // extension file access by renaming the pref. We should eventually clean up 83 // extension file access by renaming the pref. We should eventually clean up
84 // the old flag and possibly go back to that name. 84 // the old flag and possibly go back to that name.
85 // const char kPrefAllowFileAccessOld[] = "allowFileAccess"; 85 // const char kPrefAllowFileAccessOld[] = "allowFileAccess";
86 86
87 // A preference indicating that the extension wants to delay network requests
88 // on browser launch until it indicates it's ready. For example, an extension
89 // using the webRequest API might want to ensure that no requests are sent
90 // before it has registered its event handlers.
91 const char kPrefDelayNetworkRequests[] = "delayNetworkRequests";
92
87 // A preference set by the web store to indicate login information for 93 // A preference set by the web store to indicate login information for
88 // purchased apps. 94 // purchased apps.
89 const char kWebStoreLogin[] = "extensions.webstore_login"; 95 const char kWebStoreLogin[] = "extensions.webstore_login";
90 96
91 // A preference set by the the NTP to persist the desired launch container type 97 // A preference set by the the NTP to persist the desired launch container type
92 // used for apps. 98 // used for apps.
93 const char kPrefLaunchType[] = "launchType"; 99 const char kPrefLaunchType[] = "launchType";
94 100
95 // A preference determining the order of which the apps appear on the NTP. 101 // A preference determining the order of which the apps appear on the NTP.
96 const char kPrefAppLaunchIndex[] = "app_launcher_index"; 102 const char kPrefAppLaunchIndex[] = "app_launcher_index";
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 UpdateExtensionPref(extension_id, kPrefAllowFileAccess, 820 UpdateExtensionPref(extension_id, kPrefAllowFileAccess,
815 Value::CreateBooleanValue(allow)); 821 Value::CreateBooleanValue(allow));
816 } 822 }
817 823
818 bool ExtensionPrefs::HasAllowFileAccessSetting( 824 bool ExtensionPrefs::HasAllowFileAccessSetting(
819 const std::string& extension_id) const { 825 const std::string& extension_id) const {
820 const DictionaryValue* ext = GetExtensionPref(extension_id); 826 const DictionaryValue* ext = GetExtensionPref(extension_id);
821 return ext && ext->HasKey(kPrefAllowFileAccess); 827 return ext && ext->HasKey(kPrefAllowFileAccess);
822 } 828 }
823 829
830 void ExtensionPrefs::SetDelaysNetworkRequests(const std::string& extension_id,
831 bool does_delay) {
832 if (does_delay) {
833 UpdateExtensionPref(extension_id, kPrefDelayNetworkRequests,
834 Value::CreateBooleanValue(true));
835 } else {
836 // Remove the pref.
837 UpdateExtensionPref(extension_id, kPrefDelayNetworkRequests, NULL);
838 }
839 }
840
841 bool ExtensionPrefs::DelaysNetworkRequests(const std::string& extension_id) {
842 return ReadExtensionPrefBoolean(extension_id, kPrefDelayNetworkRequests);
843 }
844
824 ExtensionPrefs::LaunchType ExtensionPrefs::GetLaunchType( 845 ExtensionPrefs::LaunchType ExtensionPrefs::GetLaunchType(
825 const std::string& extension_id, 846 const std::string& extension_id,
826 ExtensionPrefs::LaunchType default_pref_value) { 847 ExtensionPrefs::LaunchType default_pref_value) {
827 int value = -1; 848 int value = -1;
828 LaunchType result = LAUNCH_REGULAR; 849 LaunchType result = LAUNCH_REGULAR;
829 850
830 if (ReadExtensionPrefInteger(extension_id, kPrefLaunchType, &value) && 851 if (ReadExtensionPrefInteger(extension_id, kPrefLaunchType, &value) &&
831 (value == LAUNCH_PINNED || 852 (value == LAUNCH_PINNED ||
832 value == LAUNCH_REGULAR || 853 value == LAUNCH_REGULAR ||
833 value == LAUNCH_FULLSCREEN || 854 value == LAUNCH_FULLSCREEN ||
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 for (DictionaryValue::key_iterator i = prefs->begin_keys(); 1599 for (DictionaryValue::key_iterator i = prefs->begin_keys();
1579 i != prefs->end_keys(); ++i) { 1600 i != prefs->end_keys(); ++i) {
1580 Value* value; 1601 Value* value;
1581 if (!prefs->GetWithoutPathExpansion(*i, &value)) 1602 if (!prefs->GetWithoutPathExpansion(*i, &value))
1582 continue; 1603 continue;
1583 extension_pref_value_map_->SetExtensionPref( 1604 extension_pref_value_map_->SetExtensionPref(
1584 *ext_id, *i, kExtensionPrefsScopeIncognitoPersistent, 1605 *ext_id, *i, kExtensionPrefsScopeIncognitoPersistent,
1585 value->DeepCopy()); 1606 value->DeepCopy());
1586 } 1607 }
1587 1608
1609 // Set content settings.
1588 const DictionaryValue* extension_prefs = GetExtensionPref(*ext_id); 1610 const DictionaryValue* extension_prefs = GetExtensionPref(*ext_id);
1589 DCHECK(extension_prefs); 1611 DCHECK(extension_prefs);
1590 ListValue* content_settings = NULL; 1612 ListValue* content_settings = NULL;
1591 if (extension_prefs->GetList(kPrefContentSettings, 1613 if (extension_prefs->GetList(kPrefContentSettings,
1592 &content_settings)) { 1614 &content_settings)) {
1593 content_settings_store_->SetExtensionContentSettingsFromList( 1615 content_settings_store_->SetExtensionContentSettingsFromList(
1594 *ext_id, content_settings, 1616 *ext_id, content_settings,
1595 kExtensionPrefsScopeRegular); 1617 kExtensionPrefsScopeRegular);
1596 } 1618 }
1597 if (extension_prefs->GetList(kPrefIncognitoContentSettings, 1619 if (extension_prefs->GetList(kPrefIncognitoContentSettings,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, 1736 prefs->RegisterListPref(prefs::kExtensionInstallAllowList,
1715 PrefService::UNSYNCABLE_PREF); 1737 PrefService::UNSYNCABLE_PREF);
1716 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, 1738 prefs->RegisterListPref(prefs::kExtensionInstallDenyList,
1717 PrefService::UNSYNCABLE_PREF); 1739 PrefService::UNSYNCABLE_PREF);
1718 prefs->RegisterListPref(prefs::kExtensionInstallForceList, 1740 prefs->RegisterListPref(prefs::kExtensionInstallForceList,
1719 PrefService::UNSYNCABLE_PREF); 1741 PrefService::UNSYNCABLE_PREF);
1720 prefs->RegisterStringPref(kWebStoreLogin, 1742 prefs->RegisterStringPref(kWebStoreLogin,
1721 std::string() /* default_value */, 1743 std::string() /* default_value */,
1722 PrefService::UNSYNCABLE_PREF); 1744 PrefService::UNSYNCABLE_PREF);
1723 } 1745 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698