| OLD | NEW |
| 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/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/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/scoped_temp_dir.h" | 14 #include "base/scoped_temp_dir.h" |
| 15 #include "base/stl_util-inl.h" | 15 #include "base/stl_util-inl.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/task.h" | 17 #include "base/task.h" |
| 18 #include "base/threading/thread_restrictions.h" | 18 #include "base/threading/thread_restrictions.h" |
| 19 #include "base/time.h" | 19 #include "base/time.h" |
| 20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 21 #include "base/version.h" | 21 #include "base/version.h" |
| 22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/extensions/convert_user_script.h" | 23 #include "chrome/browser/extensions/convert_user_script.h" |
| 24 #include "chrome/browser/extensions/convert_web_app.h" | 24 #include "chrome/browser/extensions/convert_web_app.h" |
| 25 #include "chrome/browser/extensions/extension_error_reporter.h" | 25 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 26 #include "chrome/browser/extensions/extension_service.h" | 26 #include "chrome/browser/extensions/extension_service.h" |
| 27 #include "chrome/browser/shell_integration.h" | 27 #include "chrome/browser/shell_integration.h" |
| 28 #include "chrome/browser/web_applications/web_app.h" | 28 #include "chrome/browser/web_applications/web_app.h" |
| 29 #include "chrome/common/chrome_notification_types.h" |
| 29 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 30 #include "chrome/common/extensions/extension_constants.h" | 31 #include "chrome/common/extensions/extension_constants.h" |
| 31 #include "chrome/common/extensions/extension_file_util.h" | 32 #include "chrome/common/extensions/extension_file_util.h" |
| 32 #include "content/browser/browser_thread.h" | 33 #include "content/browser/browser_thread.h" |
| 33 #include "content/common/notification_service.h" | 34 #include "content/common/notification_service.h" |
| 34 #include "content/common/notification_type.h" | |
| 35 #include "grit/chromium_strings.h" | 35 #include "grit/chromium_strings.h" |
| 36 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
| 37 #include "grit/theme_resources.h" | 37 #include "grit/theme_resources.h" |
| 38 #include "third_party/skia/include/core/SkBitmap.h" | 38 #include "third_party/skia/include/core/SkBitmap.h" |
| 39 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| 40 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 struct Whitelist { | 44 struct Whitelist { |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 431 |
| 432 void CrxInstaller::InstallUIAbort(bool user_initiated) { | 432 void CrxInstaller::InstallUIAbort(bool user_initiated) { |
| 433 std::string histogram_name = user_initiated ? | 433 std::string histogram_name = user_initiated ? |
| 434 "Extensions.Permissions_InstallCancel" : | 434 "Extensions.Permissions_InstallCancel" : |
| 435 "Extensions.Permissions_InstallAbort"; | 435 "Extensions.Permissions_InstallAbort"; |
| 436 ExtensionService::RecordPermissionMessagesHistogram( | 436 ExtensionService::RecordPermissionMessagesHistogram( |
| 437 extension_, histogram_name.c_str()); | 437 extension_, histogram_name.c_str()); |
| 438 | 438 |
| 439 // Kill the theme loading bubble. | 439 // Kill the theme loading bubble. |
| 440 NotificationService* service = NotificationService::current(); | 440 NotificationService* service = NotificationService::current(); |
| 441 service->Notify(NotificationType::NO_THEME_DETECTED, | 441 service->Notify(chrome::NOTIFICATION_NO_THEME_DETECTED, |
| 442 Source<CrxInstaller>(this), | 442 Source<CrxInstaller>(this), |
| 443 NotificationService::NoDetails()); | 443 NotificationService::NoDetails()); |
| 444 Release(); // balanced in ConfirmInstall(). | 444 Release(); // balanced in ConfirmInstall(). |
| 445 | 445 |
| 446 NotifyCrxInstallComplete(); | 446 NotifyCrxInstallComplete(); |
| 447 | 447 |
| 448 // We're done. Since we don't post any more tasks to ourself, our ref count | 448 // We're done. Since we don't post any more tasks to ourself, our ref count |
| 449 // should go to zero and we die. The destructor will clean up the temp dir. | 449 // should go to zero and we die. The destructor will clean up the temp dir. |
| 450 } | 450 } |
| 451 | 451 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 NewRunnableMethod(this, | 504 NewRunnableMethod(this, |
| 505 &CrxInstaller::ReportFailureFromUIThread, | 505 &CrxInstaller::ReportFailureFromUIThread, |
| 506 error))) | 506 error))) |
| 507 NOTREACHED(); | 507 NOTREACHED(); |
| 508 } | 508 } |
| 509 | 509 |
| 510 void CrxInstaller::ReportFailureFromUIThread(const std::string& error) { | 510 void CrxInstaller::ReportFailureFromUIThread(const std::string& error) { |
| 511 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 511 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 512 | 512 |
| 513 NotificationService* service = NotificationService::current(); | 513 NotificationService* service = NotificationService::current(); |
| 514 service->Notify(NotificationType::EXTENSION_INSTALL_ERROR, | 514 service->Notify(chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
| 515 Source<CrxInstaller>(this), | 515 Source<CrxInstaller>(this), |
| 516 Details<const std::string>(&error)); | 516 Details<const std::string>(&error)); |
| 517 | 517 |
| 518 // This isn't really necessary, it is only used because unit tests expect to | 518 // This isn't really necessary, it is only used because unit tests expect to |
| 519 // see errors get reported via this interface. | 519 // see errors get reported via this interface. |
| 520 // | 520 // |
| 521 // TODO(aa): Need to go through unit tests and clean them up too, probably get | 521 // TODO(aa): Need to go through unit tests and clean them up too, probably get |
| 522 // rid of this line. | 522 // rid of this line. |
| 523 ExtensionErrorReporter::GetInstance()->ReportError(error, false); // quiet | 523 ExtensionErrorReporter::GetInstance()->ReportError(error, false); // quiet |
| 524 | 524 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 // soon. | 565 // soon. |
| 566 } | 566 } |
| 567 | 567 |
| 568 void CrxInstaller::NotifyCrxInstallComplete() { | 568 void CrxInstaller::NotifyCrxInstallComplete() { |
| 569 // Some users (such as the download shelf) need to know when a | 569 // Some users (such as the download shelf) need to know when a |
| 570 // CRXInstaller is done. Listening for the EXTENSION_* events | 570 // CRXInstaller is done. Listening for the EXTENSION_* events |
| 571 // is problematic because they don't know anything about the | 571 // is problematic because they don't know anything about the |
| 572 // extension before it is unpacked, so they can not filter based | 572 // extension before it is unpacked, so they can not filter based |
| 573 // on the extension. | 573 // on the extension. |
| 574 NotificationService::current()->Notify( | 574 NotificationService::current()->Notify( |
| 575 NotificationType::CRX_INSTALLER_DONE, | 575 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 576 Source<CrxInstaller>(this), | 576 Source<CrxInstaller>(this), |
| 577 NotificationService::NoDetails()); | 577 NotificationService::NoDetails()); |
| 578 } | 578 } |
| OLD | NEW |