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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_messaging_test_util.cc

Issue 2806283002: Revert of Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Created 3 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> 7 #include <memory>
8 #include <utility>
9 8
10 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
11 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
12 #include "base/path_service.h" 11 #include "base/path_service.h"
13 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
14 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
15 #include "base/values.h" 14 #include "base/values.h"
16 #include "build/build_config.h" 15 #include "build/build_config.h"
17 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
18 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 12 matching lines...) Expand all
31 bool user_level) { 30 bool user_level) {
32 std::unique_ptr<base::DictionaryValue> manifest(new base::DictionaryValue()); 31 std::unique_ptr<base::DictionaryValue> manifest(new base::DictionaryValue());
33 manifest->SetString("name", host_name); 32 manifest->SetString("name", host_name);
34 manifest->SetString("description", "Native Messaging Echo Test"); 33 manifest->SetString("description", "Native Messaging Echo Test");
35 manifest->SetString("type", "stdio"); 34 manifest->SetString("type", "stdio");
36 manifest->SetString("path", host_path.AsUTF8Unsafe()); 35 manifest->SetString("path", host_path.AsUTF8Unsafe());
37 36
38 std::unique_ptr<base::ListValue> origins(new base::ListValue()); 37 std::unique_ptr<base::ListValue> origins(new base::ListValue());
39 origins->AppendString(base::StringPrintf( 38 origins->AppendString(base::StringPrintf(
40 "chrome-extension://%s/", ScopedTestNativeMessagingHost::kExtensionId)); 39 "chrome-extension://%s/", ScopedTestNativeMessagingHost::kExtensionId));
41 manifest->Set("allowed_origins", std::move(origins)); 40 manifest->Set("allowed_origins", origins.release());
42 41
43 base::FilePath manifest_path = target_dir.AppendASCII(host_name + ".json"); 42 base::FilePath manifest_path = target_dir.AppendASCII(host_name + ".json");
44 JSONFileValueSerializer serializer(manifest_path); 43 JSONFileValueSerializer serializer(manifest_path);
45 ASSERT_TRUE(serializer.Serialize(*manifest)); 44 ASSERT_TRUE(serializer.Serialize(*manifest));
46 45
47 #if defined(OS_WIN) 46 #if defined(OS_WIN)
48 HKEY root_key = user_level ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; 47 HKEY root_key = user_level ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
49 base::string16 key = L"SOFTWARE\\Google\\Chrome\\NativeMessagingHosts\\" + 48 base::string16 key = L"SOFTWARE\\Google\\Chrome\\NativeMessagingHosts\\" +
50 base::UTF8ToUTF16(host_name); 49 base::UTF8ToUTF16(host_name);
51 base::win::RegKey manifest_key( 50 base::win::RegKey manifest_key(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 temp_dir_.GetPath(), kHostName, host_path, user_level)); 94 temp_dir_.GetPath(), kHostName, host_path, user_level));
96 95
97 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest( 96 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest(
98 temp_dir_.GetPath(), kBinaryMissingHostName, 97 temp_dir_.GetPath(), kBinaryMissingHostName,
99 test_user_data_dir.AppendASCII("missing_nm_binary.exe"), user_level)); 98 test_user_data_dir.AppendASCII("missing_nm_binary.exe"), user_level));
100 } 99 }
101 100
102 ScopedTestNativeMessagingHost::~ScopedTestNativeMessagingHost() {} 101 ScopedTestNativeMessagingHost::~ScopedTestNativeMessagingHost() {}
103 102
104 } // namespace extensions 103 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698