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

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 6246036: FilePath: Remove most of ToWStringHack, adding a LossyDisplayName() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 if (temp[i] < 'a' || temp[i] > 'p') 461 if (temp[i] < 'a' || temp[i] > 'p')
462 return false; 462 return false;
463 463
464 return true; 464 return true;
465 } 465 }
466 466
467 // static 467 // static
468 std::string Extension::GenerateIdForPath(const FilePath& path) { 468 std::string Extension::GenerateIdForPath(const FilePath& path) {
469 FilePath new_path = Extension::MaybeNormalizePath(path); 469 FilePath new_path = Extension::MaybeNormalizePath(path);
470 std::string id; 470 std::string id;
471 if (!GenerateId(WideToUTF8(new_path.ToWStringHack()), &id)) 471 if (!GenerateId(UTF16ToUTF8(new_path.LossyDisplayName()), &id))
Mark Mentovai 2011/02/01 22:54:55 Not for display?
472 return ""; 472 return "";
473 return id; 473 return id;
474 } 474 }
475 475
476 Extension::Type Extension::GetType() const { 476 Extension::Type Extension::GetType() const {
477 if (is_theme()) 477 if (is_theme())
478 return TYPE_THEME; 478 return TYPE_THEME;
479 if (converted_from_user_script()) 479 if (converted_from_user_script())
480 return TYPE_USER_SCRIPT; 480 return TYPE_USER_SCRIPT;
481 if (is_hosted_app()) 481 if (is_hosted_app())
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 1237
1238 // static 1238 // static
1239 void Extension::DecodeIconFromPath(const FilePath& icon_path, 1239 void Extension::DecodeIconFromPath(const FilePath& icon_path,
1240 Icons icon_size, 1240 Icons icon_size,
1241 scoped_ptr<SkBitmap>* result) { 1241 scoped_ptr<SkBitmap>* result) {
1242 if (icon_path.empty()) 1242 if (icon_path.empty())
1243 return; 1243 return;
1244 1244
1245 std::string file_contents; 1245 std::string file_contents;
1246 if (!file_util::ReadFileToString(icon_path, &file_contents)) { 1246 if (!file_util::ReadFileToString(icon_path, &file_contents)) {
1247 LOG(ERROR) << "Could not read icon file: " 1247 LOG(ERROR) << "Could not read icon file: " << icon_path.LossyDisplayName();
1248 << WideToUTF8(icon_path.ToWStringHack());
1249 return; 1248 return;
1250 } 1249 }
1251 1250
1252 // Decode the image using WebKit's image decoder. 1251 // Decode the image using WebKit's image decoder.
1253 const unsigned char* data = 1252 const unsigned char* data =
1254 reinterpret_cast<const unsigned char*>(file_contents.data()); 1253 reinterpret_cast<const unsigned char*>(file_contents.data());
1255 webkit_glue::ImageDecoder decoder; 1254 webkit_glue::ImageDecoder decoder;
1256 scoped_ptr<SkBitmap> decoded(new SkBitmap()); 1255 scoped_ptr<SkBitmap> decoded(new SkBitmap());
1257 *decoded = decoder.Decode(data, file_contents.length()); 1256 *decoded = decoder.Decode(data, file_contents.length());
1258 if (decoded->empty()) { 1257 if (decoded->empty()) {
1259 LOG(ERROR) << "Could not decode icon file: " 1258 LOG(ERROR) << "Could not decode icon file: "
1260 << WideToUTF8(icon_path.ToWStringHack()); 1259 << icon_path.LossyDisplayName();
1261 return; 1260 return;
1262 } 1261 }
1263 1262
1264 if (decoded->width() != icon_size || decoded->height() != icon_size) { 1263 if (decoded->width() != icon_size || decoded->height() != icon_size) {
1265 LOG(ERROR) << "Icon file has unexpected size: " 1264 LOG(ERROR) << "Icon file has unexpected size: "
1266 << base::IntToString(decoded->width()) << "x" 1265 << base::IntToString(decoded->width()) << "x"
1267 << base::IntToString(decoded->height()); 1266 << base::IntToString(decoded->height());
1268 return; 1267 return;
1269 } 1268 }
1270 1269
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2380 2379
2381 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} 2380 UninstalledExtensionInfo::~UninstalledExtensionInfo() {}
2382 2381
2383 2382
2384 UnloadedExtensionInfo::UnloadedExtensionInfo( 2383 UnloadedExtensionInfo::UnloadedExtensionInfo(
2385 const Extension* extension, 2384 const Extension* extension,
2386 Reason reason) 2385 Reason reason)
2387 : reason(reason), 2386 : reason(reason),
2388 already_disabled(false), 2387 already_disabled(false),
2389 extension(extension) {} 2388 extension(extension) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698