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

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

Issue 11054006: Make application shortcuts point to app_host.exe, install App Host during app installation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Changing code entry from class to function. Created 8 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/crx_installer.h" 5 #include "chrome/browser/extensions/crx_installer.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/scoped_temp_dir.h" 16 #include "base/scoped_temp_dir.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
19 #include "base/threading/thread_restrictions.h" 19 #include "base/threading/thread_restrictions.h"
20 #include "base/time.h" 20 #include "base/time.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #include "base/version.h" 22 #include "base/version.h"
23 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/extensions/app_host_installer.h"
24 #include "chrome/browser/extensions/convert_user_script.h" 25 #include "chrome/browser/extensions/convert_user_script.h"
25 #include "chrome/browser/extensions/convert_web_app.h" 26 #include "chrome/browser/extensions/convert_web_app.h"
26 #include "chrome/browser/extensions/default_apps_trial.h" 27 #include "chrome/browser/extensions/default_apps_trial.h"
27 #include "chrome/browser/extensions/extension_error_reporter.h" 28 #include "chrome/browser/extensions/extension_error_reporter.h"
28 #include "chrome/browser/extensions/extension_install_ui.h" 29 #include "chrome/browser/extensions/extension_install_ui.h"
29 #include "chrome/browser/extensions/extension_service.h" 30 #include "chrome/browser/extensions/extension_service.h"
30 #include "chrome/browser/extensions/extension_system.h" 31 #include "chrome/browser/extensions/extension_system.h"
31 #include "chrome/browser/extensions/permissions_updater.h" 32 #include "chrome/browser/extensions/permissions_updater.h"
32 #include "chrome/browser/extensions/requirements_checker.h" 33 #include "chrome/browser/extensions/requirements_checker.h"
33 #include "chrome/browser/extensions/webstore_installer.h" 34 #include "chrome/browser/extensions/webstore_installer.h"
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 451
451 current_version_ = 452 current_version_ =
452 frontend_weak_->extension_prefs()->GetVersionString(extension_->id()); 453 frontend_weak_->extension_prefs()->GetVersionString(extension_->id());
453 454
454 if (client_ && (!allow_silent_install_ || !approved_)) { 455 if (client_ && (!allow_silent_install_ || !approved_)) {
455 AddRef(); // Balanced in Proceed() and Abort(). 456 AddRef(); // Balanced in Proceed() and Abort().
456 client_->ConfirmInstall(this, extension_.get()); 457 client_->ConfirmInstall(this, extension_.get());
457 } else { 458 } else {
458 if (!BrowserThread::PostTask( 459 if (!BrowserThread::PostTask(
459 BrowserThread::FILE, FROM_HERE, 460 BrowserThread::FILE, FROM_HERE,
460 base::Bind(&CrxInstaller::CompleteInstall, this))) 461 base::Bind(&CrxInstaller::BeginInstall, this)))
461 NOTREACHED(); 462 NOTREACHED();
462 } 463 }
463 return; 464 return;
464 } 465 }
465 466
466 void CrxInstaller::InstallUIProceed() { 467 void CrxInstaller::InstallUIProceed() {
467 if (!BrowserThread::PostTask( 468 if (!BrowserThread::PostTask(
468 BrowserThread::FILE, FROM_HERE, 469 BrowserThread::FILE, FROM_HERE,
469 base::Bind(&CrxInstaller::CompleteInstall, this))) 470 base::Bind(&CrxInstaller::BeginInstall, this)))
470 NOTREACHED(); 471 NOTREACHED();
471 472
472 Release(); // balanced in ConfirmInstall(). 473 Release(); // balanced in ConfirmInstall().
473 } 474 }
474 475
475 void CrxInstaller::InstallUIAbort(bool user_initiated) { 476 void CrxInstaller::InstallUIAbort(bool user_initiated) {
476 std::string histogram_name = user_initiated ? 477 std::string histogram_name = user_initiated ?
477 "Extensions.Permissions_InstallCancel" : 478 "Extensions.Permissions_InstallCancel" :
478 "Extensions.Permissions_InstallAbort"; 479 "Extensions.Permissions_InstallAbort";
479 ExtensionService::RecordPermissionMessagesHistogram( 480 ExtensionService::RecordPermissionMessagesHistogram(
480 extension_, histogram_name.c_str()); 481 extension_, histogram_name.c_str());
481 482
482 // Kill the theme loading bubble. 483 // Kill the theme loading bubble.
483 content::NotificationService* service = 484 content::NotificationService* service =
484 content::NotificationService::current(); 485 content::NotificationService::current();
485 service->Notify(chrome::NOTIFICATION_NO_THEME_DETECTED, 486 service->Notify(chrome::NOTIFICATION_NO_THEME_DETECTED,
486 content::Source<CrxInstaller>(this), 487 content::Source<CrxInstaller>(this),
487 content::NotificationService::NoDetails()); 488 content::NotificationService::NoDetails());
488 489
489 NotifyCrxInstallComplete(NULL); 490 NotifyCrxInstallComplete(NULL);
490 491
491 Release(); // balanced in ConfirmInstall(). 492 Release(); // balanced in ConfirmInstall().
492 493
493 // We're done. Since we don't post any more tasks to ourself, our ref count 494 // We're done. Since we don't post any more tasks to ourself, our ref count
494 // should go to zero and we die. The destructor will clean up the temp dir. 495 // should go to zero and we die. The destructor will clean up the temp dir.
495 } 496 }
496 497
497 void CrxInstaller::CompleteInstall() { 498 void CrxInstaller::BeginInstall() {
498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 499 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
499 500
500 if (!current_version_.empty()) { 501 if (!current_version_.empty()) {
501 Version current_version(current_version_); 502 Version current_version(current_version_);
502 if (current_version.CompareTo(*(extension_->version())) > 0) { 503 if (current_version.CompareTo(*(extension_->version())) > 0) {
503 ReportFailureFromFileThread( 504 ReportFailureFromFileThread(
504 CrxInstallerError( 505 CrxInstallerError(
505 l10n_util::GetStringUTF16(extension_->is_app() ? 506 l10n_util::GetStringUTF16(extension_->is_app() ?
506 IDS_APP_CANT_DOWNGRADE_VERSION : 507 IDS_APP_CANT_DOWNGRADE_VERSION :
507 IDS_EXTENSION_CANT_DOWNGRADE_VERSION))); 508 IDS_EXTENSION_CANT_DOWNGRADE_VERSION)));
508 return; 509 return;
509 } 510 }
510 } 511 }
512 app_host_installer::InstallAppHostIfNecessary(*extension_,
513 base::Bind(&CrxInstaller::OnAppHostInstallationComplete, this));
514 }
515
516 void CrxInstaller::OnAppHostInstallationComplete(bool success) {
517 if (!success) {
erikwright (departed) 2012/10/09 19:24:48 Add a DCHECK for current thread == FILE
huangs 2012/10/09 21:09:15 Done.
518 ReportFailureFromFileThread(
519 CrxInstallerError(
520 l10n_util::GetStringUTF16(
521 IDS_EXTENSION_APP_HOST_INSTALL_ERROR)));
522 return;
523 }
524 CompleteInstall();
525 }
526
527 void CrxInstaller::CompleteInstall() {
528 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
511 529
512 // See how long extension install paths are. This is important on 530 // See how long extension install paths are. This is important on
513 // windows, because file operations may fail if the path to a file 531 // windows, because file operations may fail if the path to a file
514 // exceeds a small constant. See crbug.com/69693 . 532 // exceeds a small constant. See crbug.com/69693 .
515 UMA_HISTOGRAM_CUSTOM_COUNTS( 533 UMA_HISTOGRAM_CUSTOM_COUNTS(
516 "Extensions.CrxInstallDirPathLength", 534 "Extensions.CrxInstallDirPathLength",
517 install_directory_.value().length(), 0, 500, 100); 535 install_directory_.value().length(), 0, 500, 100);
518 536
519 FilePath version_dir = extension_file_util::InstallExtension( 537 FilePath version_dir = extension_file_util::InstallExtension(
520 unpacked_extension_root_, 538 unpacked_extension_root_,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 // is problematic because they don't know anything about the 668 // is problematic because they don't know anything about the
651 // extension before it is unpacked, so they cannot filter based 669 // extension before it is unpacked, so they cannot filter based
652 // on the extension. 670 // on the extension.
653 content::NotificationService::current()->Notify( 671 content::NotificationService::current()->Notify(
654 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 672 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
655 content::Source<CrxInstaller>(this), 673 content::Source<CrxInstaller>(this),
656 content::Details<const Extension>(extension)); 674 content::Details<const Extension>(extension));
657 } 675 }
658 676
659 } // namespace extensions 677 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698