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

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

Issue 1120006: detect preferences errors (Closed)
Patch Set: changes from review Created 10 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 bool require_key, 108 bool require_key,
109 std::string* error) { 109 std::string* error) {
110 FilePath manifest_path = 110 FilePath manifest_path =
111 extension_path.Append(Extension::kManifestFilename); 111 extension_path.Append(Extension::kManifestFilename);
112 if (!file_util::PathExists(manifest_path)) { 112 if (!file_util::PathExists(manifest_path)) {
113 *error = extension_manifest_errors::kManifestUnreadable; 113 *error = extension_manifest_errors::kManifestUnreadable;
114 return NULL; 114 return NULL;
115 } 115 }
116 116
117 JSONFileValueSerializer serializer(manifest_path); 117 JSONFileValueSerializer serializer(manifest_path);
118 scoped_ptr<Value> root(serializer.Deserialize(error)); 118 scoped_ptr<Value> root(serializer.Deserialize(NULL, error));
119 if (!root.get()) { 119 if (!root.get()) {
120 if (error->empty()) { 120 if (error->empty()) {
121 // If |error| is empty, than the file could not be read. 121 // If |error| is empty, than the file could not be read.
122 // It would be cleaner to have the JSON reader give a specific error 122 // It would be cleaner to have the JSON reader give a specific error
123 // in this case, but other code tests for a file error with 123 // in this case, but other code tests for a file error with
124 // error->empty(). For now, be consistent. 124 // error->empty(). For now, be consistent.
125 *error = extension_manifest_errors::kManifestUnreadable; 125 *error = extension_manifest_errors::kManifestUnreadable;
126 } else { 126 } else {
127 *error = StringPrintf("%s %s", 127 *error = StringPrintf("%s %s",
128 extension_manifest_errors::kManifestParseError, 128 extension_manifest_errors::kManifestParseError,
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); 509 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS);
510 510
511 #if defined(OS_POSIX) 511 #if defined(OS_POSIX)
512 return FilePath(file_path); 512 return FilePath(file_path);
513 #elif defined(OS_WIN) 513 #elif defined(OS_WIN)
514 return FilePath(UTF8ToWide(file_path)); 514 return FilePath(UTF8ToWide(file_path));
515 #endif 515 #endif
516 } 516 }
517 517
518 } // namespace extension_file_util 518 } // namespace extension_file_util
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/preference_model_associator.cc ('k') | chrome/common/extensions/extension_l10n_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698