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

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: Rearranged code for unpacked_installer.cc; moved App Host code from chrome_launch_support to app_ho… 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 if (AppHostInstaller::IsAppHostInstallRequired(*extension_)) {
513 app_host_installer_.InstallAppHost(
514 base::Bind(&CrxInstaller::OnAppHostInstallation, this));
benwells 2012/10/04 07:53:01 early return here and remove the else
huangs 2012/10/04 22:56:42 Done.
515 } else {
516 CompleteInstall();
517 }
518 }
519
520 void CrxInstaller::OnAppHostInstallation(bool success) {
erikwright (departed) 2012/10/04 01:28:16 OnAppHostInstallationComplete
huangs 2012/10/04 22:56:42 Done.
521 if (success) {
522 CompleteInstall();
benwells 2012/10/04 07:53:01 Early return and remove the else
huangs 2012/10/04 22:56:42 Done.
523 } else {
524 // TODO(huangs): Error message.
benwells 2012/10/04 07:53:01 I take it you'll remove this TODO / fix the error
huangs 2012/10/04 22:56:42 Done.
525 string16 error = L"Some random error message";
526 ReportFailureFromFileThread(CrxInstallerError(error));
527 }
528 }
529
530 void CrxInstaller::CompleteInstall() {
531 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
511 532
512 // See how long extension install paths are. This is important on 533 // See how long extension install paths are. This is important on
513 // windows, because file operations may fail if the path to a file 534 // windows, because file operations may fail if the path to a file
514 // exceeds a small constant. See crbug.com/69693 . 535 // exceeds a small constant. See crbug.com/69693 .
515 UMA_HISTOGRAM_CUSTOM_COUNTS( 536 UMA_HISTOGRAM_CUSTOM_COUNTS(
516 "Extensions.CrxInstallDirPathLength", 537 "Extensions.CrxInstallDirPathLength",
517 install_directory_.value().length(), 0, 500, 100); 538 install_directory_.value().length(), 0, 500, 100);
518 539
519 FilePath version_dir = extension_file_util::InstallExtension( 540 FilePath version_dir = extension_file_util::InstallExtension(
520 unpacked_extension_root_, 541 unpacked_extension_root_,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 // is problematic because they don't know anything about the 672 // is problematic because they don't know anything about the
652 // extension before it is unpacked, so they cannot filter based 673 // extension before it is unpacked, so they cannot filter based
653 // on the extension. 674 // on the extension.
654 content::NotificationService::current()->Notify( 675 content::NotificationService::current()->Notify(
655 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 676 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
656 content::Source<CrxInstaller>(this), 677 content::Source<CrxInstaller>(this),
657 content::Details<const Extension>(extension)); 678 content::Details<const Extension>(extension));
658 } 679 }
659 680
660 } // namespace extensions 681 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698