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

Side by Side Diff: chrome/common/extensions/api/plugins/plugins_handler.cc

Issue 23744004: Move the rest of extension_manifest_constants to top-level extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 7 years, 3 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/common/extensions/api/plugins/plugins_handler.h" 5 #include "chrome/common/extensions/api/plugins/plugins_handler.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/common/extensions/extension_manifest_constants.h"
12 #include "chrome/common/extensions/permissions/api_permission.h" 11 #include "chrome/common/extensions/permissions/api_permission.h"
13 #include "chrome/common/extensions/permissions/api_permission_set.h" 12 #include "chrome/common/extensions/permissions/api_permission_set.h"
14 #include "chrome/common/extensions/permissions/permissions_data.h" 13 #include "chrome/common/extensions/permissions/permissions_data.h"
15 #include "extensions/common/error_utils.h" 14 #include "extensions/common/error_utils.h"
16 #include "extensions/common/manifest.h" 15 #include "extensions/common/manifest.h"
16 #include "extensions/common/manifest_constants.h"
17 #include "grit/generated_resources.h" 17 #include "grit/generated_resources.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 19
20 #if defined(OS_WIN) 20 #if defined(OS_WIN)
21 #include "base/win/metro.h" 21 #include "base/win/metro.h"
22 #endif 22 #endif
23 23
24 namespace extensions { 24 namespace extensions {
25 25
26 namespace keys = manifest_keys; 26 namespace keys = manifest_keys;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 PluginsHandler::~PluginsHandler() { 62 PluginsHandler::~PluginsHandler() {
63 } 63 }
64 64
65 const std::vector<std::string> PluginsHandler::Keys() const { 65 const std::vector<std::string> PluginsHandler::Keys() const {
66 return SingleKey(keys::kPlugins); 66 return SingleKey(keys::kPlugins);
67 } 67 }
68 68
69 bool PluginsHandler::Parse(Extension* extension, string16* error) { 69 bool PluginsHandler::Parse(Extension* extension, string16* error) {
70 const base::ListValue* list_value = NULL; 70 const base::ListValue* list_value = NULL;
71 if (!extension->manifest()->GetList(keys::kPlugins, &list_value)) { 71 if (!extension->manifest()->GetList(keys::kPlugins, &list_value)) {
72 *error = ASCIIToUTF16(extension_manifest_errors::kInvalidPlugins); 72 *error = ASCIIToUTF16(manifest_errors::kInvalidPlugins);
73 return false; 73 return false;
74 } 74 }
75 75
76 scoped_ptr<PluginManifestData> plugins_data(new PluginManifestData); 76 scoped_ptr<PluginManifestData> plugins_data(new PluginManifestData);
77 77
78 for (size_t i = 0; i < list_value->GetSize(); ++i) { 78 for (size_t i = 0; i < list_value->GetSize(); ++i) {
79 const base::DictionaryValue* plugin_value = NULL; 79 const base::DictionaryValue* plugin_value = NULL;
80 if (!list_value->GetDictionary(i, &plugin_value)) { 80 if (!list_value->GetDictionary(i, &plugin_value)) {
81 *error = ASCIIToUTF16(extension_manifest_errors::kInvalidPlugins); 81 *error = ASCIIToUTF16(manifest_errors::kInvalidPlugins);
82 return false; 82 return false;
83 } 83 }
84 // Get plugins[i].path. 84 // Get plugins[i].path.
85 std::string path_str; 85 std::string path_str;
86 if (!plugin_value->GetString(keys::kPluginsPath, &path_str)) { 86 if (!plugin_value->GetString(keys::kPluginsPath, &path_str)) {
87 *error = ErrorUtils::FormatErrorMessageUTF16( 87 *error = ErrorUtils::FormatErrorMessageUTF16(
88 extension_manifest_errors::kInvalidPluginsPath, base::IntToString(i)); 88 manifest_errors::kInvalidPluginsPath, base::IntToString(i));
89 return false; 89 return false;
90 } 90 }
91 91
92 // Get plugins[i].content (optional). 92 // Get plugins[i].content (optional).
93 bool is_public = false; 93 bool is_public = false;
94 if (plugin_value->HasKey(keys::kPluginsPublic)) { 94 if (plugin_value->HasKey(keys::kPluginsPublic)) {
95 if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) { 95 if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) {
96 *error = ErrorUtils::FormatErrorMessageUTF16( 96 *error = ErrorUtils::FormatErrorMessageUTF16(
97 extension_manifest_errors::kInvalidPluginsPublic, 97 manifest_errors::kInvalidPluginsPublic,
98 base::IntToString(i)); 98 base::IntToString(i));
99 return false; 99 return false;
100 } 100 }
101 } 101 }
102 102
103 // We don't allow extensions to load NPAPI plugins on Chrome OS, or under 103 // We don't allow extensions to load NPAPI plugins on Chrome OS, or under
104 // Windows 8 Metro mode, but still parse the entries to display consistent 104 // Windows 8 Metro mode, but still parse the entries to display consistent
105 // error messages. If the extension actually requires the plugins then 105 // error messages. If the extension actually requires the plugins then
106 // LoadRequirements will prevent it loading. 106 // LoadRequirements will prevent it loading.
107 #if defined(OS_CHROMEOS) 107 #if defined(OS_CHROMEOS)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 IDS_EXTENSION_LOAD_PLUGIN_PATH_FAILED, 141 IDS_EXTENSION_LOAD_PLUGIN_PATH_FAILED,
142 plugin->path.LossyDisplayName()); 142 plugin->path.LossyDisplayName());
143 return false; 143 return false;
144 } 144 }
145 } 145 }
146 } 146 }
147 return true; 147 return true;
148 } 148 }
149 149
150 } // namespace extensions 150 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698