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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/registry_unittest.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
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/ptr_util.h"
12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h" 14 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h"
13 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy stem_provider_capabilities_handler.h" 15 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy stem_provider_capabilities_handler.h"
14 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
15 #include "chrome/test/base/testing_browser_process.h" 17 #include "chrome/test/base/testing_browser_process.h"
16 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
17 #include "chrome/test/base/testing_profile_manager.h" 19 #include "chrome/test/base/testing_profile_manager.h"
18 #include "components/sync_preferences/testing_pref_service_syncable.h" 20 #include "components/sync_preferences/testing_pref_service_syncable.h"
19 #include "components/user_prefs/user_prefs.h" 21 #include "components/user_prefs/user_prefs.h"
20 #include "content/public/test/test_browser_thread_bundle.h" 22 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 26 matching lines...) Expand all
48 bool supports_notify_tag, 50 bool supports_notify_tag,
49 int opened_files_limit, 51 int opened_files_limit,
50 const Watcher& watcher) { 52 const Watcher& watcher) {
51 // Warning. Updating this code means that backward compatibility may be 53 // Warning. Updating this code means that backward compatibility may be
52 // broken, what is unexpected and should be avoided. 54 // broken, what is unexpected and should be avoided.
53 sync_preferences::TestingPrefServiceSyncable* const pref_service = 55 sync_preferences::TestingPrefServiceSyncable* const pref_service =
54 profile->GetTestingPrefService(); 56 profile->GetTestingPrefService();
55 ASSERT_TRUE(pref_service); 57 ASSERT_TRUE(pref_service);
56 58
57 base::DictionaryValue extensions; 59 base::DictionaryValue extensions;
58 base::DictionaryValue* const file_systems = new base::DictionaryValue(); 60 auto file_systems = base::MakeUnique<base::DictionaryValue>();
jdoerrie 2017/04/06 14:25:49 Consider moving this down to where it's needed for
vabr (Chromium) 2017/04/07 20:40:39 Done.
59 base::DictionaryValue* const file_system = new base::DictionaryValue(); 61 auto file_system = base::MakeUnique<base::DictionaryValue>();
60 file_system->SetStringWithoutPathExpansion(kPrefKeyFileSystemId, 62 file_system->SetStringWithoutPathExpansion(kPrefKeyFileSystemId,
61 kFileSystemId); 63 kFileSystemId);
62 file_system->SetStringWithoutPathExpansion(kPrefKeyDisplayName, kDisplayName); 64 file_system->SetStringWithoutPathExpansion(kPrefKeyDisplayName, kDisplayName);
63 file_system->SetBooleanWithoutPathExpansion(kPrefKeyWritable, writable); 65 file_system->SetBooleanWithoutPathExpansion(kPrefKeyWritable, writable);
64 file_system->SetBooleanWithoutPathExpansion(kPrefKeySupportsNotifyTag, 66 file_system->SetBooleanWithoutPathExpansion(kPrefKeySupportsNotifyTag,
65 supports_notify_tag); 67 supports_notify_tag);
66 file_system->SetIntegerWithoutPathExpansion(kPrefKeyOpenedFilesLimit, 68 file_system->SetIntegerWithoutPathExpansion(kPrefKeyOpenedFilesLimit,
67 opened_files_limit); 69 opened_files_limit);
68 file_systems->SetWithoutPathExpansion(kFileSystemId, file_system);
69 extensions.SetWithoutPathExpansion(kExtensionId, file_systems);
70 70
71 // Remember watchers. 71 // Remember watchers.
72 base::DictionaryValue* const watchers = new base::DictionaryValue(); 72 auto watchers = base::MakeUnique<base::DictionaryValue>();
jdoerrie 2017/04/06 14:25:49 Same here.
vabr (Chromium) 2017/04/07 20:40:39 Done.
73 file_system->SetWithoutPathExpansion(kPrefKeyWatchers, watchers); 73 auto watcher_value = base::MakeUnique<base::DictionaryValue>();
74 base::DictionaryValue* const watcher_value = new base::DictionaryValue();
75 watchers->SetWithoutPathExpansion(watcher.entry_path.value(), watcher_value);
76 watcher_value->SetStringWithoutPathExpansion(kPrefKeyWatcherEntryPath, 74 watcher_value->SetStringWithoutPathExpansion(kPrefKeyWatcherEntryPath,
77 watcher.entry_path.value()); 75 watcher.entry_path.value());
78 watcher_value->SetBooleanWithoutPathExpansion(kPrefKeyWatcherRecursive, 76 watcher_value->SetBooleanWithoutPathExpansion(kPrefKeyWatcherRecursive,
79 watcher.recursive); 77 watcher.recursive);
80 watcher_value->SetStringWithoutPathExpansion(kPrefKeyWatcherLastTag, 78 watcher_value->SetStringWithoutPathExpansion(kPrefKeyWatcherLastTag,
81 watcher.last_tag); 79 watcher.last_tag);
82 base::ListValue* const persistent_origins_value = new base::ListValue(); 80 auto persistent_origins_value = base::MakeUnique<base::ListValue>();
83 watcher_value->SetWithoutPathExpansion(kPrefKeyWatcherPersistentOrigins,
84 persistent_origins_value);
85 for (const auto& subscriber_it : watcher.subscribers) { 81 for (const auto& subscriber_it : watcher.subscribers) {
86 if (subscriber_it.second.persistent) 82 if (subscriber_it.second.persistent)
87 persistent_origins_value->AppendString(subscriber_it.first.spec()); 83 persistent_origins_value->AppendString(subscriber_it.first.spec());
88 } 84 }
89 85
86 watcher_value->SetWithoutPathExpansion(kPrefKeyWatcherPersistentOrigins,
87 std::move(persistent_origins_value));
88 watchers->SetWithoutPathExpansion(watcher.entry_path.value(),
89 std::move(watcher_value));
90 file_system->SetWithoutPathExpansion(kPrefKeyWatchers, std::move(watchers));
91 file_systems->SetWithoutPathExpansion(kFileSystemId, std::move(file_system));
92 extensions.SetWithoutPathExpansion(kExtensionId, std::move(file_systems));
90 pref_service->Set(prefs::kFileSystemProviderMounted, extensions); 93 pref_service->Set(prefs::kFileSystemProviderMounted, extensions);
91 } 94 }
92 95
93 } // namespace 96 } // namespace
94 97
95 class FileSystemProviderRegistryTest : public testing::Test { 98 class FileSystemProviderRegistryTest : public testing::Test {
96 protected: 99 protected:
97 FileSystemProviderRegistryTest() : profile_(NULL) {} 100 FileSystemProviderRegistryTest() : profile_(NULL) {}
98 101
99 ~FileSystemProviderRegistryTest() override {} 102 ~FileSystemProviderRegistryTest() override {}
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 fake_watcher_.entry_path.value(), &watcher)); 317 fake_watcher_.entry_path.value(), &watcher));
315 318
316 std::string last_tag; 319 std::string last_tag;
317 EXPECT_TRUE(watcher->GetStringWithoutPathExpansion(kPrefKeyWatcherLastTag, 320 EXPECT_TRUE(watcher->GetStringWithoutPathExpansion(kPrefKeyWatcherLastTag,
318 &last_tag)); 321 &last_tag));
319 EXPECT_EQ(fake_watcher_.last_tag, last_tag); 322 EXPECT_EQ(fake_watcher_.last_tag, last_tag);
320 } 323 }
321 324
322 } // namespace file_system_provider 325 } // namespace file_system_provider
323 } // namespace chromeos 326 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698