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

Side by Side Diff: chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc

Issue 1880143002: Convert chrome/common to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . 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 <memory>
6
5 #include "base/command_line.h" 7 #include "base/command_line.h"
6 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
7 #include "base/macros.h" 9 #include "base/macros.h"
8 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
11 #include "base/memory/ptr_util.h"
9 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" 12 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
10 #include "extensions/common/error_utils.h" 13 #include "extensions/common/error_utils.h"
11 #include "extensions/common/features/simple_feature.h" 14 #include "extensions/common/features/simple_feature.h"
12 #include "extensions/common/manifest_constants.h" 15 #include "extensions/common/manifest_constants.h"
13 #include "extensions/common/manifest_handlers/app_isolation_info.h" 16 #include "extensions/common/manifest_handlers/app_isolation_info.h"
14 #include "extensions/common/manifest_handlers/csp_info.h" 17 #include "extensions/common/manifest_handlers/csp_info.h"
15 #include "extensions/common/manifest_handlers/incognito_info.h" 18 #include "extensions/common/manifest_handlers/incognito_info.h"
16 #include "extensions/common/switches.h" 19 #include "extensions/common/switches.h"
17 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
18 21
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 "dns", 111 "dns",
109 "serial", 112 "serial",
110 }; 113 };
111 // TODO(miket): When the first platform-app API leaves experimental, write 114 // TODO(miket): When the first platform-app API leaves experimental, write
112 // similar code that tests without the experimental flag. 115 // similar code that tests without the experimental flag.
113 116
114 // This manifest is a skeleton used to build more specific manifests for 117 // This manifest is a skeleton used to build more specific manifests for
115 // testing. The requirements are that (1) it be a valid platform app, and (2) 118 // testing. The requirements are that (1) it be a valid platform app, and (2)
116 // it contain no permissions dictionary. 119 // it contain no permissions dictionary.
117 std::string error; 120 std::string error;
118 scoped_ptr<base::DictionaryValue> manifest( 121 std::unique_ptr<base::DictionaryValue> manifest(
119 LoadManifest("init_valid_platform_app.json", &error)); 122 LoadManifest("init_valid_platform_app.json", &error));
120 123
121 std::vector<scoped_ptr<ManifestData>> manifests; 124 std::vector<std::unique_ptr<ManifestData>> manifests;
122 // Create each manifest. 125 // Create each manifest.
123 for (const char* api_name : kPlatformAppExperimentalApis) { 126 for (const char* api_name : kPlatformAppExperimentalApis) {
124 // DictionaryValue will take ownership of this ListValue. 127 // DictionaryValue will take ownership of this ListValue.
125 base::ListValue *permissions = new base::ListValue(); 128 base::ListValue *permissions = new base::ListValue();
126 permissions->Append(new base::StringValue("experimental")); 129 permissions->Append(new base::StringValue("experimental"));
127 permissions->Append(new base::StringValue(api_name)); 130 permissions->Append(new base::StringValue(api_name));
128 manifest->Set("permissions", permissions); 131 manifest->Set("permissions", permissions);
129 manifests.push_back( 132 manifests.push_back(
130 make_scoped_ptr(new ManifestData(manifest->CreateDeepCopy(), ""))); 133 base::WrapUnique(new ManifestData(manifest->CreateDeepCopy(), "")));
131 } 134 }
132 // First try to load without any flags. This should warn for every API. 135 // First try to load without any flags. This should warn for every API.
133 for (const scoped_ptr<ManifestData>& manifest : manifests) { 136 for (const std::unique_ptr<ManifestData>& manifest : manifests) {
134 LoadAndExpectWarning( 137 LoadAndExpectWarning(
135 *manifest, 138 *manifest,
136 "'experimental' requires the 'experimental-extension-apis' " 139 "'experimental' requires the 'experimental-extension-apis' "
137 "command line switch to be enabled."); 140 "command line switch to be enabled.");
138 } 141 }
139 142
140 // Now try again with the experimental flag set. 143 // Now try again with the experimental flag set.
141 base::CommandLine::ForCurrentProcess()->AppendSwitch( 144 base::CommandLine::ForCurrentProcess()->AppendSwitch(
142 switches::kEnableExperimentalExtensionApis); 145 switches::kEnableExperimentalExtensionApis);
143 for (const scoped_ptr<ManifestData>& manifest : manifests) 146 for (const std::unique_ptr<ManifestData>& manifest : manifests)
144 LoadAndExpectSuccess(*manifest); 147 LoadAndExpectSuccess(*manifest);
145 } 148 }
146 149
147 } // namespace extensions 150 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698