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

Side by Side Diff: chrome/browser/extensions/extension_assets_manager_chromeos.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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/extensions/extension_assets_manager_chromeos.h" 5 #include "chrome/browser/extensions/extension_assets_manager_chromeos.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <utility>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h"
15 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
16 #include "base/sequenced_task_runner.h" 18 #include "base/sequenced_task_runner.h"
17 #include "base/sys_info.h" 19 #include "base/sys_info.h"
jdoerrie 2017/04/06 14:25:51 #include "base/values.h"
vabr (Chromium) 2017/04/07 20:40:40 Done.
18 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chromeos/profiles/profile_helper.h" 21 #include "chrome/browser/chromeos/profiles/profile_helper.h"
20 #include "chrome/browser/extensions/extension_service.h" 22 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
22 #include "chromeos/chromeos_switches.h" 24 #include "chromeos/chromeos_switches.h"
23 #include "components/prefs/pref_registry_simple.h" 25 #include "components/prefs/pref_registry_simple.h"
24 #include "components/prefs/pref_service.h" 26 #include "components/prefs/pref_service.h"
25 #include "components/prefs/scoped_user_pref_update.h" 27 #include "components/prefs/scoped_user_pref_update.h"
26 #include "components/user_manager/user_manager.h" 28 #include "components/user_manager/user_manager.h"
27 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 version, 392 version,
391 info.unpacked_extension_root, 393 info.unpacked_extension_root,
392 info.local_install_dir, 394 info.local_install_dir,
393 info.callback)); 395 info.callback));
394 } 396 }
395 return; 397 return;
396 } 398 }
397 399
398 PrefService* local_state = g_browser_process->local_state(); 400 PrefService* local_state = g_browser_process->local_state();
399 DictionaryPrefUpdate shared_extensions(local_state, kSharedExtensions); 401 DictionaryPrefUpdate shared_extensions(local_state, kSharedExtensions);
400 base::DictionaryValue* extension_info = NULL; 402 base::DictionaryValue* extension_info_weak = NULL;
401 if (!shared_extensions->GetDictionary(id, &extension_info)) { 403 if (!shared_extensions->GetDictionary(id, &extension_info_weak)) {
402 extension_info = new base::DictionaryValue; 404 auto extension_info = base::MakeUnique<base::DictionaryValue>();
403 shared_extensions->Set(id, extension_info); 405 extension_info_weak = extension_info.get();
406 shared_extensions->Set(id, std::move(extension_info));
404 } 407 }
405 408
406 CHECK(!shared_extensions->HasKey(version)); 409 CHECK(!shared_extensions->HasKey(version));
407 base::DictionaryValue* version_info = new base::DictionaryValue; 410 auto version_info = base::MakeUnique<base::DictionaryValue>();
408 extension_info->SetWithoutPathExpansion(version, version_info);
409 version_info->SetString(kSharedExtensionPath, shared_version_dir.value()); 411 version_info->SetString(kSharedExtensionPath, shared_version_dir.value());
410 412
411 base::ListValue* users = new base::ListValue; 413 auto users = base::MakeUnique<base::ListValue>();
412 version_info->Set(kSharedExtensionUsers, users);
413 for (size_t i = 0; i < pending_installs.size(); i++) { 414 for (size_t i = 0; i < pending_installs.size(); i++) {
414 ExtensionAssetsManagerHelper::PendingInstallInfo& info = 415 ExtensionAssetsManagerHelper::PendingInstallInfo& info =
415 pending_installs[i]; 416 pending_installs[i];
416 users->AppendString(info.profile->GetProfileUserName()); 417 users->AppendString(info.profile->GetProfileUserName());
417 418
418 ExtensionAssetsManagerChromeOS::GetFileTaskRunner(info.profile)->PostTask( 419 ExtensionAssetsManagerChromeOS::GetFileTaskRunner(info.profile)->PostTask(
419 FROM_HERE, 420 FROM_HERE,
420 base::Bind(info.callback, shared_version_dir)); 421 base::Bind(info.callback, shared_version_dir));
421 } 422 }
423 version_info->Set(kSharedExtensionUsers, std::move(users));
424 extension_info_weak->SetWithoutPathExpansion(version,
425 std::move(version_info));
422 } 426 }
423 427
424 // static 428 // static
425 void ExtensionAssetsManagerChromeOS::InstallLocalExtension( 429 void ExtensionAssetsManagerChromeOS::InstallLocalExtension(
426 const std::string& id, 430 const std::string& id,
427 const std::string& version, 431 const std::string& version,
428 const base::FilePath& unpacked_extension_root, 432 const base::FilePath& unpacked_extension_root,
429 const base::FilePath& local_install_dir, 433 const base::FilePath& local_install_dir,
430 InstallExtensionCallback callback) { 434 InstallExtensionCallback callback) {
431 callback.Run(file_util::InstallExtension( 435 callback.Run(file_util::InstallExtension(
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 std::make_pair(id, base::FilePath(shared_path))); 575 std::make_pair(id, base::FilePath(shared_path)));
572 } else { 576 } else {
573 extension_info->RemoveWithoutPathExpansion(*it, NULL); 577 extension_info->RemoveWithoutPathExpansion(*it, NULL);
574 } 578 }
575 } 579 }
576 580
577 return true; 581 return true;
578 } 582 }
579 583
580 } // namespace extensions 584 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698