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

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

Issue 8538008: Linux: Move base/mime_util* to base/nix. It's not used on any other platform. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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.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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/icon_loader.h" 5 #include "chrome/browser/icon_loader.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/mime_util.h" 12 #include "base/nix/mime_util_xdg.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "webkit/glue/image_decoder.h" 14 #include "webkit/glue/image_decoder.h"
15 15
16 using std::string; 16 using std::string;
17 17
18 void IconLoader::ReadIcon() { 18 void IconLoader::ReadIcon() {
19 int size_pixels = 0; 19 int size_pixels = 0;
20 switch (icon_size_) { 20 switch (icon_size_) {
21 case IconLoader::SMALL: 21 case IconLoader::SMALL:
22 size_pixels = 16; 22 size_pixels = 16;
23 break; 23 break;
24 case IconLoader::NORMAL: 24 case IconLoader::NORMAL:
25 size_pixels = 32; 25 size_pixels = 32;
26 break; 26 break;
27 case IconLoader::LARGE: 27 case IconLoader::LARGE:
28 size_pixels = 48; 28 size_pixels = 48;
29 break; 29 break;
30 default: 30 default:
31 NOTREACHED(); 31 NOTREACHED();
32 } 32 }
33 33
34 FilePath filename = mime_util::GetMimeIcon(group_, size_pixels); 34 FilePath filename = base::nix::GetMimeIcon(group_, size_pixels);
35 string icon_data; 35 string icon_data;
36 file_util::ReadFileToString(filename, &icon_data); 36 file_util::ReadFileToString(filename, &icon_data);
37 37
38 webkit_glue::ImageDecoder decoder; 38 webkit_glue::ImageDecoder decoder;
39 scoped_ptr<SkBitmap> bitmap(new SkBitmap()); 39 scoped_ptr<SkBitmap> bitmap(new SkBitmap());
40 *bitmap = decoder.Decode( 40 *bitmap = decoder.Decode(
41 reinterpret_cast<const unsigned char*>(icon_data.data()), 41 reinterpret_cast<const unsigned char*>(icon_data.data()),
42 icon_data.length()); 42 icon_data.length());
43 if (!bitmap->empty()) { 43 if (!bitmap->empty()) {
44 DCHECK_EQ(size_pixels, bitmap->width()); 44 DCHECK_EQ(size_pixels, bitmap->width());
45 DCHECK_EQ(size_pixels, bitmap->height()); 45 DCHECK_EQ(size_pixels, bitmap->height());
46 image_.reset(new gfx::Image(bitmap.release())); 46 image_.reset(new gfx::Image(bitmap.release()));
47 } else { 47 } else {
48 LOG(WARNING) << "Unsupported file type or load error: " << filename.value(); 48 LOG(WARNING) << "Unsupported file type or load error: " << filename.value();
49 } 49 }
50 50
51 target_message_loop_->PostTask( 51 target_message_loop_->PostTask(
52 FROM_HERE, NewRunnableMethod(this, &IconLoader::NotifyDelegate)); 52 FROM_HERE, NewRunnableMethod(this, &IconLoader::NotifyDelegate));
53 } 53 }
OLDNEW
« no previous file with comments | « chrome/browser/icon_loader.cc ('k') | chrome/browser/icon_manager_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698