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

Side by Side Diff: chrome/browser/icon_loader_linux.cc

Issue 8501030: aura: Make the Linux version of IconLoader not require GTK+. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move platform-specific include Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/icon_loader_gtk.cc ('k') | chrome/browser/icon_manager_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/icon_loader.h"
6
7 #include <string>
8
9 #include "base/file_util.h"
10 #include "base/logging.h"
11 #include "base/message_loop.h"
12 #include "base/mime_util.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "webkit/glue/image_decoder.h"
15
16 using std::string;
17
18 void IconLoader::ReadIcon() {
19 int size_pixels = 0;
20 switch (icon_size_) {
21 case IconLoader::SMALL:
22 size_pixels = 16;
23 break;
24 case IconLoader::NORMAL:
25 size_pixels = 32;
26 break;
27 case IconLoader::LARGE:
28 size_pixels = 48;
29 break;
30 default:
31 NOTREACHED();
32 }
33
34 FilePath filename = mime_util::GetMimeIcon(group_, size_pixels);
35 string icon_data;
36 file_util::ReadFileToString(filename, &icon_data);
37
38 webkit_glue::ImageDecoder decoder;
39 scoped_ptr<SkBitmap> bitmap(new SkBitmap());
40 *bitmap = decoder.Decode(
41 reinterpret_cast<const unsigned char*>(icon_data.data()),
42 icon_data.length());
43 if (!bitmap->empty()) {
44 DCHECK_EQ(size_pixels, bitmap->width());
45 DCHECK_EQ(size_pixels, bitmap->height());
46 image_.reset(new gfx::Image(bitmap.release()));
47 } else {
48 LOG(WARNING) << "Unsupported file type or load error: " << filename.value();
49 }
50
51 target_message_loop_->PostTask(
52 FROM_HERE, NewRunnableMethod(this, &IconLoader::NotifyDelegate));
53 }
OLDNEW
« no previous file with comments | « chrome/browser/icon_loader_gtk.cc ('k') | chrome/browser/icon_manager_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698