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

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

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

Powered by Google App Engine
This is Rietveld 408576698