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

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

Issue 8368018: Convert chrome/common non-debug logs to debug logs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/extensions/extension_file_util.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // deterministicly choose a location. 275 // deterministicly choose a location.
276 CHECK(loc1_rank != loc2_rank); 276 CHECK(loc1_rank != loc2_rank);
277 277
278 // Highest rank has highest priority. 278 // Highest rank has highest priority.
279 return (loc1_rank > loc2_rank ? loc1 : loc2 ); 279 return (loc1_rank > loc2_rank ? loc1 : loc2 );
280 } 280 }
281 281
282 void Extension::OverrideLaunchUrl(const GURL& override_url) { 282 void Extension::OverrideLaunchUrl(const GURL& override_url) {
283 GURL new_url(override_url); 283 GURL new_url(override_url);
284 if (!new_url.is_valid()) { 284 if (!new_url.is_valid()) {
285 LOG(WARNING) << "Invalid override url given for " << name(); 285 DLOG(WARNING) << "Invalid override url given for " << name();
286 } else { 286 } else {
287 if (new_url.has_port()) { 287 if (new_url.has_port()) {
288 LOG(WARNING) << "Override URL passed for " << name() 288 DLOG(WARNING) << "Override URL passed for " << name()
289 << " should not contain a port. Removing it."; 289 << " should not contain a port. Removing it.";
290 290
291 GURL::Replacements remove_port; 291 GURL::Replacements remove_port;
292 remove_port.ClearPort(); 292 remove_port.ClearPort();
293 new_url = new_url.ReplaceComponents(remove_port); 293 new_url = new_url.ReplaceComponents(remove_port);
294 } 294 }
295 295
296 launch_web_url_ = new_url.spec(); 296 launch_web_url_ = new_url.spec();
297 297
298 URLPattern pattern(kValidWebExtentSchemes); 298 URLPattern pattern(kValidWebExtentSchemes);
299 pattern.Parse(new_url.spec(), URLPattern::ERROR_ON_PORTS); 299 pattern.Parse(new_url.spec(), URLPattern::ERROR_ON_PORTS);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 DCHECK(extension_url.SchemeIs(chrome::kExtensionScheme)); 373 DCHECK(extension_url.SchemeIs(chrome::kExtensionScheme));
374 DCHECK_EQ("/", extension_url.path()); 374 DCHECK_EQ("/", extension_url.path());
375 375
376 GURL ret_val = GURL(extension_url.spec() + relative_path); 376 GURL ret_val = GURL(extension_url.spec() + relative_path);
377 DCHECK(StartsWithASCII(ret_val.spec(), extension_url.spec(), false)); 377 DCHECK(StartsWithASCII(ret_val.spec(), extension_url.spec(), false));
378 378
379 return ret_val; 379 return ret_val;
380 } 380 }
381 381
382 bool Extension::GenerateId(const std::string& input, std::string* output) { 382 bool Extension::GenerateId(const std::string& input, std::string* output) {
383 CHECK(output); 383 DCHECK(output);
384 uint8 hash[Extension::kIdSize]; 384 uint8 hash[Extension::kIdSize];
385 crypto::SHA256HashString(input, hash, sizeof(hash)); 385 crypto::SHA256HashString(input, hash, sizeof(hash));
386 *output = StringToLowerASCII(base::HexEncode(hash, sizeof(hash))); 386 *output = StringToLowerASCII(base::HexEncode(hash, sizeof(hash)));
387 ConvertHexadecimalToIDAlphabet(output); 387 ConvertHexadecimalToIDAlphabet(output);
388 388
389 return true; 389 return true;
390 } 390 }
391 391
392 // Helper method that loads a UserScript object from a dictionary in the 392 // Helper method that loads a UserScript object from a dictionary in the
393 // content_script list of the manifest. 393 // content_script list of the manifest.
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 *error = ExtensionErrorUtils::FormatErrorMessage( 1152 *error = ExtensionErrorUtils::FormatErrorMessage(
1153 errors::kInvalidIsolationValue, 1153 errors::kInvalidIsolationValue,
1154 base::UintToString(i)); 1154 base::UintToString(i));
1155 return false; 1155 return false;
1156 } 1156 }
1157 1157
1158 // Check for isolated storage. 1158 // Check for isolated storage.
1159 if (isolation_string == values::kIsolatedStorage) { 1159 if (isolation_string == values::kIsolatedStorage) {
1160 is_storage_isolated_ = true; 1160 is_storage_isolated_ = true;
1161 } else { 1161 } else {
1162 LOG(WARNING) << "Did not recognize isolation type: " 1162 DLOG(WARNING) << "Did not recognize isolation type: "
1163 << isolation_string; 1163 << isolation_string;
1164 } 1164 }
1165 } 1165 }
1166 return true; 1166 return true;
1167 } 1167 }
1168 1168
1169 bool Extension::LoadWebIntents(const base::DictionaryValue& manifest, 1169 bool Extension::LoadWebIntents(const base::DictionaryValue& manifest,
1170 std::string* error) { 1170 std::string* error) {
1171 DCHECK(error); 1171 DCHECK(error);
1172 1172
1173 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) 1173 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents))
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 1327
1328 working = working.substr(start_pos, end_pos - start_pos); 1328 working = working.substr(start_pos, end_pos - start_pos);
1329 if (working.length() == 0) 1329 if (working.length() == 0)
1330 return false; 1330 return false;
1331 } 1331 }
1332 1332
1333 return base::Base64Decode(working, output); 1333 return base::Base64Decode(working, output);
1334 } 1334 }
1335 1335
1336 bool Extension::ProducePEM(const std::string& input, std::string* output) { 1336 bool Extension::ProducePEM(const std::string& input, std::string* output) {
1337 CHECK(output); 1337 DCHECK(output);
1338 if (input.length() == 0) 1338 if (input.length() == 0)
1339 return false; 1339 return false;
1340 1340
1341 return base::Base64Encode(input, output); 1341 return base::Base64Encode(input, output);
1342 } 1342 }
1343 1343
1344 bool Extension::FormatPEMForFileOutput(const std::string& input, 1344 bool Extension::FormatPEMForFileOutput(const std::string& input,
1345 std::string* output, 1345 std::string* output,
1346 bool is_public) { 1346 bool is_public) {
1347 CHECK(output); 1347 DCHECK(output);
1348 if (input.length() == 0) 1348 if (input.length() == 0)
1349 return false; 1349 return false;
1350 *output = ""; 1350 *output = "";
1351 output->append(kKeyBeginHeaderMarker); 1351 output->append(kKeyBeginHeaderMarker);
1352 output->append(" "); 1352 output->append(" ");
1353 output->append(is_public ? kPublic : kPrivate); 1353 output->append(is_public ? kPublic : kPrivate);
1354 output->append(" "); 1354 output->append(" ");
1355 output->append(kKeyInfoEndMarker); 1355 output->append(kKeyInfoEndMarker);
1356 output->append("\n"); 1356 output->append("\n");
1357 for (size_t i = 0; i < input.length(); ) { 1357 for (size_t i = 0; i < input.length(); ) {
(...skipping 23 matching lines...) Expand all
1381 1381
1382 // static 1382 // static
1383 void Extension::DecodeIconFromPath(const FilePath& icon_path, 1383 void Extension::DecodeIconFromPath(const FilePath& icon_path,
1384 Icons icon_size, 1384 Icons icon_size,
1385 scoped_ptr<SkBitmap>* result) { 1385 scoped_ptr<SkBitmap>* result) {
1386 if (icon_path.empty()) 1386 if (icon_path.empty())
1387 return; 1387 return;
1388 1388
1389 std::string file_contents; 1389 std::string file_contents;
1390 if (!file_util::ReadFileToString(icon_path, &file_contents)) { 1390 if (!file_util::ReadFileToString(icon_path, &file_contents)) {
1391 LOG(ERROR) << "Could not read icon file: " << icon_path.LossyDisplayName(); 1391 DLOG(ERROR) << "Could not read icon file: " << icon_path.LossyDisplayName();
1392 return; 1392 return;
1393 } 1393 }
1394 1394
1395 // Decode the image using WebKit's image decoder. 1395 // Decode the image using WebKit's image decoder.
1396 const unsigned char* data = 1396 const unsigned char* data =
1397 reinterpret_cast<const unsigned char*>(file_contents.data()); 1397 reinterpret_cast<const unsigned char*>(file_contents.data());
1398 webkit_glue::ImageDecoder decoder; 1398 webkit_glue::ImageDecoder decoder;
1399 scoped_ptr<SkBitmap> decoded(new SkBitmap()); 1399 scoped_ptr<SkBitmap> decoded(new SkBitmap());
1400 *decoded = decoder.Decode(data, file_contents.length()); 1400 *decoded = decoder.Decode(data, file_contents.length());
1401 if (decoded->empty()) { 1401 if (decoded->empty()) {
1402 LOG(ERROR) << "Could not decode icon file: " 1402 DLOG(ERROR) << "Could not decode icon file: "
1403 << icon_path.LossyDisplayName(); 1403 << icon_path.LossyDisplayName();
1404 return; 1404 return;
1405 } 1405 }
1406 1406
1407 if (decoded->width() != icon_size || decoded->height() != icon_size) { 1407 if (decoded->width() != icon_size || decoded->height() != icon_size) {
1408 LOG(ERROR) << "Icon file has unexpected size: " 1408 DLOG(ERROR) << "Icon file has unexpected size: "
1409 << base::IntToString(decoded->width()) << "x" 1409 << base::IntToString(decoded->width()) << "x"
1410 << base::IntToString(decoded->height()); 1410 << base::IntToString(decoded->height());
1411 return; 1411 return;
1412 } 1412 }
1413 1413
1414 result->swap(decoded); 1414 result->swap(decoded);
1415 } 1415 }
1416 1416
1417 // static 1417 // static
1418 const SkBitmap& Extension::GetDefaultIcon(bool is_app) { 1418 const SkBitmap& Extension::GetDefaultIcon(bool is_app) {
1419 if (is_app) { 1419 if (is_app) {
1420 return *ResourceBundle::GetSharedInstance().GetBitmapNamed( 1420 return *ResourceBundle::GetSharedInstance().GetBitmapNamed(
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after
2988 already_disabled(false), 2988 already_disabled(false),
2989 extension(extension) {} 2989 extension(extension) {}
2990 2990
2991 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 2991 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
2992 const Extension* extension, 2992 const Extension* extension,
2993 const ExtensionPermissionSet* permissions, 2993 const ExtensionPermissionSet* permissions,
2994 Reason reason) 2994 Reason reason)
2995 : reason(reason), 2995 : reason(reason),
2996 extension(extension), 2996 extension(extension),
2997 permissions(permissions) {} 2997 permissions(permissions) {}
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/extension_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698