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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_messaging_test_util.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/extensions/api/messaging/native_messaging_test_util.h" 5 #include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h"
6 6
7 #include <memory>
8
7 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
8 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/path_service.h" 11 #include "base/path_service.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "build/build_config.h" 15 #include "build/build_config.h"
15 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 #if defined(OS_WIN) 19 #if defined(OS_WIN)
19 #include "base/win/registry.h" 20 #include "base/win/registry.h"
20 #endif 21 #endif
21 22
22 namespace extensions { 23 namespace extensions {
23 24
24 namespace { 25 namespace {
25 26
26 void WriteTestNativeHostManifest(const base::FilePath& target_dir, 27 void WriteTestNativeHostManifest(const base::FilePath& target_dir,
27 const std::string& host_name, 28 const std::string& host_name,
28 const base::FilePath& host_path, 29 const base::FilePath& host_path,
29 bool user_level) { 30 bool user_level) {
30 scoped_ptr<base::DictionaryValue> manifest(new base::DictionaryValue()); 31 std::unique_ptr<base::DictionaryValue> manifest(new base::DictionaryValue());
31 manifest->SetString("name", host_name); 32 manifest->SetString("name", host_name);
32 manifest->SetString("description", "Native Messaging Echo Test"); 33 manifest->SetString("description", "Native Messaging Echo Test");
33 manifest->SetString("type", "stdio"); 34 manifest->SetString("type", "stdio");
34 manifest->SetString("path", host_path.AsUTF8Unsafe()); 35 manifest->SetString("path", host_path.AsUTF8Unsafe());
35 36
36 scoped_ptr<base::ListValue> origins(new base::ListValue()); 37 std::unique_ptr<base::ListValue> origins(new base::ListValue());
37 origins->AppendString(base::StringPrintf( 38 origins->AppendString(base::StringPrintf(
38 "chrome-extension://%s/", ScopedTestNativeMessagingHost::kExtensionId)); 39 "chrome-extension://%s/", ScopedTestNativeMessagingHost::kExtensionId));
39 manifest->Set("allowed_origins", origins.release()); 40 manifest->Set("allowed_origins", origins.release());
40 41
41 base::FilePath manifest_path = target_dir.AppendASCII(host_name + ".json"); 42 base::FilePath manifest_path = target_dir.AppendASCII(host_name + ".json");
42 JSONFileValueSerializer serializer(manifest_path); 43 JSONFileValueSerializer serializer(manifest_path);
43 ASSERT_TRUE(serializer.Serialize(*manifest)); 44 ASSERT_TRUE(serializer.Serialize(*manifest));
44 45
45 #if defined(OS_WIN) 46 #if defined(OS_WIN)
46 HKEY root_key = user_level ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; 47 HKEY root_key = user_level ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 temp_dir_.path(), kHostName, host_path, user_level)); 94 temp_dir_.path(), kHostName, host_path, user_level));
94 95
95 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest( 96 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest(
96 temp_dir_.path(), kBinaryMissingHostName, 97 temp_dir_.path(), kBinaryMissingHostName,
97 test_user_data_dir.AppendASCII("missing_nm_binary.exe"), user_level)); 98 test_user_data_dir.AppendASCII("missing_nm_binary.exe"), user_level));
98 } 99 }
99 100
100 ScopedTestNativeMessagingHost::~ScopedTestNativeMessagingHost() {} 101 ScopedTestNativeMessagingHost::~ScopedTestNativeMessagingHost() {}
101 102
102 } // namespace extensions 103 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698