OLD | NEW |
---|---|
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 |
jdoerrie
2017/04/06 14:25:51
#include <utility>
vabr (Chromium)
2017/04/07 20:40:41
Done.
| |
5 #include "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/memory/ptr_util.h" | |
6 #include "build/build_config.h" | 7 #include "build/build_config.h" |
7 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | 8 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
8 #include "chrome/common/extensions/sync_helper.h" | 9 #include "chrome/common/extensions/sync_helper.h" |
9 #include "extensions/common/error_utils.h" | 10 #include "extensions/common/error_utils.h" |
10 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
11 #include "extensions/common/features/simple_feature.h" | 12 #include "extensions/common/features/simple_feature.h" |
12 #include "extensions/common/manifest.h" | 13 #include "extensions/common/manifest.h" |
13 #include "extensions/common/manifest_constants.h" | 14 #include "extensions/common/manifest_constants.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 source.SetString(keys::kUpdateURL, update_url.spec()); | 50 source.SetString(keys::kUpdateURL, update_url.spec()); |
50 } | 51 } |
51 if (!launch_url.is_empty()) { | 52 if (!launch_url.is_empty()) { |
52 source.SetString(keys::kLaunchWebURL, launch_url.spec()); | 53 source.SetString(keys::kLaunchWebURL, launch_url.spec()); |
53 } | 54 } |
54 if (type != THEME) { | 55 if (type != THEME) { |
55 source.SetBoolean(keys::kConvertedFromUserScript, type == USER_SCRIPT); | 56 source.SetBoolean(keys::kConvertedFromUserScript, type == USER_SCRIPT); |
56 if (num_plugins >= 0) { | 57 if (num_plugins >= 0) { |
57 base::ListValue* plugins = new base::ListValue(); | 58 base::ListValue* plugins = new base::ListValue(); |
58 for (int i = 0; i < num_plugins; ++i) { | 59 for (int i = 0; i < num_plugins; ++i) { |
59 base::DictionaryValue* plugin = new base::DictionaryValue(); | 60 auto plugin = base::MakeUnique<base::DictionaryValue>(); |
60 plugin->SetString(keys::kPluginsPath, std::string()); | 61 plugin->SetString(keys::kPluginsPath, std::string()); |
61 plugins->Set(i, plugin); | 62 plugins->Set(i, std::move(plugin)); |
62 } | 63 } |
63 source.Set(keys::kPlugins, plugins); | 64 source.Set(keys::kPlugins, plugins); |
64 } | 65 } |
65 } | 66 } |
66 if (has_plugin_permission) { | 67 if (has_plugin_permission) { |
67 base::ListValue* plugins = new base::ListValue(); | 68 base::ListValue* plugins = new base::ListValue(); |
68 plugins->Set(0, new base::Value("plugin")); | 69 plugins->Set(0, base::MakeUnique<base::Value>("plugin")); |
69 source.Set(keys::kPermissions, plugins); | 70 source.Set(keys::kPermissions, plugins); |
70 } | 71 } |
71 | 72 |
72 std::string error; | 73 std::string error; |
73 scoped_refptr<Extension> extension = Extension::Create( | 74 scoped_refptr<Extension> extension = Extension::Create( |
74 extension_path, location, source, creation_flags, &error); | 75 extension_path, location, source, creation_flags, &error); |
75 if (expected_error.empty()) | 76 if (expected_error.empty()) |
76 EXPECT_TRUE(extension.get()); | 77 EXPECT_TRUE(extension.get()); |
77 else | 78 else |
78 EXPECT_FALSE(extension.get()); | 79 EXPECT_FALSE(extension.get()); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 EXTENSION, GURL(), GURL(), | 309 EXTENSION, GURL(), GURL(), |
309 Manifest::INTERNAL, base::FilePath(), | 310 Manifest::INTERNAL, base::FilePath(), |
310 Extension::NO_FLAGS, 0, true, | 311 Extension::NO_FLAGS, 0, true, |
311 ErrorUtils::FormatErrorMessage( | 312 ErrorUtils::FormatErrorMessage( |
312 errors::kPermissionNotAllowedInManifest, "plugin"))); | 313 errors::kPermissionNotAllowedInManifest, "plugin"))); |
313 } | 314 } |
314 | 315 |
315 #endif // !defined(OS_CHROMEOS) | 316 #endif // !defined(OS_CHROMEOS) |
316 | 317 |
317 } // namespace extensions | 318 } // namespace extensions |
OLD | NEW |