diff options
author | mtytel@chromium.org <mtytel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-12 22:39:09 +0000 |
---|---|---|
committer | mtytel@chromium.org <mtytel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-12 22:39:09 +0000 |
commit | 07ff5fdb0c27afeed02cec68d42c49c4d694d521 (patch) | |
tree | 9c616ed2d25f1284716fd193999943fb24ae4cb2 | |
parent | b8da3c2d5cb4399505bd3e8cd05a00c588c1e45f (diff) | |
download | chromium_src-07ff5fdb0c27afeed02cec68d42c49c4d694d521.zip chromium_src-07ff5fdb0c27afeed02cec68d42c49c4d694d521.tar.gz chromium_src-07ff5fdb0c27afeed02cec68d42c49c4d694d521.tar.bz2 |
Added support for multiple parameters to Extension API callbacks.
BUG=135269
TEST=
Review URL: https://chromiumcodereview.appspot.com/10694106
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146469 0039d316-1c4b-4281-b951-d872f2087c98
75 files changed, 370 insertions, 355 deletions
diff --git a/chrome/browser/accessibility/accessibility_extension_api.cc b/chrome/browser/accessibility/accessibility_extension_api.cc index e2c9fa9..8d4e20a5 100644 --- a/chrome/browser/accessibility/accessibility_extension_api.cc +++ b/chrome/browser/accessibility/accessibility_extension_api.cc @@ -185,9 +185,9 @@ bool GetFocusedControlFunction::RunImpl() { DictionaryValue *last_focused_control_dict = accessibility_event_router->last_focused_control_dict(); if (last_focused_control_dict->size()) { - result_.reset(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); + SetResult(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); } else { - result_.reset(Value::CreateNullValue()); + SetResult(Value::CreateNullValue()); } return true; } @@ -223,6 +223,6 @@ bool GetAlertsForTabFunction::RunImpl() { } } - result_.reset(alerts_value); + SetResult(alerts_value); return true; } diff --git a/chrome/browser/bookmarks/bookmark_extension_api.cc b/chrome/browser/bookmarks/bookmark_extension_api.cc index 96ac5b2..7413006 100644 --- a/chrome/browser/bookmarks/bookmark_extension_api.cc +++ b/chrome/browser/bookmarks/bookmark_extension_api.cc @@ -324,7 +324,7 @@ bool GetBookmarksFunction::RunImpl() { bookmark_extension_helpers::AddNode(node, json.get(), false); } - result_.reset(json.release()); + SetResult(json.release()); return true; } @@ -347,7 +347,7 @@ bool GetBookmarkChildrenFunction::RunImpl() { bookmark_extension_helpers::AddNode(child, json.get(), false); } - result_.reset(json.release()); + SetResult(json.release()); return true; } @@ -366,7 +366,7 @@ bool GetBookmarkRecentFunction::RunImpl() { const BookmarkNode* node = *i; bookmark_extension_helpers::AddNode(node, json, false); } - result_.reset(json); + SetResult(json); return true; } @@ -375,7 +375,7 @@ bool GetBookmarkTreeFunction::RunImpl() { scoped_ptr<ListValue> json(new ListValue()); const BookmarkNode* node = model->root_node(); bookmark_extension_helpers::AddNode(node, json.get(), true); - result_.reset(json.release()); + SetResult(json.release()); return true; } @@ -395,7 +395,7 @@ bool GetBookmarkSubTreeFunction::RunImpl() { return false; } bookmark_extension_helpers::AddNode(node, json.get(), true); - result_.reset(json.release()); + SetResult(json.release()); return true; } @@ -416,7 +416,7 @@ bool SearchBookmarksFunction::RunImpl() { bookmark_extension_helpers::AddNode(node, json, false); } - result_.reset(json); + SetResult(json); return true; } @@ -522,7 +522,7 @@ bool CreateBookmarkFunction::RunImpl() { DictionaryValue* ret = bookmark_extension_helpers::GetNodeDictionary(node, false, false); - result_.reset(ret); + SetResult(ret); return true; } @@ -601,7 +601,7 @@ bool MoveBookmarkFunction::RunImpl() { DictionaryValue* ret = bookmark_extension_helpers::GetNodeDictionary(node, false, false); - result_.reset(ret); + SetResult(ret); return true; } @@ -659,7 +659,7 @@ bool UpdateBookmarkFunction::RunImpl() { DictionaryValue* ret = bookmark_extension_helpers::GetNodeDictionary(node, false, false); - result_.reset(ret); + SetResult(ret); return true; } diff --git a/chrome/browser/bookmarks/bookmark_manager_extension_api.cc b/chrome/browser/bookmarks/bookmark_manager_extension_api.cc index 4679096..4b07946 100644 --- a/chrome/browser/bookmarks/bookmark_manager_extension_api.cc +++ b/chrome/browser/bookmarks/bookmark_manager_extension_api.cc @@ -280,7 +280,7 @@ bool CanPasteBookmarkManagerFunction::RunImpl() { return false; } bool can_paste = bookmark_utils::CanPasteFromClipboard(parent_node); - result_.reset(Value::CreateBooleanValue(can_paste)); + SetResult(Value::CreateBooleanValue(can_paste)); return true; } @@ -371,7 +371,7 @@ bool BookmarkManagerGetStringsFunction::RunImpl() { ChromeURLDataManager::DataSource::SetFontAndTextDirection(localized_strings); - result_.reset(localized_strings); + SetResult(localized_strings); // This is needed because unlike the rest of these functions, this class // inherits from AsyncFunction directly, rather than BookmarkFunction. @@ -490,12 +490,12 @@ bool GetSubtreeBookmarkManagerFunction::RunImpl() { } else { bookmark_extension_helpers::AddNode(node, json.get(), true); } - result_.reset(json.release()); + SetResult(json.release()); return true; } bool CanEditBookmarkManagerFunction::RunImpl() { - result_.reset(Value::CreateBooleanValue( + SetResult(Value::CreateBooleanValue( profile_->GetPrefs()->GetBoolean(prefs::kEditBookmarksEnabled))); return true; } @@ -513,6 +513,6 @@ bool CanOpenNewWindowsBookmarkFunction::RunImpl() { can_open_new_windows = false; #endif // OS_WIN - result_.reset(Value::CreateBooleanValue(can_open_new_windows)); + SetResult(Value::CreateBooleanValue(can_open_new_windows)); return true; } diff --git a/chrome/browser/chromeos/extensions/echo_private_api.cc b/chrome/browser/chromeos/extensions/echo_private_api.cc index a48c704..9c1729d 100644 --- a/chrome/browser/chromeos/extensions/echo_private_api.cc +++ b/chrome/browser/chromeos/extensions/echo_private_api.cc @@ -44,6 +44,6 @@ GetRegistrationCodeFunction::~GetRegistrationCodeFunction() { bool GetRegistrationCodeFunction::RunImpl() { std::string type; EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &type)); - result_.reset(GetValueForRegistrationCodeType(type)); + SetResult(GetValueForRegistrationCodeType(type)); return true; } diff --git a/chrome/browser/chromeos/extensions/file_browser_handler_api.cc b/chrome/browser/chromeos/extensions/file_browser_handler_api.cc index 6f4b507..d3e2368 100644 --- a/chrome/browser/chromeos/extensions/file_browser_handler_api.cc +++ b/chrome/browser/chromeos/extensions/file_browser_handler_api.cc @@ -309,7 +309,7 @@ void FileHandlerSelectFileFunction::Respond( result->entry->file_is_directory = false; } - result_.reset(SelectFile::Result::Create(*result)); + SetResult(SelectFile::Result::Create(*result)); SendResponse(true); } diff --git a/chrome/browser/chromeos/extensions/file_browser_handler_api_test.cc b/chrome/browser/chromeos/extensions/file_browser_handler_api_test.cc index 569d481..11328fd 100644 --- a/chrome/browser/chromeos/extensions/file_browser_handler_api_test.cc +++ b/chrome/browser/chromeos/extensions/file_browser_handler_api_test.cc @@ -196,7 +196,7 @@ IN_PROC_BROWSER_TEST_F(FileBrowserHandlerTest, SelectionFailed) { select_file_function->set_user_gesture(true); scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( select_file_function.get(), "[{\"suggestedName\": \"some_file_name.txt\"}]", browser()))); @@ -223,7 +223,7 @@ IN_PROC_BROWSER_TEST_F(FileBrowserHandlerTest, SuggestedFullPath) { select_file_function->set_user_gesture(true); scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( select_file_function.get(), "[{\"suggestedName\": \"/path_to_file/some_file_name.txt\"}]", browser()))); diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc index a3faf00..154b54b 100644 --- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc +++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc @@ -490,8 +490,8 @@ void RequestLocalFileSystemFunction::RespondSuccessOnUIThread( // proper authentication. if (gdata::util::IsGDataAvailable(profile_)) AddGDataMountPoint(profile_, extension_id(), render_view_host()); - result_.reset(new DictionaryValue()); - DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); + DictionaryValue* dict = new DictionaryValue(); + SetResult(dict); dict->SetString("name", name); dict->SetString("path", root_path.spec()); dict->SetInteger("error", base::PLATFORM_FILE_OK); @@ -531,7 +531,7 @@ bool FileWatchBrowserFunctionBase::GetLocalFilePath( } void FileWatchBrowserFunctionBase::RespondOnUIThread(bool success) { - result_.reset(Value::CreateBooleanValue(success)); + SetResult(Value::CreateBooleanValue(success)); SendResponse(success); } @@ -672,7 +672,7 @@ bool GetFileTasksFileBrowserFunction::RunImpl() { } ListValue* result_list = new ListValue(); - result_.reset(result_list); + SetResult(result_list); file_handler_util::LastUsedHandlerList common_tasks; if (!file_handler_util::FindCommonTasks(profile_, file_urls, &common_tasks)) @@ -772,7 +772,7 @@ bool ExecuteTasksFileBrowserFunction::RunImpl() { base::Bind(&ExecuteTasksFileBrowserFunction::OnTaskExecuted, this))) return false; - result_.reset(new base::FundamentalValue(true)); + SetResult(new base::FundamentalValue(true)); return true; } @@ -792,7 +792,7 @@ bool SetDefaultTaskFileBrowserFunction::RunImpl() { &file_handler_util::UpdateFileHandlerUsageStats, profile_, task_id)); - result_.reset(new base::FundamentalValue(true)); + SetResult(new base::FundamentalValue(true)); return true; } @@ -1009,7 +1009,7 @@ void ViewFilesFunction::GetLocalPathsResponseOnUIThread( if (!handled && files.size() == 1) success = false; } - result_.reset(Value::CreateBooleanValue(success)); + SetResult(Value::CreateBooleanValue(success)); SendResponse(true); } @@ -1082,7 +1082,7 @@ bool AddMountFunction::RunImpl() { } // Set default return source path to the empty string. - result_.reset(Value::CreateStringValue("")); + SetResult(Value::CreateStringValue("")); chromeos::MountType mount_type = DiskMountManager::MountTypeFromString(mount_type_str); @@ -1128,7 +1128,7 @@ void AddMountFunction::RaiseGDataMountEvent(gdata::GDataErrorCode error) { } // Pass back the gdata mount point path as source path. const std::string& gdata_path = gdata::util::GetGDataMountPointPathAsString(); - result_.reset(Value::CreateStringValue(gdata_path)); + SetResult(Value::CreateStringValue(gdata_path)); DiskMountManager::MountPointInfo mount_info( gdata_path, gdata_path, @@ -1180,7 +1180,7 @@ void AddMountFunction::OnMountedStateSet(const std::string& mount_type, DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); // Pass back the actual source path of the mount point. - result_.reset(Value::CreateStringValue(file_path.value())); + SetResult(Value::CreateStringValue(file_path.value())); SendResponse(true); // MountPath() takes a std::string. disk_mount_manager->MountPath(file_path.AsUTF8Unsafe(), @@ -1236,7 +1236,7 @@ bool GetMountPointsFunction::RunImpl() { return false; base::ListValue *mounts = new base::ListValue(); - result_.reset(mounts); + SetResult(mounts); DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); DiskMountManager::MountPointMap mount_points = @@ -1347,7 +1347,7 @@ void GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); base::DictionaryValue* sizes = new base::DictionaryValue(); - result_.reset(sizes); + SetResult(sizes); sizes->SetInteger("totalSizeKB", total_size_kb); sizes->SetInteger("remainingSizeKB", remaining_size_kb); @@ -1433,14 +1433,14 @@ void GetVolumeMetadataFunction::GetLocalPathsResponseOnUIThread( return; } - result_.reset(); + results_.reset(); const DiskMountManager::Disk* volume = GetVolumeAsDisk( files[0].path.value()); if (volume) { DictionaryValue* volume_info = CreateValueFromDisk(profile_, volume); - result_.reset(volume_info); + SetResult(volume_info); } SendResponse(true); @@ -1457,14 +1457,14 @@ bool ToggleFullscreenFunction::RunImpl() { bool IsFullscreenFunction::RunImpl() { Browser* browser = GetCurrentBrowser(); - result_.reset(Value::CreateBooleanValue( + SetResult(Value::CreateBooleanValue( browser && browser->window() && browser->window()->IsFullscreen())); return true; } bool FileDialogStringsFunction::RunImpl() { - result_.reset(new DictionaryValue()); - DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); + DictionaryValue* dict = new DictionaryValue(); + SetResult(dict); #define SET_STRING(ns, id) \ dict->SetString(#id, l10n_util::GetStringUTF16(ns##_##id)) @@ -1768,7 +1768,7 @@ void GetGDataFilePropertiesFunction::PrepareResults() { void GetGDataFilePropertiesFunction::GetNextFileProperties() { if (current_index_ >= path_list_->GetSize()) { // Exit of asynchronous look and return the result. - result_.reset(file_properties_.release()); + SetResult(file_properties_.release()); SendResponse(true); return; } @@ -1983,7 +1983,7 @@ void GetFileLocationsFunction::GetLocalPathsResponseOnUIThread( } } - result_.reset(locations); + SetResult(locations); SendResponse(true); } @@ -2032,7 +2032,7 @@ void GetGDataFilesFunction::GetLocalPathsResponseOnUIThread( void GetGDataFilesFunction::GetFileOrSendResponse() { // Send the response if all files are obtained. if (remaining_gdata_paths_.empty()) { - result_.reset(local_paths_); + SetResult(local_paths_); SendResponse(true); return; } @@ -2102,7 +2102,7 @@ bool GetFileTransfersFunction::RunImpl() { return false; } - result_.reset(progress_status_list.release()); + SetResult(progress_status_list.release()); SendResponse(true); return true; } @@ -2166,7 +2166,7 @@ void CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread( responses->Append(result.release()); } - result_.reset(responses.release()); + SetResult(responses.release()); SendResponse(true); } @@ -2267,7 +2267,7 @@ bool GetGDataPreferencesFunction::RunImpl() { value->SetBoolean("hostedFilesDisabled", service->GetBoolean(prefs::kDisableGDataHostedFiles)); - result_.reset(value.release()); + SetResult(value.release()); return true; } @@ -2319,7 +2319,7 @@ void GetPathForDriveSearchResultFunction::OnEntryFound( return; } - result_.reset(Value::CreateStringValue(entry_path.value())); + SetResult(Value::CreateStringValue(entry_path.value())); SendResponse(true); } @@ -2379,7 +2379,7 @@ void SearchDriveFunction::OnSearch( entries->Append(entry); } - result_.reset(entries); + SetResult(entries); SendResponse(true); } @@ -2403,7 +2403,7 @@ bool GetNetworkConnectionStateFunction::RunImpl() { type_string = "ethernet"; // Currently we do not care about other types. value->SetString("type", type_string); - result_.reset(value.release()); + SetResult(value.release()); return true; } diff --git a/chrome/browser/chromeos/media/media_player_extension_api.cc b/chrome/browser/chromeos/media/media_player_extension_api.cc index b23a1b9..a573abe 100644 --- a/chrome/browser/chromeos/media/media_player_extension_api.cc +++ b/chrome/browser/chromeos/media/media_player_extension_api.cc @@ -58,7 +58,7 @@ bool GetPlaylistMediaplayerFunction::RunImpl() { result->Set(kPropertyItems, GetPlaylistItems()); result->SetInteger(kPropertyPosition, player->GetPlaylistPosition()); - result_.reset(result); + SetResult(result); return true; } diff --git a/chrome/browser/extensions/api/alarms/alarms_api.cc b/chrome/browser/extensions/api/alarms/alarms_api.cc index b1fdc6a..3dcde51 100644 --- a/chrome/browser/extensions/api/alarms/alarms_api.cc +++ b/chrome/browser/extensions/api/alarms/alarms_api.cc @@ -132,7 +132,7 @@ bool AlarmsGetFunction::RunImpl() { return false; } - result_.reset(alarms::Get::Result::Create(*alarm->js_alarm)); + SetResult(alarms::Get::Result::Create(*alarm->js_alarm)); return true; } @@ -146,9 +146,9 @@ bool AlarmsGetAllFunction::RunImpl() { for (size_t i = 0, size = alarms->size(); i < size; ++i) { create_arg.push_back((*alarms)[i].js_alarm); } - result_.reset(alarms::GetAll::Result::Create(create_arg)); + SetResult(alarms::GetAll::Result::Create(create_arg)); } else { - result_.reset(new base::ListValue()); + SetResult(new base::ListValue()); } return true; } diff --git a/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc b/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc index 51409fd..a6e19a8 100644 --- a/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc +++ b/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc @@ -64,7 +64,7 @@ class ExtensionAlarmsTest : public BrowserWithTestWindowTest { base::Value* RunFunctionWithExtension( UIThreadExtensionFunction* function, const std::string& args) { function->set_extension(extension_.get()); - return utils::RunFunctionAndReturnResult(function, args, browser()); + return utils::RunFunctionAndReturnSingleResult(function, args, browser()); } base::DictionaryValue* RunFunctionAndReturnDict( diff --git a/chrome/browser/extensions/api/app_window/app_window_api.cc b/chrome/browser/extensions/api/app_window/app_window_api.cc index 0faa1ee..a75795d 100644 --- a/chrome/browser/extensions/api/app_window/app_window_api.cc +++ b/chrome/browser/extensions/api/app_window/app_window_api.cc @@ -110,7 +110,7 @@ bool AppWindowCreateFunction::RunImpl() { content::WebContents* created_contents = shell_window->web_contents(); int view_id = created_contents->GetRenderViewHost()->GetRoutingID(); - result_.reset(base::Value::CreateIntegerValue(view_id)); + SetResult(base::Value::CreateIntegerValue(view_id)); return true; } diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc index a8d92c5..90528ca 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc @@ -73,17 +73,17 @@ namespace api { #if defined(OS_CHROMEOS) bool BluetoothIsAvailableFunction::RunImpl() { - result_.reset(Value::CreateBooleanValue(GetAdapter(profile())->IsPresent())); + SetResult(Value::CreateBooleanValue(GetAdapter(profile())->IsPresent())); return true; } bool BluetoothIsPoweredFunction::RunImpl() { - result_.reset(Value::CreateBooleanValue(GetAdapter(profile())->IsPowered())); + SetResult(Value::CreateBooleanValue(GetAdapter(profile())->IsPowered())); return true; } bool BluetoothGetAddressFunction::RunImpl() { - result_.reset(Value::CreateStringValue(GetAdapter(profile())->address())); + SetResult(Value::CreateStringValue(GetAdapter(profile())->address())); return true; } @@ -112,7 +112,7 @@ bool BluetoothGetDevicesFunction::RunImpl() { const experimental_bluetooth::GetDevicesOptions& options = params->options; ListValue* matches = new ListValue; - result_.reset(matches); + SetResult(matches); CHECK_EQ(0, callbacks_pending_); @@ -185,7 +185,7 @@ bool BluetoothGetServicesFunction::RunImpl() { } ListValue* services = new ListValue; - result_.reset(services); + SetResult(services); device->GetServiceRecords( base::Bind(&BluetoothGetServicesFunction::GetServiceRecordsCallback, @@ -209,7 +209,7 @@ void BluetoothConnectFunction::ConnectToServiceCallback( *device, &result_socket.device); result_socket.service_uuid = service_uuid; result_socket.id = socket_id; - result_.reset(result_socket.ToValue().release()); + SetResult(result_socket.ToValue().release()); SendResponse(true); } else { SetError(kFailedToConnect); @@ -285,7 +285,7 @@ void BluetoothReadFunction::Work() { if (total_bytes_read > 0) { success_ = true; - result_.reset(base::BinaryValue::Create(all_bytes, total_bytes_read)); + SetResult(base::BinaryValue::Create(all_bytes, total_bytes_read)); } else { success_ = (errsv == EAGAIN || errsv == EWOULDBLOCK); free(all_bytes); @@ -332,10 +332,10 @@ void BluetoothWriteFunction::Work() { int errsv = errno; if (bytes_written > 0) { - result_.reset(Value::CreateIntegerValue(bytes_written)); + SetResult(Value::CreateIntegerValue(bytes_written)); success_ = true; } else { - result_.reset(0); + results_.reset(); success_ = (errsv == EAGAIN || errsv == EWOULDBLOCK); } @@ -425,7 +425,7 @@ void BluetoothGetLocalOutOfBandPairingDataFunction::ReadCallback( result->Set("hash", hash); result->Set("randomizer", randomizer); - result_.reset(result); + SetResult(result); SendResponse(true); } diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc index 5ea158e..6eb0e20 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc @@ -46,7 +46,7 @@ class BluetoothApiTest : public PlatformAppApiTest { UIThreadExtensionFunction* function, const std::string& args) { scoped_ptr<base::Value> result( - utils::RunFunctionAndReturnResult(function, args, browser())); + utils::RunFunctionAndReturnSingleResult(function, args, browser())); ASSERT_TRUE(result.get() != NULL); ASSERT_EQ(base::Value::TYPE_BOOLEAN, result->GetType()); bool boolean_value; @@ -151,7 +151,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevices) { scoped_refptr<api::BluetoothGetDevicesFunction> get_devices; get_devices = setupFunction(new api::BluetoothGetDevicesFunction); - scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( get_devices, "[{\"uuid\":\"foo\"}]", browser())); @@ -190,7 +190,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevices) { get_devices = setupFunction(new api::BluetoothGetDevicesFunction); result.reset( - utils::RunFunctionAndReturnResult(get_devices, "[{}]", browser())); + utils::RunFunctionAndReturnSingleResult(get_devices, "[{}]", browser())); ASSERT_EQ(base::Value::TYPE_LIST, result->GetType()); ASSERT_TRUE(result->GetAsList(&list)); @@ -208,8 +208,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetLocalOutOfBandPairingData) { get_oob_function(setupFunction( new api::BluetoothGetLocalOutOfBandPairingDataFunction)); - scoped_ptr<base::Value> result( - utils::RunFunctionAndReturnResult(get_oob_function, "[]", browser())); + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( + get_oob_function, "[]", browser())); base::DictionaryValue* dict; EXPECT_TRUE(result->GetAsDictionary(&dict)); @@ -254,7 +254,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, SetOutOfBandPairingData) { set_oob_function = setupFunction( new api::BluetoothSetOutOfBandPairingDataFunction); // There isn't actually a result. - (void)utils::RunFunctionAndReturnResult(set_oob_function, params, browser()); + (void)utils::RunFunctionAndReturnSingleResult( + set_oob_function, params, browser()); // Try again with an error testing::Mock::VerifyAndClearExpectations(mock_adapter_); @@ -306,7 +307,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) { testing::_)); scoped_refptr<api::BluetoothStopDiscoveryFunction> stop_function; stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction); - (void)utils::RunFunctionAndReturnResult(stop_function, "[]", browser()); + (void)utils::RunFunctionAndReturnSingleResult(stop_function, "[]", browser()); // Reset to try stopping with an error testing::Mock::VerifyAndClearExpectations(mock_adapter_); diff --git a/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc b/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc index a6b4ec5..1d39a5d 100644 --- a/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc +++ b/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc @@ -21,7 +21,7 @@ #include "content/public/browser/notification_service.h" using extension_function_test_utils::RunFunctionAndReturnError; -using extension_function_test_utils::RunFunctionAndReturnResult; +using extension_function_test_utils::RunFunctionAndReturnSingleResult; namespace { @@ -76,8 +76,10 @@ class ExtensionBrowsingDataTest : public InProcessBrowserTest, const std::string& key, int expected_mask) { SCOPED_TRACE(key); - EXPECT_EQ(NULL, RunFunctionAndReturnResult(new RemoveBrowsingDataFunction(), - std::string("[{\"since\": 1}, {\"") + key + "\": true}]", browser())); + EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( + new RemoveBrowsingDataFunction(), + std::string("[{\"since\": 1}, {\"") + key + "\": true}]", + browser())); EXPECT_EQ(expected_mask, GetRemovalMask()); EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); } @@ -86,7 +88,8 @@ class ExtensionBrowsingDataTest : public InProcessBrowserTest, const std::string& protectedStr, int expected_mask) { SCOPED_TRACE(protectedStr); - EXPECT_EQ(NULL, RunFunctionAndReturnResult(new RemoveBrowsingDataFunction(), + EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( + new RemoveBrowsingDataFunction(), "[{\"originType\": " + protectedStr + "}, {\"cookies\": true}]", browser())); EXPECT_EQ(expected_mask, GetOriginSetMask()); @@ -116,8 +119,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, OneAtATime) { // Use-after-free, see http://crbug.com/116522 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, DISABLED_RemoveBrowsingDataAll) { - EXPECT_EQ(NULL, RunFunctionAndReturnResult(new RemoveBrowsingDataFunction(), - kRemoveEverythingArguments, browser())); + EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( + new RemoveBrowsingDataFunction(), + kRemoveEverythingArguments, + browser())); EXPECT_EQ(base::Time::FromDoubleT(1.0), GetBeginTime()); EXPECT_EQ((BrowsingDataRemover::REMOVE_SITE_DATA | diff --git a/chrome/browser/extensions/api/content_settings/content_settings_api.cc b/chrome/browser/extensions/api/content_settings/content_settings_api.cc index 9e16a45..f2587b5 100644 --- a/chrome/browser/extensions/api/content_settings/content_settings_api.cc +++ b/chrome/browser/extensions/api/content_settings/content_settings_api.cc @@ -163,7 +163,7 @@ bool GetContentSettingFunction::RunImpl() { result->SetString(keys::kContentSettingKey, helpers::ContentSettingToString(setting)); - result_.reset(result); + SetResult(result); return true; } @@ -283,7 +283,7 @@ void GetResourceIdentifiersFunction::OnGotPluginGroups( dict->SetString(keys::kDescriptionKey, it->GetGroupName()); list->Append(dict); } - result_.reset(list); + SetResult(list); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind( &GetResourceIdentifiersFunction::SendResponse, this, true)); diff --git a/chrome/browser/extensions/api/cookies/cookies_api.cc b/chrome/browser/extensions/api/cookies/cookies_api.cc index cb17f30..58f928e 100644 --- a/chrome/browser/extensions/api/cookies/cookies_api.cc +++ b/chrome/browser/extensions/api/cookies/cookies_api.cc @@ -230,15 +230,14 @@ void GetCookieFunction::GetCookieCallback(const net::CookieList& cookie_list) { // CookieMonster returns them in canonical order (longest path, then // earliest creation time). if (it->Name() == name_) { - result_.reset( - cookies_helpers::CreateCookieValue(*it, store_id_)); + SetResult(cookies_helpers::CreateCookieValue(*it, store_id_)); break; } } // The cookie doesn't exist; return null. if (it == cookie_list.end()) - result_.reset(Value::CreateNullValue()); + SetResult(Value::CreateNullValue()); bool rv = BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, @@ -296,7 +295,7 @@ void GetAllCookiesFunction::GetAllCookiesCallback( cookies_helpers::AppendMatchingCookiesToList( cookie_list, store_id_, url_, details_, GetExtension(), matching_list); - result_.reset(matching_list); + SetResult(matching_list); } bool rv = BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, @@ -408,8 +407,7 @@ void SetCookieFunction::PullCookieCallback(const net::CookieList& cookie_list) { // CookieMonster returns them in canonical order (longest path, then // earliest creation time). if (it->Name() == name_) { - result_.reset( - cookies_helpers::CreateCookieValue(*it, store_id_)); + SetResult(cookies_helpers::CreateCookieValue(*it, store_id_)); break; } } @@ -481,7 +479,7 @@ void RemoveCookieFunction::RemoveCookieCallback() { resultDictionary->SetString(keys::kNameKey, name_); resultDictionary->SetString(keys::kUrlKey, url_.spec()); resultDictionary->SetString(keys::kStoreIdKey, store_id_); - result_.reset(resultDictionary); + SetResult(resultDictionary); // Return to UI thread bool rv = BrowserThread::PostTask( @@ -536,7 +534,7 @@ bool GetAllCookieStoresFunction::RunImpl() { cookies_helpers::CreateCookieStoreValue( incognito_profile, incognito_tab_ids.release())); } - result_.reset(cookie_store_list); + SetResult(cookie_store_list); return true; } diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc index d1c960c..77ba8cd 100644 --- a/chrome/browser/extensions/api/debugger/debugger_api.cc +++ b/chrome/browser/extensions/api/debugger/debugger_api.cc @@ -484,8 +484,8 @@ void SendCommandDebuggerFunction::SendResponseBody( Value* result_body; if (dictionary->Get("result", &result_body)) - result_.reset(result_body->DeepCopy()); + SetResult(result_body->DeepCopy()); else - result_.reset(new DictionaryValue()); + SetResult(new DictionaryValue()); SendResponse(true); } diff --git a/chrome/browser/extensions/api/declarative/declarative_api.cc b/chrome/browser/extensions/api/declarative/declarative_api.cc index 3606972..aaab9ad 100644 --- a/chrome/browser/extensions/api/declarative/declarative_api.cc +++ b/chrome/browser/extensions/api/declarative/declarative_api.cc @@ -78,7 +78,7 @@ bool AddRulesFunction::RunImplOnCorrectThread() { error_ = rules_registry_->AddRules(extension_id(), params->rules); if (error_.empty()) - result_.reset(AddRules::Result::Create(params->rules)); + SetResult(AddRules::Result::Create(params->rules)); return error_.empty(); } @@ -111,7 +111,7 @@ bool GetRulesFunction::RunImplOnCorrectThread() { } if (error_.empty()) - result_.reset(GetRules::Result::Create(rules)); + SetResult(GetRules::Result::Create(rules)); return error_.empty(); } diff --git a/chrome/browser/extensions/api/discovery/discovery_api_unittest.cc b/chrome/browser/extensions/api/discovery/discovery_api_unittest.cc index 267c88e..4bca9b1 100644 --- a/chrome/browser/extensions/api/discovery/discovery_api_unittest.cc +++ b/chrome/browser/extensions/api/discovery/discovery_api_unittest.cc @@ -80,7 +80,7 @@ class ExtensionDiscoveryTest : public BrowserWithTestWindowTest { base::Value* RunFunctionWithExtension( UIThreadExtensionFunction* function, const std::string& args) { function->set_extension(extension_.get()); - return utils::RunFunctionAndReturnResult(function, args, browser()); + return utils::RunFunctionAndReturnSingleResult(function, args, browser()); } // Runs a function and ignores the return value. diff --git a/chrome/browser/extensions/api/dns/dns_api.cc b/chrome/browser/extensions/api/dns/dns_api.cc index 063873a..4b9f354 100644 --- a/chrome/browser/extensions/api/dns/dns_api.cc +++ b/chrome/browser/extensions/api/dns/dns_api.cc @@ -85,7 +85,7 @@ void DnsResolveFunction::OnLookupFinished(int resolve_result) { resolve_info->address.reset( new std::string(addresses_->front().ToStringWithoutPort())); } - result_.reset(Resolve::Result::Create(*resolve_info)); + SetResult(Resolve::Result::Create(*resolve_info)); response_ = true; bool post_task_result = BrowserThread::PostTask( diff --git a/chrome/browser/extensions/api/dns/dns_apitest.cc b/chrome/browser/extensions/api/dns/dns_apitest.cc index f499390..e215a64 100644 --- a/chrome/browser/extensions/api/dns/dns_apitest.cc +++ b/chrome/browser/extensions/api/dns/dns_apitest.cc @@ -14,7 +14,7 @@ #include "net/base/net_util.h" using extension_function_test_utils::CreateEmptyExtension; -using extension_function_test_utils::RunFunctionAndReturnResult; +using extension_function_test_utils::RunFunctionAndReturnSingleResult; namespace { @@ -54,7 +54,7 @@ IN_PROC_BROWSER_TEST_F(DnsApiTest, DnsResolveIPLiteral) { resolve_function->set_extension(empty_extension.get()); resolve_function->set_has_callback(true); - scoped_ptr<base::Value> result(RunFunctionAndReturnResult( + scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult( resolve_function, "[\"127.0.0.1\"]", browser())); ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); @@ -80,8 +80,8 @@ IN_PROC_BROWSER_TEST_F(DnsApiTest, DnsResolveHostname) { function_arguments += extensions::MockHostResolverCreator::kHostname; function_arguments += "\"]"; scoped_ptr<base::Value> result( - RunFunctionAndReturnResult(resolve_function.get(), - function_arguments, browser())); + RunFunctionAndReturnSingleResult(resolve_function.get(), + function_arguments, browser())); ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc index 16b076cc..c8ec46a 100644 --- a/chrome/browser/extensions/api/downloads/downloads_api.cc +++ b/chrome/browser/extensions/api/downloads/downloads_api.cc @@ -556,7 +556,7 @@ void DownloadsDownloadFunction::OnStarted(DownloadId dl_id, net::Error error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); VLOG(1) << __FUNCTION__ << " " << dl_id << " " << error; if (dl_id.local() >= 0) { - result_.reset(base::Value::CreateIntegerValue(dl_id.local())); + SetResult(base::Value::CreateIntegerValue(dl_id.local())); } else { error_ = net::ErrorToString(error); } @@ -581,7 +581,7 @@ bool DownloadsSearchFunction::RunImpl() { scoped_ptr<base::DictionaryValue> item(DownloadItemToJSON(*it)); json_results->Append(item.release()); } - result_.reset(json_results); + SetResult(json_results); RecordApiFunctions(DOWNLOADS_FUNCTION_SEARCH); return true; } @@ -781,7 +781,7 @@ void DownloadsGetFileIconFunction::OnIconURLExtracted(const std::string& url) { error_ = download_extension_errors::kIconNotFoundError; } else { RecordApiFunctions(DOWNLOADS_FUNCTION_GET_FILE_ICON); - result_.reset(base::Value::CreateStringValue(url)); + SetResult(base::Value::CreateStringValue(url)); } SendResponse(error_.empty()); } diff --git a/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc b/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc index 909c3ca..bba9b21 100644 --- a/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc +++ b/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc @@ -496,7 +496,7 @@ class DownloadExtensionTest : public ExtensionApiTest { base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, const std::string& args) { SetUpExtensionFunction(function); - return extension_function_test_utils::RunFunctionAndReturnResult( + return extension_function_test_utils::RunFunctionAndReturnSingleResult( function, args, browser(), GetFlags()); } diff --git a/chrome/browser/extensions/api/extension_action/extension_actions_api.cc b/chrome/browser/extensions/api/extension_action/extension_actions_api.cc index fb17ffd..0a3779d 100644 --- a/chrome/browser/extensions/api/extension_action/extension_actions_api.cc +++ b/chrome/browser/extensions/api/extension_action/extension_actions_api.cc @@ -281,19 +281,18 @@ bool ExtensionActionSetBadgeBackgroundColorFunction::RunExtensionAction() { } bool ExtensionActionGetTitleFunction::RunExtensionAction() { - result_.reset(Value::CreateStringValue(extension_action_->GetTitle(tab_id_))); + SetResult(Value::CreateStringValue(extension_action_->GetTitle(tab_id_))); return true; } bool ExtensionActionGetPopupFunction::RunExtensionAction() { - result_.reset(Value::CreateStringValue( - extension_action_->GetPopupUrl(tab_id_).spec())); + SetResult( + Value::CreateStringValue(extension_action_->GetPopupUrl(tab_id_).spec())); return true; } bool ExtensionActionGetBadgeTextFunction::RunExtensionAction() { - result_.reset(Value::CreateStringValue( - extension_action_->GetBadgeText(tab_id_))); + SetResult(Value::CreateStringValue(extension_action_->GetBadgeText(tab_id_))); return true; } @@ -304,6 +303,6 @@ bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { list->Append(Value::CreateIntegerValue(SkColorGetG(color))); list->Append(Value::CreateIntegerValue(SkColorGetB(color))); list->Append(Value::CreateIntegerValue(SkColorGetA(color))); - result_.reset(list); + SetResult(list); return true; } diff --git a/chrome/browser/extensions/api/file_system/file_system_api.cc b/chrome/browser/extensions/api/file_system/file_system_api.cc index 37a59c25..e0fc80f 100644 --- a/chrome/browser/extensions/api/file_system/file_system_api.cc +++ b/chrome/browser/extensions/api/file_system/file_system_api.cc @@ -150,7 +150,7 @@ bool FileSystemGetDisplayPathFunction::RunImpl() { return false; file_path = PrettifyPath(file_path); - result_.reset(base::Value::CreateStringValue(file_path.value())); + SetResult(base::Value::CreateStringValue(file_path.value())); return true; } @@ -202,7 +202,7 @@ void FileSystemEntryFunction::RegisterFileSystemAndSendResponse( policy->GrantReadFile(renderer_id, path); DictionaryValue* dict = new DictionaryValue(); - result_.reset(dict); + SetResult(dict); dict->SetString("fileSystemId", filesystem_id); dict->SetString("baseName", registered_name); SendResponse(true); diff --git a/chrome/browser/extensions/api/identity/identity_api.cc b/chrome/browser/extensions/api/identity/identity_api.cc index 4333d34..4536d76 100644 --- a/chrome/browser/extensions/api/identity/identity_api.cc +++ b/chrome/browser/extensions/api/identity/identity_api.cc @@ -52,7 +52,7 @@ bool GetAuthTokenFunction::RunImpl() { } void GetAuthTokenFunction::OnMintTokenSuccess(const std::string& access_token) { - result_.reset(Value::CreateStringValue(access_token)); + SetResult(Value::CreateStringValue(access_token)); SendResponse(true); Release(); // Balanced in RunImpl. } @@ -147,7 +147,7 @@ bool LaunchWebAuthFlowFunction::RunImpl() { void LaunchWebAuthFlowFunction::OnAuthFlowSuccess( const std::string& redirect_url) { - result_.reset(Value::CreateStringValue(redirect_url)); + SetResult(Value::CreateStringValue(redirect_url)); SendResponse(true); Release(); // Balanced in RunImpl. } diff --git a/chrome/browser/extensions/api/idltest/idltest_api.cc b/chrome/browser/extensions/api/idltest/idltest_api.cc index 1feff0a..744aa79 100644 --- a/chrome/browser/extensions/api/idltest/idltest_api.cc +++ b/chrome/browser/extensions/api/idltest/idltest_api.cc @@ -24,14 +24,14 @@ ListValue* CopyBinaryValueToIntegerList(const BinaryValue* input) { bool IdltestSendArrayBufferFunction::RunImpl() { BinaryValue* input = NULL; EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input)); - result_.reset(CopyBinaryValueToIntegerList(input)); + SetResult(CopyBinaryValueToIntegerList(input)); return true; } bool IdltestSendArrayBufferViewFunction::RunImpl() { BinaryValue* input = NULL; EXTENSION_FUNCTION_VALIDATE(args_ != NULL && args_->GetBinary(0, &input)); - result_.reset(CopyBinaryValueToIntegerList(input)); + SetResult(CopyBinaryValueToIntegerList(input)); return true; } @@ -39,6 +39,6 @@ bool IdltestGetArrayBufferFunction::RunImpl() { std::string hello = "hello world"; BinaryValue* output = BinaryValue::CreateWithCopiedBuffer(hello.c_str(), hello.size()); - result_.reset(output); + SetResult(output); return true; } diff --git a/chrome/browser/extensions/api/media_gallery/media_gallery_api.cc b/chrome/browser/extensions/api/media_gallery/media_gallery_api.cc index 7e46ee1..15698f6 100644 --- a/chrome/browser/extensions/api/media_gallery/media_gallery_api.cc +++ b/chrome/browser/extensions/api/media_gallery/media_gallery_api.cc @@ -59,7 +59,7 @@ bool GetMediaFileSystemsFunction::RunImpl() { policy->GrantReadFileSystem(child_id, fsid); } - result_.reset(list); + SetResult(list); return true; } @@ -67,7 +67,7 @@ OpenMediaGalleryManagerFunction::~OpenMediaGalleryManagerFunction() {} bool OpenMediaGalleryManagerFunction::RunImpl() { // TODO(vandebo) Open the Media Gallery Manager UI. - result_.reset(Value::CreateNullValue()); + SetResult(Value::CreateNullValue()); return true; } @@ -75,7 +75,7 @@ AssembleMediaFileFunction::~AssembleMediaFileFunction() {} bool AssembleMediaFileFunction::RunImpl() { // TODO(vandebo) Update the metadata and return the new file. - result_.reset(Value::CreateNullValue()); + SetResult(Value::CreateNullValue()); return true; } diff --git a/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc b/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc index 28bb985..c2b4571 100644 --- a/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc +++ b/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc @@ -513,7 +513,7 @@ bool CreateOffscreenTabFunction::RunImpl() { // TODO(alexbost): Maybe the callback is called too soon. It should probably // be called once we have navigated to the url. if (has_callback()) { - result_.reset(offscreen_tab.CreateValue()); + SetResult(offscreen_tab.CreateValue()); SendResponse(true); } @@ -535,7 +535,7 @@ bool GetOffscreenTabFunction::RunImpl() { return false; } - result_.reset(offscreen_tab->CreateValue()); + SetResult(offscreen_tab->CreateValue()); return true; } @@ -555,7 +555,7 @@ bool GetAllOffscreenTabFunction::RunImpl() { tab_list->Append((*i)->CreateValue()); } - result_.reset(tab_list); + SetResult(tab_list); return true; } diff --git a/chrome/browser/extensions/api/permissions/permissions_api.cc b/chrome/browser/extensions/api/permissions/permissions_api.cc index 7184072..b798030 100644 --- a/chrome/browser/extensions/api/permissions/permissions_api.cc +++ b/chrome/browser/extensions/api/permissions/permissions_api.cc @@ -59,7 +59,7 @@ bool ContainsPermissionsFunction::RunImpl() { if (!permissions.get()) return false; - result_.reset(Contains::Result::Create( + SetResult(Contains::Result::Create( GetExtension()->GetActivePermissions()->Contains(*permissions))); return true; } @@ -67,7 +67,7 @@ bool ContainsPermissionsFunction::RunImpl() { bool GetAllPermissionsFunction::RunImpl() { scoped_ptr<Permissions> permissions = helpers::PackPermissionSet(GetExtension()->GetActivePermissions()); - result_.reset(GetAll::Result::Create(*permissions)); + SetResult(GetAll::Result::Create(*permissions)); return true; } @@ -101,12 +101,12 @@ bool RemovePermissionsFunction::RunImpl() { PermissionSet::CreateIntersection(permissions.get(), required)); if (!intersection->IsEmpty()) { error_ = kCantRemoveRequiredPermissionsError; - result_.reset(Remove::Result::Create(false)); + SetResult(Remove::Result::Create(false)); return false; } PermissionsUpdater(profile()).RemovePermissions(extension, permissions.get()); - result_.reset(Remove::Result::Create(true)); + SetResult(Remove::Result::Create(true)); return true; } @@ -127,14 +127,14 @@ void RequestPermissionsFunction::InstallUIProceed() { PermissionsUpdater perms_updater(profile()); perms_updater.AddPermissions(GetExtension(), requested_permissions_.get()); - result_.reset(Request::Result::Create(true)); + SetResult(Request::Result::Create(true)); SendResponse(true); Release(); // Balanced in RunImpl(). } void RequestPermissionsFunction::InstallUIAbort(bool user_initiated) { - result_.reset(Request::Result::Create(false)); + SetResult(Request::Result::Create(false)); SendResponse(true); Release(); // Balanced in RunImpl(). @@ -176,7 +176,7 @@ bool RequestPermissionsFunction::RunImpl() { if (!GetExtension()->optional_permission_set()->Contains( *requested_permissions_)) { error_ = kNotInOptionalPermissionsError; - result_.reset(Request::Result::Create(false)); + SetResult(Request::Result::Create(false)); return false; } @@ -187,7 +187,7 @@ bool RequestPermissionsFunction::RunImpl() { if (granted.get() && granted->Contains(*requested_permissions_)) { PermissionsUpdater perms_updater(profile()); perms_updater.AddPermissions(GetExtension(), requested_permissions_.get()); - result_.reset(Request::Result::Create(true)); + SetResult(Request::Result::Create(true)); SendResponse(true); return true; } diff --git a/chrome/browser/extensions/api/record/record_api.cc b/chrome/browser/extensions/api/record/record_api.cc index 1ebed8c..1a0bcd1 100644 --- a/chrome/browser/extensions/api/record/record_api.cc +++ b/chrome/browser/extensions/api/record/record_api.cc @@ -53,7 +53,7 @@ bool RunPageCyclerFunction::RunImpl() { // parameter parsing) then return a list of such errors, else perform // RunTestBrowser on the BlockingPool. if (!errors_.empty()) { - result_.reset(record::CaptureURLs::Result::Create(errors_)); + SetResult(record::CaptureURLs::Result::Create(errors_)); SendResponse(true); } else { content::BrowserThread::PostBlockingPoolTask(FROM_HERE, @@ -180,7 +180,7 @@ void CaptureURLsFunction::AddSwitches(CommandLine* line) { } void CaptureURLsFunction::Finish() { - result_.reset(record::CaptureURLs::Result::Create(errors_)); + SetResult(record::CaptureURLs::Result::Create(errors_)); SendResponse(true); } @@ -247,7 +247,7 @@ void ReplayURLsFunction::Finish() { result.stats = stats_; result.errors = errors_; - result_.reset(record::ReplayURLs::Result::Create(result)); + SetResult(record::ReplayURLs::Result::Create(result)); SendResponse(true); } diff --git a/chrome/browser/extensions/api/record/record_api_test.cc b/chrome/browser/extensions/api/record/record_api_test.cc index 317a16f..9dfed9a 100644 --- a/chrome/browser/extensions/api/record/record_api_test.cc +++ b/chrome/browser/extensions/api/record/record_api_test.cc @@ -231,7 +231,7 @@ class RecordApiTest : public InProcessBrowserTest { &escaped_user_data_dir); out_list->reset(utils::ToList( - utils::RunFunctionAndReturnResult(capture_function.get(), + utils::RunFunctionAndReturnSingleResult(capture_function.get(), base::StringPrintf(kCaptureArgs1, escaped_user_data_dir.c_str()), browser()))); @@ -315,7 +315,7 @@ IN_PROC_BROWSER_TEST_F(RecordApiTest, MAYBE_CheckPlayback) { scoped_refptr<ReplayURLsFunction> playback_function(new ReplayURLsFunction( new TestProcessStrategy(&temp_files_))); scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( - utils::RunFunctionAndReturnResult(playback_function, + utils::RunFunctionAndReturnSingleResult(playback_function, base::StringPrintf(kPlaybackArgs1, escaped_user_data_dir.c_str()), browser()))); diff --git a/chrome/browser/extensions/api/serial/serial_api.cc b/chrome/browser/extensions/api/serial/serial_api.cc index 4f06f66..9517d2c 100644 --- a/chrome/browser/extensions/api/serial/serial_api.cc +++ b/chrome/browser/extensions/api/serial/serial_api.cc @@ -48,7 +48,7 @@ void SerialGetPortsFunction::Work() { ports->Append(Value::CreateStringValue(*i++)); } - result_.reset(ports); + SetResult(ports); } bool SerialGetPortsFunction::Respond() { @@ -115,12 +115,12 @@ void SerialOpenFunction::Work() { DictionaryValue* result = new DictionaryValue(); result->SetInteger(kConnectionIdKey, id); - result_.reset(result); + SetResult(result); AsyncWorkCompleted(); } else { DictionaryValue* result = new DictionaryValue(); result->SetInteger(kConnectionIdKey, -1); - result_.reset(result); + SetResult(result); AsyncWorkCompleted(); } } @@ -166,7 +166,7 @@ void SerialCloseFunction::Work() { close_result = true; } - result_.reset(Value::CreateBooleanValue(close_result)); + SetResult(Value::CreateBooleanValue(close_result)); } bool SerialCloseFunction::Respond() { @@ -204,7 +204,7 @@ void SerialReadFunction::Work() { result->SetInteger(kBytesReadKey, bytes_read); result->Set(kDataKey, base::BinaryValue::CreateWithCopiedBuffer( reinterpret_cast<char*>(&byte), bytes_read)); - result_.reset(result); + SetResult(result); } bool SerialReadFunction::Respond() { @@ -241,7 +241,7 @@ void SerialWriteFunction::Work() { DictionaryValue* result = new DictionaryValue(); result->SetInteger(kBytesWrittenKey, bytes_written); - result_.reset(result); + SetResult(result); } bool SerialWriteFunction::Respond() { @@ -271,7 +271,7 @@ void SerialFlushFunction::Work() { flush_result = true; } - result_.reset(Value::CreateBooleanValue(flush_result)); + SetResult(Value::CreateBooleanValue(flush_result)); } bool SerialFlushFunction::Respond() { @@ -312,7 +312,7 @@ void SerialGetControlSignalsFunction::Work() { result->SetBoolean(kSuccessKey, false); } - result_.reset(result); + SetResult(result); } bool SerialGetControlSignalsFunction::Respond() { @@ -346,14 +346,14 @@ void SerialSetControlSignalsFunction::Work() { if (control_signals.should_set_rts) control_signals.rts = *(params_->options.rts); if (serial_connection->SetControlSignals(control_signals)) { - result_.reset(Value::CreateBooleanValue(true)); + SetResult(Value::CreateBooleanValue(true)); } else { error_ = kErrorSetControlSignalsFailed; - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); } } else { error_ = kSerialConnectionNotFoundError; - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); } } diff --git a/chrome/browser/extensions/api/serial/serial_apitest.cc b/chrome/browser/extensions/api/serial/serial_apitest.cc index 2dc740d..ad6672c 100644 --- a/chrome/browser/extensions/api/serial/serial_apitest.cc +++ b/chrome/browser/extensions/api/serial/serial_apitest.cc @@ -39,7 +39,7 @@ class FakeSerialGetPortsFunction : public AsyncExtensionFunction { ListValue* ports = new ListValue(); ports->Append(Value::CreateStringValue("/dev/fakeserial")); ports->Append(Value::CreateStringValue("\\\\COM800\\")); - result_.reset(ports); + SetResult(ports); SendResponse(true); return true; } diff --git a/chrome/browser/extensions/api/socket/socket_api.cc b/chrome/browser/extensions/api/socket/socket_api.cc index f7bae9e..ca87d2c 100644 --- a/chrome/browser/extensions/api/socket/socket_api.cc +++ b/chrome/browser/extensions/api/socket/socket_api.cc @@ -123,7 +123,7 @@ void SocketCreateFunction::Work() { DictionaryValue* result = new DictionaryValue(); result->SetInteger(kSocketIdKey, controller()->AddAPIResource(socket)); - result_.reset(result); + SetResult(result); } bool SocketDestroyFunction::Prepare() { @@ -157,7 +157,7 @@ void SocketConnectFunction::AfterDnsLookup(int lookup_result) { if (lookup_result == net::OK) { StartConnect(); } else { - result_.reset(Value::CreateIntegerValue(lookup_result)); + SetResult(Value::CreateIntegerValue(lookup_result)); AsyncWorkCompleted(); } } @@ -175,7 +175,7 @@ void SocketConnectFunction::StartConnect() { } void SocketConnectFunction::OnConnect(int result) { - result_.reset(Value::CreateIntegerValue(result)); + SetResult(Value::CreateIntegerValue(result)); AsyncWorkCompleted(); } @@ -190,7 +190,7 @@ void SocketDisconnectFunction::Work() { socket->Disconnect(); else error_ = kSocketNotFoundError; - result_.reset(Value::CreateNullValue()); + SetResult(Value::CreateNullValue()); } bool SocketBindFunction::Prepare() { @@ -208,7 +208,7 @@ void SocketBindFunction::Work() { else error_ = kSocketNotFoundError; - result_.reset(Value::CreateIntegerValue(result)); + SetResult(Value::CreateIntegerValue(result)); } SocketReadFunction::SocketReadFunction() @@ -248,7 +248,7 @@ void SocketReadFunction::OnCompleted(int bytes_read, // http://crbug.com/127630 result->Set(kDataKey, base::BinaryValue::Create(new char[1], 0)); } - result_.reset(result); + SetResult(result); AsyncWorkCompleted(); } @@ -287,7 +287,7 @@ void SocketWriteFunction::AsyncWorkStart() { void SocketWriteFunction::OnCompleted(int bytes_written) { DictionaryValue* result = new DictionaryValue(); result->SetInteger(kBytesWrittenKey, bytes_written); - result_.reset(result); + SetResult(result); AsyncWorkCompleted(); } @@ -333,7 +333,7 @@ void SocketRecvFromFunction::OnCompleted(int bytes_read, } result->SetString(kAddressKey, address); result->SetInteger(kPortKey, port); - result_.reset(result); + SetResult(result); AsyncWorkCompleted(); } @@ -366,7 +366,7 @@ void SocketSendToFunction::AfterDnsLookup(int lookup_result) { if (lookup_result == net::OK) { StartSendTo(); } else { - result_.reset(Value::CreateIntegerValue(lookup_result)); + SetResult(Value::CreateIntegerValue(lookup_result)); AsyncWorkCompleted(); } } @@ -386,7 +386,7 @@ void SocketSendToFunction::StartSendTo() { void SocketSendToFunction::OnCompleted(int bytes_written) { DictionaryValue* result = new DictionaryValue(); result->SetInteger(kBytesWrittenKey, bytes_written); - result_.reset(result); + SetResult(result); AsyncWorkCompleted(); } @@ -414,7 +414,7 @@ void SocketSetKeepAliveFunction::Work() { } else { error_ = kSocketNotFoundError; } - result_.reset(Value::CreateBooleanValue(result)); + SetResult(Value::CreateBooleanValue(result)); } SocketSetNoDelayFunction::SocketSetNoDelayFunction() @@ -436,7 +436,7 @@ void SocketSetNoDelayFunction::Work() { result = socket->SetNoDelay(params_->no_delay); else error_ = kSocketNotFoundError; - result_.reset(Value::CreateBooleanValue(result)); + SetResult(Value::CreateBooleanValue(result)); } } // namespace extensions diff --git a/chrome/browser/extensions/api/socket/socket_apitest.cc b/chrome/browser/extensions/api/socket/socket_apitest.cc index e334123..c2afcbb 100644 --- a/chrome/browser/extensions/api/socket/socket_apitest.cc +++ b/chrome/browser/extensions/api/socket/socket_apitest.cc @@ -63,7 +63,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPCreateGood) { socket_create_function->set_extension(empty_extension.get()); socket_create_function->set_has_callback(true); - scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( socket_create_function, "[\"udp\"]", browser(), utils::NONE)); @@ -82,7 +82,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) { socket_create_function->set_extension(empty_extension.get()); socket_create_function->set_has_callback(true); - scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( socket_create_function, "[\"tcp\"]", browser(), utils::NONE)); diff --git a/chrome/browser/extensions/api/tabs/tabs.cc b/chrome/browser/extensions/api/tabs/tabs.cc index d3e8f449..045565b 100644 --- a/chrome/browser/extensions/api/tabs/tabs.cc +++ b/chrome/browser/extensions/api/tabs/tabs.cc @@ -261,9 +261,9 @@ bool GetWindowFunction::RunImpl() { return false; if (populate_tabs) - result_.reset(controller->CreateWindowValueWithTabs()); + SetResult(controller->CreateWindowValueWithTabs()); else - result_.reset(controller->CreateWindowValue()); + SetResult(controller->CreateWindowValue()); return true; } @@ -282,9 +282,9 @@ bool GetCurrentWindowFunction::RunImpl() { return false; } if (populate_tabs) - result_.reset(controller->CreateWindowValueWithTabs()); + SetResult(controller->CreateWindowValueWithTabs()); else - result_.reset(controller->CreateWindowValue()); + SetResult(controller->CreateWindowValue()); return true; } @@ -309,9 +309,9 @@ bool GetLastFocusedWindowFunction::RunImpl() { ExtensionWindowController* controller = browser->extension_window_controller(); if (populate_tabs) - result_.reset(controller->CreateWindowValueWithTabs()); + SetResult(controller->CreateWindowValueWithTabs()); else - result_.reset(controller->CreateWindowValue()); + SetResult(controller->CreateWindowValue()); return true; } @@ -336,7 +336,7 @@ bool GetAllWindowsFunction::RunImpl() { else window_list->Append((*iter)->CreateWindowValue()); } - result_.reset(window_list); + SetResult(window_list); return true; } @@ -584,8 +584,8 @@ bool CreateWindowFunction::RunImpl() { else panel->Show(); - result_.reset( - panel->extension_window_controller()->CreateWindowValueWithTabs()); + SetResult( + panel->extension_window_controller()->CreateWindowValueWithTabs()); return true; } #endif @@ -635,9 +635,9 @@ bool CreateWindowFunction::RunImpl() { if (new_window->profile()->IsOffTheRecord() && !include_incognito()) { // Don't expose incognito windows if the extension isn't allowed. - result_.reset(Value::CreateNullValue()); + SetResult(Value::CreateNullValue()); } else { - result_.reset( + SetResult( new_window->extension_window_controller()->CreateWindowValueWithTabs()); } @@ -775,7 +775,7 @@ bool UpdateWindowFunction::RunImpl() { controller->window()->FlashFrame(draw_attention); } - result_.reset(controller->CreateWindowValue()); + SetResult(controller->CreateWindowValue()); return true; } @@ -817,9 +817,9 @@ bool GetSelectedTabFunction::RunImpl() { error_ = keys::kNoSelectedTabError; return false; } - result_.reset(ExtensionTabUtil::CreateTabValue(contents->web_contents(), - tab_strip, - tab_strip->active_index())); + SetResult(ExtensionTabUtil::CreateTabValue(contents->web_contents(), + tab_strip, + tab_strip->active_index())); return true; } @@ -833,7 +833,7 @@ bool GetAllTabsInWindowFunction::RunImpl() { if (!GetBrowserFromWindowID(this, window_id, &browser)) return false; - result_.reset(ExtensionTabUtil::CreateTabList(browser)); + SetResult(ExtensionTabUtil::CreateTabList(browser)); return true; } @@ -948,7 +948,7 @@ bool QueryTabsFunction::RunImpl() { } } - result_.reset(result); + SetResult(result); return true; } @@ -1079,7 +1079,7 @@ bool CreateTabFunction::RunImpl() { // Return data about the newly created tab. if (has_callback()) { - result_.reset(ExtensionTabUtil::CreateTabValue( + SetResult(ExtensionTabUtil::CreateTabValue( params.target_contents->web_contents(), tab_strip, new_index)); } @@ -1098,9 +1098,9 @@ bool GetTabFunction::RunImpl() { NULL, &tab_strip, &contents, &tab_index, &error_)) return false; - result_.reset(ExtensionTabUtil::CreateTabValue(contents->web_contents(), - tab_strip, - tab_index)); + SetResult(ExtensionTabUtil::CreateTabValue(contents->web_contents(), + tab_strip, + tab_index)); return true; } @@ -1109,7 +1109,7 @@ bool GetCurrentTabFunction::RunImpl() { WebContents* contents = dispatcher()->delegate()->GetAssociatedWebContents(); if (contents) - result_.reset(ExtensionTabUtil::CreateTabValue(contents)); + SetResult(ExtensionTabUtil::CreateTabValue(contents)); return true; } @@ -1165,7 +1165,7 @@ bool HighlightTabsFunction::RunImpl() { selection.set_active(active_index); browser->tab_strip_model()->SetSelectionFromModel(selection); - result_.reset( + SetResult( browser->extension_window_controller()->CreateWindowValueWithTabs()); return true; } @@ -1339,10 +1339,9 @@ void UpdateTabFunction::PopulateResult() { return; if (GetExtension()->HasAPIPermission(extensions::APIPermission::kTab)) { - result_.reset( - ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents())); + SetResult(ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents())); } else { - result_.reset(Value::CreateNullValue()); + SetResult(Value::CreateNullValue()); } } @@ -1465,11 +1464,11 @@ bool MoveTabsFunction::RunImpl() { // Only return the results as an array if there are multiple tabs. if (tab_ids.size() > 1) { - result_.reset(tab_values.DeepCopy()); + SetResult(tab_values.DeepCopy()); } else if (tab_ids.size() == 1) { Value* value = NULL; CHECK(tab_values.Get(0, &value)); - result_.reset(value->DeepCopy()); + SetResult(value->DeepCopy()); } return true; } @@ -1736,7 +1735,7 @@ void CaptureVisibleTabFunction::SendResultFromBitmap( base::Base64Encode(stream_as_string, &base64_result); base64_result.insert(0, base::StringPrintf("data:%s;base64,", mime_type.c_str())); - result_.reset(new StringValue(base64_result)); + SetResult(new StringValue(base64_result)); SendResponse(true); } @@ -1812,7 +1811,7 @@ void DetectTabLanguageFunction::Observe( } void DetectTabLanguageFunction::GotLanguage(const std::string& language) { - result_.reset(Value::CreateStringValue(language.c_str())); + SetResult(Value::CreateStringValue(language.c_str())); SendResponse(true); Release(); // Balanced in Run() diff --git a/chrome/browser/extensions/api/tabs/tabs_test.cc b/chrome/browser/extensions/api/tabs/tabs_test.cc index c634950..63f95f8 100644 --- a/chrome/browser/extensions/api/tabs/tabs_test.cc +++ b/chrome/browser/extensions/api/tabs/tabs_test.cc @@ -51,7 +51,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { bounds = browser()->window()->GetBounds(); scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new GetWindowFunction(), base::StringPrintf("[%u]", window_id), browser()))); @@ -65,7 +65,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { // With "populate" enabled. result.reset(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new GetWindowFunction(), base::StringPrintf("[%u, {\"populate\": true}]", window_id), browser()))); @@ -88,7 +88,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { Browser* popup_browser = Browser::CreateWithParams( Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); result.reset(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new GetWindowFunction(), base::StringPrintf( "[%u]", ExtensionTabUtil::GetWindowId(popup_browser)), @@ -99,7 +99,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { Browser* panel_browser = Browser::CreateWithParams( Browser::CreateParams(Browser::TYPE_PANEL, browser()->profile())); result.reset(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new GetWindowFunction(), base::StringPrintf( "[%u]", ExtensionTabUtil::GetWindowId(panel_browser)), @@ -120,7 +120,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { // With "include_incognito". result.reset(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new GetWindowFunction(), base::StringPrintf("[%u]", incognito_window_id), browser(), @@ -135,26 +135,26 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetCurrentWindow) { // Get the current window using new_browser. scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new GetCurrentWindowFunction(), "[]", new_browser))); // The id should match the window id of the browser instance that was passed - // to RunFunctionAndReturnResult. + // to RunFunctionAndReturnSingleResult. EXPECT_EQ(new_id, utils::GetInteger(result.get(), "id")); ListValue* tabs = NULL; EXPECT_FALSE(result.get()->GetList(keys::kTabsKey, &tabs)); // Get the current window using the old window and make the tabs populated. result.reset(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new GetCurrentWindowFunction(), "[{\"populate\": true}]", browser()))); // The id should match the window id of the browser instance that was passed - // to RunFunctionAndReturnResult. + // to RunFunctionAndReturnSingleResult. EXPECT_EQ(window_id, utils::GetInteger(result.get(), "id")); // "populate" was enabled so tabs should be populated. EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs)); @@ -167,25 +167,25 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetLastFocusedWindow) { int focused_window_id = ExtensionTabUtil::GetWindowId(new_browser); scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new GetLastFocusedWindowFunction(), "[]", new_browser))); // The id should always match the last focused window and does not depend - // on what was passed to RunFunctionAndReturnResult. + // on what was passed to RunFunctionAndReturnSingleResult. EXPECT_EQ(focused_window_id, utils::GetInteger(result.get(), "id")); ListValue* tabs = NULL; EXPECT_FALSE(result.get()->GetList(keys::kTabsKey, &tabs)); result.reset(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new GetLastFocusedWindowFunction(), "[{\"populate\": true}]", browser()))); // The id should always match the last focused window and does not depend - // on what was passed to RunFunctionAndReturnResult. + // on what was passed to RunFunctionAndReturnSingleResult. EXPECT_EQ(focused_window_id, utils::GetInteger(result.get(), "id")); // "populate" was enabled so tabs should be populated. EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs)); @@ -203,7 +203,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { } scoped_ptr<base::ListValue> result(utils::ToList( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new GetAllWindowsFunction(), "[]", browser()))); @@ -224,7 +224,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { result_ids.clear(); result.reset(utils::ToList( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new GetAllWindowsFunction(), "[{\"populate\": true}]", browser()))); @@ -254,7 +254,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, UpdateNoPermissions) { // Without a callback the function will not generate a result. update_tab_function->set_has_callback(true); - scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( update_tab_function.get(), "[null, {\"url\": \"neutrinos\"}]", browser())); @@ -270,7 +270,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, IncognitoModePrefs::FORCED); // Run without an explicit "incognito" param. scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new CreateWindowFunction(), kArgsWithoutExplicitIncognitoParam, browser(), @@ -286,7 +286,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, Browser* incognito_browser = CreateIncognitoBrowser(); // Run without an explicit "incognito" param. result.reset(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new CreateWindowFunction(), kArgsWithoutExplicitIncognitoParam, incognito_browser, @@ -306,7 +306,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, IncognitoModePrefs::FORCED); // Run without an explicit "incognito" param. scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new CreateWindowFunction(), kEmptyArgs, browser(), @@ -322,7 +322,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, Browser* incognito_browser = CreateIncognitoBrowser(); // Run without an explicit "incognito" param. result.reset(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new CreateWindowFunction(), kEmptyArgs, incognito_browser, @@ -398,7 +398,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) { // Get tabs in the 'current' window called from non-focused browser. scoped_ptr<base::ListValue> result(utils::ToList( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new QueryTabsFunction(), "[{\"currentWindow\":true}]", browser()))); @@ -414,7 +414,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) { // Get tabs NOT in the 'current' window called from non-focused browser. result.reset(utils::ToList( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new QueryTabsFunction(), "[{\"currentWindow\":false}]", browser()))); @@ -452,7 +452,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) { // Get tabs in the 'last focused' window called from non-focused browser. scoped_ptr<base::ListValue> result(utils::ToList( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new QueryTabsFunction(), "[{\"lastFocusedWindow\":true}]", browser()))); @@ -469,7 +469,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) { // Get tabs NOT in the 'last focused' window called from the focused browser. result.reset(utils::ToList( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( new QueryTabsFunction(), "[{\"lastFocusedWindow\":false}]", browser()))); @@ -502,7 +502,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DontCreateTabInClosingPopupWindow) { "[{\"url\": \"about:blank\", \"windowId\": %u}]"; scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( - utils::RunFunctionAndReturnResult( + utils::RunFunctionAndReturnSingleResult( create_tab_function.get(), base::StringPrintf(kNewBlankTabArgs, window_id), browser()))); diff --git a/chrome/browser/extensions/api/terminal/terminal_private_api.cc b/chrome/browser/extensions/api/terminal/terminal_private_api.cc index 91e1483..976220d 100644 --- a/chrome/browser/extensions/api/terminal/terminal_private_api.cc +++ b/chrome/browser/extensions/api/terminal/terminal_private_api.cc @@ -117,7 +117,7 @@ void OpenTerminalProcessFunction::OpenOnFileThread() { SendInputToTerminalProcessFunction::~SendInputToTerminalProcessFunction() {} void OpenTerminalProcessFunction::RespondOnUIThread(pid_t pid) { - result_.reset(new base::FundamentalValue(pid)); + SetResult(new base::FundamentalValue(pid)); SendResponse(true); } @@ -147,7 +147,7 @@ void SendInputToTerminalProcessFunction::SendInputOnFileThread(pid_t pid, } void SendInputToTerminalProcessFunction::RespondOnUIThread(bool success) { - result_.reset(new base::FundamentalValue(success)); + SetResult(new base::FundamentalValue(success)); SendResponse(true); } @@ -176,7 +176,7 @@ void CloseTerminalProcessFunction::CloseOnFileThread(pid_t pid) { } void CloseTerminalProcessFunction::RespondOnUIThread(bool success) { - result_.reset(new base::FundamentalValue(success)); + SetResult(new base::FundamentalValue(success)); SendResponse(true); } @@ -217,6 +217,6 @@ void OnTerminalResizeFunction::OnResizeOnFileThread(pid_t pid, } void OnTerminalResizeFunction::RespondOnUIThread(bool success) { - result_.reset(new base::FundamentalValue(success)); + SetResult(new base::FundamentalValue(success)); SendResponse(true); } diff --git a/chrome/browser/extensions/api/test/test_api.cc b/chrome/browser/extensions/api/test/test_api.cc index 03cc46d..8c4c27b 100644 --- a/chrome/browser/extensions/api/test/test_api.cc +++ b/chrome/browser/extensions/api/test/test_api.cc @@ -107,7 +107,7 @@ bool TestSendMessageFunction::RunImpl() { TestSendMessageFunction::~TestSendMessageFunction() {} void TestSendMessageFunction::Reply(const std::string& message) { - result_.reset(Value::CreateStringValue(message)); + SetResult(Value::CreateStringValue(message)); SendResponse(true); Release(); // balanced in RunImpl } @@ -138,7 +138,7 @@ bool TestGetConfigFunction::RunImpl() { return false; } - result_.reset(test_config_state->config_state()->DeepCopy()); + SetResult(test_config_state->config_state()->DeepCopy()); return true; } diff --git a/chrome/browser/extensions/api/usb/usb_api.cc b/chrome/browser/extensions/api/usb/usb_api.cc index a11b0c5..bb84186 100644 --- a/chrome/browser/extensions/api/usb/usb_api.cc +++ b/chrome/browser/extensions/api/usb/usb_api.cc @@ -46,7 +46,7 @@ void UsbFindDeviceFunction::Work() { UsbDevice* const device = service->FindDevice(parameters_->vendor_id, parameters_->product_id); if (!device) { - result_.reset(base::Value::CreateNullValue()); + SetResult(base::Value::CreateNullValue()); return; } @@ -57,7 +57,7 @@ void UsbFindDeviceFunction::Work() { result.handle = controller()->AddAPIResource(resource); result.vendor_id = parameters_->vendor_id; result.product_id = parameters_->product_id; - result_ = result.ToValue(); + SetResult(FindDevice::Result::Create(result)); } bool UsbFindDeviceFunction::Respond() { diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc index b17dd6a..c69c127 100644 --- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc +++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc @@ -791,7 +791,7 @@ bool GetFrameFunction::RunImpl() { int tab_id = params->details.tab_id; int frame_id = params->details.frame_id; - result_.reset(Value::CreateNullValue()); + SetResult(Value::CreateNullValue()); TabContents* tab_contents; if (!ExtensionTabUtil::GetTabById(tab_id, @@ -825,7 +825,7 @@ bool GetFrameFunction::RunImpl() { frame_details.url = frame_url.spec(); frame_details.error_occurred = frame_navigation_state.GetErrorOccurredInFrame(frame_id); - result_.reset(GetFrame::Result::Create(frame_details)); + SetResult(GetFrame::Result::Create(frame_details)); return true; } @@ -834,7 +834,7 @@ bool GetAllFramesFunction::RunImpl() { EXTENSION_FUNCTION_VALIDATE(params.get()); int tab_id = params->details.tab_id; - result_.reset(Value::CreateNullValue()); + SetResult(Value::CreateNullValue()); TabContents* tab_contents; if (!ExtensionTabUtil::GetTabById(tab_id, @@ -870,7 +870,7 @@ bool GetAllFramesFunction::RunImpl() { frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); result_list.push_back(frame); } - result_.reset(GetAllFrames::Result::Create(result_list)); + SetResult(GetAllFrames::Result::Create(result_list)); return true; } diff --git a/chrome/browser/extensions/api/web_socket_proxy_private/web_socket_proxy_private_api.cc b/chrome/browser/extensions/api/web_socket_proxy_private/web_socket_proxy_private_api.cc index 834bad0..30b45ed 100644 --- a/chrome/browser/extensions/api/web_socket_proxy_private/web_socket_proxy_private_api.cc +++ b/chrome/browser/extensions/api/web_socket_proxy_private/web_socket_proxy_private_api.cc @@ -95,7 +95,7 @@ void WebSocketProxyPrivate::ResolveHostIOPart(IOThread* io_thread) { bool WebSocketProxyPrivate::RunImpl() { AddRef(); - result_.reset(Value::CreateStringValue("")); + SetResult(Value::CreateStringValue("")); #if defined(OS_CHROMEOS) bool delay_response = false; @@ -165,7 +165,7 @@ void WebSocketProxyPrivateGetURLForTCPFunction::CustomFinalize() { StringValue* url = Value::CreateStringValue(std::string( "ws://127.0.0.1:" + base::IntToString(listening_port_) + "/tcpproxy?" + query)); - result_.reset(url); + SetResult(url); #endif } @@ -201,7 +201,7 @@ void WebSocketProxyPrivateGetPassportForTCPFunction::CustomFinalize() { "web_socket_proxy", map_) + std::string(":"); if (ContainsKey(map_, "addr")) passport += map_["addr"]; - result_.reset(Value::CreateStringValue(passport)); + SetResult(Value::CreateStringValue(passport)); #endif } diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc index 1d11a78..e7b5fc1 100644 --- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc +++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc @@ -260,7 +260,7 @@ bool BeginInstallWithManifestFunction::RunImpl() { EXTENSION_FUNCTION_VALIDATE(details->GetString(kIdKey, &id_)); if (!extensions::Extension::IdIsValid(id_)) { - SetResult(INVALID_ID); + SetResultCode(INVALID_ID); error_ = kInvalidIdError; return false; } @@ -268,7 +268,7 @@ bool BeginInstallWithManifestFunction::RunImpl() { EXTENSION_FUNCTION_VALIDATE(details->GetString(kManifestKey, &manifest_)); if (details->HasKey(kIconDataKey) && details->HasKey(kIconUrlKey)) { - SetResult(ICON_ERROR); + SetResultCode(ICON_ERROR); error_ = kCannotSpecifyIconDataAndUrlError; return false; } @@ -282,7 +282,7 @@ bool BeginInstallWithManifestFunction::RunImpl() { EXTENSION_FUNCTION_VALIDATE(details->GetString(kIconUrlKey, &tmp_url)); icon_url = source_url().Resolve(tmp_url); if (!icon_url.is_valid()) { - SetResult(INVALID_ICON_URL); + SetResultCode(INVALID_ICON_URL); error_ = kInvalidIconUrlError; return false; } @@ -316,31 +316,31 @@ bool BeginInstallWithManifestFunction::RunImpl() { } -void BeginInstallWithManifestFunction::SetResult(ResultCode code) { +void BeginInstallWithManifestFunction::SetResultCode(ResultCode code) { switch (code) { case ERROR_NONE: - result_.reset(Value::CreateStringValue("")); + SetResult(Value::CreateStringValue("")); break; case UNKNOWN_ERROR: - result_.reset(Value::CreateStringValue("unknown_error")); + SetResult(Value::CreateStringValue("unknown_error")); break; case USER_CANCELLED: - result_.reset(Value::CreateStringValue("user_cancelled")); + SetResult(Value::CreateStringValue("user_cancelled")); break; case MANIFEST_ERROR: - result_.reset(Value::CreateStringValue("manifest_error")); + SetResult(Value::CreateStringValue("manifest_error")); break; case ICON_ERROR: - result_.reset(Value::CreateStringValue("icon_error")); + SetResult(Value::CreateStringValue("icon_error")); break; case INVALID_ID: - result_.reset(Value::CreateStringValue("invalid_id")); + SetResult(Value::CreateStringValue("invalid_id")); break; case PERMISSION_DENIED: - result_.reset(Value::CreateStringValue("permission_denied")); + SetResult(Value::CreateStringValue("permission_denied")); break; case INVALID_ICON_URL: - result_.reset(Value::CreateStringValue("invalid_icon_url")); + SetResult(Value::CreateStringValue("invalid_icon_url")); break; default: CHECK(false); @@ -381,13 +381,13 @@ void BeginInstallWithManifestFunction::OnWebstoreParseFailure( // Map from WebstoreInstallHelper's result codes to ours. switch (result_code) { case WebstoreInstallHelper::Delegate::UNKNOWN_ERROR: - SetResult(UNKNOWN_ERROR); + SetResultCode(UNKNOWN_ERROR); break; case WebstoreInstallHelper::Delegate::ICON_ERROR: - SetResult(ICON_ERROR); + SetResultCode(ICON_ERROR); break; case WebstoreInstallHelper::Delegate::MANIFEST_ERROR: - SetResult(MANIFEST_ERROR); + SetResultCode(MANIFEST_ERROR); break; default: CHECK(false); @@ -410,7 +410,7 @@ void BeginInstallWithManifestFunction::InstallUIProceed() { approval->record_oauth2_grant = install_prompt_->record_oauth2_grant(); g_pending_approvals.Get().PushApproval(approval.Pass()); - SetResult(ERROR_NONE); + SetResultCode(ERROR_NONE); SendResponse(true); // The Permissions_Install histogram is recorded from the ExtensionService @@ -425,7 +425,7 @@ void BeginInstallWithManifestFunction::InstallUIProceed() { void BeginInstallWithManifestFunction::InstallUIAbort(bool user_initiated) { error_ = kUserCancelledError; - SetResult(USER_CANCELLED); + SetResultCode(USER_CANCELLED); SendResponse(false); // The web store install histograms are a subset of the install histograms. @@ -552,7 +552,7 @@ void SilentlyInstallFunction::OnExtensionInstallFailure( } bool GetBrowserLoginFunction::RunImpl() { - result_.reset(CreateLoginResult(profile_->GetOriginalProfile())); + SetResult(CreateLoginResult(profile_->GetOriginalProfile())); return true; } @@ -561,9 +561,9 @@ bool GetStoreLoginFunction::RunImpl() { ExtensionPrefs* prefs = service->extension_prefs(); std::string login; if (prefs->GetWebStoreLogin(&login)) { - result_.reset(Value::CreateStringValue(login)); + SetResult(Value::CreateStringValue(login)); } else { - result_.reset(Value::CreateStringValue(std::string())); + SetResult(Value::CreateStringValue(std::string())); } return true; } @@ -586,7 +586,7 @@ GetWebGLStatusFunction::GetWebGLStatusFunction() { GetWebGLStatusFunction::~GetWebGLStatusFunction() {} void GetWebGLStatusFunction::CreateResult(bool webgl_allowed) { - result_.reset(Value::CreateStringValue( + SetResult(Value::CreateStringValue( webgl_allowed ? "webgl_allowed" : "webgl_blocked")); } diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.h b/chrome/browser/extensions/api/webstore_private/webstore_private_api.h index d359c6e..e19cc6d 100644 --- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.h +++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.h @@ -131,7 +131,7 @@ class BeginInstallWithManifestFunction virtual bool RunImpl() OVERRIDE; // Sets the result_ as a string based on |code|. - void SetResult(ResultCode code); + void SetResultCode(ResultCode code); private: // These store the input parameters to the function. diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc index 77e0a38..f464781 100644 --- a/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc +++ b/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc @@ -245,7 +245,7 @@ class ExtensionWebstoreGetWebGLStatusTest : public InProcessBrowserTest { static const char kEmptyArgs[] = "[]"; static const char kWebGLStatusAllowed[] = "webgl_allowed"; static const char kWebGLStatusBlocked[] = "webgl_blocked"; - scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( new GetWebGLStatusFunction(), kEmptyArgs, browser())); EXPECT_EQ(base::Value::TYPE_STRING, result->GetType()); StringValue* value = static_cast<StringValue*>(result.get()); diff --git a/chrome/browser/extensions/extension_chrome_auth_private_api.cc b/chrome/browser/extensions/extension_chrome_auth_private_api.cc index fcc4e2b..d613ccc 100644 --- a/chrome/browser/extensions/extension_chrome_auth_private_api.cc +++ b/chrome/browser/extensions/extension_chrome_auth_private_api.cc @@ -34,7 +34,7 @@ bool SetCloudPrintCredentialsFunction::RunImpl() { std::string test_response = user_email; test_response.append(robot_email); test_response.append(credentials); - result_.reset(Value::CreateStringValue(test_response)); + SetResult(Value::CreateStringValue(test_response)); } else { CloudPrintProxyServiceFactory::GetForProfile(profile_)-> EnableForUserWithRobot(credentials, robot_email, user_email); diff --git a/chrome/browser/extensions/extension_font_settings_api.cc b/chrome/browser/extensions/extension_font_settings_api.cc index 32d91d0..fe855f21 100644 --- a/chrome/browser/extensions/extension_font_settings_api.cc +++ b/chrome/browser/extensions/extension_font_settings_api.cc @@ -294,7 +294,7 @@ bool GetFontFunction::RunImpl() { DictionaryValue* result = new DictionaryValue(); result->SetString(kFontNameKey, font_name); result->SetString(kLevelOfControlKey, level_of_control); - result_.reset(result); + SetResult(result); return true; } @@ -362,7 +362,7 @@ bool GetFontListFunction::CopyFontsToResult(ListValue* fonts) { result->Append(font_name); } - result_.reset(result.release()); + SetResult(result.release()); return true; } @@ -398,7 +398,7 @@ bool GetFontPrefExtensionFunction::RunImpl() { DictionaryValue* result = new DictionaryValue(); result->Set(GetKey(), pref->GetValue()->DeepCopy()); result->SetString(kLevelOfControlKey, level_of_control); - result_.reset(result); + SetResult(result); return true; } diff --git a/chrome/browser/extensions/extension_function.cc b/chrome/browser/extensions/extension_function.cc index d8ab5b9..9caad98 100644 --- a/chrome/browser/extensions/extension_function.cc +++ b/chrome/browser/extensions/extension_function.cc @@ -93,8 +93,13 @@ void ExtensionFunction::SetArgs(const base::ListValue* args) { args_.reset(args->DeepCopy()); } -const Value* ExtensionFunction::GetResultValue() { - return result_.get(); +void ExtensionFunction::SetResult(base::Value* result) { + results_.reset(new base::ListValue()); + results_->Append(result); +} + +const ListValue* ExtensionFunction::GetResultList() { + return results_.get(); } const std::string ExtensionFunction::GetError() { @@ -129,14 +134,12 @@ void ExtensionFunction::SendResponseImpl(base::ProcessHandle process, return; } - // Value objects can't be directly serialized in our IPC code, so we wrap the - // result_ Value with a ListValue (also transferring ownership of result_). - base::ListValue result_wrapper; - if (result_.get()) - result_wrapper.Append(result_.release()); + // If results were never set, we send an empty argument list. + if (!results_.get()) + results_.reset(new ListValue()); ipc_sender->Send(new ExtensionMsg_Response( - routing_id, request_id_, success, result_wrapper, GetError())); + routing_id, request_id_, success, *results_.release(), GetError())); } void ExtensionFunction::HandleBadMessage(base::ProcessHandle process) { diff --git a/chrome/browser/extensions/extension_function.h b/chrome/browser/extensions/extension_function.h index e0c2a9b..af2074e 100644 --- a/chrome/browser/extensions/extension_function.h +++ b/chrome/browser/extensions/extension_function.h @@ -107,8 +107,11 @@ class ExtensionFunction // Specifies the raw arguments to the function, as a JSON value. virtual void SetArgs(const base::ListValue* args); - // Retrieves the results of the function as a Value. - const base::Value* GetResultValue(); + // Sets a single Value as the results of the function. + void SetResult(base::Value* result); + + // Retrieves the results of the function as a ListValue. + const base::ListValue* GetResultList(); // Retrieves any error string from the function. virtual const std::string GetError(); @@ -206,9 +209,9 @@ class ExtensionFunction // The arguments to the API. Only non-null if argument were specified. scoped_ptr<base::ListValue> args_; - // The result of the API. This should be populated by the derived class before - // SendResponse() is called. - scoped_ptr<base::Value> result_; + // The results of the API. This should be populated by the derived class + // before SendResponse() is called. + scoped_ptr<base::ListValue> results_; // Any detailed error from the API. This should be populated by the derived // class before Run() returns. diff --git a/chrome/browser/extensions/extension_function_test_utils.cc b/chrome/browser/extensions/extension_function_test_utils.cc index 2f0fc46..29097ec 100644 --- a/chrome/browser/extensions/extension_function_test_utils.cc +++ b/chrome/browser/extensions/extension_function_test_utils.cc @@ -130,25 +130,31 @@ std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, RunFunctionFlags flags) { scoped_refptr<ExtensionFunction> function_owner(function); RunFunction(function, args, browser, flags); - EXPECT_FALSE(function->GetResultValue()) << "Did not expect a result"; + EXPECT_FALSE(function->GetResultList()) << "Did not expect a result"; return function->GetError(); } -base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, - const std::string& args, - Browser* browser) { - return RunFunctionAndReturnResult(function, args, browser, NONE); +base::Value* RunFunctionAndReturnSingleResult( + UIThreadExtensionFunction* function, + const std::string& args, + Browser* browser) { + return RunFunctionAndReturnSingleResult(function, args, browser, NONE); } -base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, - const std::string& args, - Browser* browser, - RunFunctionFlags flags) { +base::Value* RunFunctionAndReturnSingleResult( + UIThreadExtensionFunction* function, + const std::string& args, + Browser* browser, + RunFunctionFlags flags) { scoped_refptr<ExtensionFunction> function_owner(function); RunFunction(function, args, browser, flags); EXPECT_TRUE(function->GetError().empty()) << "Unexpected error: " << function->GetError(); - return (function->GetResultValue() == NULL) ? NULL : - function->GetResultValue()->DeepCopy(); + base::Value* single_result = NULL; + if (function->GetResultList() != NULL && + function->GetResultList()->Get(0, &single_result)) { + return single_result->DeepCopy(); + } + return NULL; } // This helps us be able to wait until an AsyncExtensionFunction calls diff --git a/chrome/browser/extensions/extension_function_test_utils.h b/chrome/browser/extensions/extension_function_test_utils.h index 9712b94..7bcf84d 100644 --- a/chrome/browser/extensions/extension_function_test_utils.h +++ b/chrome/browser/extensions/extension_function_test_utils.h @@ -72,13 +72,15 @@ std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, // Run |function| with |args| and return the result. Adds an error to the // current test if |function| returns an error. The caller takes ownership of // the result. -base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, - const std::string& args, - Browser* browser, - RunFunctionFlags flags); -base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, - const std::string& args, - Browser* browser); +base::Value* RunFunctionAndReturnSingleResult( + UIThreadExtensionFunction* function, + const std::string& args, + Browser* browser, + RunFunctionFlags flags); +base::Value* RunFunctionAndReturnSingleResult( + UIThreadExtensionFunction* function, + const std::string& args, + Browser* browser); // Create and run |function| with |args|. Works with both synchronous and async // functions. diff --git a/chrome/browser/extensions/extension_i18n_api.cc b/chrome/browser/extensions/extension_i18n_api.cc index def4380..d1b8708 100644 --- a/chrome/browser/extensions/extension_i18n_api.cc +++ b/chrome/browser/extensions/extension_i18n_api.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,7 +26,8 @@ bool GetAcceptLanguagesFunction::RunImpl() { // of the language code) on accept-languages set through editing preference // file directly. So, here, we're adding extra checks to be resistant to // crashes caused by data corruption. - result_.reset(new ListValue()); + ListValue* result_languages = new ListValue(); + SetResult(result_languages); if (acceptLanguages.empty()) { error_ = kEmptyAcceptLanguagesError; return false; @@ -38,8 +39,7 @@ bool GetAcceptLanguagesFunction::RunImpl() { if (end > begin) { // Guard against a malformed value with multiple "," in a row. string16 acceptLang = acceptLanguages.substr(begin, end - begin); - static_cast<ListValue*>(result_.get())-> - Append(Value::CreateStringValue(acceptLang)); + result_languages->Append(Value::CreateStringValue(acceptLang)); } begin = end + 1; // 'begin >= acceptLanguages.length()' to guard against a value @@ -47,7 +47,7 @@ bool GetAcceptLanguagesFunction::RunImpl() { if (end == string16::npos || begin >= acceptLanguages.length()) break; } - if (static_cast<ListValue*>(result_.get())->GetSize() == 0) { + if (result_languages->GetSize() == 0) { error_ = kEmptyAcceptLanguagesError; return false; } diff --git a/chrome/browser/extensions/extension_idle_api.cc b/chrome/browser/extensions/extension_idle_api.cc index 87ce764..fdfce26 100644 --- a/chrome/browser/extensions/extension_idle_api.cc +++ b/chrome/browser/extensions/extension_idle_api.cc @@ -155,7 +155,7 @@ bool ExtensionIdleQueryStateFunction::RunImpl() { IdleState state = ExtensionIdleCache::CalculateIdleState(threshold); if (state != IDLE_STATE_UNKNOWN) { - result_.reset(CreateIdleValue(state)); + SetResult(CreateIdleValue(state)); SendResponse(true); return true; } @@ -175,7 +175,7 @@ void ExtensionIdleQueryStateFunction::IdleStateCallback(int threshold, ExtensionIdlePollingTask::CreateNewPollTask(threshold, state, profile_); } - result_.reset(CreateIdleValue(state)); + SetResult(CreateIdleValue(state)); ExtensionIdleCache::UpdateCache(threshold, state); diff --git a/chrome/browser/extensions/extension_info_private_api_chromeos.cc b/chrome/browser/extensions/extension_info_private_api_chromeos.cc index 8224784..75fb9c8 100644 --- a/chrome/browser/extensions/extension_info_private_api_chromeos.cc +++ b/chrome/browser/extensions/extension_info_private_api_chromeos.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -46,7 +46,7 @@ bool GetChromeosInfoFunction::RunImpl() { if (GetValue(property_name, &value)) result->Set(property_name, Value::CreateStringValue(value)); } - result_.reset(result.release()); + SetResult(result.release()); SendResponse(true); return true; } diff --git a/chrome/browser/extensions/extension_input_ime_api.cc b/chrome/browser/extensions/extension_input_ime_api.cc index eebc13e..0701ec2c 100644 --- a/chrome/browser/extensions/extension_input_ime_api.cc +++ b/chrome/browser/extensions/extension_input_ime_api.cc @@ -467,7 +467,7 @@ bool SetCompositionFunction::RunImpl() { ExtensionInputImeEventRouter::GetInstance()-> GetActiveEngine(extension_id()); if (!engine) { - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); return true; } @@ -531,9 +531,9 @@ bool SetCompositionFunction::RunImpl() { if (engine->SetComposition(context_id, text.c_str(), selection_start, selection_end, cursor, segments, &error_)) { - result_.reset(Value::CreateBooleanValue(true)); + SetResult(Value::CreateBooleanValue(true)); } else { - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); } return true; } @@ -543,7 +543,7 @@ bool ClearCompositionFunction::RunImpl() { ExtensionInputImeEventRouter::GetInstance()-> GetActiveEngine(extension_id()); if (!engine) { - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); return true; } @@ -555,9 +555,9 @@ bool ClearCompositionFunction::RunImpl() { &context_id)); if (engine->ClearComposition(context_id, &error_)) { - result_.reset(Value::CreateBooleanValue(true)); + SetResult(Value::CreateBooleanValue(true)); } else { - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); } return true; } @@ -568,7 +568,7 @@ bool CommitTextFunction::RunImpl() { ExtensionInputImeEventRouter::GetInstance()-> GetActiveEngine(extension_id()); if (!engine) { - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); return true; } @@ -582,9 +582,9 @@ bool CommitTextFunction::RunImpl() { EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kTextKey, &text)); if (engine->CommitText(context_id, text.c_str(), &error_)) { - result_.reset(Value::CreateBooleanValue(true)); + SetResult(Value::CreateBooleanValue(true)); } else { - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); } return true; } @@ -600,7 +600,7 @@ bool SetCandidateWindowPropertiesFunction::RunImpl() { ExtensionInputImeEventRouter::GetInstance()->GetEngine(extension_id(), engine_id); if (!engine) { - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); return true; } @@ -613,7 +613,7 @@ bool SetCandidateWindowPropertiesFunction::RunImpl() { EXTENSION_FUNCTION_VALIDATE(properties->GetBoolean(keys::kVisibleKey, &visible)); if (!engine->SetCandidateWindowVisible(visible, &error_)) { - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); return true; } } @@ -654,7 +654,7 @@ bool SetCandidateWindowPropertiesFunction::RunImpl() { engine->SetCandidateWindowAuxTextVisible(visible); } - result_.reset(Value::CreateBooleanValue(true)); + SetResult(Value::CreateBooleanValue(true)); return true; } @@ -711,7 +711,7 @@ bool SetCandidatesFunction::RunImpl() { ExtensionInputImeEventRouter::GetInstance()-> GetActiveEngine(extension_id()); if (!engine) { - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); return true; } @@ -734,9 +734,9 @@ bool SetCandidatesFunction::RunImpl() { std::string error; if (engine->SetCandidates(context_id, candidates, &error_)) { - result_.reset(Value::CreateBooleanValue(true)); + SetResult(Value::CreateBooleanValue(true)); } else { - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); } return true; } @@ -746,7 +746,7 @@ bool SetCursorPositionFunction::RunImpl() { ExtensionInputImeEventRouter::GetInstance()-> GetActiveEngine(extension_id()); if (!engine) { - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); return true; } @@ -761,9 +761,9 @@ bool SetCursorPositionFunction::RunImpl() { &candidate_id)); if (engine->SetCursorPosition(context_id, candidate_id, &error_)) { - result_.reset(Value::CreateBooleanValue(true)); + SetResult(Value::CreateBooleanValue(true)); } else { - result_.reset(Value::CreateBooleanValue(false)); + SetResult(Value::CreateBooleanValue(false)); } return true; } diff --git a/chrome/browser/extensions/extension_input_method_api.cc b/chrome/browser/extensions/extension_input_method_api.cc index 310892e..5dd349c 100644 --- a/chrome/browser/extensions/extension_input_method_api.cc +++ b/chrome/browser/extensions/extension_input_method_api.cc @@ -27,7 +27,7 @@ bool GetInputMethodFunction::RunImpl() { chromeos::input_method::InputMethodManager::GetInstance(); const std::string input_method = router->GetInputMethodForXkb(manager->GetCurrentInputMethod().id()); - result_.reset(Value::CreateStringValue(input_method)); + SetResult(Value::CreateStringValue(input_method)); return true; #endif } diff --git a/chrome/browser/extensions/extension_managed_mode_api.cc b/chrome/browser/extensions/extension_managed_mode_api.cc index 11e9f6f..9ca66e0 100644 --- a/chrome/browser/extensions/extension_managed_mode_api.cc +++ b/chrome/browser/extensions/extension_managed_mode_api.cc @@ -78,7 +78,7 @@ bool GetManagedModeFunction::RunImpl() { scoped_ptr<DictionaryValue> result(new DictionaryValue); result->SetBoolean(keys::kValue, in_managed_mode); - result_.reset(result.release()); + SetResult(result.release()); return true; } @@ -94,7 +94,7 @@ bool EnterManagedModeFunction::RunImpl() { void EnterManagedModeFunction::SendResult(bool success) { scoped_ptr<DictionaryValue> result(new DictionaryValue); result->SetBoolean(kEnterSuccessKey, success); - result_.reset(result.release()); + SetResult(result.release()); SendResponse(true); } @@ -108,7 +108,7 @@ bool GetPolicyFunction::RunImpl() { ManagedModePolicyProviderFactory::GetForProfile(profile_); const base::Value* policy = policy_provider->GetPolicy(key); if (policy) - result_.reset(policy->DeepCopy()); + SetResult(policy->DeepCopy()); #endif return true; } diff --git a/chrome/browser/extensions/extension_management_api.cc b/chrome/browser/extensions/extension_management_api.cc index 1fd716b..1973969 100644 --- a/chrome/browser/extensions/extension_management_api.cc +++ b/chrome/browser/extensions/extension_management_api.cc @@ -162,7 +162,7 @@ static void AddExtensionInfo(ListValue* list, bool GetAllExtensionsFunction::RunImpl() { ListValue* result = new ListValue(); - result_.reset(result); + SetResult(result); AddExtensionInfo(result, *service()->extensions(), service()); AddExtensionInfo(result, *service()->disabled_extensions(), service()); @@ -180,7 +180,7 @@ bool GetExtensionByIdFunction::RunImpl() { return false; } DictionaryValue* result = CreateExtensionInfo(*extension, service()); - result_.reset(result); + SetResult(result); return true; } @@ -201,7 +201,7 @@ bool GetPermissionWarningsByIdFunction::RunImpl() { for (PermissionMessages::const_iterator i = warnings.begin(); i < warnings.end(); ++i) result->Append(Value::CreateStringValue(i->message())); - result_.reset(result); + SetResult(result); return true; } @@ -325,7 +325,7 @@ void GetPermissionWarningsByManifestFunction::OnParseSuccess( for (PermissionMessages::const_iterator i = warnings.begin(); i < warnings.end(); ++i) result->Append(Value::CreateStringValue(i->message())); - result_.reset(result); + SetResult(result); SendResponse(true); // Matched with AddRef() in RunImpl(). diff --git a/chrome/browser/extensions/extension_management_api_browsertest.cc b/chrome/browser/extensions/extension_management_api_browsertest.cc index cb0207a..7211b2e 100644 --- a/chrome/browser/extensions/extension_management_api_browsertest.cc +++ b/chrome/browser/extensions/extension_management_api_browsertest.cc @@ -101,7 +101,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest, uninstall_function = new UninstallFunction(); UninstallFunction::SetAutoConfirmForTest(true); - util::RunFunctionAndReturnResult( + util::RunFunctionAndReturnSingleResult( uninstall_function, base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", id.c_str()), browser()); @@ -170,10 +170,10 @@ const char ExtensionManagementApiEscalationTest::kId[] = IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest, DisabledReason) { - scoped_ptr<base::Value> result( - util::RunFunctionAndReturnResult(new GetExtensionByIdFunction(), - base::StringPrintf("[\"%s\"]", kId), - browser())); + scoped_ptr<base::Value> result(util::RunFunctionAndReturnSingleResult( + new GetExtensionByIdFunction(), + base::StringPrintf("[\"%s\"]", kId), + browser())); ASSERT_TRUE(result.get() != NULL); ASSERT_TRUE(result->IsType(base::Value::TYPE_DICTIONARY)); base::DictionaryValue* dict = diff --git a/chrome/browser/extensions/extension_module.cc b/chrome/browser/extensions/extension_module.cc index d3d4927..ac1b96c 100644 --- a/chrome/browser/extensions/extension_module.cc +++ b/chrome/browser/extensions/extension_module.cc @@ -26,7 +26,7 @@ bool IsAllowedIncognitoAccessFunction::RunImpl() { ExtensionService* ext_service = profile()->GetExtensionService(); const extensions::Extension* extension = GetExtension(); - result_.reset(Value::CreateBooleanValue( + SetResult(Value::CreateBooleanValue( ext_service->IsIncognitoEnabled(extension->id()))); return true; } @@ -35,7 +35,7 @@ bool IsAllowedFileSchemeAccessFunction::RunImpl() { ExtensionService* ext_service = profile()->GetExtensionService(); const extensions::Extension* extension = GetExtension(); - result_.reset(Value::CreateBooleanValue( - ext_service->AllowFileAccess(extension))); + SetResult(Value::CreateBooleanValue( + ext_service->AllowFileAccess(extension))); return true; } diff --git a/chrome/browser/extensions/extension_page_capture_api.cc b/chrome/browser/extensions/extension_page_capture_api.cc index d42dd0e..377d56e 100644 --- a/chrome/browser/extensions/extension_page_capture_api.cc +++ b/chrome/browser/extensions/extension_page_capture_api.cc @@ -173,7 +173,7 @@ void PageCaptureSaveAsMHTMLFunction::ReturnSuccess(int64 file_size) { child_id, mhtml_path_); DictionaryValue* dict = new DictionaryValue(); - result_.reset(dict); + SetResult(dict); dict->SetString("mhtmlFilePath", mhtml_path_.value()); dict->SetInteger("mhtmlFileLength", file_size); diff --git a/chrome/browser/extensions/extension_preference_api.cc b/chrome/browser/extensions/extension_preference_api.cc index c60673f..fff6d0c 100644 --- a/chrome/browser/extensions/extension_preference_api.cc +++ b/chrome/browser/extensions/extension_preference_api.cc @@ -368,7 +368,7 @@ bool GetPreferenceFunction::RunImpl() { ep->HasIncognitoPrefValue(browser_pref)); } - result_.reset(result.release()); + SetResult(result.release()); return true; } diff --git a/chrome/browser/extensions/extension_processes_api.cc b/chrome/browser/extensions/extension_processes_api.cc index c853495..47436ec 100644 --- a/chrome/browser/extensions/extension_processes_api.cc +++ b/chrome/browser/extensions/extension_processes_api.cc @@ -568,11 +568,11 @@ void GetProcessIdForTabFunction::GetProcessIdForTab() { error_ = ExtensionErrorUtils::FormatErrorMessage( extensions::tabs_constants::kTabNotFoundError, base::IntToString(tab_id_)); - result_.reset(Value::CreateIntegerValue(-1)); + SetResult(Value::CreateIntegerValue(-1)); SendResponse(false); } else { int process_id = contents->web_contents()->GetRenderProcessHost()->GetID(); - result_.reset(Value::CreateIntegerValue(process_id)); + SetResult(Value::CreateIntegerValue(process_id)); SendResponse(true); } @@ -644,7 +644,7 @@ void TerminateFunction::TerminateProcess() { base::IntToString(process_id_)); SendResponse(false); } else { - result_.reset(Value::CreateBooleanValue(killed)); + SetResult(Value::CreateBooleanValue(killed)); SendResponse(true); } @@ -744,7 +744,7 @@ void GetProcessInfoFunction::GatherProcessInfo() { DCHECK(process_ids_.size() == 0); } - result_.reset(processes); + SetResult(processes); SendResponse(true); // Balance the AddRef in the RunImpl. diff --git a/chrome/browser/extensions/platform_app_browsertest_util.cc b/chrome/browser/extensions/platform_app_browsertest_util.cc index 1fe12ea..ba4f091 100644 --- a/chrome/browser/extensions/platform_app_browsertest_util.cc +++ b/chrome/browser/extensions/platform_app_browsertest_util.cc @@ -68,7 +68,7 @@ size_t PlatformAppBrowserTest::RunGetWindowsFunctionForExtension( GetAllWindowsFunction* function = new GetAllWindowsFunction(); function->set_extension(extension); scoped_ptr<base::ListValue> result(utils::ToList( - utils::RunFunctionAndReturnResult(function, "[]", browser()))); + utils::RunFunctionAndReturnSingleResult(function, "[]", browser()))); return result->GetSize(); } @@ -82,7 +82,7 @@ bool PlatformAppBrowserTest::RunGetWindowFunctionForExtension( base::StringPrintf("[%u]", window_id), browser(), utils::NONE); - return function->GetResultValue() != NULL; + return function->GetResultList() != NULL; } size_t PlatformAppBrowserTest::GetShellWindowCount() { diff --git a/chrome/browser/extensions/settings/settings_api.cc b/chrome/browser/extensions/settings/settings_api.cc index 4c57356..bcb05dc 100644 --- a/chrome/browser/extensions/settings/settings_api.cc +++ b/chrome/browser/extensions/settings/settings_api.cc @@ -78,7 +78,7 @@ bool SettingsFunction::UseReadResult(ValueStore::ReadResult result) { return false; } - result_ = result->settings().Pass(); + SetResult(result->settings().release()); return true; } @@ -223,7 +223,7 @@ bool GetBytesInUseSettingsFunction::RunWithStorage(ValueStore* storage) { return false; } - result_.reset(Value::CreateIntegerValue(bytes_in_use)); + SetResult(Value::CreateIntegerValue(bytes_in_use)); return true; } diff --git a/chrome/browser/extensions/system/system_api.cc b/chrome/browser/extensions/system/system_api.cc index 042eb35..14923a3 100644 --- a/chrome/browser/extensions/system/system_api.cc +++ b/chrome/browser/extensions/system/system_api.cc @@ -73,8 +73,7 @@ bool GetIncognitoModeAvailabilityFunction::RunImpl() { EXTENSION_FUNCTION_VALIDATE( value >= 0 && value < static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings))); - result_.reset( - Value::CreateStringValue(kIncognitoModeAvailabilityStrings[value])); + SetResult(Value::CreateStringValue(kIncognitoModeAvailabilityStrings[value])); return true; } @@ -134,7 +133,7 @@ bool GetUpdateStatusFunction::RunImpl() { DictionaryValue* dict = new DictionaryValue(); dict->SetString(kStateKey, state); dict->SetDouble(kDownloadProgressKey, download_progress); - result_.reset(dict); + SetResult(dict); return true; } diff --git a/chrome/browser/history/history_extension_api.cc b/chrome/browser/history/history_extension_api.cc index a55d095..4848fc2 100644 --- a/chrome/browser/history/history_extension_api.cc +++ b/chrome/browser/history/history_extension_api.cc @@ -265,7 +265,7 @@ void GetVisitsHistoryFunction::QueryComplete( AddVisitNode(*iterator, list); } } - result_.reset(list); + SetResult(list); SendAsyncResponse(); } @@ -318,7 +318,7 @@ void SearchHistoryFunction::SearchComplete( AddHistoryNode(**iterator, list); } } - result_.reset(list); + SetResult(list); SendAsyncResponse(); } diff --git a/chrome/browser/history/top_sites_extension_api.cc b/chrome/browser/history/top_sites_extension_api.cc index 89b7238..0f57b78 100644 --- a/chrome/browser/history/top_sites_extension_api.cc +++ b/chrome/browser/history/top_sites_extension_api.cc @@ -41,6 +41,6 @@ void GetTopSitesFunction::OnMostVisitedURLsAvailable( } } - result_.reset(pages_value.release()); + SetResult(pages_value.release()); SendResponse(true); } diff --git a/chrome/browser/history/top_sites_extension_test.cc b/chrome/browser/history/top_sites_extension_test.cc index 13f8e69..187faa7 100644 --- a/chrome/browser/history/top_sites_extension_test.cc +++ b/chrome/browser/history/top_sites_extension_test.cc @@ -60,7 +60,7 @@ IN_PROC_BROWSER_TEST_F(TopSitesExtensionTest, GetTopSites) { // Without a callback the function will not generate a result. get_top_sites_function->set_has_callback(true); - scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult( + scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( get_top_sites_function.get(), "[]", browser())); base::ListValue* list; ASSERT_TRUE(result->GetAsList(&list)); diff --git a/chrome/browser/infobars/infobar_extension_api.cc b/chrome/browser/infobars/infobar_extension_api.cc index 027a3cd..f3b256f 100644 --- a/chrome/browser/infobars/infobar_extension_api.cc +++ b/chrome/browser/infobars/infobar_extension_api.cc @@ -74,7 +74,7 @@ bool ShowInfoBarFunction::RunImpl() { // TODO(finnur): Return the actual DOMWindow object. Bug 26463. DCHECK(browser->extension_window_controller()); - result_.reset(browser->extension_window_controller()->CreateWindowValue()); + SetResult(browser->extension_window_controller()->CreateWindowValue()); return true; } diff --git a/chrome/browser/rlz/rlz_extension_api.cc b/chrome/browser/rlz/rlz_extension_api.cc index e164506..e61c8fd 100644 --- a/chrome/browser/rlz/rlz_extension_api.cc +++ b/chrome/browser/rlz/rlz_extension_api.cc @@ -113,7 +113,7 @@ bool RlzGetAccessPointRlzFunction::RunImpl() { char rlz[rlz_lib::kMaxRlzLength + 1]; rlz_lib::GetAccessPointRlz(access_point, rlz, rlz_lib::kMaxRlzLength); - result_.reset(Value::CreateStringValue(rlz)); + SetResult(Value::CreateStringValue(rlz)); return true; } @@ -179,7 +179,7 @@ void RlzSendFinancialPingFunction::WorkOnWorkerThread() { id_.c_str(), lang_.c_str(), exclude_machine_id_); - result_.reset(Value::CreateBooleanValue(sent)); + SetResult(Value::CreateBooleanValue(sent)); bool post_task_result = content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, diff --git a/chrome/browser/speech/extension_api/tts_extension_api.cc b/chrome/browser/speech/extension_api/tts_extension_api.cc index 1824a15..8645aef 100644 --- a/chrome/browser/speech/extension_api/tts_extension_api.cc +++ b/chrome/browser/speech/extension_api/tts_extension_api.cc @@ -163,12 +163,12 @@ bool ExtensionTtsStopSpeakingFunction::RunImpl() { } bool ExtensionTtsIsSpeakingFunction::RunImpl() { - result_.reset(Value::CreateBooleanValue( + SetResult(Value::CreateBooleanValue( ExtensionTtsController::GetInstance()->IsSpeaking())); return true; } bool ExtensionTtsGetVoicesFunction::RunImpl() { - result_.reset(ExtensionTtsController::GetInstance()->GetVoices(profile())); + SetResult(ExtensionTtsController::GetInstance()->GetVoices(profile())); return true; } diff --git a/chrome/browser/speech/speech_input_extension_api.cc b/chrome/browser/speech/speech_input_extension_api.cc index 23afea0..f3fd65e 100644 --- a/chrome/browser/speech/speech_input_extension_api.cc +++ b/chrome/browser/speech/speech_input_extension_api.cc @@ -166,15 +166,15 @@ bool StopSpeechInputFunction::RunImpl() { profile())->Stop(extension_id(), &error_); } -void IsRecordingSpeechInputFunction::SetResult(bool result) { +void IsRecordingSpeechInputFunction::SetIsRecordingResult(bool result) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - result_.reset(Value::CreateBooleanValue(result)); + SetResult(Value::CreateBooleanValue(result)); SendResponse(true); } void IsRecordingSpeechInputFunction::Run() { SpeechInputExtensionManager::GetForProfile(profile())->IsRecording( - base::Bind(&IsRecordingSpeechInputFunction::SetResult, this)); + base::Bind(&IsRecordingSpeechInputFunction::SetIsRecordingResult, this)); } bool IsRecordingSpeechInputFunction::RunImpl() { diff --git a/chrome/browser/speech/speech_input_extension_api.h b/chrome/browser/speech/speech_input_extension_api.h index 4982657..d330210 100644 --- a/chrome/browser/speech/speech_input_extension_api.h +++ b/chrome/browser/speech/speech_input_extension_api.h @@ -75,7 +75,7 @@ class IsRecordingSpeechInputFunction : public SyncExtensionFunction { DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.isRecording"); // Called back from SpeechInputExtensionManager in the UI thread. - void SetResult(bool result); + void SetIsRecordingResult(bool result); protected: // ExtensionFunction: |