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

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

Issue 10855190: Disable sync for default apps (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: comments Created 8 years, 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/admin_policy.h" 10 #include "chrome/browser/extensions/admin_policy.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 const char kPrefInstallTime[] = "install_time"; 159 const char kPrefInstallTime[] = "install_time";
160 160
161 // A preference that indicates whether the extension was installed from the 161 // A preference that indicates whether the extension was installed from the
162 // Chrome Web Store. 162 // Chrome Web Store.
163 const char kPrefFromWebStore[] = "from_webstore"; 163 const char kPrefFromWebStore[] = "from_webstore";
164 164
165 // A preference that indicates whether the extension was installed from a 165 // A preference that indicates whether the extension was installed from a
166 // mock App created from a bookmark. 166 // mock App created from a bookmark.
167 const char kPrefFromBookmark[] = "from_bookmark"; 167 const char kPrefFromBookmark[] = "from_bookmark";
168 168
169 // A prefrence that indicates whethere the extension was installed as
170 // default apps.
171 const char kPrefWasInstalledByDefault[] = "was_installed_by_default";
172
169 // A preference that contains any extension-controlled preferences. 173 // A preference that contains any extension-controlled preferences.
170 const char kPrefPreferences[] = "preferences"; 174 const char kPrefPreferences[] = "preferences";
171 175
172 // A preference that contains any extension-controlled incognito preferences. 176 // A preference that contains any extension-controlled incognito preferences.
173 const char kPrefIncognitoPreferences[] = "incognito_preferences"; 177 const char kPrefIncognitoPreferences[] = "incognito_preferences";
174 178
175 // A preference that contains any extension-controlled regular-only preferences. 179 // A preference that contains any extension-controlled regular-only preferences.
176 const char kPrefRegularOnlyPreferences[] = "regular_only_preferences"; 180 const char kPrefRegularOnlyPreferences[] = "regular_only_preferences";
177 181
178 // A preference that contains extension-set content settings. 182 // A preference that contains extension-set content settings.
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 ScopedExtensionPrefUpdate update(prefs_, id); 1406 ScopedExtensionPrefUpdate update(prefs_, id);
1403 DictionaryValue* extension_dict = update.Get(); 1407 DictionaryValue* extension_dict = update.Get();
1404 const base::Time install_time = GetCurrentTime(); 1408 const base::Time install_time = GetCurrentTime();
1405 extension_dict->Set(kPrefState, Value::CreateIntegerValue(initial_state)); 1409 extension_dict->Set(kPrefState, Value::CreateIntegerValue(initial_state));
1406 extension_dict->Set(kPrefLocation, 1410 extension_dict->Set(kPrefLocation,
1407 Value::CreateIntegerValue(extension->location())); 1411 Value::CreateIntegerValue(extension->location()));
1408 extension_dict->Set(kPrefFromWebStore, 1412 extension_dict->Set(kPrefFromWebStore,
1409 Value::CreateBooleanValue(from_webstore)); 1413 Value::CreateBooleanValue(from_webstore));
1410 extension_dict->Set(kPrefFromBookmark, 1414 extension_dict->Set(kPrefFromBookmark,
1411 Value::CreateBooleanValue(extension->from_bookmark())); 1415 Value::CreateBooleanValue(extension->from_bookmark()));
1416 extension_dict->Set(kPrefWasInstalledByDefault,
1417 Value::CreateBooleanValue(extension->was_installed_by_default()));
1412 extension_dict->Set(kPrefInstallTime, 1418 extension_dict->Set(kPrefInstallTime,
1413 Value::CreateStringValue( 1419 Value::CreateStringValue(
1414 base::Int64ToString(install_time.ToInternalValue()))); 1420 base::Int64ToString(install_time.ToInternalValue())));
1415 extension_dict->Set(kPrefPreferences, new DictionaryValue()); 1421 extension_dict->Set(kPrefPreferences, new DictionaryValue());
1416 extension_dict->Set(kPrefIncognitoPreferences, new DictionaryValue()); 1422 extension_dict->Set(kPrefIncognitoPreferences, new DictionaryValue());
1417 extension_dict->Set(kPrefRegularOnlyPreferences, new DictionaryValue()); 1423 extension_dict->Set(kPrefRegularOnlyPreferences, new DictionaryValue());
1418 extension_dict->Set(kPrefContentSettings, new ListValue()); 1424 extension_dict->Set(kPrefContentSettings, new ListValue());
1419 extension_dict->Set(kPrefIncognitoContentSettings, new ListValue()); 1425 extension_dict->Set(kPrefIncognitoContentSettings, new ListValue());
1420 1426
1421 FilePath::StringType path = MakePathRelative(install_directory_, 1427 FilePath::StringType path = MakePathRelative(install_directory_,
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 1817
1812 bool ExtensionPrefs::IsFromBookmark( 1818 bool ExtensionPrefs::IsFromBookmark(
1813 const std::string& extension_id) const { 1819 const std::string& extension_id) const {
1814 const DictionaryValue* dictionary = GetExtensionPref(extension_id); 1820 const DictionaryValue* dictionary = GetExtensionPref(extension_id);
1815 bool result = false; 1821 bool result = false;
1816 if (dictionary && dictionary->GetBoolean(kPrefFromBookmark, &result)) 1822 if (dictionary && dictionary->GetBoolean(kPrefFromBookmark, &result))
1817 return result; 1823 return result;
1818 return false; 1824 return false;
1819 } 1825 }
1820 1826
1827 bool ExtensionPrefs::WasInstalledByDefault(
1828 const std::string& extension_id) const {
1829 const DictionaryValue* dictionary = GetExtensionPref(extension_id);
1830 bool result = false;
1831 if (dictionary &&
1832 dictionary->GetBoolean(kPrefWasInstalledByDefault, &result))
1833 return result;
1834 return false;
1835 }
1836
1821 base::Time ExtensionPrefs::GetInstallTime( 1837 base::Time ExtensionPrefs::GetInstallTime(
1822 const std::string& extension_id) const { 1838 const std::string& extension_id) const {
1823 const DictionaryValue* extension = GetExtensionPref(extension_id); 1839 const DictionaryValue* extension = GetExtensionPref(extension_id);
1824 if (!extension) { 1840 if (!extension) {
1825 NOTREACHED(); 1841 NOTREACHED();
1826 return base::Time(); 1842 return base::Time();
1827 } 1843 }
1828 std::string install_time_str; 1844 std::string install_time_str;
1829 if (!extension->GetString(kPrefInstallTime, &install_time_str)) 1845 if (!extension->GetString(kPrefInstallTime, &install_time_str))
1830 return base::Time(); 1846 return base::Time();
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2139 const ExtensionIds& strings) { 2155 const ExtensionIds& strings) {
2140 ListPrefUpdate update(prefs_, pref); 2156 ListPrefUpdate update(prefs_, pref);
2141 ListValue* list_of_values = update.Get(); 2157 ListValue* list_of_values = update.Get();
2142 list_of_values->Clear(); 2158 list_of_values->Clear();
2143 for (ExtensionIds::const_iterator iter = strings.begin(); 2159 for (ExtensionIds::const_iterator iter = strings.begin();
2144 iter != strings.end(); ++iter) 2160 iter != strings.end(); ++iter)
2145 list_of_values->Append(new StringValue(*iter)); 2161 list_of_values->Append(new StringValue(*iter));
2146 } 2162 }
2147 2163
2148 } // namespace extensions 2164 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extension_prefs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698