OLD | NEW |
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> | 5 #include <memory> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // 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 |
118 // 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) |
119 // it contain no permissions dictionary. | 119 // it contain no permissions dictionary. |
120 std::string error; | 120 std::string error; |
121 std::unique_ptr<base::DictionaryValue> manifest( | 121 std::unique_ptr<base::DictionaryValue> manifest( |
122 LoadManifest("init_valid_platform_app.json", &error)); | 122 LoadManifest("init_valid_platform_app.json", &error)); |
123 | 123 |
124 std::vector<std::unique_ptr<ManifestData>> manifests; | 124 std::vector<std::unique_ptr<ManifestData>> manifests; |
125 // Create each manifest. | 125 // Create each manifest. |
126 for (const char* api_name : kPlatformAppExperimentalApis) { | 126 for (const char* api_name : kPlatformAppExperimentalApis) { |
127 // DictionaryValue will take ownership of this ListValue. | 127 auto permissions = base::MakeUnique<base::ListValue>(); |
128 base::ListValue *permissions = new base::ListValue(); | |
129 permissions->AppendString("experimental"); | 128 permissions->AppendString("experimental"); |
130 permissions->AppendString(api_name); | 129 permissions->AppendString(api_name); |
131 manifest->Set("permissions", permissions); | 130 manifest->Set("permissions", std::move(permissions)); |
132 manifests.push_back( | 131 manifests.push_back(base::MakeUnique<ManifestData>( |
133 base::MakeUnique<ManifestData>(manifest->CreateDeepCopy(), "")); | 132 base::MakeUnique<base::DictionaryValue>(*manifest), "")); |
134 } | 133 } |
135 // First try to load without any flags. This should warn for every API. | 134 // First try to load without any flags. This should warn for every API. |
136 for (const std::unique_ptr<ManifestData>& manifest : manifests) { | 135 for (const std::unique_ptr<ManifestData>& manifest : manifests) { |
137 LoadAndExpectWarning( | 136 LoadAndExpectWarning( |
138 *manifest, | 137 *manifest, |
139 "'experimental' requires the 'experimental-extension-apis' " | 138 "'experimental' requires the 'experimental-extension-apis' " |
140 "command line switch to be enabled."); | 139 "command line switch to be enabled."); |
141 } | 140 } |
142 | 141 |
143 // Now try again with the experimental flag set. | 142 // Now try again with the experimental flag set. |
144 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 143 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
145 switches::kEnableExperimentalExtensionApis); | 144 switches::kEnableExperimentalExtensionApis); |
146 for (const std::unique_ptr<ManifestData>& manifest : manifests) | 145 for (const std::unique_ptr<ManifestData>& manifest : manifests) |
147 LoadAndExpectSuccess(*manifest); | 146 LoadAndExpectSuccess(*manifest); |
148 } | 147 } |
149 | 148 |
150 } // namespace extensions | 149 } // namespace extensions |
OLD | NEW |