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

Side by Side Diff: chrome/common/resource_bundle_linux.cc

Issue 67024: Adds some ifdefs so that test_shell can be compiled on linux... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/resource_bundle.cc ('k') | chrome/views/widget/root_view.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/common/resource_bundle.h" 5 #include "chrome/common/resource_bundle.h"
6 6
7 #if defined(TOOLKIT_GTK)
7 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif
8 10
9 #include "base/base_paths.h" 11 #include "base/base_paths.h"
10 #include "base/data_pack.h" 12 #include "base/data_pack.h"
11 #include "base/file_path.h" 13 #include "base/file_path.h"
12 #include "base/file_util.h" 14 #include "base/file_util.h"
13 #include "base/logging.h" 15 #include "base/logging.h"
14 #include "base/path_service.h" 16 #include "base/path_service.h"
15 #include "base/string_piece.h" 17 #include "base/string_piece.h"
16 #include "base/string_util.h" 18 #include "base/string_util.h"
17 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return std::wstring(); 115 return std::wstring();
114 } 116 }
115 } 117 }
116 118
117 // Data pack encodes strings as UTF16. 119 // Data pack encodes strings as UTF16.
118 string16 msg(reinterpret_cast<const char16*>(data.data()), 120 string16 msg(reinterpret_cast<const char16*>(data.data()),
119 data.length() / 2); 121 data.length() / 2);
120 return UTF16ToWide(msg); 122 return UTF16ToWide(msg);
121 } 123 }
122 124
125 #if defined(TOOLKIT_GTK)
123 GdkPixbuf* ResourceBundle::LoadPixbuf(int resource_id) { 126 GdkPixbuf* ResourceBundle::LoadPixbuf(int resource_id) {
124 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 127 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
125 std::vector<unsigned char> data; 128 std::vector<unsigned char> data;
126 rb.LoadImageResourceBytes(resource_id, &data); 129 rb.LoadImageResourceBytes(resource_id, &data);
127 130
128 GdkPixbufLoader* loader = gdk_pixbuf_loader_new(); 131 GdkPixbufLoader* loader = gdk_pixbuf_loader_new();
129 bool ok = gdk_pixbuf_loader_write(loader, static_cast<guint8*>(data.data()), 132 bool ok = gdk_pixbuf_loader_write(loader, static_cast<guint8*>(data.data()),
130 data.size(), NULL); 133 data.size(), NULL);
131 DCHECK(ok) << "failed to write " << resource_id; 134 DCHECK(ok) << "failed to write " << resource_id;
132 // Calling gdk_pixbuf_loader_close forces the data to be parsed by the 135 // Calling gdk_pixbuf_loader_close forces the data to be parsed by the
133 // loader. We must do this before calling gdk_pixbuf_loader_get_pixbuf. 136 // loader. We must do this before calling gdk_pixbuf_loader_get_pixbuf.
134 ok = gdk_pixbuf_loader_close(loader, NULL); 137 ok = gdk_pixbuf_loader_close(loader, NULL);
135 DCHECK(ok) << "close failed " << resource_id; 138 DCHECK(ok) << "close failed " << resource_id;
136 GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); 139 GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
137 DCHECK(pixbuf) << "failed to load " << resource_id << " " << data.size(); 140 DCHECK(pixbuf) << "failed to load " << resource_id << " " << data.size();
138 141
139 // The pixbuf is owned by the loader, so add a ref so when we delete the 142 // The pixbuf is owned by the loader, so add a ref so when we delete the
140 // loader, the pixbuf still exists. 143 // loader, the pixbuf still exists.
141 g_object_ref(pixbuf); 144 g_object_ref(pixbuf);
142 g_object_unref(loader); 145 g_object_unref(loader);
143 146
144 return pixbuf; 147 return pixbuf;
145 } 148 }
149 #endif
OLDNEW
« no previous file with comments | « chrome/common/resource_bundle.cc ('k') | chrome/views/widget/root_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698