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

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: Updated checkout 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 const char kPrefIncognitoEnabled[] = "incognito"; 82 const char kPrefIncognitoEnabled[] = "incognito";
83 83
84 // A preference to control whether an extension is allowed to inject script in 84 // A preference to control whether an extension is allowed to inject script in
85 // pages with file URLs. 85 // pages with file URLs.
86 const char kPrefAllowFileAccess[] = "newAllowFileAccess"; 86 const char kPrefAllowFileAccess[] = "newAllowFileAccess";
87 // TODO(jstritar): As part of fixing http://crbug.com/91577, we revoked all 87 // TODO(jstritar): As part of fixing http://crbug.com/91577, we revoked all
88 // extension file access by renaming the pref. We should eventually clean up 88 // extension file access by renaming the pref. We should eventually clean up
89 // the old flag and possibly go back to that name. 89 // the old flag and possibly go back to that name.
90 // const char kPrefAllowFileAccessOld[] = "allowFileAccess"; 90 // const char kPrefAllowFileAccessOld[] = "allowFileAccess";
91 91
92 // A preference indicating that the extension wants to delay network requests
93 // on browser launch until it indicates it's ready. For example, an extension
94 // using the webRequest API might want to ensure that no requests are sent
95 // before it has registered its event handlers.
96 const char kPrefDelayNetworkRequests[] = "delayNetworkRequests";
97
92 // A preference set by the web store to indicate login information for 98 // A preference set by the web store to indicate login information for
93 // purchased apps. 99 // purchased apps.
94 const char kWebStoreLogin[] = "extensions.webstore_login"; 100 const char kWebStoreLogin[] = "extensions.webstore_login";
95 101
96 // A preference set by the the NTP to persist the desired launch container type 102 // A preference set by the the NTP to persist the desired launch container type
97 // used for apps. 103 // used for apps.
98 const char kPrefLaunchType[] = "launchType"; 104 const char kPrefLaunchType[] = "launchType";
99 105
100 // A preference determining the order of which the apps appear on the NTP. 106 // A preference determining the order of which the apps appear on the NTP.
101 const char kPrefAppLaunchIndex[] = "app_launcher_index"; 107 const char kPrefAppLaunchIndex[] = "app_launcher_index";
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 UpdateExtensionPref(extension_id, kPrefAllowFileAccess, 876 UpdateExtensionPref(extension_id, kPrefAllowFileAccess,
871 Value::CreateBooleanValue(allow)); 877 Value::CreateBooleanValue(allow));
872 } 878 }
873 879
874 bool ExtensionPrefs::HasAllowFileAccessSetting( 880 bool ExtensionPrefs::HasAllowFileAccessSetting(
875 const std::string& extension_id) const { 881 const std::string& extension_id) const {
876 const DictionaryValue* ext = GetExtensionPref(extension_id); 882 const DictionaryValue* ext = GetExtensionPref(extension_id);
877 return ext && ext->HasKey(kPrefAllowFileAccess); 883 return ext && ext->HasKey(kPrefAllowFileAccess);
878 } 884 }
879 885
886 void ExtensionPrefs::SetDelaysNetworkRequests(const std::string& extension_id,
887 bool does_delay) {
888 if (does_delay) {
889 UpdateExtensionPref(extension_id, kPrefDelayNetworkRequests,
890 Value::CreateBooleanValue(true));
891 } else {
892 // Remove the pref.
893 UpdateExtensionPref(extension_id, kPrefDelayNetworkRequests, NULL);
894 }
895 }
896
897 bool ExtensionPrefs::DelaysNetworkRequests(const std::string& extension_id) {
898 return ReadExtensionPrefBoolean(extension_id, kPrefDelayNetworkRequests);
899 }
900
880 ExtensionPrefs::LaunchType ExtensionPrefs::GetLaunchType( 901 ExtensionPrefs::LaunchType ExtensionPrefs::GetLaunchType(
881 const std::string& extension_id, 902 const std::string& extension_id,
882 ExtensionPrefs::LaunchType default_pref_value) { 903 ExtensionPrefs::LaunchType default_pref_value) {
883 int value = -1; 904 int value = -1;
884 LaunchType result = LAUNCH_REGULAR; 905 LaunchType result = LAUNCH_REGULAR;
885 906
886 if (ReadExtensionPrefInteger(extension_id, kPrefLaunchType, &value) && 907 if (ReadExtensionPrefInteger(extension_id, kPrefLaunchType, &value) &&
887 (value == LAUNCH_PINNED || 908 (value == LAUNCH_PINNED ||
888 value == LAUNCH_REGULAR || 909 value == LAUNCH_REGULAR ||
889 value == LAUNCH_FULLSCREEN || 910 value == LAUNCH_FULLSCREEN ||
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 for (DictionaryValue::key_iterator i = prefs->begin_keys(); 1655 for (DictionaryValue::key_iterator i = prefs->begin_keys();
1635 i != prefs->end_keys(); ++i) { 1656 i != prefs->end_keys(); ++i) {
1636 Value* value; 1657 Value* value;
1637 if (!prefs->GetWithoutPathExpansion(*i, &value)) 1658 if (!prefs->GetWithoutPathExpansion(*i, &value))
1638 continue; 1659 continue;
1639 extension_pref_value_map_->SetExtensionPref( 1660 extension_pref_value_map_->SetExtensionPref(
1640 *ext_id, *i, kExtensionPrefsScopeIncognitoPersistent, 1661 *ext_id, *i, kExtensionPrefsScopeIncognitoPersistent,
1641 value->DeepCopy()); 1662 value->DeepCopy());
1642 } 1663 }
1643 1664
1665 // Set content settings.
1644 const DictionaryValue* extension_prefs = GetExtensionPref(*ext_id); 1666 const DictionaryValue* extension_prefs = GetExtensionPref(*ext_id);
1645 DCHECK(extension_prefs); 1667 DCHECK(extension_prefs);
1646 ListValue* content_settings = NULL; 1668 ListValue* content_settings = NULL;
1647 if (extension_prefs->GetList(kPrefContentSettings, 1669 if (extension_prefs->GetList(kPrefContentSettings,
1648 &content_settings)) { 1670 &content_settings)) {
1649 content_settings_store_->SetExtensionContentSettingsFromList( 1671 content_settings_store_->SetExtensionContentSettingsFromList(
1650 *ext_id, content_settings, 1672 *ext_id, content_settings,
1651 kExtensionPrefsScopeRegular); 1673 kExtensionPrefsScopeRegular);
1652 } 1674 }
1653 if (extension_prefs->GetList(kPrefIncognitoContentSettings, 1675 if (extension_prefs->GetList(kPrefIncognitoContentSettings,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, 1792 prefs->RegisterListPref(prefs::kExtensionInstallAllowList,
1771 PrefService::UNSYNCABLE_PREF); 1793 PrefService::UNSYNCABLE_PREF);
1772 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, 1794 prefs->RegisterListPref(prefs::kExtensionInstallDenyList,
1773 PrefService::UNSYNCABLE_PREF); 1795 PrefService::UNSYNCABLE_PREF);
1774 prefs->RegisterListPref(prefs::kExtensionInstallForceList, 1796 prefs->RegisterListPref(prefs::kExtensionInstallForceList,
1775 PrefService::UNSYNCABLE_PREF); 1797 PrefService::UNSYNCABLE_PREF);
1776 prefs->RegisterStringPref(kWebStoreLogin, 1798 prefs->RegisterStringPref(kWebStoreLogin,
1777 std::string() /* default_value */, 1799 std::string() /* default_value */,
1778 PrefService::UNSYNCABLE_PREF); 1800 PrefService::UNSYNCABLE_PREF);
1779 } 1801 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extension_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698