From 1cb4c0e1be53447096ae11f820bb408b71184682 Mon Sep 17 00:00:00 2001 From: "rdevlin.cronin" Date: Thu, 24 Mar 2016 13:52:17 -0700 Subject: [Extensions] Convert APIs to use movable types [3] Generated extensions code used to rely on linked_ptrs for non-copyable types in containers. Now, we can make these types movable. Update the following APIs to use movable types in this CL: - browser.idl - browsing_data.json - cast_devices_private.idl - cast_streaming_receiver_session.idl - cast_streaming_rtp_stream.idl - cast_streaming_session.idl - cast_streaming_udp_transport.idl - certificate_provider.idl - certificate_provider_internal.idl - chrome_web_view_internal.json - chromeos_info_private.json - cloud_print_private.json - command_line_private.json - commands.json - content_settings.json - context_menus.json - context_menus_internal.json - cookies.json - copresence.idl - copresence_private.idl BUG=595949 Review URL: https://codereview.chromium.org/1828683002 Cr-Commit-Position: refs/heads/master@{#383142} --- .../cast_devices_private_api.cc | 6 +- .../certificate_provider_api.cc | 8 +-- .../cloud_print_private_apitest.cc | 11 ++-- .../browser/extensions/api/cookies/cookies_api.cc | 44 +++++++-------- .../extensions/api/cookies/cookies_helpers.cc | 66 ++++++++++------------ .../extensions/api/cookies/cookies_helpers.h | 38 ++++++------- .../extensions/api/cookies/cookies_unittest.cc | 61 ++++++++++---------- .../extensions/api/copresence/copresence_api.cc | 21 ++++--- .../api/copresence/copresence_translations.cc | 44 +++++++-------- .../api/copresence/copresence_translations.h | 3 +- .../copresence_private/copresence_private_api.cc | 4 +- chrome/common/extensions/api/browser.idl | 6 +- chrome/common/extensions/api/browsing_data.json | 1 + .../common/extensions/api/cast_devices_private.idl | 2 +- .../api/cast_streaming_receiver_session.idl | 2 +- .../extensions/api/cast_streaming_rtp_stream.idl | 2 +- .../extensions/api/cast_streaming_session.idl | 2 +- .../api/cast_streaming_udp_transport.idl | 2 +- .../common/extensions/api/certificate_provider.idl | 2 +- .../api/certificate_provider_internal.idl | 2 +- .../extensions/api/chrome_web_view_internal.json | 3 +- .../extensions/api/chromeos_info_private.json | 3 +- .../common/extensions/api/cloud_print_private.json | 1 + .../extensions/api/command_line_private.json | 1 + chrome/common/extensions/api/commands.json | 1 + chrome/common/extensions/api/content_settings.json | 3 +- chrome/common/extensions/api/context_menus.json | 1 + .../extensions/api/context_menus_internal.json | 1 + chrome/common/extensions/api/cookies.json | 1 + chrome/common/extensions/api/copresence.idl | 2 +- .../common/extensions/api/copresence_private.idl | 2 +- .../extensions/cast_streaming_native_handler.cc | 9 ++- 32 files changed, 169 insertions(+), 186 deletions(-) diff --git a/chrome/browser/extensions/api/cast_devices_private/cast_devices_private_api.cc b/chrome/browser/extensions/api/cast_devices_private/cast_devices_private_api.cc index ab944b2..b40895c 100644 --- a/chrome/browser/extensions/api/cast_devices_private/cast_devices_private_api.cc +++ b/chrome/browser/extensions/api/cast_devices_private/cast_devices_private_api.cc @@ -93,10 +93,10 @@ CastDevicesPrivateUpdateDevicesFunction::Run() { api::cast_devices_private::UpdateDevices::Params::Create(*args_); CastDeviceUpdateListeners::ReceiverAndActivityList devices; - for (linked_ptr device : + for (const api::cast_devices_private::ReceiverActivity& device : params->devices) { - devices.push_back(ConvertReceiverAndActivityType(device->receiver, - device->activity.get())); + devices.push_back( + ConvertReceiverAndActivityType(device.receiver, device.activity.get())); } auto listeners = CastDeviceUpdateListeners::Get(browser_context()); diff --git a/chrome/browser/extensions/api/certificate_provider/certificate_provider_api.cc b/chrome/browser/extensions/api/certificate_provider/certificate_provider_api.cc index 98c9627..a4f4c3e 100644 --- a/chrome/browser/extensions/api/certificate_provider/certificate_provider_api.cc +++ b/chrome/browser/extensions/api/certificate_provider/certificate_provider_api.cc @@ -10,7 +10,6 @@ #include #include "base/logging.h" -#include "base/memory/linked_ptr.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/chromeos/certificate_provider/certificate_provider_service.h" #include "chrome/browser/chromeos/certificate_provider/certificate_provider_service_factory.h" @@ -59,14 +58,13 @@ CertificateProviderInternalReportCertificatesFunction::Run() { chromeos::certificate_provider::CertificateInfoList cert_infos; std::vector> rejected_certificates; - for (linked_ptr input_cert_info : - *params->certificates) { + for (const api_cp::CertificateInfo& input_cert_info : *params->certificates) { chromeos::certificate_provider::CertificateInfo parsed_cert_info; - if (ParseCertificateInfo(*input_cert_info, &parsed_cert_info)) + if (ParseCertificateInfo(input_cert_info, &parsed_cert_info)) cert_infos.push_back(parsed_cert_info); else - rejected_certificates.push_back(input_cert_info->certificate); + rejected_certificates.push_back(input_cert_info.certificate); } if (service->SetCertificatesProvidedByExtension( diff --git a/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc b/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc index 47dc897..7e44909 100644 --- a/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc +++ b/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc @@ -79,12 +79,11 @@ class CloudPrintTestsDelegateMock : public extensions::CloudPrintTestsDelegate { MATCHER(IsExpectedUserSettings, "") { const UserSettings& settings = arg; - return settings.connect_new_printers && - settings.printers.size() == 2 && - settings.printers[0]->name == "printer1" && - !settings.printers[0]->connect && - settings.printers[1]->name == "printer2" && - settings.printers[1]->connect; + return settings.connect_new_printers && settings.printers.size() == 2 && + settings.printers[0].name == "printer1" && + !settings.printers[0].connect && + settings.printers[1].name == "printer2" && + settings.printers[1].connect; } // http://crbug.com/177163 diff --git a/chrome/browser/extensions/api/cookies/cookies_api.cc b/chrome/browser/extensions/api/cookies/cookies_api.cc index 85418ac..3485bb8 100644 --- a/chrome/browser/extensions/api/cookies/cookies_api.cc +++ b/chrome/browser/extensions/api/cookies/cookies_api.cc @@ -143,9 +143,9 @@ void CookiesEventRouter::CookieChanged( base::DictionaryValue* dict = new base::DictionaryValue(); dict->SetBoolean(keys::kRemovedKey, details->removed); - scoped_ptr cookie(cookies_helpers::CreateCookie( - *details->cookie, cookies_helpers::GetStoreIdFromProfile(profile))); - dict->Set(keys::kCookieKey, cookie->ToValue().release()); + cookies::Cookie cookie = cookies_helpers::CreateCookie( + *details->cookie, cookies_helpers::GetStoreIdFromProfile(profile)); + dict->Set(keys::kCookieKey, cookie.ToValue()); // Map the internal cause to an external string. std::string cause; @@ -243,21 +243,20 @@ void CookiesGetFunction::GetCookieOnIOThread() { } void CookiesGetFunction::GetCookieCallback(const net::CookieList& cookie_list) { - net::CookieList::const_iterator it; - for (it = cookie_list.begin(); it != cookie_list.end(); ++it) { + for (const net::CanonicalCookie& cookie : cookie_list) { // Return the first matching cookie. Relies on the fact that the // CookieMonster returns them in canonical order (longest path, then // earliest creation time). - if (it->Name() == parsed_args_->details.name) { - scoped_ptr cookie( - cookies_helpers::CreateCookie(*it, *parsed_args_->details.store_id)); - results_ = Get::Results::Create(*cookie); + if (cookie.Name() == parsed_args_->details.name) { + cookies::Cookie api_cookie = cookies_helpers::CreateCookie( + cookie, *parsed_args_->details.store_id); + results_ = Get::Results::Create(api_cookie); break; } } // The cookie doesn't exist; return null. - if (it == cookie_list.end()) + if (!results_) SetResult(base::Value::CreateNullValue()); bool rv = BrowserThread::PostTask( @@ -317,7 +316,7 @@ void CookiesGetAllFunction::GetAllCookiesOnIOThread() { void CookiesGetAllFunction::GetAllCookiesCallback( const net::CookieList& cookie_list) { if (extension()) { - std::vector> match_vector; + std::vector match_vector; cookies_helpers::AppendMatchingCookiesToVector( cookie_list, url_, &parsed_args_->details, extension(), &match_vector); @@ -436,18 +435,17 @@ void CookiesSetFunction::PullCookie(bool set_cookie_result) { void CookiesSetFunction::PullCookieCallback( const net::CookieList& cookie_list) { - net::CookieList::const_iterator it; - for (it = cookie_list.begin(); it != cookie_list.end(); ++it) { + for (const net::CanonicalCookie& cookie : cookie_list) { // Return the first matching cookie. Relies on the fact that the // CookieMonster returns them in canonical order (longest path, then // earliest creation time). std::string name = parsed_args_->details.name.get() ? *parsed_args_->details.name : std::string(); - if (it->Name() == name) { - scoped_ptr cookie( - cookies_helpers::CreateCookie(*it, *parsed_args_->details.store_id)); - results_ = Set::Results::Create(*cookie); + if (cookie.Name() == name) { + cookies::Cookie api_cookie = cookies_helpers::CreateCookie( + cookie, *parsed_args_->details.store_id); + results_ = Set::Results::Create(api_cookie); break; } } @@ -559,17 +557,15 @@ bool CookiesGetAllCookieStoresFunction::RunSync() { } } // Return a list of all cookie stores with at least one open tab. - std::vector> cookie_stores; + std::vector cookie_stores; if (original_tab_ids->GetSize() > 0) { - cookie_stores.push_back(make_linked_ptr( - cookies_helpers::CreateCookieStore( - original_profile, original_tab_ids.release()).release())); + cookie_stores.push_back(cookies_helpers::CreateCookieStore( + original_profile, original_tab_ids.release())); } if (incognito_tab_ids.get() && incognito_tab_ids->GetSize() > 0 && incognito_profile) { - cookie_stores.push_back(make_linked_ptr( - cookies_helpers::CreateCookieStore( - incognito_profile, incognito_tab_ids.release()).release())); + cookie_stores.push_back(cookies_helpers::CreateCookieStore( + incognito_profile, incognito_tab_ids.release())); } results_ = GetAllCookieStores::Results::Create(cookie_stores); return true; diff --git a/chrome/browser/extensions/api/cookies/cookies_helpers.cc b/chrome/browser/extensions/api/cookies/cookies_helpers.cc index 3ae02ac..350a5b9 100644 --- a/chrome/browser/extensions/api/cookies/cookies_helpers.cc +++ b/chrome/browser/extensions/api/cookies/cookies_helpers.cc @@ -11,8 +11,6 @@ #include #include "base/logging.h" -#include "base/memory/linked_ptr.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" @@ -65,63 +63,62 @@ const char* GetStoreIdFromProfile(Profile* profile) { kOffTheRecordProfileStoreId : kOriginalProfileStoreId; } -scoped_ptr CreateCookie( - const net::CanonicalCookie& canonical_cookie, - const std::string& store_id) { - scoped_ptr cookie(new Cookie()); +Cookie CreateCookie(const net::CanonicalCookie& canonical_cookie, + const std::string& store_id) { + Cookie cookie; // A cookie is a raw byte sequence. By explicitly parsing it as UTF-8, we // apply error correction, so the string can be safely passed to the renderer. - cookie->name = base::UTF16ToUTF8(base::UTF8ToUTF16(canonical_cookie.Name())); - cookie->value = - base::UTF16ToUTF8(base::UTF8ToUTF16(canonical_cookie.Value())); - cookie->domain = canonical_cookie.Domain(); - cookie->host_only = net::cookie_util::DomainIsHostOnly( - canonical_cookie.Domain()); + cookie.name = base::UTF16ToUTF8(base::UTF8ToUTF16(canonical_cookie.Name())); + cookie.value = base::UTF16ToUTF8(base::UTF8ToUTF16(canonical_cookie.Value())); + cookie.domain = canonical_cookie.Domain(); + cookie.host_only = + net::cookie_util::DomainIsHostOnly(canonical_cookie.Domain()); // A non-UTF8 path is invalid, so we just replace it with an empty string. - cookie->path = base::IsStringUTF8(canonical_cookie.Path()) ? - canonical_cookie.Path() : std::string(); - cookie->secure = canonical_cookie.IsSecure(); - cookie->http_only = canonical_cookie.IsHttpOnly(); + cookie.path = base::IsStringUTF8(canonical_cookie.Path()) + ? canonical_cookie.Path() + : std::string(); + cookie.secure = canonical_cookie.IsSecure(); + cookie.http_only = canonical_cookie.IsHttpOnly(); switch (canonical_cookie.SameSite()) { case net::CookieSameSite::DEFAULT_MODE: - cookie->same_site = api::cookies::SAME_SITE_STATUS_NO_RESTRICTION; + cookie.same_site = api::cookies::SAME_SITE_STATUS_NO_RESTRICTION; break; case net::CookieSameSite::LAX_MODE: - cookie->same_site = api::cookies::SAME_SITE_STATUS_LAX; + cookie.same_site = api::cookies::SAME_SITE_STATUS_LAX; break; case net::CookieSameSite::STRICT_MODE: - cookie->same_site = api::cookies::SAME_SITE_STATUS_STRICT; + cookie.same_site = api::cookies::SAME_SITE_STATUS_STRICT; break; } - cookie->session = !canonical_cookie.IsPersistent(); + cookie.session = !canonical_cookie.IsPersistent(); if (canonical_cookie.IsPersistent()) { - cookie->expiration_date.reset( + cookie.expiration_date.reset( new double(canonical_cookie.ExpiryDate().ToDoubleT())); } - cookie->store_id = store_id; + cookie.store_id = store_id; return cookie; } -scoped_ptr CreateCookieStore(Profile* profile, - base::ListValue* tab_ids) { +CookieStore CreateCookieStore(Profile* profile, base::ListValue* tab_ids) { DCHECK(profile); DCHECK(tab_ids); base::DictionaryValue dict; dict.SetString(keys::kIdKey, GetStoreIdFromProfile(profile)); dict.Set(keys::kTabIdsKey, tab_ids); - CookieStore* cookie_store = new CookieStore(); - bool rv = CookieStore::Populate(dict, cookie_store); + CookieStore cookie_store; + bool rv = CookieStore::Populate(dict, &cookie_store); CHECK(rv); - return scoped_ptr(cookie_store); + return cookie_store; } void GetCookieListFromStore( - net::CookieStore* cookie_store, const GURL& url, + net::CookieStore* cookie_store, + const GURL& url, const net::CookieMonster::GetCookieListCallback& callback) { DCHECK(cookie_store); if (!url.is_empty()) { @@ -145,20 +142,17 @@ void AppendMatchingCookiesToVector(const net::CookieList& all_cookies, const GURL& url, const GetAll::Params::Details* details, const Extension* extension, - LinkedCookieVec* match_vector) { - net::CookieList::const_iterator it; - for (it = all_cookies.begin(); it != all_cookies.end(); ++it) { + std::vector* match_vector) { + for (const net::CanonicalCookie& cookie : all_cookies) { // Ignore any cookie whose domain doesn't match the extension's // host permissions. - GURL cookie_domain_url = GetURLFromCanonicalCookie(*it); + GURL cookie_domain_url = GetURLFromCanonicalCookie(cookie); if (!extension->permissions_data()->HasHostPermission(cookie_domain_url)) continue; // Filter the cookie using the match filter. cookies_helpers::MatchFilter filter(details); - if (filter.MatchesCookie(*it)) { - match_vector->push_back(make_linked_ptr( - CreateCookie(*it, *details->store_id).release())); - } + if (filter.MatchesCookie(cookie)) + match_vector->push_back(CreateCookie(cookie, *details->store_id)); } } diff --git a/chrome/browser/extensions/api/cookies/cookies_helpers.h b/chrome/browser/extensions/api/cookies/cookies_helpers.h index 86dd5d9..0894741 100644 --- a/chrome/browser/extensions/api/cookies/cookies_helpers.h +++ b/chrome/browser/extensions/api/cookies/cookies_helpers.h @@ -13,8 +13,6 @@ #include #include -#include "base/memory/linked_ptr.h" -#include "base/memory/scoped_ptr.h" #include "chrome/common/extensions/api/cookies.h" #include "net/cookies/cookie_monster.h" #include "net/cookies/canonical_cookie.h" @@ -37,9 +35,6 @@ class Extension; namespace cookies_helpers { -typedef std::vector > - LinkedCookieVec; - // Returns either the original profile or the incognito profile, based on the // given store ID. Returns NULL if the profile doesn't exist or is not allowed // (e.g. if incognito mode is not enabled for the extension). @@ -50,23 +45,21 @@ Profile* ChooseProfileFromStoreId(const std::string& store_id, // Returns the store ID for a particular user profile. const char* GetStoreIdFromProfile(Profile* profile); -// Allocates and construct a new Cookie object representing a cookie as defined -// by the cookies API. -scoped_ptr CreateCookie( - const net::CanonicalCookie& cookie, - const std::string& store_id); +// Constructs a new Cookie object representing a cookie as defined by the +// cookies API. +api::cookies::Cookie CreateCookie(const net::CanonicalCookie& cookie, + const std::string& store_id); -// Allocates and constructs a new CookieStore object as defined by the cookies -// API. -scoped_ptr CreateCookieStore( - Profile* profile, - base::ListValue* tab_ids); +// Constructs a new CookieStore object as defined by the cookies API. +api::cookies::CookieStore CreateCookieStore(Profile* profile, + base::ListValue* tab_ids); // Retrieves all cookies from the given cookie store corresponding to the given // URL. If the URL is empty, all cookies in the cookie store are retrieved. // This can only be called on the IO thread. void GetCookieListFromStore( - net::CookieStore* cookie_store, const GURL& url, + net::CookieStore* cookie_store, + const GURL& url, const net::CookieMonster::GetCookieListCallback& callback); // Constructs a URL from a cookie's information for use in checking @@ -80,9 +73,11 @@ GURL GetURLFromCanonicalCookie( // match vector all the cookies that both match the given URL and cookie details // and are allowed by extension host permissions. void AppendMatchingCookiesToVector( - const net::CookieList& all_cookies, const GURL& url, - const extensions::api::cookies::GetAll::Params::Details* details, - const Extension* extension, LinkedCookieVec* match_vector); + const net::CookieList& all_cookies, + const GURL& url, + const api::cookies::GetAll::Params::Details* details, + const Extension* extension, + std::vector* match_vector); // Appends the IDs of all tabs belonging to the given browser to the // given list. @@ -99,8 +94,7 @@ class MatchFilter { // Takes the details dictionary argument given by the user as input. // This class does not take ownership of the lifetime of the Details // object. - explicit MatchFilter( - const extensions::api::cookies::GetAll::Params::Details* details); + explicit MatchFilter(const api::cookies::GetAll::Params::Details* details); // Returns true if the given cookie matches the properties in the match // filter. @@ -116,7 +110,7 @@ class MatchFilter { // 'foo.bar.com', '.foo.bar.com', and 'baz.foo.bar.com'. bool MatchesDomain(const std::string& domain); - const extensions::api::cookies::GetAll::Params::Details* details_; + const api::cookies::GetAll::Params::Details* details_; }; } // namespace cookies_helpers diff --git a/chrome/browser/extensions/api/cookies/cookies_unittest.cc b/chrome/browser/extensions/api/cookies/cookies_unittest.cc index 6ba5e14..6952519 100644 --- a/chrome/browser/extensions/api/cookies/cookies_unittest.cc +++ b/chrome/browser/extensions/api/cookies/cookies_unittest.cc @@ -87,41 +87,39 @@ TEST_F(ExtensionCookiesTest, ExtensionTypeCreation) { GURL(), "ABC", "DEF", "www.foobar.com", "/", base::Time(), base::Time(), base::Time(), false, false, net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT); - scoped_ptr cookie1( - cookies_helpers::CreateCookie( - canonical_cookie1, "some cookie store")); - EXPECT_EQ("ABC", cookie1->name); - EXPECT_EQ("DEF", cookie1->value); - EXPECT_EQ("www.foobar.com", cookie1->domain); - EXPECT_TRUE(cookie1->host_only); - EXPECT_EQ("/", cookie1->path); - EXPECT_FALSE(cookie1->secure); - EXPECT_FALSE(cookie1->http_only); - EXPECT_EQ(api::cookies::SAME_SITE_STATUS_NO_RESTRICTION, cookie1->same_site); - EXPECT_TRUE(cookie1->session); - EXPECT_FALSE(cookie1->expiration_date.get()); - EXPECT_EQ("some cookie store", cookie1->store_id); + Cookie cookie1 = + cookies_helpers::CreateCookie(canonical_cookie1, "some cookie store"); + EXPECT_EQ("ABC", cookie1.name); + EXPECT_EQ("DEF", cookie1.value); + EXPECT_EQ("www.foobar.com", cookie1.domain); + EXPECT_TRUE(cookie1.host_only); + EXPECT_EQ("/", cookie1.path); + EXPECT_FALSE(cookie1.secure); + EXPECT_FALSE(cookie1.http_only); + EXPECT_EQ(api::cookies::SAME_SITE_STATUS_NO_RESTRICTION, cookie1.same_site); + EXPECT_TRUE(cookie1.session); + EXPECT_FALSE(cookie1.expiration_date.get()); + EXPECT_EQ("some cookie store", cookie1.store_id); net::CanonicalCookie canonical_cookie2( GURL(), "ABC", "DEF", ".foobar.com", "/", base::Time(), base::Time::FromDoubleT(10000), base::Time(), false, false, net::CookieSameSite::STRICT_MODE, net::COOKIE_PRIORITY_DEFAULT); - scoped_ptr cookie2( - cookies_helpers::CreateCookie( - canonical_cookie2, "some cookie store")); - EXPECT_FALSE(cookie2->host_only); - EXPECT_FALSE(cookie2->session); - EXPECT_EQ(api::cookies::SAME_SITE_STATUS_STRICT, cookie2->same_site); - ASSERT_TRUE(cookie2->expiration_date.get()); - EXPECT_EQ(10000, *cookie2->expiration_date); + Cookie cookie2 = + cookies_helpers::CreateCookie(canonical_cookie2, "some cookie store"); + EXPECT_FALSE(cookie2.host_only); + EXPECT_FALSE(cookie2.session); + EXPECT_EQ(api::cookies::SAME_SITE_STATUS_STRICT, cookie2.same_site); + ASSERT_TRUE(cookie2.expiration_date.get()); + EXPECT_EQ(10000, *cookie2.expiration_date); TestingProfile profile; base::ListValue* tab_ids_list = new base::ListValue(); std::vector tab_ids; - scoped_ptr cookie_store( - cookies_helpers::CreateCookieStore(&profile, tab_ids_list)); - EXPECT_EQ("0", cookie_store->id); - EXPECT_EQ(tab_ids, cookie_store->tab_ids); + CookieStore cookie_store = + cookies_helpers::CreateCookieStore(&profile, tab_ids_list); + EXPECT_EQ("0", cookie_store.id); + EXPECT_EQ(tab_ids, cookie_store.tab_ids); } TEST_F(ExtensionCookiesTest, GetURLFromCanonicalCookie) { @@ -185,11 +183,12 @@ TEST_F(ExtensionCookiesTest, DecodeUTF8WithErrorHandling) { GURL(), std::string(), "011Q255bNX_1!yd\203e+", "test.com", "/path\203", base::Time(), base::Time(), base::Time(), false, false, net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT); - scoped_ptr cookie( - cookies_helpers::CreateCookie( - canonical_cookie, "some cookie store")); - EXPECT_EQ(std::string("011Q255bNX_1!yd\xEF\xBF\xBD" "e+"), cookie->value); - EXPECT_EQ(std::string(), cookie->path); + Cookie cookie = + cookies_helpers::CreateCookie(canonical_cookie, "some cookie store"); + EXPECT_EQ(std::string("011Q255bNX_1!yd\xEF\xBF\xBD" + "e+"), + cookie.value); + EXPECT_EQ(std::string(), cookie.path); } } // namespace extensions diff --git a/chrome/browser/extensions/api/copresence/copresence_api.cc b/chrome/browser/extensions/api/copresence/copresence_api.cc index e5e6e6d..44bfca7 100644 --- a/chrome/browser/extensions/api/copresence/copresence_api.cc +++ b/chrome/browser/extensions/api/copresence/copresence_api.cc @@ -7,7 +7,6 @@ #include #include "base/lazy_instance.h" -#include "base/memory/linked_ptr.h" #include "chrome/browser/copresence/chrome_whispernet_client.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" @@ -136,16 +135,16 @@ void CopresenceService::HandleMessages( } int message_count = messages.size(); - std::vector> api_messages( - message_count); - - for (int m = 0; m < message_count; ++m) { - api_messages[m].reset(new api::copresence::Message); - api_messages[m]->type = messages[m].type().type(); - api_messages[m]->payload.assign(messages[m].payload().begin(), - messages[m].payload().end()); - DVLOG(2) << "Dispatching message of type " << api_messages[m]->type << ":\n" - << messages[m].payload(); + std::vector api_messages(message_count); + + for (const copresence::Message& message : messages) { + api::copresence::Message api_message; + api_message.type = message.type().type(); + api_message.payload.assign(message.payload().begin(), + message.payload().end()); + api_messages.push_back(std::move(api_message)); + DVLOG(2) << "Dispatching message of type " << api_message.type << ":\n" + << message.payload(); } // Send the messages to the client app. diff --git a/chrome/browser/extensions/api/copresence/copresence_translations.cc b/chrome/browser/extensions/api/copresence/copresence_translations.cc index 779040e..3537e2c 100644 --- a/chrome/browser/extensions/api/copresence/copresence_translations.cc +++ b/chrome/browser/extensions/api/copresence/copresence_translations.cc @@ -197,37 +197,33 @@ bool AddUnsubscribeToRequest(const std::string& app_id, return true; } -bool PrepareReportRequestProto( - const std::vector>& operations, - const std::string& app_id, - SubscriptionToAppMap* apps_by_subscription_id, - ReportRequest* request) { - for (const linked_ptr& op : operations) { - DCHECK(op.get()); - +bool PrepareReportRequestProto(const std::vector& operations, + const std::string& app_id, + SubscriptionToAppMap* apps_by_subscription_id, + ReportRequest* request) { + for (const Operation& op : operations) { // Verify our object has exactly one operation. - if (static_cast(op->publish != nullptr) + - static_cast(op->subscribe != nullptr) + - static_cast(op->unpublish != nullptr) + - static_cast(op->unsubscribe != nullptr) != 1) { + if (static_cast(op.publish != nullptr) + + static_cast(op.subscribe != nullptr) + + static_cast(op.unpublish != nullptr) + + static_cast(op.unsubscribe != nullptr) != + 1) { return false; } - if (op->publish) { - if (!AddPublishToRequest(app_id, *(op->publish), request)) + if (op.publish) { + if (!AddPublishToRequest(app_id, *(op.publish), request)) return false; - } else if (op->subscribe) { - if (!AddSubscribeToRequest( - app_id, *(op->subscribe), apps_by_subscription_id, request)) + } else if (op.subscribe) { + if (!AddSubscribeToRequest(app_id, *(op.subscribe), + apps_by_subscription_id, request)) return false; - } else if (op->unpublish) { - if (!AddUnpublishToRequest(op->unpublish->unpublish_id, request)) + } else if (op.unpublish) { + if (!AddUnpublishToRequest(op.unpublish->unpublish_id, request)) return false; - } else { // if (op->unsubscribe) - if (!AddUnsubscribeToRequest(app_id, - op->unsubscribe->unsubscribe_id, - apps_by_subscription_id, - request)) + } else { // if (op.unsubscribe) + if (!AddUnsubscribeToRequest(app_id, op.unsubscribe->unsubscribe_id, + apps_by_subscription_id, request)) return false; } } diff --git a/chrome/browser/extensions/api/copresence/copresence_translations.h b/chrome/browser/extensions/api/copresence/copresence_translations.h index a0f9fd9..4903c62 100644 --- a/chrome/browser/extensions/api/copresence/copresence_translations.h +++ b/chrome/browser/extensions/api/copresence/copresence_translations.h @@ -10,7 +10,6 @@ #include #include "base/macros.h" -#include "base/memory/linked_ptr.h" #include "components/copresence/proto/enums.pb.h" namespace copresence { @@ -34,7 +33,7 @@ typedef std::map SubscriptionToAppMap; // Returns report request protocol buffer containing all the operations in the // given vector. If parsing any of the operations fails, we return false. bool PrepareReportRequestProto( - const std::vector>& operations, + const std::vector& operations, const std::string& app_id, SubscriptionToAppMap* apps_by_subscription_id, copresence::ReportRequest* request); diff --git a/chrome/browser/extensions/api/copresence_private/copresence_private_api.cc b/chrome/browser/extensions/api/copresence_private/copresence_private_api.cc index 63df1d2..71d33ec 100644 --- a/chrome/browser/extensions/api/copresence_private/copresence_private_api.cc +++ b/chrome/browser/extensions/api/copresence_private/copresence_private_api.cc @@ -103,8 +103,8 @@ ExtensionFunction::ResponseAction CopresencePrivateSendFoundFunction::Run() { std::vector tokens; for (size_t i = 0; i < params->tokens.size(); ++i) { - tokens.push_back(audio_modem::AudioToken(params->tokens[i]->token, - params->tokens[i]->audible)); + tokens.push_back(audio_modem::AudioToken(params->tokens[i].token, + params->tokens[i].audible)); } whispernet_client->GetTokensCallback().Run(tokens); return RespondNow(NoArguments()); diff --git a/chrome/common/extensions/api/browser.idl b/chrome/common/extensions/api/browser.idl index 248fec8..84858dd 100644 --- a/chrome/common/extensions/api/browser.idl +++ b/chrome/common/extensions/api/browser.idl @@ -4,7 +4,7 @@ // Use the chrome.browser API to interact with the Chrome browser // associated with the current application and Chrome profile. -namespace browser { +[use_movable_types=true] namespace browser { // Options for the $(ref:openTab) function. dictionary OpenTabOptions { // The URL to navigate to when the new tab is initially opened. @@ -17,8 +17,8 @@ namespace browser { // Opens a new tab in a browser window associated with the current // application and Chrome profile. If no browser window for the Chrome // profile is opened, a new one is opened prior to creating the new tab. - // |options| - Configures how the tab should be opened. - // |callback| - Called when the tab was successfully created, or failed to + // |options|: Configures how the tab should be opened. + // |callback|: Called when the tab was successfully created, or failed to // be created. If failed, $(ref:runtime.lastError) will be set. static void openTab(OpenTabOptions options, optional Callback callback); diff --git a/chrome/common/extensions/api/browsing_data.json b/chrome/common/extensions/api/browsing_data.json index 10fd0b71..900d330 100644 --- a/chrome/common/extensions/api/browsing_data.json +++ b/chrome/common/extensions/api/browsing_data.json @@ -6,6 +6,7 @@ { "namespace": "browsingData", "description": "Use the chrome.browsingData API to remove browsing data from a user's local profile.", + "compiler_options": {"use_movable_types": true}, "types": [ { "id": "RemovalOptions", diff --git a/chrome/common/extensions/api/cast_devices_private.idl b/chrome/common/extensions/api/cast_devices_private.idl index 2903a58..d6e4f85 100644 --- a/chrome/common/extensions/api/cast_devices_private.idl +++ b/chrome/common/extensions/api/cast_devices_private.idl @@ -5,7 +5,7 @@ // The chrome.cast.devicesPrivate API manages starting and stopping // casts based on receiver names. It also provides a list of available // receivers. -namespace cast.devicesPrivate { +[use_movable_types=true] namespace cast.devicesPrivate { // A cast receiver is an actual cast device. It has a unique |id| and a // non-unique |name| which is how people identify it. dictionary Receiver { diff --git a/chrome/common/extensions/api/cast_streaming_receiver_session.idl b/chrome/common/extensions/api/cast_streaming_receiver_session.idl index 15a7f0a7..6c5f8ca 100644 --- a/chrome/common/extensions/api/cast_streaming_receiver_session.idl +++ b/chrome/common/extensions/api/cast_streaming_receiver_session.idl @@ -5,7 +5,7 @@ // The chrome.cast.streaming.receiverSession API creates a Cast // receiver session and adds the resulting audio and video tracks to a // MediaStream. -namespace cast.streaming.receiverSession { +[use_movable_types=true]namespace cast.streaming.receiverSession { // The UDP socket address and port. dictionary IPEndPoint { DOMString address; diff --git a/chrome/common/extensions/api/cast_streaming_rtp_stream.idl b/chrome/common/extensions/api/cast_streaming_rtp_stream.idl index 8425609..da5d02f 100644 --- a/chrome/common/extensions/api/cast_streaming_rtp_stream.idl +++ b/chrome/common/extensions/api/cast_streaming_rtp_stream.idl @@ -7,7 +7,7 @@ // session. // // Valid stream IDs are positive and non-zero. -namespace cast.streaming.rtpStream { +[use_movable_types=true]namespace cast.streaming.rtpStream { // Params for audio and video codec. dictionary CodecSpecificParams { DOMString key; diff --git a/chrome/common/extensions/api/cast_streaming_session.idl b/chrome/common/extensions/api/cast_streaming_session.idl index 29d43d9..e2ad595 100644 --- a/chrome/common/extensions/api/cast_streaming_session.idl +++ b/chrome/common/extensions/api/cast_streaming_session.idl @@ -11,7 +11,7 @@ // APIs. // // Valid resource IDs are positive and non-zero. -namespace cast.streaming.session { +[use_movable_types=true]namespace cast.streaming.session { // Callback from the create method. // |audioStreamId| : The audio RTP stream ID. // |videoStreamId| : The video RTP stream ID. diff --git a/chrome/common/extensions/api/cast_streaming_udp_transport.idl b/chrome/common/extensions/api/cast_streaming_udp_transport.idl index 8106a58..fd43a61 100644 --- a/chrome/common/extensions/api/cast_streaming_udp_transport.idl +++ b/chrome/common/extensions/api/cast_streaming_udp_transport.idl @@ -8,7 +8,7 @@ // It is used to configure the UDP transport used in Cast session. // // Valid transport IDs are positive and non-zero. -namespace cast.streaming.udpTransport { +[use_movable_types=true]namespace cast.streaming.udpTransport { // The UDP socket address and port. dictionary IPEndPoint { DOMString address; diff --git a/chrome/common/extensions/api/certificate_provider.idl b/chrome/common/extensions/api/certificate_provider.idl index 4062d04..50ec63a 100644 --- a/chrome/common/extensions/api/certificate_provider.idl +++ b/chrome/common/extensions/api/certificate_provider.idl @@ -4,7 +4,7 @@ // Use this API to expose certificates to the platform which can use these // certificates for TLS authentications. -namespace certificateProvider { +[use_movable_types=true]namespace certificateProvider { enum Hash { MD5_SHA1, SHA1, diff --git a/chrome/common/extensions/api/certificate_provider_internal.idl b/chrome/common/extensions/api/certificate_provider_internal.idl index aa179d2..dc2d3aa 100644 --- a/chrome/common/extensions/api/certificate_provider_internal.idl +++ b/chrome/common/extensions/api/certificate_provider_internal.idl @@ -10,7 +10,7 @@ // runs the callback to report its results, the callback magically prepends the // request ID to the results and calls the respective internal report function // (reportSignature or reportCertificates). -[implemented_in = "chrome/browser/extensions/api/certificate_provider/certificate_provider_api.h"] +[implemented_in = "chrome/browser/extensions/api/certificate_provider/certificate_provider_api.h",use_movable_types=true] namespace certificateProviderInternal { callback DoneCallback = void (); callback ResultCallback = void (ArrayBuffer[] rejectedCertificates); diff --git a/chrome/common/extensions/api/chrome_web_view_internal.json b/chrome/common/extensions/api/chrome_web_view_internal.json index 0797d47e..225147f 100644 --- a/chrome/common/extensions/api/chrome_web_view_internal.json +++ b/chrome/common/extensions/api/chrome_web_view_internal.json @@ -7,7 +7,8 @@ "namespace": "chromeWebViewInternal", "description": "none", "compiler_options": { - "implemented_in": "chrome/browser/extensions/api/web_view/chrome_web_view_internal_api.h" + "implemented_in": "chrome/browser/extensions/api/web_view/chrome_web_view_internal_api.h", + "use_movable_types": true }, "dependencies": ["contextMenusInternal", "contextMenus"], "types": [ diff --git a/chrome/common/extensions/api/chromeos_info_private.json b/chrome/common/extensions/api/chromeos_info_private.json index b87c606..8b8c7e1 100644 --- a/chrome/common/extensions/api/chromeos_info_private.json +++ b/chrome/common/extensions/api/chromeos_info_private.json @@ -7,7 +7,8 @@ "namespace": "chromeosInfoPrivate", "description": "none", "compiler_options": { - "implemented_in": "chrome/browser/chromeos/extensions/info_private_api.h" + "implemented_in": "chrome/browser/chromeos/extensions/info_private_api.h", + "use_movable_types": true }, "types": [ { diff --git a/chrome/common/extensions/api/cloud_print_private.json b/chrome/common/extensions/api/cloud_print_private.json index edd3e02..f1fb223 100644 --- a/chrome/common/extensions/api/cloud_print_private.json +++ b/chrome/common/extensions/api/cloud_print_private.json @@ -6,6 +6,7 @@ { "namespace": "cloudPrintPrivate", "description": "none", + "compiler_options": {"use_movable_types": true}, "types": [ { "id": "PrinterSettings", diff --git a/chrome/common/extensions/api/command_line_private.json b/chrome/common/extensions/api/command_line_private.json index 90c052d..9a9d670 100644 --- a/chrome/common/extensions/api/command_line_private.json +++ b/chrome/common/extensions/api/command_line_private.json @@ -6,6 +6,7 @@ { "namespace": "commandLinePrivate", "description": "none", + "compiler_options": {"use_movable_types": true}, "functions": [ { "name": "hasSwitch", diff --git a/chrome/common/extensions/api/commands.json b/chrome/common/extensions/api/commands.json index c02008e..e6d1e23 100644 --- a/chrome/common/extensions/api/commands.json +++ b/chrome/common/extensions/api/commands.json @@ -6,6 +6,7 @@ { "namespace": "commands", "description": "Use the commands API to add keyboard shortcuts that trigger actions in your extension, for example, an action to open the browser action or send a command to the extension.", + "compiler_options": {"use_movable_types": true}, "types": [ { "id": "Command", diff --git a/chrome/common/extensions/api/content_settings.json b/chrome/common/extensions/api/content_settings.json index 455c870..a89f010 100644 --- a/chrome/common/extensions/api/content_settings.json +++ b/chrome/common/extensions/api/content_settings.json @@ -7,7 +7,8 @@ "namespace": "contentSettings", "description": "Use the chrome.contentSettings API to change settings that control whether websites can use features such as cookies, JavaScript, and plugins. More generally speaking, content settings allow you to customize Chrome's behavior on a per-site basis instead of globally.", "compiler_options": { - "generate_type_functions": true + "generate_type_functions": true, + "use_movable_types": true }, "types": [ { diff --git a/chrome/common/extensions/api/context_menus.json b/chrome/common/extensions/api/context_menus.json index 764af5b..53ca171 100644 --- a/chrome/common/extensions/api/context_menus.json +++ b/chrome/common/extensions/api/context_menus.json @@ -6,6 +6,7 @@ { "namespace": "contextMenus", "description": "Use the chrome.contextMenus API to add items to Google Chrome's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.", + "compiler_options": {"use_movable_types": true}, "properties": { "ACTION_MENU_TOP_LEVEL_LIMIT": { "value": 6, diff --git a/chrome/common/extensions/api/context_menus_internal.json b/chrome/common/extensions/api/context_menus_internal.json index 2e879b0..b6d4e56 100644 --- a/chrome/common/extensions/api/context_menus_internal.json +++ b/chrome/common/extensions/api/context_menus_internal.json @@ -6,6 +6,7 @@ { "namespace": "contextMenusInternal", "description": "Use the chrome.contextMenus API to add items to Google Chrome's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.", + "compiler_options": {"use_movable_types": true}, "types": [ { "id": "OnClickData", diff --git a/chrome/common/extensions/api/cookies.json b/chrome/common/extensions/api/cookies.json index 98dd565..0bd4e2d 100644 --- a/chrome/common/extensions/api/cookies.json +++ b/chrome/common/extensions/api/cookies.json @@ -6,6 +6,7 @@ { "namespace": "cookies", "description": "Use the chrome.cookies API to query and modify cookies, and to be notified when they change.", + "compiler_options": {"use_movable_types": true}, "types": [ { "id": "SameSiteStatus", diff --git a/chrome/common/extensions/api/copresence.idl b/chrome/common/extensions/api/copresence.idl index a9c6090..fd87efa 100644 --- a/chrome/common/extensions/api/copresence.idl +++ b/chrome/common/extensions/api/copresence.idl @@ -4,7 +4,7 @@ // Use the chrome.copresence API to communicate with other nearby // devices using Google's copresence service. -namespace copresence { +[use_movable_types=true] namespace copresence { // Suggestions to copresence on how to do the publication and subscription. // Note: These are only suggestions. Actual behavior may not always match // what is requested. diff --git a/chrome/common/extensions/api/copresence_private.idl b/chrome/common/extensions/api/copresence_private.idl index 6db3420..f6b4cb8 100644 --- a/chrome/common/extensions/api/copresence_private.idl +++ b/chrome/common/extensions/api/copresence_private.idl @@ -4,7 +4,7 @@ // Use the chrome.copresencePrivate API to interface with Chrome // from the whispernet_proxy extension. -namespace copresencePrivate { +[use_movable_types=true]namespace copresencePrivate { dictionary Token { DOMString token; boolean audible; diff --git a/chrome/renderer/extensions/cast_streaming_native_handler.cc b/chrome/renderer/extensions/cast_streaming_native_handler.cc index 6695ef4..6b55fdb 100644 --- a/chrome/renderer/extensions/cast_streaming_native_handler.cc +++ b/chrome/renderer/extensions/cast_streaming_native_handler.cc @@ -124,7 +124,7 @@ bool ToCastRtpPayloadParamsOrThrow(v8::Isolate* isolate, } for (size_t i = 0; i < ext_params.codec_specific_params.size(); ++i) { CastCodecSpecificParams cast_codec_params; - ToCastCodecSpecificParams(*ext_params.codec_specific_params[i], + ToCastCodecSpecificParams(ext_params.codec_specific_params[i], &cast_codec_params); cast_params->codec_specific_params.push_back(cast_codec_params); } @@ -151,11 +151,10 @@ void FromCastRtpPayloadParams(const CastRtpPayloadParams& cast_params, if (cast_params.max_frame_rate > 0.0) ext_params->max_frame_rate.reset(new double(cast_params.max_frame_rate)); for (size_t i = 0; i < cast_params.codec_specific_params.size(); ++i) { - linked_ptr ext_codec_params( - new CodecSpecificParams()); + CodecSpecificParams ext_codec_params; FromCastCodecSpecificParams(cast_params.codec_specific_params[i], - ext_codec_params.get()); - ext_params->codec_specific_params.push_back(ext_codec_params); + &ext_codec_params); + ext_params->codec_specific_params.push_back(std::move(ext_codec_params)); } } -- cgit v1.1