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

Unified Diff: chrome/browser/extensions/api/commands/command_service.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/commands/command_service.cc
diff --git a/chrome/browser/extensions/api/commands/command_service.cc b/chrome/browser/extensions/api/commands/command_service.cc
index 772a9390f938b71a251fe5bfb85c27f23d023904..a5bc5e0b407b7311b84468e18e789e6434c565e1 100644
--- a/chrome/browser/extensions/api/commands/command_service.cc
+++ b/chrome/browser/extensions/api/commands/command_service.cc
@@ -12,6 +12,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/values.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/extensions/api/commands/commands.h"
#include "chrome/browser/extensions/extension_commands_global_registry.h"
@@ -277,12 +278,12 @@ bool CommandService::AddKeybindingPref(
RemoveKeybindingPrefs(extension_id, command_name);
// Set the keybinding pref.
- base::DictionaryValue* keybinding = new base::DictionaryValue();
+ auto keybinding = base::MakeUnique<base::DictionaryValue>();
keybinding->SetString(kExtension, extension_id);
keybinding->SetString(kCommandName, command_name);
keybinding->SetBoolean(kGlobal, global);
- bindings->Set(key, keybinding);
+ bindings->Set(key, std::move(keybinding));
// Set the was_assigned pref for the suggested key.
std::unique_ptr<base::DictionaryValue> command_keys(
@@ -290,7 +291,7 @@ bool CommandService::AddKeybindingPref(
command_keys->SetBoolean(kSuggestedKeyWasAssigned, true);
std::unique_ptr<base::DictionaryValue> suggested_key_prefs(
new base::DictionaryValue);
- suggested_key_prefs->Set(command_name, command_keys.release());
+ suggested_key_prefs->Set(command_name, std::move(command_keys));
MergeSuggestedKeyPrefs(extension_id, ExtensionPrefs::Get(profile_),
std::move(suggested_key_prefs));
@@ -646,7 +647,7 @@ void CommandService::UpdateExtensionSuggestedCommandPrefs(
command_keys->SetString(
kSuggestedKey,
Command::AcceleratorToString(command.accelerator()));
- suggested_key_prefs->Set(command.command_name(), command_keys.release());
+ suggested_key_prefs->Set(command.command_name(), std::move(command_keys));
}
}
@@ -663,7 +664,7 @@ void CommandService::UpdateExtensionSuggestedCommandPrefs(
kSuggestedKey,
Command::AcceleratorToString(browser_action_command->accelerator()));
suggested_key_prefs->Set(browser_action_command->command_name(),
- command_keys.release());
+ std::move(command_keys));
}
const Command* page_action_command =
@@ -675,7 +676,7 @@ void CommandService::UpdateExtensionSuggestedCommandPrefs(
kSuggestedKey,
Command::AcceleratorToString(page_action_command->accelerator()));
suggested_key_prefs->Set(page_action_command->command_name(),
- command_keys.release());
+ std::move(command_keys));
}
// Merge into current prefs, if present.

Powered by Google App Engine
This is Rietveld 408576698