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

Side by Side Diff: chrome/browser/extensions/api/certificate_provider/certificate_provider_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <openssl/evp.h> 5 #include <openssl/evp.h>
6 #include <openssl/rsa.h> 6 #include <openssl/rsa.h>
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
11 #include <memory>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/bind.h" 15 #include "base/bind.h"
15 #include "base/callback.h" 16 #include "base/callback.h"
16 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
17 #include "base/files/file_util.h" 18 #include "base/files/file_util.h"
18 #include "base/memory/scoped_ptr.h"
19 #include "base/run_loop.h" 19 #include "base/run_loop.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/values.h" 22 #include "base/values.h"
23 #include "chrome/browser/extensions/extension_apitest.h" 23 #include "chrome/browser/extensions/extension_apitest.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/test/base/ui_test_utils.h" 25 #include "chrome/test/base/ui_test_utils.h"
26 #include "components/policy/core/browser/browser_policy_connector.h" 26 #include "components/policy/core/browser/browser_policy_connector.h"
27 #include "components/policy/core/common/mock_configuration_policy_provider.h" 27 #include "components/policy/core/common/mock_configuration_policy_provider.h"
28 #include "components/policy/core/common/policy_map.h" 28 #include "components/policy/core/common/policy_map.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); 134 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
135 } 135 }
136 136
137 void SetUpOnMainThread() override { 137 void SetUpOnMainThread() override {
138 // Set up the AutoSelectCertificateForUrls policy to avoid the client 138 // Set up the AutoSelectCertificateForUrls policy to avoid the client
139 // certificate selection dialog. 139 // certificate selection dialog.
140 const std::string autoselect_pattern = 140 const std::string autoselect_pattern =
141 "{\"pattern\": \"*\", \"filter\": {\"ISSUER\": {\"CN\": \"root\"}}}"; 141 "{\"pattern\": \"*\", \"filter\": {\"ISSUER\": {\"CN\": \"root\"}}}";
142 142
143 scoped_ptr<base::ListValue> autoselect_policy(new base::ListValue); 143 std::unique_ptr<base::ListValue> autoselect_policy(new base::ListValue);
144 autoselect_policy->AppendString(autoselect_pattern); 144 autoselect_policy->AppendString(autoselect_pattern);
145 145
146 policy::PolicyMap policy; 146 policy::PolicyMap policy;
147 policy.Set(policy::key::kAutoSelectCertificateForUrls, 147 policy.Set(policy::key::kAutoSelectCertificateForUrls,
148 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, 148 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
149 policy::POLICY_SOURCE_CLOUD, autoselect_policy.release(), 149 policy::POLICY_SOURCE_CLOUD, autoselect_policy.release(),
150 nullptr); 150 nullptr);
151 provider_.UpdateChromePolicy(policy); 151 provider_.UpdateChromePolicy(policy);
152 152
153 content::RunAllPendingInMessageLoop(); 153 content::RunAllPendingInMessageLoop();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 base::Bind(&StoreDigest, &request_digest, run_loop.QuitClosure())); 206 base::Bind(&StoreDigest, &request_digest, run_loop.QuitClosure()));
207 run_loop.Run(); 207 run_loop.Run();
208 } 208 }
209 209
210 VLOG(1) << "Sign the digest using the private key."; 210 VLOG(1) << "Sign the digest using the private key.";
211 std::string key_pk8; 211 std::string key_pk8;
212 base::ReadFileToString(extension_path.AppendASCII("l1_leaf.pk8"), &key_pk8); 212 base::ReadFileToString(extension_path.AppendASCII("l1_leaf.pk8"), &key_pk8);
213 213
214 const uint8_t* const key_pk8_begin = 214 const uint8_t* const key_pk8_begin =
215 reinterpret_cast<const uint8_t*>(key_pk8.data()); 215 reinterpret_cast<const uint8_t*>(key_pk8.data());
216 scoped_ptr<crypto::RSAPrivateKey> key( 216 std::unique_ptr<crypto::RSAPrivateKey> key(
217 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo( 217 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(
218 std::vector<uint8_t>(key_pk8_begin, key_pk8_begin + key_pk8.size()))); 218 std::vector<uint8_t>(key_pk8_begin, key_pk8_begin + key_pk8.size())));
219 ASSERT_TRUE(key); 219 ASSERT_TRUE(key);
220 220
221 std::vector<uint8_t> signature; 221 std::vector<uint8_t> signature;
222 EXPECT_TRUE(RsaSign(request_digest, key.get(), &signature)); 222 EXPECT_TRUE(RsaSign(request_digest, key.get(), &signature));
223 223
224 VLOG(1) << "Inject the signature back to the extension and let it reply."; 224 VLOG(1) << "Inject the signature back to the extension and let it reply.";
225 { 225 {
226 base::RunLoop run_loop; 226 base::RunLoop run_loop;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 base::RunLoop run_loop; 260 base::RunLoop run_loop;
261 const std::string code = "replyWithSignatureSecondTime();"; 261 const std::string code = "replyWithSignatureSecondTime();";
262 bool result = false; 262 bool result = false;
263 extension_contents->GetMainFrame()->ExecuteJavaScriptForTests( 263 extension_contents->GetMainFrame()->ExecuteJavaScriptForTests(
264 base::ASCIIToUTF16(code), 264 base::ASCIIToUTF16(code),
265 base::Bind(&StoreBool, &result, run_loop.QuitClosure())); 265 base::Bind(&StoreBool, &result, run_loop.QuitClosure()));
266 run_loop.Run(); 266 run_loop.Run();
267 EXPECT_TRUE(result); 267 EXPECT_TRUE(result);
268 } 268 }
269 } 269 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698