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

Side by Side Diff: chrome/browser/extensions/extension_messages_apitest.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 class MessageSender : public content::NotificationObserver { 56 class MessageSender : public content::NotificationObserver {
57 public: 57 public:
58 MessageSender() { 58 MessageSender() {
59 registrar_.Add(this, 59 registrar_.Add(this,
60 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, 60 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD,
61 content::NotificationService::AllSources()); 61 content::NotificationService::AllSources());
62 } 62 }
63 63
64 private: 64 private:
65 static scoped_ptr<base::ListValue> BuildEventArguments( 65 static std::unique_ptr<base::ListValue> BuildEventArguments(
66 const bool last_message, 66 const bool last_message,
67 const std::string& data) { 67 const std::string& data) {
68 base::DictionaryValue* event = new base::DictionaryValue(); 68 base::DictionaryValue* event = new base::DictionaryValue();
69 event->SetBoolean("lastMessage", last_message); 69 event->SetBoolean("lastMessage", last_message);
70 event->SetString("data", data); 70 event->SetString("data", data);
71 scoped_ptr<base::ListValue> arguments(new base::ListValue()); 71 std::unique_ptr<base::ListValue> arguments(new base::ListValue());
72 arguments->Append(event); 72 arguments->Append(event);
73 return arguments; 73 return arguments;
74 } 74 }
75 75
76 static scoped_ptr<Event> BuildEvent(scoped_ptr<base::ListValue> event_args, 76 static std::unique_ptr<Event> BuildEvent(
77 Profile* profile, 77 std::unique_ptr<base::ListValue> event_args,
78 GURL event_url) { 78 Profile* profile,
79 scoped_ptr<Event> event(new Event(events::TEST_ON_MESSAGE, "test.onMessage", 79 GURL event_url) {
80 std::move(event_args))); 80 std::unique_ptr<Event> event(new Event(
81 events::TEST_ON_MESSAGE, "test.onMessage", std::move(event_args)));
81 event->restrict_to_browser_context = profile; 82 event->restrict_to_browser_context = profile;
82 event->event_url = event_url; 83 event->event_url = event_url;
83 return event; 84 return event;
84 } 85 }
85 86
86 void Observe(int type, 87 void Observe(int type,
87 const content::NotificationSource& source, 88 const content::NotificationSource& source,
88 const content::NotificationDetails& details) override { 89 const content::NotificationDetails& details) override {
89 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, 90 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD,
90 type); 91 type);
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 class ExternallyConnectableMessagingWithTlsChannelIdTest : 1021 class ExternallyConnectableMessagingWithTlsChannelIdTest :
1021 public ExternallyConnectableMessagingTest { 1022 public ExternallyConnectableMessagingTest {
1022 public: 1023 public:
1023 ExternallyConnectableMessagingWithTlsChannelIdTest() 1024 ExternallyConnectableMessagingWithTlsChannelIdTest()
1024 : tls_channel_id_created_(false, false) { 1025 : tls_channel_id_created_(false, false) {
1025 } 1026 }
1026 1027
1027 std::string CreateTlsChannelId() { 1028 std::string CreateTlsChannelId() {
1028 scoped_refptr<net::URLRequestContextGetter> request_context_getter( 1029 scoped_refptr<net::URLRequestContextGetter> request_context_getter(
1029 profile()->GetRequestContext()); 1030 profile()->GetRequestContext());
1030 scoped_ptr<crypto::ECPrivateKey> channel_id_key; 1031 std::unique_ptr<crypto::ECPrivateKey> channel_id_key;
1031 net::ChannelIDService::Request request; 1032 net::ChannelIDService::Request request;
1032 content::BrowserThread::PostTask( 1033 content::BrowserThread::PostTask(
1033 content::BrowserThread::IO, FROM_HERE, 1034 content::BrowserThread::IO, FROM_HERE,
1034 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest:: 1035 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest::
1035 CreateDomainBoundCertOnIOThread, 1036 CreateDomainBoundCertOnIOThread,
1036 base::Unretained(this), base::Unretained(&channel_id_key), 1037 base::Unretained(this), base::Unretained(&channel_id_key),
1037 base::Unretained(&request), request_context_getter)); 1038 base::Unretained(&request), request_context_getter));
1038 tls_channel_id_created_.Wait(); 1039 tls_channel_id_created_.Wait();
1039 // Create the expected value. 1040 // Create the expected value.
1040 std::vector<uint8_t> spki_vector; 1041 std::vector<uint8_t> spki_vector;
1041 if (!channel_id_key->ExportPublicKey(&spki_vector)) 1042 if (!channel_id_key->ExportPublicKey(&spki_vector))
1042 return std::string(); 1043 return std::string();
1043 base::StringPiece spki(reinterpret_cast<char*>(spki_vector.data()), 1044 base::StringPiece spki(reinterpret_cast<char*>(spki_vector.data()),
1044 spki_vector.size()); 1045 spki_vector.size());
1045 base::DictionaryValue jwk_value; 1046 base::DictionaryValue jwk_value;
1046 net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value); 1047 net::JwkSerializer::ConvertSpkiFromDerToJwk(spki, &jwk_value);
1047 std::string tls_channel_id_value; 1048 std::string tls_channel_id_value;
1048 base::JSONWriter::Write(jwk_value, &tls_channel_id_value); 1049 base::JSONWriter::Write(jwk_value, &tls_channel_id_value);
1049 return tls_channel_id_value; 1050 return tls_channel_id_value;
1050 } 1051 }
1051 1052
1052 private: 1053 private:
1053 void CreateDomainBoundCertOnIOThread( 1054 void CreateDomainBoundCertOnIOThread(
1054 scoped_ptr<crypto::ECPrivateKey>* channel_id_key, 1055 std::unique_ptr<crypto::ECPrivateKey>* channel_id_key,
1055 net::ChannelIDService::Request* request, 1056 net::ChannelIDService::Request* request,
1056 scoped_refptr<net::URLRequestContextGetter> request_context_getter) { 1057 scoped_refptr<net::URLRequestContextGetter> request_context_getter) {
1057 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 1058 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
1058 net::ChannelIDService* channel_id_service = 1059 net::ChannelIDService* channel_id_service =
1059 request_context_getter->GetURLRequestContext()-> 1060 request_context_getter->GetURLRequestContext()->
1060 channel_id_service(); 1061 channel_id_service();
1061 int status = channel_id_service->GetOrCreateChannelID( 1062 int status = channel_id_service->GetOrCreateChannelID(
1062 chromium_org_url().host(), channel_id_key, 1063 chromium_org_url().host(), channel_id_key,
1063 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest:: 1064 base::Bind(&ExternallyConnectableMessagingWithTlsChannelIdTest::
1064 GotDomainBoundCert, 1065 GotDomainBoundCert,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); 1250 ui_test_utils::NavigateToURL(browser(), chromium_org_url());
1250 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, 1251 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR,
1251 CanConnectAndSendMessagesToMainFrame(invalid.get())); 1252 CanConnectAndSendMessagesToMainFrame(invalid.get()));
1252 } 1253 }
1253 1254
1254 #endif // !defined(OS_WIN) - http://crbug.com/350517. 1255 #endif // !defined(OS_WIN) - http://crbug.com/350517.
1255 1256
1256 } // namespace 1257 } // namespace
1257 1258
1258 }; // namespace extensions 1259 }; // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698