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

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

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | 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/utility/extensions/unpacker.h" 5 #include "chrome/utility/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 39
40 namespace { 40 namespace {
41 41
42 // A limit to stop us passing dangerously large canvases to the browser. 42 // A limit to stop us passing dangerously large canvases to the browser.
43 const int kMaxImageCanvas = 4096 * 4096; 43 const int kMaxImageCanvas = 4096 * 4096;
44 44
45 SkBitmap DecodeImage(const base::FilePath& path) { 45 SkBitmap DecodeImage(const base::FilePath& path) {
46 // Read the file from disk. 46 // Read the file from disk.
47 std::string file_contents; 47 std::string file_contents;
48 if (!base::PathExists(path) || 48 if (!base::PathExists(path) ||
49 !file_util::ReadFileToString(path, &file_contents)) { 49 !base::ReadFileToString(path, &file_contents)) {
50 return SkBitmap(); 50 return SkBitmap();
51 } 51 }
52 52
53 // Decode the image using WebKit's image decoder. 53 // Decode the image using WebKit's image decoder.
54 const unsigned char* data = 54 const unsigned char* data =
55 reinterpret_cast<const unsigned char*>(file_contents.data()); 55 reinterpret_cast<const unsigned char*>(file_contents.data());
56 SkBitmap bitmap = content::DecodeImage(data, 56 SkBitmap bitmap = content::DecodeImage(data,
57 gfx::Size(), 57 gfx::Size(),
58 file_contents.length()); 58 file_contents.length());
59 Sk64 bitmap_size = bitmap.getSize64(); 59 Sk64 bitmap_size = bitmap.getSize64();
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 315
316 void Unpacker::SetError(const std::string &error) { 316 void Unpacker::SetError(const std::string &error) {
317 SetUTF16Error(UTF8ToUTF16(error)); 317 SetUTF16Error(UTF8ToUTF16(error));
318 } 318 }
319 319
320 void Unpacker::SetUTF16Error(const string16 &error) { 320 void Unpacker::SetUTF16Error(const string16 &error) {
321 error_message_ = error; 321 error_message_ = error;
322 } 322 }
323 323
324 } // namespace extensions 324 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/test/webdriver/webdriver_util_unittest.cc ('k') | chrome/utility/importer/bookmark_html_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698