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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/icon_loader_gtk.cc ('k') | chrome/browser/icon_manager_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/icon_loader_linux.cc
diff --git a/chrome/browser/icon_loader_linux.cc b/chrome/browser/icon_loader_linux.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0bb68795b31a0f448cf0f0bc1106abe4c4edb06a
--- /dev/null
+++ b/chrome/browser/icon_loader_linux.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/icon_loader.h"
+
+#include <string>
+
+#include "base/file_util.h"
+#include "base/logging.h"
+#include "base/message_loop.h"
+#include "base/mime_util.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "webkit/glue/image_decoder.h"
+
+using std::string;
+
+void IconLoader::ReadIcon() {
+ int size_pixels = 0;
+ switch (icon_size_) {
+ case IconLoader::SMALL:
+ size_pixels = 16;
+ break;
+ case IconLoader::NORMAL:
+ size_pixels = 32;
+ break;
+ case IconLoader::LARGE:
+ size_pixels = 48;
+ break;
+ default:
+ NOTREACHED();
+ }
+
+ FilePath filename = mime_util::GetMimeIcon(group_, size_pixels);
+ string icon_data;
+ file_util::ReadFileToString(filename, &icon_data);
+
+ webkit_glue::ImageDecoder decoder;
+ scoped_ptr<SkBitmap> bitmap(new SkBitmap());
+ *bitmap = decoder.Decode(
+ reinterpret_cast<const unsigned char*>(icon_data.data()),
+ icon_data.length());
+ if (!bitmap->empty()) {
+ DCHECK_EQ(size_pixels, bitmap->width());
+ DCHECK_EQ(size_pixels, bitmap->height());
+ image_.reset(new gfx::Image(bitmap.release()));
+ } else {
+ LOG(WARNING) << "Unsupported file type or load error: " << filename.value();
+ }
+
+ target_message_loop_->PostTask(
+ FROM_HERE, NewRunnableMethod(this, &IconLoader::NotifyDelegate));
+}
« 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