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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/registry.cc

Issue 2777063003: Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Fix SupervisedUserWhitelistInstaller Created 3 years, 8 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
OLDNEW
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
jdoerrie 2017/04/06 14:25:49 #include <utility>
vabr (Chromium) 2017/04/07 20:40:39 Done.
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" 10 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h"
11 #include "chrome/browser/chromeos/file_system_provider/observer.h" 11 #include "chrome/browser/chromeos/file_system_provider/observer.h"
12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h" 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h"
13 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h" 13 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h"
14 #include "chrome/browser/chromeos/file_system_provider/service_factory.h" 14 #include "chrome/browser/chromeos/file_system_provider/service_factory.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
(...skipping 24 matching lines...) Expand all
41 41
42 Registry::Registry(Profile* profile) : profile_(profile) { 42 Registry::Registry(Profile* profile) : profile_(profile) {
43 } 43 }
44 44
45 Registry::~Registry() { 45 Registry::~Registry() {
46 } 46 }
47 47
48 void Registry::RememberFileSystem( 48 void Registry::RememberFileSystem(
49 const ProvidedFileSystemInfo& file_system_info, 49 const ProvidedFileSystemInfo& file_system_info,
50 const Watchers& watchers) { 50 const Watchers& watchers) {
51 base::DictionaryValue* const file_system = new base::DictionaryValue(); 51 auto file_system = base::MakeUnique<base::DictionaryValue>();
52 file_system->SetStringWithoutPathExpansion(kPrefKeyFileSystemId, 52 file_system->SetStringWithoutPathExpansion(kPrefKeyFileSystemId,
53 file_system_info.file_system_id()); 53 file_system_info.file_system_id());
54 file_system->SetStringWithoutPathExpansion(kPrefKeyDisplayName, 54 file_system->SetStringWithoutPathExpansion(kPrefKeyDisplayName,
55 file_system_info.display_name()); 55 file_system_info.display_name());
56 file_system->SetBooleanWithoutPathExpansion(kPrefKeyWritable, 56 file_system->SetBooleanWithoutPathExpansion(kPrefKeyWritable,
57 file_system_info.writable()); 57 file_system_info.writable());
58 file_system->SetBooleanWithoutPathExpansion( 58 file_system->SetBooleanWithoutPathExpansion(
59 kPrefKeySupportsNotifyTag, file_system_info.supports_notify_tag()); 59 kPrefKeySupportsNotifyTag, file_system_info.supports_notify_tag());
60 file_system->SetIntegerWithoutPathExpansion( 60 file_system->SetIntegerWithoutPathExpansion(
61 kPrefKeyOpenedFilesLimit, file_system_info.opened_files_limit()); 61 kPrefKeyOpenedFilesLimit, file_system_info.opened_files_limit());
62 62
63 base::DictionaryValue* const watchers_value = new base::DictionaryValue(); 63 auto watchers_value = base::MakeUnique<base::DictionaryValue>();
64 file_system->SetWithoutPathExpansion(kPrefKeyWatchers, watchers_value);
65 64
66 for (const auto& it : watchers) { 65 for (const auto& it : watchers) {
67 base::DictionaryValue* const watcher = new base::DictionaryValue(); 66 auto watcher = base::MakeUnique<base::DictionaryValue>();
68 watchers_value->SetWithoutPathExpansion(it.second.entry_path.value(),
69 watcher);
70 watcher->SetStringWithoutPathExpansion(kPrefKeyWatcherEntryPath, 67 watcher->SetStringWithoutPathExpansion(kPrefKeyWatcherEntryPath,
71 it.second.entry_path.value()); 68 it.second.entry_path.value());
72 watcher->SetBooleanWithoutPathExpansion(kPrefKeyWatcherRecursive, 69 watcher->SetBooleanWithoutPathExpansion(kPrefKeyWatcherRecursive,
73 it.second.recursive); 70 it.second.recursive);
74 watcher->SetStringWithoutPathExpansion(kPrefKeyWatcherLastTag, 71 watcher->SetStringWithoutPathExpansion(kPrefKeyWatcherLastTag,
75 it.second.last_tag); 72 it.second.last_tag);
76 base::ListValue* const persistent_origins_value = new base::ListValue(); 73 auto persistent_origins_value = base::MakeUnique<base::ListValue>();
77 watcher->SetWithoutPathExpansion(kPrefKeyWatcherPersistentOrigins,
78 persistent_origins_value);
79 for (const auto& subscriber_it : it.second.subscribers) { 74 for (const auto& subscriber_it : it.second.subscribers) {
80 // Only persistent subscribers should be stored in persistent storage. 75 // Only persistent subscribers should be stored in persistent storage.
81 // Other ones should not be restired after a restart. 76 // Other ones should not be restired after a restart.
82 if (subscriber_it.second.persistent) 77 if (subscriber_it.second.persistent)
83 persistent_origins_value->AppendString(subscriber_it.first.spec()); 78 persistent_origins_value->AppendString(subscriber_it.first.spec());
84 } 79 }
80 watcher->SetWithoutPathExpansion(kPrefKeyWatcherPersistentOrigins,
81 std::move(persistent_origins_value));
82 watchers_value->SetWithoutPathExpansion(it.second.entry_path.value(),
83 std::move(watcher));
85 } 84 }
85 file_system->SetWithoutPathExpansion(kPrefKeyWatchers,
86 std::move(watchers_value));
86 87
87 PrefService* const pref_service = profile_->GetPrefs(); 88 PrefService* const pref_service = profile_->GetPrefs();
88 DCHECK(pref_service); 89 DCHECK(pref_service);
89 90
90 DictionaryPrefUpdate dict_update(pref_service, 91 DictionaryPrefUpdate dict_update(pref_service,
91 prefs::kFileSystemProviderMounted); 92 prefs::kFileSystemProviderMounted);
92 93
93 base::DictionaryValue* file_systems_per_extension = NULL; 94 base::DictionaryValue* file_systems_per_extension_weak = NULL;
94 if (!dict_update->GetDictionaryWithoutPathExpansion( 95 if (!dict_update->GetDictionaryWithoutPathExpansion(
95 file_system_info.extension_id(), &file_systems_per_extension)) { 96 file_system_info.extension_id(), &file_systems_per_extension_weak)) {
96 file_systems_per_extension = new base::DictionaryValue(); 97 auto file_systems_per_extension = base::MakeUnique<base::DictionaryValue>();
98 file_systems_per_extension_weak = file_systems_per_extension.get();
97 dict_update->SetWithoutPathExpansion(file_system_info.extension_id(), 99 dict_update->SetWithoutPathExpansion(file_system_info.extension_id(),
98 file_systems_per_extension); 100 std::move(file_systems_per_extension));
99 } 101 }
100 102
101 file_systems_per_extension->SetWithoutPathExpansion( 103 file_systems_per_extension_weak->SetWithoutPathExpansion(
102 file_system_info.file_system_id(), file_system); 104 file_system_info.file_system_id(), std::move(file_system));
103 } 105 }
104 106
105 void Registry::ForgetFileSystem(const std::string& extension_id, 107 void Registry::ForgetFileSystem(const std::string& extension_id,
106 const std::string& file_system_id) { 108 const std::string& file_system_id) {
107 PrefService* const pref_service = profile_->GetPrefs(); 109 PrefService* const pref_service = profile_->GetPrefs();
108 DCHECK(pref_service); 110 DCHECK(pref_service);
109 111
110 DictionaryPrefUpdate dict_update(pref_service, 112 DictionaryPrefUpdate dict_update(pref_service,
111 prefs::kFileSystemProviderMounted); 113 prefs::kFileSystemProviderMounted);
112 114
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 LOG(ERROR) << "Broken preferences detected while updating a tag."; 273 LOG(ERROR) << "Broken preferences detected while updating a tag.";
272 return; 274 return;
273 } 275 }
274 276
275 watcher_value->SetStringWithoutPathExpansion(kPrefKeyWatcherLastTag, 277 watcher_value->SetStringWithoutPathExpansion(kPrefKeyWatcherLastTag,
276 watcher.last_tag); 278 watcher.last_tag);
277 } 279 }
278 280
279 } // namespace file_system_provider 281 } // namespace file_system_provider
280 } // namespace chromeos 282 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698