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

Side by Side Diff: chrome/browser/extensions/sandboxed_extension_unpacker.cc

Issue 6992047: Change the web store private install API to accept a localized extension name. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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) 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/browser/extensions/sandboxed_extension_unpacker.h" 5 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 std::string("Manifest is invalid: ") + error); 277 std::string("Manifest is invalid: ") + error);
278 return; 278 return;
279 } 279 }
280 280
281 if (!RewriteImageFiles()) 281 if (!RewriteImageFiles())
282 return; 282 return;
283 283
284 if (!RewriteCatalogFiles()) 284 if (!RewriteCatalogFiles())
285 return; 285 return;
286 286
287 ReportSuccess(); 287 ReportSuccess(manifest);
288 } 288 }
289 289
290 void SandboxedExtensionUnpacker::OnUnpackExtensionFailed( 290 void SandboxedExtensionUnpacker::OnUnpackExtensionFailed(
291 const std::string& error) { 291 const std::string& error) {
292 CHECK(BrowserThread::CurrentlyOn(thread_identifier_)); 292 CHECK(BrowserThread::CurrentlyOn(thread_identifier_));
293 got_response_ = true; 293 got_response_ = true;
294 ReportFailure( 294 ReportFailure(
295 UNPACKER_CLIENT_FAILED, 295 UNPACKER_CLIENT_FAILED,
296 l10n_util::GetStringFUTF8( 296 l10n_util::GetStringFUTF8(
297 IDS_EXTENSION_PACKAGE_ERROR_MESSAGE, 297 IDS_EXTENSION_PACKAGE_ERROR_MESSAGE,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 void SandboxedExtensionUnpacker::ReportFailure(FailureReason reason, 473 void SandboxedExtensionUnpacker::ReportFailure(FailureReason reason,
474 const std::string& error) { 474 const std::string& error) {
475 UMA_HISTOGRAM_ENUMERATION("Extensions.SandboxUnpackFailureReason", 475 UMA_HISTOGRAM_ENUMERATION("Extensions.SandboxUnpackFailureReason",
476 reason, NUM_FAILURE_REASONS); 476 reason, NUM_FAILURE_REASONS);
477 UMA_HISTOGRAM_TIMES("Extensions.SandboxUnpackFailureTime", 477 UMA_HISTOGRAM_TIMES("Extensions.SandboxUnpackFailureTime",
478 base::TimeTicks::Now() - unpack_start_time_); 478 base::TimeTicks::Now() - unpack_start_time_);
479 479
480 client_->OnUnpackFailure(error); 480 client_->OnUnpackFailure(error);
481 } 481 }
482 482
483 void SandboxedExtensionUnpacker::ReportSuccess() { 483 void SandboxedExtensionUnpacker::ReportSuccess(
484 const DictionaryValue& original_manifest) {
484 UMA_HISTOGRAM_COUNTS("Extensions.SandboxUnpackSuccess", 1); 485 UMA_HISTOGRAM_COUNTS("Extensions.SandboxUnpackSuccess", 1);
485 486
486 RecordSuccessfulUnpackTimeHistograms( 487 RecordSuccessfulUnpackTimeHistograms(
487 crx_path_, base::TimeTicks::Now() - unpack_start_time_); 488 crx_path_, base::TimeTicks::Now() - unpack_start_time_);
488 489
489 // Client takes ownership of temporary directory and extension. 490 // Client takes ownership of temporary directory and extension.
490 client_->OnUnpackSuccess(temp_dir_.Take(), extension_root_, extension_); 491 client_->OnUnpackSuccess(temp_dir_.Take(),
492 extension_root_,
493 &original_manifest,
494 extension_);
491 extension_ = NULL; 495 extension_ = NULL;
492 } 496 }
493 497
494 DictionaryValue* SandboxedExtensionUnpacker::RewriteManifestFile( 498 DictionaryValue* SandboxedExtensionUnpacker::RewriteManifestFile(
495 const DictionaryValue& manifest) { 499 const DictionaryValue& manifest) {
496 // Add the public key extracted earlier to the parsed manifest and overwrite 500 // Add the public key extracted earlier to the parsed manifest and overwrite
497 // the original manifest. We do this to ensure the manifest doesn't contain an 501 // the original manifest. We do this to ensure the manifest doesn't contain an
498 // exploitable bug that could be used to compromise the browser. 502 // exploitable bug that could be used to compromise the browser.
499 scoped_ptr<DictionaryValue> final_manifest(manifest.DeepCopy()); 503 scoped_ptr<DictionaryValue> final_manifest(manifest.DeepCopy());
500 final_manifest->SetString(extension_manifest_keys::kPublicKey, public_key_); 504 final_manifest->SetString(extension_manifest_keys::kPublicKey, public_key_);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 ERROR_SAVING_CATALOG, 692 ERROR_SAVING_CATALOG,
689 l10n_util::GetStringFUTF8( 693 l10n_util::GetStringFUTF8(
690 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, 694 IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
691 ASCIIToUTF16("ERROR_SAVING_CATALOG"))); 695 ASCIIToUTF16("ERROR_SAVING_CATALOG")));
692 return false; 696 return false;
693 } 697 }
694 } 698 }
695 699
696 return true; 700 return true;
697 } 701 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698