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

Side by Side Diff: app/resource_bundle_linux.cc

Issue 193072: Move StringPiece into the base namespace. It is colliding (Closed)
Patch Set: take 2 Created 11 years, 3 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
« no previous file with comments | « app/resource_bundle.h ('k') | app/resource_bundle_mac.mm » ('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 "app/resource_bundle.h" 5 #include "app/resource_bundle.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "app/app_paths.h" 9 #include "app/app_paths.h"
10 #include "app/gfx/font.h" 10 #include "app/gfx/font.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 theme_data_path = theme_data_path.Append(FILE_PATH_LITERAL("default.pak")); 114 theme_data_path = theme_data_path.Append(FILE_PATH_LITERAL("default.pak"));
115 theme_data_ = new base::DataPack; 115 theme_data_ = new base::DataPack;
116 bool success = theme_data_->Load(theme_data_path); 116 bool success = theme_data_->Load(theme_data_path);
117 DCHECK(success) << "failed to load theme data"; 117 DCHECK(success) << "failed to load theme data";
118 } 118 }
119 119
120 /* static */ 120 /* static */
121 bool ResourceBundle::LoadResourceBytes(DataHandle module, int resource_id, 121 bool ResourceBundle::LoadResourceBytes(DataHandle module, int resource_id,
122 std::vector<unsigned char>* bytes) { 122 std::vector<unsigned char>* bytes) {
123 DCHECK(module); 123 DCHECK(module);
124 StringPiece data; 124 base::StringPiece data;
125 if (!module->Get(resource_id, &data)) 125 if (!module->Get(resource_id, &data))
126 return false; 126 return false;
127 127
128 bytes->resize(data.length()); 128 bytes->resize(data.length());
129 memcpy(&(bytes->front()), data.data(), data.length()); 129 memcpy(&(bytes->front()), data.data(), data.length());
130 130
131 return true; 131 return true;
132 } 132 }
133 133
134 StringPiece ResourceBundle::GetRawDataResource(int resource_id) { 134 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) {
135 DCHECK(resources_data_); 135 DCHECK(resources_data_);
136 StringPiece data; 136 base::StringPiece data;
137 if (!resources_data_->Get(resource_id, &data)) 137 if (!resources_data_->Get(resource_id, &data))
138 return StringPiece(); 138 return base::StringPiece();
139 return data; 139 return data;
140 } 140 }
141 141
142 string16 ResourceBundle::GetLocalizedString(int message_id) { 142 string16 ResourceBundle::GetLocalizedString(int message_id) {
143 // If for some reason we were unable to load a resource dll, return an empty 143 // If for some reason we were unable to load a resource dll, return an empty
144 // string (better than crashing). 144 // string (better than crashing).
145 if (!locale_resources_data_) { 145 if (!locale_resources_data_) {
146 LOG(WARNING) << "locale resources are not loaded"; 146 LOG(WARNING) << "locale resources are not loaded";
147 return string16(); 147 return string16();
148 } 148 }
149 149
150 StringPiece data; 150 base::StringPiece data;
151 if (!locale_resources_data_->Get(message_id, &data)) { 151 if (!locale_resources_data_->Get(message_id, &data)) {
152 // Fall back on the main data pack (shouldn't be any strings here except in 152 // Fall back on the main data pack (shouldn't be any strings here except in
153 // unittests). 153 // unittests).
154 data = GetRawDataResource(message_id); 154 data = GetRawDataResource(message_id);
155 if (data.empty()) { 155 if (data.empty()) {
156 NOTREACHED() << "unable to find resource: " << message_id; 156 NOTREACHED() << "unable to find resource: " << message_id;
157 return string16(); 157 return string16();
158 } 158 }
159 } 159 }
160 160
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 } 216 }
217 217
218 GdkPixbuf* ResourceBundle::GetPixbufNamed(int resource_id) { 218 GdkPixbuf* ResourceBundle::GetPixbufNamed(int resource_id) {
219 return GetPixbufImpl(resource_id, false); 219 return GetPixbufImpl(resource_id, false);
220 } 220 }
221 221
222 GdkPixbuf* ResourceBundle::GetRTLEnabledPixbufNamed(int resource_id) { 222 GdkPixbuf* ResourceBundle::GetRTLEnabledPixbufNamed(int resource_id) {
223 return GetPixbufImpl(resource_id, true); 223 return GetPixbufImpl(resource_id, true);
224 } 224 }
OLDNEW
« no previous file with comments | « app/resource_bundle.h ('k') | app/resource_bundle_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698