OLD | NEW |
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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_notifier.h" | 8 #include "base/prefs/pref_notifier.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 extension_dict->Remove(kFileEntries, NULL); | 1170 extension_dict->Remove(kFileEntries, NULL); |
1171 } | 1171 } |
1172 | 1172 |
1173 void ExtensionPrefs::GetSavedFileEntries( | 1173 void ExtensionPrefs::GetSavedFileEntries( |
1174 const std::string& extension_id, | 1174 const std::string& extension_id, |
1175 std::vector<app_file_handler_util::SavedFileEntry>* out) { | 1175 std::vector<app_file_handler_util::SavedFileEntry>* out) { |
1176 const DictionaryValue* prefs = GetExtensionPref(extension_id); | 1176 const DictionaryValue* prefs = GetExtensionPref(extension_id); |
1177 const DictionaryValue* file_entries = NULL; | 1177 const DictionaryValue* file_entries = NULL; |
1178 if (!prefs->GetDictionary(kFileEntries, &file_entries)) | 1178 if (!prefs->GetDictionary(kFileEntries, &file_entries)) |
1179 return; | 1179 return; |
1180 for (DictionaryValue::key_iterator it = file_entries->begin_keys(); | 1180 for (DictionaryValue::Iterator it(*file_entries); !it.IsAtEnd(); |
1181 it != file_entries->end_keys(); ++it) { | 1181 it.Advance()) { |
1182 std::string id = *it; | |
1183 const DictionaryValue* file_entry = NULL; | 1182 const DictionaryValue* file_entry = NULL; |
1184 if (!file_entries->GetDictionaryWithoutPathExpansion(id, &file_entry)) | 1183 if (!it.value().GetAsDictionary(&file_entry)) |
1185 continue; | 1184 continue; |
1186 base::FilePath::StringType path_string; | 1185 base::FilePath::StringType path_string; |
1187 if (!file_entry->GetString(kFileEntryPath, &path_string)) | 1186 if (!file_entry->GetString(kFileEntryPath, &path_string)) |
1188 continue; | 1187 continue; |
1189 bool writable = false; | 1188 bool writable = false; |
1190 if (!file_entry->GetBoolean(kFileEntryWritable, &writable)) | 1189 if (!file_entry->GetBoolean(kFileEntryWritable, &writable)) |
1191 continue; | 1190 continue; |
1192 base::FilePath file_path(path_string); | 1191 base::FilePath file_path(path_string); |
1193 out->push_back(app_file_handler_util::SavedFileEntry( | 1192 out->push_back(app_file_handler_util::SavedFileEntry( |
1194 id, file_path, writable)); | 1193 it.key(), file_path, writable)); |
1195 } | 1194 } |
1196 } | 1195 } |
1197 | 1196 |
1198 ExtensionOmniboxSuggestion | 1197 ExtensionOmniboxSuggestion |
1199 ExtensionPrefs::GetOmniboxDefaultSuggestion(const std::string& extension_id) { | 1198 ExtensionPrefs::GetOmniboxDefaultSuggestion(const std::string& extension_id) { |
1200 ExtensionOmniboxSuggestion suggestion; | 1199 ExtensionOmniboxSuggestion suggestion; |
1201 | 1200 |
1202 const DictionaryValue* extension = GetExtensionPref(extension_id); | 1201 const DictionaryValue* extension = GetExtensionPref(extension_id); |
1203 const DictionaryValue* dict = NULL; | 1202 const DictionaryValue* dict = NULL; |
1204 if (extension && extension->GetDictionary(kOmniboxDefaultSuggestion, &dict)) | 1203 if (extension && extension->GetDictionary(kOmniboxDefaultSuggestion, &dict)) |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2040 std::string scope_string; | 2039 std::string scope_string; |
2041 bool success = ScopeToPrefKey(scope, &scope_string); | 2040 bool success = ScopeToPrefKey(scope, &scope_string); |
2042 DCHECK(success); | 2041 DCHECK(success); |
2043 std::string key = extension_id + "." + scope_string; | 2042 std::string key = extension_id + "." + scope_string; |
2044 const DictionaryValue* preferences = NULL; | 2043 const DictionaryValue* preferences = NULL; |
2045 // First try the regular lookup. | 2044 // First try the regular lookup. |
2046 const DictionaryValue* source_dict = prefs_->GetDictionary(kExtensionsPref); | 2045 const DictionaryValue* source_dict = prefs_->GetDictionary(kExtensionsPref); |
2047 if (!source_dict->GetDictionary(key, &preferences)) | 2046 if (!source_dict->GetDictionary(key, &preferences)) |
2048 return; | 2047 return; |
2049 | 2048 |
2050 for (DictionaryValue::Iterator i(*preferences); i.HasNext(); i.Advance()) { | 2049 for (DictionaryValue::Iterator i(*preferences); !i.IsAtEnd(); i.Advance()) { |
2051 extension_pref_value_map_->SetExtensionPref( | 2050 extension_pref_value_map_->SetExtensionPref( |
2052 extension_id, i.key(), scope, i.value().DeepCopy()); | 2051 extension_id, i.key(), scope, i.value().DeepCopy()); |
2053 } | 2052 } |
2054 } | 2053 } |
2055 | 2054 |
2056 void ExtensionPrefs::InitPrefStore(bool extensions_disabled) { | 2055 void ExtensionPrefs::InitPrefStore(bool extensions_disabled) { |
2057 if (extensions_disabled) { | 2056 if (extensions_disabled) { |
2058 extension_pref_value_map_->NotifyInitializationCompleted(); | 2057 extension_pref_value_map_->NotifyInitializationCompleted(); |
2059 return; | 2058 return; |
2060 } | 2059 } |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2434 is_enabled = initial_state == Extension::ENABLED; | 2433 is_enabled = initial_state == Extension::ENABLED; |
2435 } | 2434 } |
2436 | 2435 |
2437 extension_pref_value_map_->RegisterExtension(extension_id, install_time, | 2436 extension_pref_value_map_->RegisterExtension(extension_id, install_time, |
2438 is_enabled); | 2437 is_enabled); |
2439 content_settings_store_->RegisterExtension(extension_id, install_time, | 2438 content_settings_store_->RegisterExtension(extension_id, install_time, |
2440 is_enabled); | 2439 is_enabled); |
2441 } | 2440 } |
2442 | 2441 |
2443 } // namespace extensions | 2442 } // namespace extensions |
OLD | NEW |