| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/file_system_provider/registry.h" | 5 #include "chrome/browser/chromeos/file_system_provider/registry.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 file_system->SetBooleanWithoutPathExpansion( | 57 file_system->SetBooleanWithoutPathExpansion( |
| 58 kPrefKeySupportsNotifyTag, file_system_info.supports_notify_tag()); | 58 kPrefKeySupportsNotifyTag, file_system_info.supports_notify_tag()); |
| 59 | 59 |
| 60 base::DictionaryValue* const observed_entries_value = | 60 base::DictionaryValue* const observed_entries_value = |
| 61 new base::DictionaryValue(); | 61 new base::DictionaryValue(); |
| 62 file_system->SetWithoutPathExpansion(kPrefKeyObservedEntries, | 62 file_system->SetWithoutPathExpansion(kPrefKeyObservedEntries, |
| 63 observed_entries_value); | 63 observed_entries_value); |
| 64 | 64 |
| 65 for (const auto& it : observed_entries) { | 65 for (const auto& it : observed_entries) { |
| 66 base::DictionaryValue* const observed_entry = new base::DictionaryValue(); | 66 base::DictionaryValue* const observed_entry = new base::DictionaryValue(); |
| 67 observed_entries_value->SetWithoutPathExpansion(it.first.value(), | 67 observed_entries_value->SetWithoutPathExpansion( |
| 68 observed_entry); | 68 it.second.entry_path.value(), observed_entry); |
| 69 observed_entry->SetStringWithoutPathExpansion( | 69 observed_entry->SetStringWithoutPathExpansion( |
| 70 kPrefKeyObservedEntryEntryPath, it.second.entry_path.value()); | 70 kPrefKeyObservedEntryEntryPath, it.second.entry_path.value()); |
| 71 observed_entry->SetBooleanWithoutPathExpansion( | 71 observed_entry->SetBooleanWithoutPathExpansion( |
| 72 kPrefKeyObservedEntryRecursive, it.second.recursive); | 72 kPrefKeyObservedEntryRecursive, it.second.recursive); |
| 73 observed_entry->SetStringWithoutPathExpansion(kPrefKeyObservedEntryLastTag, | 73 observed_entry->SetStringWithoutPathExpansion(kPrefKeyObservedEntryLastTag, |
| 74 it.second.last_tag); | 74 it.second.last_tag); |
| 75 } | 75 } |
| 76 | 76 |
| 77 PrefService* const pref_service = profile_->GetPrefs(); | 77 PrefService* const pref_service = profile_->GetPrefs(); |
| 78 DCHECK(pref_service); | 78 DCHECK(pref_service); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 (!options.supports_notify_tag && !last_tag.empty())) { | 194 (!options.supports_notify_tag && !last_tag.empty())) { |
| 195 LOG(ERROR) << "Malformed observed entry information in preferences."; | 195 LOG(ERROR) << "Malformed observed entry information in preferences."; |
| 196 continue; | 196 continue; |
| 197 } | 197 } |
| 198 | 198 |
| 199 ObservedEntry restored_observed_entry; | 199 ObservedEntry restored_observed_entry; |
| 200 restored_observed_entry.entry_path = | 200 restored_observed_entry.entry_path = |
| 201 base::FilePath::FromUTF8Unsafe(entry_path); | 201 base::FilePath::FromUTF8Unsafe(entry_path); |
| 202 restored_observed_entry.recursive = recursive; | 202 restored_observed_entry.recursive = recursive; |
| 203 restored_observed_entry.last_tag = last_tag; | 203 restored_observed_entry.last_tag = last_tag; |
| 204 restored_file_system | 204 restored_file_system.observed_entries[ObservedEntryKey( |
| 205 .observed_entries[base::FilePath::FromUTF8Unsafe(entry_path)] = | 205 base::FilePath::FromUTF8Unsafe(entry_path), recursive)] = |
| 206 restored_observed_entry; | 206 restored_observed_entry; |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 restored_file_systems->push_back(restored_file_system); | 209 restored_file_systems->push_back(restored_file_system); |
| 210 } | 210 } |
| 211 | 211 |
| 212 return restored_file_systems.Pass(); | 212 return restored_file_systems.Pass(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void Registry::UpdateObservedEntryTag( | 215 void Registry::UpdateObservedEntryTag( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 241 LOG(ERROR) << "Broken preferences detected while updating a tag."; | 241 LOG(ERROR) << "Broken preferences detected while updating a tag."; |
| 242 return; | 242 return; |
| 243 } | 243 } |
| 244 | 244 |
| 245 observed_entry_value->SetStringWithoutPathExpansion( | 245 observed_entry_value->SetStringWithoutPathExpansion( |
| 246 kPrefKeyObservedEntryLastTag, observed_entry.last_tag); | 246 kPrefKeyObservedEntryLastTag, observed_entry.last_tag); |
| 247 } | 247 } |
| 248 | 248 |
| 249 } // namespace file_system_provider | 249 } // namespace file_system_provider |
| 250 } // namespace chromeos | 250 } // namespace chromeos |
| OLD | NEW |