diff options
author | dcheng <dcheng@chromium.org> | 2015-12-18 09:48:00 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-18 17:48:52 +0000 |
commit | e59eca16010c109a5e3e4922189c8b264d34caa9 (patch) | |
tree | 838815399c6364a99a465938df9978aeaf75c766 /extensions/common | |
parent | 5100baf1eac806abbdaaf8002887aacf652f34e5 (diff) | |
download | chromium_src-e59eca16010c109a5e3e4922189c8b264d34caa9.zip chromium_src-e59eca16010c109a5e3e4922189c8b264d34caa9.tar.gz chromium_src-e59eca16010c109a5e3e4922189c8b264d34caa9.tar.bz2 |
Convert Pass()→std::move() in //extensions
BUG=557422
Review URL: https://codereview.chromium.org/1537893002
Cr-Commit-Position: refs/heads/master@{#366120}
Diffstat (limited to 'extensions/common')
32 files changed, 131 insertions, 95 deletions
diff --git a/extensions/common/api/bluetooth/bluetooth_manifest_data.cc b/extensions/common/api/bluetooth/bluetooth_manifest_data.cc index cb85e08..94ba7fe 100644 --- a/extensions/common/api/bluetooth/bluetooth_manifest_data.cc +++ b/extensions/common/api/bluetooth/bluetooth_manifest_data.cc @@ -4,6 +4,8 @@ #include "extensions/common/api/bluetooth/bluetooth_manifest_data.h" +#include <utility> + #include "extensions/common/api/bluetooth/bluetooth_manifest_permission.h" #include "extensions/common/manifest_constants.h" @@ -11,7 +13,7 @@ namespace extensions { BluetoothManifestData::BluetoothManifestData( scoped_ptr<BluetoothManifestPermission> permission) - : permission_(permission.Pass()) { + : permission_(std::move(permission)) { DCHECK(permission_); } @@ -63,7 +65,7 @@ scoped_ptr<BluetoothManifestData> BluetoothManifestData::FromValue( return scoped_ptr<BluetoothManifestData>(); return scoped_ptr<BluetoothManifestData>( - new BluetoothManifestData(permission.Pass())).Pass(); + new BluetoothManifestData(std::move(permission))); } BluetoothPermissionRequest::BluetoothPermissionRequest( diff --git a/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc b/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc index 08cc1b7a..c2c6d2c 100644 --- a/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc +++ b/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc @@ -88,7 +88,7 @@ scoped_ptr<BluetoothManifestPermission> BluetoothManifestPermission::FromValue( if (bluetooth->peripheral) { result->peripheral_ = *(bluetooth->peripheral); } - return result.Pass(); + return result; } bool BluetoothManifestPermission::CheckRequest( @@ -154,7 +154,7 @@ scoped_ptr<base::Value> BluetoothManifestPermission::ToValue() const { api::extensions_manifest_types::Bluetooth bluetooth; bluetooth.uuids.reset(new std::vector<std::string>(uuids_.begin(), uuids_.end())); - return bluetooth.ToValue().Pass(); + return bluetooth.ToValue(); } ManifestPermission* BluetoothManifestPermission::Diff( diff --git a/extensions/common/api/declarative/declarative_manifest_data.cc b/extensions/common/api/declarative/declarative_manifest_data.cc index 31f0ce0..0808887b 100644 --- a/extensions/common/api/declarative/declarative_manifest_data.cc +++ b/extensions/common/api/declarative/declarative_manifest_data.cc @@ -167,7 +167,7 @@ scoped_ptr<DeclarativeManifestData> DeclarativeManifestData::FromValue( result->event_rules_map_[event].push_back(rule); } - return result.Pass(); + return result; } std::vector<linked_ptr<DeclarativeManifestData::Rule>>& diff --git a/extensions/common/api/declarative/declarative_manifest_unittest.cc b/extensions/common/api/declarative/declarative_manifest_unittest.cc index 2940d48..fc785e5 100644 --- a/extensions/common/api/declarative/declarative_manifest_unittest.cc +++ b/extensions/common/api/declarative/declarative_manifest_unittest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <utility> + #include "extensions/browser/api_test_utils.h" #include "extensions/common/api/declarative/declarative_manifest_data.h" #include "extensions/common/manifest_test.h" @@ -49,7 +51,7 @@ TEST_F(DeclarativeManifestTest, ConditionMissingType) { " }" " ]" "}"); - ManifestData manifest(manifest_data.Pass(), "test"); + ManifestData manifest(std::move(manifest_data), "test"); LoadAndExpectError(manifest, "'type' is required and must be a string"); } @@ -69,7 +71,7 @@ TEST_F(DeclarativeManifestTest, ConditionNotDictionary) { " }" " ]" "}"); - ManifestData manifest(manifest_data.Pass(), "test"); + ManifestData manifest(std::move(manifest_data), "test"); LoadAndExpectError(manifest, "expected dictionary, got boolean"); } @@ -90,7 +92,7 @@ TEST_F(DeclarativeManifestTest, ActionMissingType) { " }" " ]" "}"); - ManifestData manifest(manifest_data.Pass(), "test"); + ManifestData manifest(std::move(manifest_data), "test"); LoadAndExpectError(manifest, "'type' is required and must be a string"); } @@ -111,7 +113,7 @@ TEST_F(DeclarativeManifestTest, ActionNotDictionary) { " }" " ]" "}"); - ManifestData manifest(manifest_data.Pass(), "test"); + ManifestData manifest(std::move(manifest_data), "test"); LoadAndExpectError(manifest, "expected dictionary, got list"); } @@ -123,7 +125,7 @@ TEST_F(DeclarativeManifestTest, EventRulesNotList) { " \"version\": \"1\"," " \"event_rules\": {}" "}"); - ManifestData manifest(manifest_data.Pass(), "test"); + ManifestData manifest(std::move(manifest_data), "test"); LoadAndExpectError(manifest, "'event_rules' expected list, got dictionary"); } @@ -135,7 +137,7 @@ TEST_F(DeclarativeManifestTest, EventRuleNotDictionary) { " \"version\": \"1\"," " \"event_rules\": [0,1,2]" "}"); - ManifestData manifest(manifest_data.Pass(), "test"); + ManifestData manifest(std::move(manifest_data), "test"); LoadAndExpectError(manifest, "expected dictionary, got integer"); } @@ -157,7 +159,7 @@ TEST_F(DeclarativeManifestTest, EventMissingFromRule) { " }" " ]" "}"); - ManifestData manifest(manifest_data.Pass(), "test"); + ManifestData manifest(std::move(manifest_data), "test"); LoadAndExpectError(manifest, "'event' is required"); } @@ -173,7 +175,7 @@ TEST_F(DeclarativeManifestTest, RuleFailedToPopulate) { " }" " ]" "}"); - ManifestData manifest(manifest_data.Pass(), "test"); + ManifestData manifest(std::move(manifest_data), "test"); LoadAndExpectError(manifest, "rule failed to populate"); } diff --git a/extensions/common/api/printer_provider/usb_printer_manifest_data.cc b/extensions/common/api/printer_provider/usb_printer_manifest_data.cc index 79c1eed..919364e 100644 --- a/extensions/common/api/printer_provider/usb_printer_manifest_data.cc +++ b/extensions/common/api/printer_provider/usb_printer_manifest_data.cc @@ -61,7 +61,7 @@ scoped_ptr<UsbPrinterManifestData> UsbPrinterManifestData::FromValue( } result->filters_.push_back(output); } - return result.Pass(); + return result; } bool UsbPrinterManifestData::SupportsDevice( diff --git a/extensions/common/api/sockets/sockets_manifest_data.cc b/extensions/common/api/sockets/sockets_manifest_data.cc index b68964c..9cedcf8 100644 --- a/extensions/common/api/sockets/sockets_manifest_data.cc +++ b/extensions/common/api/sockets/sockets_manifest_data.cc @@ -4,6 +4,8 @@ #include "extensions/common/api/sockets/sockets_manifest_data.h" +#include <utility> + #include "extensions/common/api/sockets/sockets_manifest_permission.h" #include "extensions/common/manifest_constants.h" @@ -11,7 +13,7 @@ namespace extensions { SocketsManifestData::SocketsManifestData( scoped_ptr<SocketsManifestPermission> permission) - : permission_(permission.Pass()) { + : permission_(std::move(permission)) { DCHECK(permission_); } @@ -44,7 +46,7 @@ scoped_ptr<SocketsManifestData> SocketsManifestData::FromValue( return scoped_ptr<SocketsManifestData>(); return scoped_ptr<SocketsManifestData>( - new SocketsManifestData(permission.Pass())).Pass(); + new SocketsManifestData(std::move(permission))); } } // namespace extensions diff --git a/extensions/common/api/sockets/sockets_manifest_permission.cc b/extensions/common/api/sockets/sockets_manifest_permission.cc index a5f0271..fa0c98a 100644 --- a/extensions/common/api/sockets/sockets_manifest_permission.cc +++ b/extensions/common/api/sockets/sockets_manifest_permission.cc @@ -193,7 +193,7 @@ scoped_ptr<SocketsManifestPermission> SocketsManifestPermission::FromValue( return scoped_ptr<SocketsManifestPermission>(); } } - return result.Pass(); + return result; } bool SocketsManifestPermission::CheckRequest( @@ -264,7 +264,7 @@ scoped_ptr<base::Value> SocketsManifestPermission::ToValue() const { sockets.tcp_server.reset(NULL); } - return scoped_ptr<base::Value>(sockets.ToValue().release()).Pass(); + return scoped_ptr<base::Value>(sockets.ToValue().release()); } ManifestPermission* SocketsManifestPermission::Diff( diff --git a/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc b/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc index bccce57..66fb8c3 100644 --- a/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc +++ b/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc @@ -42,7 +42,7 @@ static void AssertEmptyPermission(const SocketsManifestPermission* permission) { static scoped_ptr<base::Value> ParsePermissionJSON(const std::string& json) { scoped_ptr<base::Value> result(base::JSONReader::Read(json)); EXPECT_TRUE(result) << "Invalid JSON string: " << json; - return result.Pass(); + return result; } static scoped_ptr<SocketsManifestPermission> PermissionFromValue( @@ -51,7 +51,7 @@ static scoped_ptr<SocketsManifestPermission> PermissionFromValue( scoped_ptr<SocketsManifestPermission> permission( SocketsManifestPermission::FromValue(value, &error16)); EXPECT_TRUE(permission) << "Error parsing Value into permission: " << error16; - return permission.Pass(); + return permission; } static scoped_ptr<SocketsManifestPermission> PermissionFromJSON( diff --git a/extensions/common/cast/cast_cert_validator.cc b/extensions/common/cast/cast_cert_validator.cc index 1bfa4e0..bafbe6a 100644 --- a/extensions/common/cast/cast_cert_validator.cc +++ b/extensions/common/cast/cast_cert_validator.cc @@ -8,6 +8,7 @@ #include <openssl/evp.h> #include <openssl/rsa.h> #include <openssl/x509.h> +#include <utility> #include "base/logging.h" #include "base/strings/string_number_conversions.h" @@ -29,7 +30,7 @@ class CertVerificationContextImpl : public CertVerificationContext { public: // Takes ownership of the passed-in x509 object explicit CertVerificationContextImpl(net::ScopedX509 x509) - : x509_(x509.Pass()) {} + : x509_(std::move(x509)) {} VerificationResult VerifySignatureOverData( const base::StringPiece& signature, @@ -148,7 +149,8 @@ VerificationResult VerifyDeviceCert( } if (context) - context->reset(new CertVerificationContextImpl(device_cert_x509.Pass())); + context->reset( + new CertVerificationContextImpl(std::move(device_cert_x509))); return VerificationResult(); } diff --git a/extensions/common/event_filter.cc b/extensions/common/event_filter.cc index ff2d1f6..955671c 100644 --- a/extensions/common/event_filter.cc +++ b/extensions/common/event_filter.cc @@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <string> - #include "extensions/common/event_filter.h" +#include <string> +#include <utility> + #include "components/url_matcher/url_matcher_factory.h" #include "ipc/ipc_message.h" @@ -19,8 +20,7 @@ EventFilter::EventMatcherEntry::EventMatcherEntry( scoped_ptr<EventMatcher> event_matcher, URLMatcher* url_matcher, const URLMatcherConditionSet::Vector& condition_sets) - : event_matcher_(event_matcher.Pass()), - url_matcher_(url_matcher) { + : event_matcher_(std::move(event_matcher)), url_matcher_(url_matcher) { for (URLMatcherConditionSet::Vector::const_iterator it = condition_sets.begin(); it != condition_sets.end(); it++) condition_set_ids_.push_back((*it)->id()); @@ -68,7 +68,7 @@ EventFilter::AddEventMatcher(const std::string& event_name, } id_to_event_name_[id] = event_name; event_matchers_[event_name][id] = linked_ptr<EventMatcherEntry>( - new EventMatcherEntry(matcher.Pass(), &url_matcher_, condition_sets)); + new EventMatcherEntry(std::move(matcher), &url_matcher_, condition_sets)); return id; } diff --git a/extensions/common/event_filter_unittest.cc b/extensions/common/event_filter_unittest.cc index 0ae063c..bb5fe04 100644 --- a/extensions/common/event_filter_unittest.cc +++ b/extensions/common/event_filter_unittest.cc @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "extensions/common/event_filter.h" + #include <string> +#include <utility> #include "base/memory/scoped_ptr.h" #include "base/values.h" -#include "extensions/common/event_filter.h" #include "extensions/common/event_filtering_info.h" #include "extensions/common/event_matcher.h" #include "ipc/ipc_message.h" @@ -37,7 +39,7 @@ class EventFilterUnittest : public testing::Test { scoped_ptr<base::ListValue> ValueAsList(scoped_ptr<base::Value> value) { scoped_ptr<base::ListValue> result(new base::ListValue()); result->Append(value.release()); - return result.Pass(); + return result; } scoped_ptr<EventMatcher> AllURLs() { @@ -54,7 +56,7 @@ class EventFilterUnittest : public testing::Test { scoped_ptr<DictionaryValue> filter_dict(new DictionaryValue); filter_dict->Set("url", url_filter_list.release()); return scoped_ptr<EventMatcher>( - new EventMatcher(filter_dict.Pass(), MSG_ROUTING_NONE)); + new EventMatcher(std::move(filter_dict), MSG_ROUTING_NONE)); } EventFilter event_filter_; @@ -137,8 +139,9 @@ TEST_F(EventFilterUnittest, TestMultipleURLFiltersMatchOnAny) { filters->Append(HostSuffixDict("google.com").release()); filters->Append(HostSuffixDict("yahoo.com").release()); - scoped_ptr<EventMatcher> matcher(MatcherFromURLFilterList(filters.Pass())); - int id = event_filter_.AddEventMatcher("event1", matcher.Pass()); + scoped_ptr<EventMatcher> matcher( + MatcherFromURLFilterList(std::move(filters))); + int id = event_filter_.AddEventMatcher("event1", std::move(matcher)); { std::set<int> matches = event_filter_.MatchEvent("event1", @@ -209,9 +212,9 @@ TEST_F(EventFilterUnittest, RemoveEventMatcherReturnsEventName) { TEST_F(EventFilterUnittest, InvalidURLFilterCantBeAdded) { scoped_ptr<base::ListValue> filter_list(new base::ListValue()); filter_list->Append(new base::ListValue()); // Should be a dict. - scoped_ptr<EventMatcher> matcher(MatcherFromURLFilterList( - filter_list.Pass())); - int id1 = event_filter_.AddEventMatcher("event1", matcher.Pass()); + scoped_ptr<EventMatcher> matcher( + MatcherFromURLFilterList(std::move(filter_list))); + int id1 = event_filter_.AddEventMatcher("event1", std::move(matcher)); EXPECT_TRUE(event_filter_.IsURLMatcherEmpty()); ASSERT_EQ(-1, id1); } @@ -220,7 +223,7 @@ TEST_F(EventFilterUnittest, EmptyListOfURLFiltersMatchesAllURLs) { scoped_ptr<base::ListValue> filter_list(new base::ListValue()); scoped_ptr<EventMatcher> matcher(MatcherFromURLFilterList( scoped_ptr<ListValue>(new ListValue))); - int id = event_filter_.AddEventMatcher("event1", matcher.Pass()); + int id = event_filter_.AddEventMatcher("event1", std::move(matcher)); std::set<int> matches = event_filter_.MatchEvent("event1", google_event_, MSG_ROUTING_NONE); ASSERT_EQ(1u, matches.size()); @@ -249,7 +252,7 @@ TEST_F(EventFilterUnittest, EmptyURLsShouldBeMatchedByEmptyURLFiltersWithAnEmptyItem) { scoped_ptr<EventMatcher> matcher(MatcherFromURLFilterList(ValueAsList( scoped_ptr<Value>(new DictionaryValue())))); - int id = event_filter_.AddEventMatcher("event1", matcher.Pass()); + int id = event_filter_.AddEventMatcher("event1", std::move(matcher)); std::set<int> matches = event_filter_.MatchEvent( "event1", empty_url_event_, MSG_ROUTING_NONE); ASSERT_EQ(1u, matches.size()); diff --git a/extensions/common/event_filtering_info.cc b/extensions/common/event_filtering_info.cc index fe9ef29..3c39864 100644 --- a/extensions/common/event_filtering_info.cc +++ b/extensions/common/event_filtering_info.cc @@ -4,6 +4,8 @@ #include "extensions/common/event_filtering_info.h" +#include <utility> + #include "base/json/json_writer.h" #include "base/values.h" @@ -59,7 +61,7 @@ scoped_ptr<base::Value> EventFilteringInfo::AsValue() const { if (has_window_exposed_by_default_) result->SetBoolean("windowExposedByDefault", window_exposed_by_default_); - return result.Pass(); + return std::move(result); } bool EventFilteringInfo::IsEmpty() const { diff --git a/extensions/common/event_matcher.cc b/extensions/common/event_matcher.cc index a5e6fc5..05dfdd8 100644 --- a/extensions/common/event_matcher.cc +++ b/extensions/common/event_matcher.cc @@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/callback.h" - #include "extensions/common/event_matcher.h" +#include <utility> + +#include "base/callback.h" #include "extensions/common/event_filtering_info.h" namespace { @@ -19,9 +20,7 @@ const char kEventFilterServiceTypeKey[] = "serviceType"; EventMatcher::EventMatcher(scoped_ptr<base::DictionaryValue> filter, int routing_id) - : filter_(filter.Pass()), - routing_id_(routing_id) { -} + : filter_(std::move(filter)), routing_id_(routing_id) {} EventMatcher::~EventMatcher() { } diff --git a/extensions/common/extension.cc b/extensions/common/extension.cc index 4232509..f51d893 100644 --- a/extensions/common/extension.cc +++ b/extensions/common/extension.cc @@ -4,6 +4,8 @@ #include "extensions/common/extension.h" +#include <utility> + #include "base/base64.h" #include "base/basictypes.h" #include "base/command_line.h" @@ -128,7 +130,7 @@ scoped_refptr<Extension> Extension::Create(const base::FilePath& path, return NULL; } - scoped_refptr<Extension> extension = new Extension(path, manifest.Pass()); + scoped_refptr<Extension> extension = new Extension(path, std::move(manifest)); extension->install_warnings_.swap(install_warnings); if (!extension->InitFromValue(flags, &error)) { diff --git a/extensions/common/extension_api.cc b/extensions/common/extension_api.cc index ec6fa18..afafa81 100644 --- a/extensions/common/extension_api.cc +++ b/extensions/common/extension_api.cc @@ -6,6 +6,7 @@ #include <algorithm> #include <string> +#include <utility> #include <vector> #include "base/json/json_reader.h" @@ -60,7 +61,7 @@ scoped_ptr<base::ListValue> LoadSchemaList(const std::string& name, CHECK(result.get()) << error_message << " for schema " << schema; CHECK(result->IsType(base::Value::TYPE_LIST)) << " for schema " << schema; - return base::ListValue::From(result.Pass()); + return base::ListValue::From(std::move(result)); } const base::DictionaryValue* FindListItem(const base::ListValue* list, diff --git a/extensions/common/extension_builder.cc b/extensions/common/extension_builder.cc index b573128..9e41166 100644 --- a/extensions/common/extension_builder.cc +++ b/extensions/common/extension_builder.cc @@ -57,7 +57,7 @@ ExtensionBuilder& ExtensionBuilder::SetLocation(Manifest::Location location) { ExtensionBuilder& ExtensionBuilder::SetManifest( scoped_ptr<base::DictionaryValue> manifest) { - manifest_ = manifest.Pass(); + manifest_ = std::move(manifest); return *this; } diff --git a/extensions/common/features/base_feature_provider.cc b/extensions/common/features/base_feature_provider.cc index cae08d6..3b60e47 100644 --- a/extensions/common/features/base_feature_provider.cc +++ b/extensions/common/features/base_feature_provider.cc @@ -128,10 +128,11 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root, feature.get())) continue; - features->push_back(feature.Pass()); + features->push_back(std::move(feature)); } - linked_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass())); + linked_ptr<ComplexFeature> feature( + new ComplexFeature(std::move(features))); feature->set_name(iter.key()); features_[iter.key()] = feature; diff --git a/extensions/common/features/complex_feature_unittest.cc b/extensions/common/features/complex_feature_unittest.cc index d06a15a..0dd7c8f 100644 --- a/extensions/common/features/complex_feature_unittest.cc +++ b/extensions/common/features/complex_feature_unittest.cc @@ -28,7 +28,7 @@ TEST(ComplexFeatureTest, MultipleRulesWhitelist) { .Set("extension_types", std::move(ListBuilder().Append("extension"))) .Build()); simple_feature->Parse(rule.get()); - features->push_back(simple_feature.Pass()); + features->push_back(std::move(simple_feature)); // Rule: "legacy_packaged_app", whitelist "bar". simple_feature.reset(new SimpleFeature); @@ -38,9 +38,9 @@ TEST(ComplexFeatureTest, MultipleRulesWhitelist) { std::move(ListBuilder().Append("legacy_packaged_app"))) .Build(); simple_feature->Parse(rule.get()); - features->push_back(simple_feature.Pass()); + features->push_back(std::move(simple_feature)); - scoped_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass())); + scoped_ptr<ComplexFeature> feature(new ComplexFeature(std::move(features))); // Test match 1st rule. EXPECT_EQ( @@ -90,7 +90,7 @@ TEST(ComplexFeatureTest, Dependencies) { "manifest:content_security_policy"))) .Build(); simple_feature->Parse(rule.get()); - features->push_back(simple_feature.Pass()); + features->push_back(std::move(simple_feature)); // Rule which depends on an platform-app-only feature (serial). simple_feature.reset(new SimpleFeature); @@ -99,9 +99,9 @@ TEST(ComplexFeatureTest, Dependencies) { std::move(ListBuilder().Append("permission:serial"))) .Build(); simple_feature->Parse(rule.get()); - features->push_back(simple_feature.Pass()); + features->push_back(std::move(simple_feature)); - scoped_ptr<ComplexFeature> feature(new ComplexFeature(features.Pass())); + scoped_ptr<ComplexFeature> feature(new ComplexFeature(std::move(features))); // Available to extensions because of the content_security_policy rule. EXPECT_EQ( diff --git a/extensions/common/features/json_feature_provider_source.cc b/extensions/common/features/json_feature_provider_source.cc index c41ecb7..4d2f834 100644 --- a/extensions/common/features/json_feature_provider_source.cc +++ b/extensions/common/features/json_feature_provider_source.cc @@ -4,6 +4,8 @@ #include "extensions/common/features/json_feature_provider_source.h" +#include <utility> + #include "base/json/json_reader.h" #include "base/logging.h" #include "ui/base/resource/resource_bundle.h" @@ -29,7 +31,7 @@ void JSONFeatureProviderSource::LoadJSON(int resource_id) { scoped_ptr<base::DictionaryValue> value_as_dict; if (value) { CHECK(value->IsType(base::Value::TYPE_DICTIONARY)) << name_; - value_as_dict = base::DictionaryValue::From(value.Pass()); + value_as_dict = base::DictionaryValue::From(std::move(value)); } else { // There was some error loading the features file. // http://crbug.com/176381 diff --git a/extensions/common/features/simple_feature.cc b/extensions/common/features/simple_feature.cc index 4ead463..68c8dfa 100644 --- a/extensions/common/features/simple_feature.cc +++ b/extensions/common/features/simple_feature.cc @@ -6,6 +6,7 @@ #include <algorithm> #include <map> +#include <utility> #include <vector> #include "base/bind.h" @@ -293,7 +294,7 @@ bool SimpleFeature::HasDependencies() const { } void SimpleFeature::AddFilter(scoped_ptr<SimpleFeatureFilter> filter) { - filters_.push_back(filter.Pass()); + filters_.push_back(std::move(filter)); } std::string SimpleFeature::Parse(const base::DictionaryValue* dictionary) { diff --git a/extensions/common/file_util.cc b/extensions/common/file_util.cc index 763fa29..a187378 100644 --- a/extensions/common/file_util.cc +++ b/extensions/common/file_util.cc @@ -268,7 +268,7 @@ scoped_ptr<base::DictionaryValue> LoadManifest( return NULL; } - return base::DictionaryValue::From(root.Pass()); + return base::DictionaryValue::From(std::move(root)); } bool ValidateExtension(const Extension* extension, diff --git a/extensions/common/file_util_unittest.cc b/extensions/common/file_util_unittest.cc index 0814334..634b338 100644 --- a/extensions/common/file_util_unittest.cc +++ b/extensions/common/file_util_unittest.cc @@ -4,6 +4,8 @@ #include "extensions/common/file_util.h" +#include <utility> + #include "base/basictypes.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" @@ -49,8 +51,8 @@ scoped_refptr<Extension> LoadExtensionManifest( return NULL; CHECK_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); return LoadExtensionManifest( - *base::DictionaryValue::From(result.Pass()).get(), manifest_dir, location, - extra_flags, error); + *base::DictionaryValue::From(std::move(result)).get(), manifest_dir, + location, extra_flags, error); } } // namespace diff --git a/extensions/common/manifest.cc b/extensions/common/manifest.cc index c552de7..cf39887 100644 --- a/extensions/common/manifest.cc +++ b/extensions/common/manifest.cc @@ -4,6 +4,8 @@ #include "extensions/common/manifest.h" +#include <utility> + #include "base/basictypes.h" #include "base/lazy_instance.h" #include "base/logging.h" @@ -109,9 +111,7 @@ Manifest::Location Manifest::GetHigherPriorityLocation( } Manifest::Manifest(Location location, scoped_ptr<base::DictionaryValue> value) - : location_(location), - value_(value.Pass()), - type_(TYPE_UNKNOWN) { + : location_(location), value_(std::move(value)), type_(TYPE_UNKNOWN) { if (value_->HasKey(keys::kTheme)) { type_ = TYPE_THEME; } else if (value_->HasKey(keys::kExport)) { diff --git a/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc b/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc index e52a103..f09c971 100644 --- a/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc +++ b/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <utility> + #include "base/test/values_test_util.h" #include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_handlers/oauth2_manifest_handler.h" @@ -156,7 +158,7 @@ TEST_F(OAuth2ManifestTest, OAuth2SectionParsing) { TEST_F(OAuth2ManifestTest, AutoApproveNotSetExtensionNotOnWhitelist) { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_DEFAULT); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); EXPECT_TRUE(extension->install_warnings().empty()); @@ -166,7 +168,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveNotSetExtensionNotOnWhitelist) { TEST_F(OAuth2ManifestTest, AutoApproveFalseExtensionNotOnWhitelist) { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_FALSE, false, CLIENT_ID_DEFAULT); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); EXPECT_EQ(1U, extension->install_warnings().size()); @@ -179,7 +181,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveFalseExtensionNotOnWhitelist) { TEST_F(OAuth2ManifestTest, AutoApproveTrueExtensionNotOnWhitelist) { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_TRUE, false, CLIENT_ID_DEFAULT); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); EXPECT_EQ(1U, extension->install_warnings().size()); @@ -192,7 +194,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveTrueExtensionNotOnWhitelist) { TEST_F(OAuth2ManifestTest, AutoApproveInvalidExtensionNotOnWhitelist) { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_INVALID, false, CLIENT_ID_DEFAULT); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); EXPECT_EQ(1U, extension->install_warnings().size()); @@ -205,7 +207,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveInvalidExtensionNotOnWhitelist) { TEST_F(OAuth2ManifestTest, AutoApproveNotSetExtensionOnWhitelist) { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_NOT_SET, true, CLIENT_ID_DEFAULT); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); EXPECT_TRUE(extension->install_warnings().empty()); @@ -215,7 +217,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveNotSetExtensionOnWhitelist) { TEST_F(OAuth2ManifestTest, AutoApproveFalseExtensionOnWhitelist) { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_FALSE, true, CLIENT_ID_DEFAULT); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); EXPECT_TRUE(extension->install_warnings().empty()); @@ -225,7 +227,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveFalseExtensionOnWhitelist) { TEST_F(OAuth2ManifestTest, AutoApproveTrueExtensionOnWhitelist) { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_DEFAULT); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest); EXPECT_TRUE(extension->install_warnings().empty()); @@ -235,7 +237,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveTrueExtensionOnWhitelist) { TEST_F(OAuth2ManifestTest, AutoApproveInvalidExtensionOnWhitelist) { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_INVALID, true, CLIENT_ID_DEFAULT); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); std::string error; scoped_refptr<extensions::Extension> extension = LoadExtension(manifest, &error); @@ -248,7 +250,7 @@ TEST_F(OAuth2ManifestTest, InvalidClientId) { { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_NOT_SET); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); std::string error; LoadAndExpectError(manifest, errors::kInvalidOAuth2ClientId); } @@ -256,7 +258,7 @@ TEST_F(OAuth2ManifestTest, InvalidClientId) { { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_EMPTY); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); std::string error; LoadAndExpectError(manifest, errors::kInvalidOAuth2ClientId); } @@ -267,7 +269,7 @@ TEST_F(OAuth2ManifestTest, ComponentInvalidClientId) { { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_NOT_SET); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); std::string error; LoadAndExpectError(manifest, errors::kInvalidOAuth2ClientId, @@ -277,7 +279,7 @@ TEST_F(OAuth2ManifestTest, ComponentInvalidClientId) { { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_EMPTY); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); std::string error; LoadAndExpectError(manifest, errors::kInvalidOAuth2ClientId, @@ -289,7 +291,7 @@ TEST_F(OAuth2ManifestTest, ComponentWithChromeClientId) { { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_NOT_SET); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest, extensions::Manifest::COMPONENT); EXPECT_TRUE(OAuth2Info::GetOAuth2Info(extension.get()).client_id.empty()); @@ -298,7 +300,7 @@ TEST_F(OAuth2ManifestTest, ComponentWithChromeClientId) { { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_EMPTY); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest, extensions::Manifest::COMPONENT); EXPECT_TRUE(OAuth2Info::GetOAuth2Info(extension.get()).client_id.empty()); @@ -308,7 +310,7 @@ TEST_F(OAuth2ManifestTest, ComponentWithChromeClientId) { TEST_F(OAuth2ManifestTest, ComponentWithStandardClientId) { scoped_ptr<base::DictionaryValue> ext_manifest = CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_DEFAULT); - ManifestData manifest(ext_manifest.Pass(), "test"); + ManifestData manifest(std::move(ext_manifest), "test"); scoped_refptr<extensions::Extension> extension = LoadAndExpectSuccess(manifest, extensions::Manifest::COMPONENT); EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension.get()).client_id); diff --git a/extensions/common/manifest_handlers/permissions_parser.cc b/extensions/common/manifest_handlers/permissions_parser.cc index a7c6db9..2afdf72 100644 --- a/extensions/common/manifest_handlers/permissions_parser.cc +++ b/extensions/common/manifest_handlers/permissions_parser.cc @@ -4,6 +4,8 @@ #include "extensions/common/manifest_handlers/permissions_parser.h" +#include <utility> + #include "base/command_line.h" #include "base/memory/ref_counted.h" #include "base/strings/utf_string_conversions.h" @@ -40,7 +42,7 @@ struct ManifestPermissions : public Extension::ManifestData { ManifestPermissions::ManifestPermissions( scoped_ptr<const PermissionSet> permissions) - : permissions(permissions.Pass()) {} + : permissions(std::move(permissions)) {} ManifestPermissions::~ManifestPermissions() { } @@ -272,7 +274,8 @@ void PermissionsParser::Finalize(Extension* extension) { initial_required_permissions_->host_permissions, initial_required_permissions_->scriptable_hosts)); extension->SetManifestData( - keys::kPermissions, new ManifestPermissions(required_permissions.Pass())); + keys::kPermissions, + new ManifestPermissions(std::move(required_permissions))); scoped_ptr<const PermissionSet> optional_permissions(new PermissionSet( initial_optional_permissions_->api_permissions, @@ -280,7 +283,7 @@ void PermissionsParser::Finalize(Extension* extension) { initial_optional_permissions_->host_permissions, URLPatternSet())); extension->SetManifestData( keys::kOptionalPermissions, - new ManifestPermissions(optional_permissions.Pass())); + new ManifestPermissions(std::move(optional_permissions))); } // static diff --git a/extensions/common/manifest_handlers/webview_info.cc b/extensions/common/manifest_handlers/webview_info.cc index 12bafcc..f66df27 100644 --- a/extensions/common/manifest_handlers/webview_info.cc +++ b/extensions/common/manifest_handlers/webview_info.cc @@ -4,6 +4,8 @@ #include "extensions/common/manifest_handlers/webview_info.h" +#include <utility> + #include "base/memory/scoped_ptr.h" #include "base/strings/pattern.h" #include "base/strings/string_number_conversions.h" @@ -83,7 +85,7 @@ bool WebviewInfo::IsResourceWebviewAccessible( } void WebviewInfo::AddPartitionItem(scoped_ptr<PartitionItem> item) { - partition_items_.push_back(item.Pass()); + partition_items_.push_back(std::move(item)); } WebviewHandler::WebviewHandler() { @@ -159,7 +161,7 @@ bool WebviewHandler::Parse(Extension* extension, base::string16* error) { relative_path).spec()); partition_item->AddPattern(pattern); } - info->AddPartitionItem(partition_item.Pass()); + info->AddPartitionItem(std::move(partition_item)); } extension->SetManifestData(keys::kWebviewAccessibleResources, info.release()); diff --git a/extensions/common/manifest_test.cc b/extensions/common/manifest_test.cc index ea32fc8..771d4b3 100644 --- a/extensions/common/manifest_test.cc +++ b/extensions/common/manifest_test.cc @@ -4,6 +4,8 @@ #include "extensions/common/manifest_test.h" +#include <utility> + #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/json/json_file_value_serializer.h" @@ -68,7 +70,7 @@ ManifestTest::ManifestData::ManifestData(base::DictionaryValue* manifest, ManifestTest::ManifestData::ManifestData( scoped_ptr<base::DictionaryValue> manifest) - : manifest_(manifest.get()), manifest_holder_(manifest.Pass()) { + : manifest_(manifest.get()), manifest_holder_(std::move(manifest)) { CHECK(manifest_) << "Manifest NULL"; } @@ -77,7 +79,7 @@ ManifestTest::ManifestData::ManifestData( const char* name) : name_(name), manifest_(manifest.get()), - manifest_holder_(manifest.Pass()) { + manifest_holder_(std::move(manifest)) { CHECK(manifest_) << "Manifest NULL"; } diff --git a/extensions/common/permissions/permissions_data.cc b/extensions/common/permissions/permissions_data.cc index 79271d7..5b28d85 100644 --- a/extensions/common/permissions/permissions_data.cc +++ b/extensions/common/permissions/permissions_data.cc @@ -4,6 +4,8 @@ #include "extensions/common/permissions/permissions_data.h" +#include <utility> + #include "base/command_line.h" #include "content/public/common/url_constants.h" #include "extensions/common/constants.h" @@ -132,14 +134,14 @@ void PermissionsData::SetPermissions( scoped_ptr<const PermissionSet> active, scoped_ptr<const PermissionSet> withheld) const { AutoLockOnValidThread lock(runtime_lock_, thread_checker_.get()); - active_permissions_unsafe_ = active.Pass(); - withheld_permissions_unsafe_ = withheld.Pass(); + active_permissions_unsafe_ = std::move(active); + withheld_permissions_unsafe_ = std::move(withheld); } void PermissionsData::SetActivePermissions( scoped_ptr<const PermissionSet> active) const { AutoLockOnValidThread lock(runtime_lock_, thread_checker_.get()); - active_permissions_unsafe_ = active.Pass(); + active_permissions_unsafe_ = std::move(active); } void PermissionsData::UpdateTabSpecificPermissions( @@ -154,7 +156,7 @@ void PermissionsData::UpdateTabSpecificPermissions( ? static_cast<const PermissionSet&>(PermissionSet()) : *iter->second, permissions); - tab_specific_permissions_[tab_id] = new_permissions.Pass(); + tab_specific_permissions_[tab_id] = std::move(new_permissions); } void PermissionsData::ClearTabSpecificPermissions(int tab_id) const { diff --git a/extensions/common/url_pattern_set.cc b/extensions/common/url_pattern_set.cc index bd489e1..52db387 100644 --- a/extensions/common/url_pattern_set.cc +++ b/extensions/common/url_pattern_set.cc @@ -231,7 +231,7 @@ scoped_ptr<base::ListValue> URLPatternSet::ToValue() const { for (URLPatternSet::const_iterator i = patterns_.begin(); i != patterns_.end(); ++i) value->AppendIfNotPresent(new base::StringValue(i->GetAsString())); - return value.Pass(); + return value; } bool URLPatternSet::Populate(const std::vector<std::string>& patterns, @@ -266,7 +266,7 @@ scoped_ptr<std::vector<std::string> > URLPatternSet::ToStringVector() const { ++i) { value->push_back(i->GetAsString()); } - return value.Pass(); + return value; } bool URLPatternSet::Populate(const base::ListValue& value, diff --git a/extensions/common/value_builder.cc b/extensions/common/value_builder.cc index b15bca8..89c3ec3 100644 --- a/extensions/common/value_builder.cc +++ b/extensions/common/value_builder.cc @@ -4,6 +4,8 @@ #include "extensions/common/value_builder.h" +#include <utility> + #include "base/json/json_writer.h" #include "base/values.h" @@ -51,19 +53,19 @@ DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, DictionaryBuilder& in_value) { - dict_->SetWithoutPathExpansion(path, in_value.Build().Pass()); + dict_->SetWithoutPathExpansion(path, in_value.Build()); return *this; } DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, ListBuilder in_value) { - dict_->SetWithoutPathExpansion(path, in_value.Build().Pass()); + dict_->SetWithoutPathExpansion(path, in_value.Build()); return *this; } DictionaryBuilder& DictionaryBuilder::Set(const std::string& path, scoped_ptr<base::Value> in_value) { - dict_->SetWithoutPathExpansion(path, in_value.Pass()); + dict_->SetWithoutPathExpansion(path, std::move(in_value)); return *this; } diff --git a/extensions/common/value_builder.h b/extensions/common/value_builder.h index cc706fa..17020a8 100644 --- a/extensions/common/value_builder.h +++ b/extensions/common/value_builder.h @@ -30,6 +30,7 @@ #define EXTENSIONS_COMMON_VALUE_BUILDER_H_ #include <string> +#include <utility> #include "base/macros.h" #include "base/memory/scoped_ptr.h" @@ -57,7 +58,7 @@ class DictionaryBuilder { DictionaryBuilder& Pass() { return *this; } // Can only be called once, after which it's invalid to use the builder. - scoped_ptr<base::DictionaryValue> Build() { return dict_.Pass(); } + scoped_ptr<base::DictionaryValue> Build() { return std::move(dict_); } // Immediately serializes the current state to JSON. Can be called as many // times as you like. diff --git a/extensions/common/value_counter.cc b/extensions/common/value_counter.cc index 3a5e662..a4e49e0 100644 --- a/extensions/common/value_counter.cc +++ b/extensions/common/value_counter.cc @@ -5,6 +5,7 @@ #include "extensions/common/value_counter.h" #include <algorithm> +#include <utility> #include "base/values.h" @@ -12,7 +13,7 @@ namespace extensions { struct ValueCounter::Entry { explicit Entry(scoped_ptr<base::Value> value) - : value(value.Pass()), count(1) {} + : value(std::move(value)), count(1) {} scoped_ptr<base::Value> value; int count; |