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

Side by Side Diff: chrome/browser/extensions/extension_assets_manager_chromeos.cc

Issue 2811673002: Reland: Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Workaround with std::move 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"
20 #include "base/values.h"
18 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chromeos/profiles/profile_helper.h" 22 #include "chrome/browser/chromeos/profiles/profile_helper.h"
20 #include "chrome/browser/extensions/extension_service.h" 23 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
22 #include "chromeos/chromeos_switches.h" 25 #include "chromeos/chromeos_switches.h"
23 #include "components/prefs/pref_registry_simple.h" 26 #include "components/prefs/pref_registry_simple.h"
24 #include "components/prefs/pref_service.h" 27 #include "components/prefs/pref_service.h"
25 #include "components/prefs/scoped_user_pref_update.h" 28 #include "components/prefs/scoped_user_pref_update.h"
26 #include "components/user_manager/user_manager.h" 29 #include "components/user_manager/user_manager.h"
27 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 version, 393 version,
391 info.unpacked_extension_root, 394 info.unpacked_extension_root,
392 info.local_install_dir, 395 info.local_install_dir,
393 info.callback)); 396 info.callback));
394 } 397 }
395 return; 398 return;
396 } 399 }
397 400
398 PrefService* local_state = g_browser_process->local_state(); 401 PrefService* local_state = g_browser_process->local_state();
399 DictionaryPrefUpdate shared_extensions(local_state, kSharedExtensions); 402 DictionaryPrefUpdate shared_extensions(local_state, kSharedExtensions);
400 base::DictionaryValue* extension_info = NULL; 403 base::DictionaryValue* extension_info_weak = NULL;
401 if (!shared_extensions->GetDictionary(id, &extension_info)) { 404 if (!shared_extensions->GetDictionary(id, &extension_info_weak)) {
402 extension_info = new base::DictionaryValue; 405 auto extension_info = base::MakeUnique<base::DictionaryValue>();
403 shared_extensions->Set(id, extension_info); 406 extension_info_weak = extension_info.get();
407 shared_extensions->Set(id, std::move(extension_info));
404 } 408 }
405 409
406 CHECK(!shared_extensions->HasKey(version)); 410 CHECK(!shared_extensions->HasKey(version));
407 base::DictionaryValue* version_info = new base::DictionaryValue; 411 auto version_info = base::MakeUnique<base::DictionaryValue>();
408 extension_info->SetWithoutPathExpansion(version, version_info);
409 version_info->SetString(kSharedExtensionPath, shared_version_dir.value()); 412 version_info->SetString(kSharedExtensionPath, shared_version_dir.value());
410 413
411 base::ListValue* users = new base::ListValue; 414 auto users = base::MakeUnique<base::ListValue>();
412 version_info->Set(kSharedExtensionUsers, users);
413 for (size_t i = 0; i < pending_installs.size(); i++) { 415 for (size_t i = 0; i < pending_installs.size(); i++) {
414 ExtensionAssetsManagerHelper::PendingInstallInfo& info = 416 ExtensionAssetsManagerHelper::PendingInstallInfo& info =
415 pending_installs[i]; 417 pending_installs[i];
416 users->AppendString(info.profile->GetProfileUserName()); 418 users->AppendString(info.profile->GetProfileUserName());
417 419
418 ExtensionAssetsManagerChromeOS::GetFileTaskRunner(info.profile)->PostTask( 420 ExtensionAssetsManagerChromeOS::GetFileTaskRunner(info.profile)->PostTask(
419 FROM_HERE, 421 FROM_HERE,
420 base::Bind(info.callback, shared_version_dir)); 422 base::Bind(info.callback, shared_version_dir));
421 } 423 }
424 version_info->Set(kSharedExtensionUsers, std::move(users));
425 extension_info_weak->SetWithoutPathExpansion(version,
426 std::move(version_info));
422 } 427 }
423 428
424 // static 429 // static
425 void ExtensionAssetsManagerChromeOS::InstallLocalExtension( 430 void ExtensionAssetsManagerChromeOS::InstallLocalExtension(
426 const std::string& id, 431 const std::string& id,
427 const std::string& version, 432 const std::string& version,
428 const base::FilePath& unpacked_extension_root, 433 const base::FilePath& unpacked_extension_root,
429 const base::FilePath& local_install_dir, 434 const base::FilePath& local_install_dir,
430 InstallExtensionCallback callback) { 435 InstallExtensionCallback callback) {
431 callback.Run(file_util::InstallExtension( 436 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))); 576 std::make_pair(id, base::FilePath(shared_path)));
572 } else { 577 } else {
573 extension_info->RemoveWithoutPathExpansion(*it, NULL); 578 extension_info->RemoveWithoutPathExpansion(*it, NULL);
574 } 579 }
575 } 580 }
576 581
577 return true; 582 return true;
578 } 583 }
579 584
580 } // namespace extensions 585 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698