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

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

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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/unpacker.h" 5 #include "chrome/common/extensions/unpacker.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 28 matching lines...) Expand all
39 namespace filenames = extension_filenames; 39 namespace filenames = extension_filenames;
40 40
41 namespace { 41 namespace {
42 42
43 // A limit to stop us passing dangerously large canvases to the browser. 43 // A limit to stop us passing dangerously large canvases to the browser.
44 const int kMaxImageCanvas = 4096 * 4096; 44 const int kMaxImageCanvas = 4096 * 4096;
45 45
46 SkBitmap DecodeImage(const base::FilePath& path) { 46 SkBitmap DecodeImage(const base::FilePath& path) {
47 // Read the file from disk. 47 // Read the file from disk.
48 std::string file_contents; 48 std::string file_contents;
49 if (!file_util::PathExists(path) || 49 if (!base::PathExists(path) ||
50 !file_util::ReadFileToString(path, &file_contents)) { 50 !file_util::ReadFileToString(path, &file_contents)) {
51 return SkBitmap(); 51 return SkBitmap();
52 } 52 }
53 53
54 // Decode the image using WebKit's image decoder. 54 // Decode the image using WebKit's image decoder.
55 const unsigned char* data = 55 const unsigned char* data =
56 reinterpret_cast<const unsigned char*>(file_contents.data()); 56 reinterpret_cast<const unsigned char*>(file_contents.data());
57 SkBitmap bitmap = content::DecodeImage(data, 57 SkBitmap bitmap = content::DecodeImage(data,
58 gfx::Size(), 58 gfx::Size(),
59 file_contents.length()); 59 file_contents.length());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 location_(location), 97 location_(location),
98 creation_flags_(creation_flags) { 98 creation_flags_(creation_flags) {
99 } 99 }
100 100
101 Unpacker::~Unpacker() { 101 Unpacker::~Unpacker() {
102 } 102 }
103 103
104 base::DictionaryValue* Unpacker::ReadManifest() { 104 base::DictionaryValue* Unpacker::ReadManifest() {
105 base::FilePath manifest_path = 105 base::FilePath manifest_path =
106 temp_install_dir_.Append(kManifestFilename); 106 temp_install_dir_.Append(kManifestFilename);
107 if (!file_util::PathExists(manifest_path)) { 107 if (!base::PathExists(manifest_path)) {
108 SetError(errors::kInvalidManifest); 108 SetError(errors::kInvalidManifest);
109 return NULL; 109 return NULL;
110 } 110 }
111 111
112 JSONFileValueSerializer serializer(manifest_path); 112 JSONFileValueSerializer serializer(manifest_path);
113 std::string error; 113 std::string error;
114 scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error)); 114 scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error));
115 if (!root.get()) { 115 if (!root.get()) {
116 SetError(error); 116 SetError(error);
117 return NULL; 117 return NULL;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 339
340 void Unpacker::SetError(const std::string &error) { 340 void Unpacker::SetError(const std::string &error) {
341 SetUTF16Error(UTF8ToUTF16(error)); 341 SetUTF16Error(UTF8ToUTF16(error));
342 } 342 }
343 343
344 void Unpacker::SetUTF16Error(const string16 &error) { 344 void Unpacker::SetUTF16Error(const string16 &error) {
345 error_message_ = error; 345 error_message_ = error;
346 } 346 }
347 347
348 } // namespace extensions 348 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/manifest_url_handler.cc ('k') | chrome/common/extensions/unpacker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698