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

Side by Side Diff: chrome/common/extensions/extension_file_util.cc

Issue 10536084: Add a warning when developing an extension that uses old manifest version. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blonk Created 8 years, 6 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 | Annotate | Revision Log
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 "chrome/common/extensions/extension_file_util.h" 5 #include "chrome/common/extensions/extension_file_util.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 scoped_refptr<Extension> extension(Extension::Create(extension_path, 146 scoped_refptr<Extension> extension(Extension::Create(extension_path,
147 location, 147 location,
148 *manifest, 148 *manifest,
149 flags, 149 flags,
150 extension_id, 150 extension_id,
151 error)); 151 error));
152 if (!extension.get()) 152 if (!extension.get())
153 return NULL; 153 return NULL;
154 154
155 std::vector<std::string> warnings; 155 Extension::InstallWarningVector warnings;
156 if (!ValidateExtension(extension.get(), error, &warnings)) 156 if (!ValidateExtension(extension.get(), error, &warnings))
157 return NULL; 157 return NULL;
158 extension->AddInstallWarnings(warnings); 158 extension->AddInstallWarnings(warnings);
159 159
160 return extension; 160 return extension;
161 } 161 }
162 162
163 DictionaryValue* LoadManifest(const FilePath& extension_path, 163 DictionaryValue* LoadManifest(const FilePath& extension_path,
164 std::string* error) { 164 std::string* error) {
165 FilePath manifest_path = 165 FilePath manifest_path =
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // that aren't available in the utility process where this check 223 // that aren't available in the utility process where this check
224 // needs to run. 224 // needs to run.
225 225
226 result.push_back(current); 226 result.push_back(current);
227 } 227 }
228 return result; 228 return result;
229 } 229 }
230 230
231 bool ValidateExtension(const Extension* extension, 231 bool ValidateExtension(const Extension* extension,
232 std::string* error, 232 std::string* error,
233 std::vector<std::string>* warnings) { 233 Extension::InstallWarningVector* warnings) {
234 // Validate icons exist. 234 // Validate icons exist.
235 for (ExtensionIconSet::IconMap::const_iterator iter = 235 for (ExtensionIconSet::IconMap::const_iterator iter =
236 extension->icons().map().begin(); 236 extension->icons().map().begin();
237 iter != extension->icons().map().end(); 237 iter != extension->icons().map().end();
238 ++iter) { 238 ++iter) {
239 const FilePath path = extension->GetResource(iter->second).GetFilePath(); 239 const FilePath path = extension->GetResource(iter->second).GetFilePath();
240 if (!file_util::PathExists(path)) { 240 if (!file_util::PathExists(path)) {
241 *error = 241 *error =
242 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_ICON_FAILED, 242 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_ICON_FAILED,
243 UTF8ToUTF16(iter->second)); 243 UTF8ToUTF16(iter->second));
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if (!private_keys.empty()) { 411 if (!private_keys.empty()) {
412 // Only print one of the private keys because l10n_util doesn't have a way 412 // Only print one of the private keys because l10n_util doesn't have a way
413 // to translate a list of strings. 413 // to translate a list of strings.
414 *error = l10n_util::GetStringFUTF8( 414 *error = l10n_util::GetStringFUTF8(
415 IDS_EXTENSION_CONTAINS_PRIVATE_KEY, 415 IDS_EXTENSION_CONTAINS_PRIVATE_KEY,
416 private_keys.front().LossyDisplayName()); 416 private_keys.front().LossyDisplayName());
417 return false; 417 return false;
418 } 418 }
419 } else { 419 } else {
420 for (size_t i = 0; i < private_keys.size(); ++i) { 420 for (size_t i = 0; i < private_keys.size(); ++i) {
421 warnings->push_back(l10n_util::GetStringFUTF8( 421 warnings->push_back(Extension::InstallWarning(
422 IDS_EXTENSION_CONTAINS_PRIVATE_KEY, 422 Extension::InstallWarning::FORMAT_TEXT,
423 private_keys[i].LossyDisplayName())); 423 l10n_util::GetStringFUTF8(
424 IDS_EXTENSION_CONTAINS_PRIVATE_KEY,
425 private_keys[i].LossyDisplayName())));
424 } 426 }
425 // Only warn; don't block loading the extension. 427 // Only warn; don't block loading the extension.
426 } 428 }
427 return true; 429 return true;
428 } 430 }
429 431
430 void GarbageCollectExtensions( 432 void GarbageCollectExtensions(
431 const FilePath& install_directory, 433 const FilePath& install_directory,
432 const std::map<std::string, FilePath>& extension_paths) { 434 const std::map<std::string, FilePath>& extension_paths) {
433 // Nothing to clean up if it doesn't exist. 435 // Nothing to clean up if it doesn't exist.
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 return temp_path; 782 return temp_path;
781 783
782 return FilePath(); 784 return FilePath();
783 } 785 }
784 786
785 void DeleteFile(const FilePath& path, bool recursive) { 787 void DeleteFile(const FilePath& path, bool recursive) {
786 file_util::Delete(path, recursive); 788 file_util::Delete(path, recursive);
787 } 789 }
788 790
789 } // namespace extension_file_util 791 } // namespace extension_file_util
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_file_util.h ('k') | chrome/common/extensions/extension_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698