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

Side by Side Diff: chrome/browser/dom_ui/fileicon_source.cc

Issue 243076: Move the JPEG and PNG codecs from base/gfx to app/gfx/codec. Move the classes... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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) 2006-2008 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/browser/dom_ui/fileicon_source.h" 5 #include "chrome/browser/dom_ui/fileicon_source.h"
6 6
7 #include "base/gfx/png_encoder.h" 7 #include "app/gfx/codec/png_codec.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/common/time_format.h" 10 #include "chrome/common/time_format.h"
11 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
12 #include "net/base/escape.h" 12 #include "net/base/escape.h"
13 13
14 // The path used in internal URLs to file icon data. 14 // The path used in internal URLs to file icon data.
15 static const char kFileIconPath[] = "fileicon"; 15 static const char kFileIconPath[] = "fileicon";
16 16
17 FileIconSource::FileIconSource() 17 FileIconSource::FileIconSource()
(...skipping 15 matching lines...) Expand all
33 std::replace(escaped_path.begin(), escaped_path.end(), '/', '\\'); 33 std::replace(escaped_path.begin(), escaped_path.end(), '/', '\\');
34 FilePath escaped_filepath(UTF8ToWide(escaped_path)); 34 FilePath escaped_filepath(UTF8ToWide(escaped_path));
35 #elif defined(OS_POSIX) 35 #elif defined(OS_POSIX)
36 // The correct encoding on Linux may not actually be UTF8. 36 // The correct encoding on Linux may not actually be UTF8.
37 FilePath escaped_filepath(escaped_path); 37 FilePath escaped_filepath(escaped_path);
38 #endif 38 #endif
39 SkBitmap* icon = im->LookupIcon(escaped_filepath, IconLoader::NORMAL); 39 SkBitmap* icon = im->LookupIcon(escaped_filepath, IconLoader::NORMAL);
40 40
41 if (icon) { 41 if (icon) {
42 std::vector<unsigned char> png_bytes; 42 std::vector<unsigned char> png_bytes;
43 PNGEncoder::EncodeBGRASkBitmap(*icon, false, &png_bytes); 43 gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &png_bytes);
44 44
45 scoped_refptr<RefCountedBytes> icon_data = new RefCountedBytes(png_bytes); 45 scoped_refptr<RefCountedBytes> icon_data = new RefCountedBytes(png_bytes);
46 SendResponse(request_id, icon_data); 46 SendResponse(request_id, icon_data);
47 } else { 47 } else {
48 // Icon was not in cache, go fetch it slowly. 48 // Icon was not in cache, go fetch it slowly.
49 IconManager::Handle h = im->LoadIcon(escaped_filepath, 49 IconManager::Handle h = im->LoadIcon(escaped_filepath,
50 IconLoader::NORMAL, 50 IconLoader::NORMAL,
51 &cancelable_consumer_, 51 &cancelable_consumer_,
52 NewCallback(this, &FileIconSource::OnFileIconDataAvailable)); 52 NewCallback(this, &FileIconSource::OnFileIconDataAvailable));
53 53
54 // Attach the ChromeURLDataManager request ID to the history request. 54 // Attach the ChromeURLDataManager request ID to the history request.
55 cancelable_consumer_.SetClientData(im, h, request_id); 55 cancelable_consumer_.SetClientData(im, h, request_id);
56 } 56 }
57 } 57 }
58 58
59 void FileIconSource::OnFileIconDataAvailable(IconManager::Handle handle, 59 void FileIconSource::OnFileIconDataAvailable(IconManager::Handle handle,
60 SkBitmap* icon) { 60 SkBitmap* icon) {
61 IconManager* im = g_browser_process->icon_manager(); 61 IconManager* im = g_browser_process->icon_manager();
62 int request_id = cancelable_consumer_.GetClientData(im, handle); 62 int request_id = cancelable_consumer_.GetClientData(im, handle);
63 63
64 if (icon) { 64 if (icon) {
65 std::vector<unsigned char> png_bytes; 65 std::vector<unsigned char> png_bytes;
66 PNGEncoder::EncodeBGRASkBitmap(*icon, false, &png_bytes); 66 gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &png_bytes);
67 67
68 scoped_refptr<RefCountedBytes> icon_data = new RefCountedBytes(png_bytes); 68 scoped_refptr<RefCountedBytes> icon_data = new RefCountedBytes(png_bytes);
69 SendResponse(request_id, icon_data); 69 SendResponse(request_id, icon_data);
70 } else { 70 } else {
71 // TODO(glen): send a dummy icon. 71 // TODO(glen): send a dummy icon.
72 SendResponse(request_id, NULL); 72 SendResponse(request_id, NULL);
73 } 73 }
74 } 74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698