Index: chrome/browser/extensions/api/tabs/tabs_api.cc |
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc |
index 885d1a7bc6e830f40ff528fcd2ef38470f8d2aa7..3179defec81ce864d026d376c237b789e42c7f34 100644 |
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc |
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc |
@@ -7,6 +7,7 @@ |
#include <stddef.h> |
#include <algorithm> |
#include <limits> |
+#include <memory> |
#include <utility> |
#include <vector> |
@@ -14,6 +15,7 @@ |
#include "base/command_line.h" |
#include "base/location.h" |
#include "base/logging.h" |
+#include "base/memory/ptr_util.h" |
#include "base/memory/ref_counted_memory.h" |
#include "base/single_thread_task_runner.h" |
#include "base/stl_util.h" |
@@ -357,7 +359,7 @@ bool WindowsGetAllFunction::RunSync() { |
EXTENSION_FUNCTION_VALIDATE(params.get()); |
ApiParameterExtractor<windows::GetAll::Params> extractor(params.get()); |
- base::ListValue* window_list = new base::ListValue(); |
+ std::unique_ptr<base::ListValue> window_list(new base::ListValue()); |
const WindowControllerList::ControllerList& windows = |
WindowControllerList::GetInstance()->windows(); |
for (WindowControllerList::ControllerList::const_iterator iter = |
@@ -371,7 +373,7 @@ bool WindowsGetAllFunction::RunSync() { |
else |
window_list->Append((*iter)->CreateWindowValue()); |
} |
- SetResult(window_list); |
+ SetResult(std::move(window_list)); |
return true; |
} |
@@ -918,7 +920,7 @@ bool TabsQueryFunction::RunSync() { |
if (params->query_info.window_type != tabs::WINDOW_TYPE_NONE) |
window_type = tabs::ToString(params->query_info.window_type); |
- base::ListValue* result = new base::ListValue(); |
+ std::unique_ptr<base::ListValue> result(new base::ListValue()); |
Browser* last_active_browser = |
chrome::FindAnyBrowser(GetProfile(), include_incognito()); |
Browser* current_browser = GetCurrentBrowser(); |
@@ -1028,7 +1030,7 @@ bool TabsQueryFunction::RunSync() { |
} |
} |
- SetResult(result); |
+ SetResult(std::move(result)); |
return true; |
} |
@@ -1058,7 +1060,7 @@ bool TabsCreateFunction::RunSync() { |
// Return data about the newly created tab. |
if (has_callback()) { |
- SetResult(result.release()); |
+ SetResult(std::move(result)); |
} |
return true; |
} |
@@ -1451,10 +1453,10 @@ bool TabsMoveFunction::RunSync() { |
} else if (num_tabs == 1) { |
std::unique_ptr<base::Value> value; |
CHECK(tab_values.get()->Remove(0, &value)); |
- SetResult(value.release()); |
+ SetResult(std::move(value)); |
} else { |
// Only return the results as an array if there are multiple tabs. |
- SetResult(tab_values.release()); |
+ SetResult(std::move(tab_values)); |
} |
return true; |
@@ -1734,7 +1736,7 @@ void TabsCaptureVisibleTabFunction::OnCaptureSuccess(const SkBitmap& bitmap) { |
return; |
} |
- SetResult(new base::StringValue(base64_result)); |
+ SetResult(base::MakeUnique<base::StringValue>(base64_result)); |
SendResponse(true); |
} |
@@ -1850,7 +1852,7 @@ void TabsDetectLanguageFunction::Observe( |
} |
void TabsDetectLanguageFunction::GotLanguage(const std::string& language) { |
- SetResult(new base::StringValue(language.c_str())); |
+ SetResult(base::MakeUnique<base::StringValue>(language.c_str())); |
SendResponse(true); |
Release(); // Balanced in Run() |
@@ -2006,7 +2008,7 @@ void TabsExecuteScriptFunction::OnExecuteCodeFinished( |
const GURL& on_url, |
const base::ListValue& result) { |
if (error.empty()) |
- SetResult(result.DeepCopy()); |
+ SetResult(result.CreateDeepCopy()); |
ExecuteCodeInTabFunction::OnExecuteCodeFinished(error, on_url, result); |
} |