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

Unified Diff: chrome/browser/shell_integration_linux.cc

Issue 12881003: ShortcutInfo::favicon is now a gfx::ImageFamily instead of gfx::Image. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: CopyGdkPixbuf and TODO. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/shell_integration.h ('k') | chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/shell_integration_linux.cc
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index c0be6de531a5e15c0546339aaeb6966c9d3106e0..b772ef6e11035d5f415a40a979354906d9e285e1 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -21,6 +21,8 @@
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/i18n/file_util_icu.h"
+#include "base/memory/ref_counted_memory.h"
+#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
@@ -35,9 +37,7 @@
#include "chrome/common/chrome_constants.h"
#include "content/public/browser/browser_thread.h"
#include "googleurl/src/gurl.h"
-#include "ui/gfx/codec/png_codec.h"
-#include "ui/gfx/image/image_skia.h"
-#include "ui/gfx/image/image_skia_rep.h"
+#include "ui/gfx/image/image_family.h"
using content::BrowserThread;
@@ -75,7 +75,7 @@ bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) {
std::string CreateShortcutIcon(
const ShellIntegration::ShortcutInfo& shortcut_info,
const base::FilePath& shortcut_filename) {
- if (shortcut_info.favicon.IsEmpty())
+ if (shortcut_info.favicon.empty())
return std::string();
// TODO(phajdan.jr): Report errors from this function, possibly as infobars.
@@ -87,22 +87,20 @@ std::string CreateShortcutIcon(
shortcut_filename.ReplaceExtension("png"));
std::string icon_name = temp_file_path.BaseName().RemoveExtension().value();
- std::vector<gfx::ImageSkiaRep> image_reps =
- shortcut_info.favicon.ToImageSkia()->image_reps();
- for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin();
- it != image_reps.end(); ++it) {
- std::vector<unsigned char> png_data;
- const SkBitmap& bitmap = it->sk_bitmap();
- if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &png_data)) {
+ for (gfx::ImageFamily::const_iterator it = shortcut_info.favicon.begin();
+ it != shortcut_info.favicon.end(); ++it) {
+ int width = it->Width();
+ scoped_refptr<base::RefCountedMemory> png_data = it->As1xPNGBytes();
+ if (png_data->size() == 0) {
// If the bitmap could not be encoded to PNG format, skip it.
LOG(WARNING) << "Could not encode icon " << icon_name << ".png at size "
- << bitmap.width() << ".";
+ << width << ".";
continue;
}
int bytes_written = file_util::WriteFile(temp_file_path,
- reinterpret_cast<char*>(png_data.data()), png_data.size());
+ reinterpret_cast<const char*>(png_data->front()), png_data->size());
- if (bytes_written != static_cast<int>(png_data.size()))
+ if (bytes_written != static_cast<int>(png_data->size()))
return std::string();
std::vector<std::string> argv;
@@ -115,14 +113,14 @@ std::string CreateShortcutIcon(
argv.push_back("user");
argv.push_back("--size");
- argv.push_back(base::IntToString(bitmap.width()));
+ argv.push_back(base::IntToString(width));
argv.push_back(temp_file_path.value());
argv.push_back(icon_name);
int exit_code;
if (!LaunchXdgUtility(argv, &exit_code) || exit_code) {
LOG(WARNING) << "Could not install icon " << icon_name << ".png at size "
- << bitmap.width() << ".";
+ << width << ".";
}
}
return icon_name;
« no previous file with comments | « chrome/browser/shell_integration.h ('k') | chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698