| 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/field_trial.h" |
| 12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 14 #include "base/scoped_temp_dir.h" | 15 #include "base/scoped_temp_dir.h" |
| 15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 16 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
| 17 #include "base/task.h" | 18 #include "base/task.h" |
| 18 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
| 19 #include "base/time.h" | 20 #include "base/time.h" |
| 20 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 21 #include "base/version.h" | 22 #include "base/version.h" |
| 22 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/extensions/convert_user_script.h" | 24 #include "chrome/browser/extensions/convert_user_script.h" |
| 24 #include "chrome/browser/extensions/convert_web_app.h" | 25 #include "chrome/browser/extensions/convert_web_app.h" |
| 26 #include "chrome/browser/extensions/default_apps_trial.h" |
| 25 #include "chrome/browser/extensions/extension_error_reporter.h" | 27 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 26 #include "chrome/browser/extensions/extension_service.h" | 28 #include "chrome/browser/extensions/extension_service.h" |
| 27 #include "chrome/browser/shell_integration.h" | 29 #include "chrome/browser/shell_integration.h" |
| 28 #include "chrome/browser/web_applications/web_app.h" | 30 #include "chrome/browser/web_applications/web_app.h" |
| 29 #include "chrome/common/chrome_notification_types.h" | 31 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
| 31 #include "chrome/common/extensions/extension_constants.h" | 33 #include "chrome/common/extensions/extension_constants.h" |
| 32 #include "chrome/common/extensions/extension_file_util.h" | 34 #include "chrome/common/extensions/extension_file_util.h" |
| 33 #include "content/browser/browser_thread.h" | 35 #include "content/browser/browser_thread.h" |
| 34 #include "content/browser/user_metrics.h" | 36 #include "content/browser/user_metrics.h" |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 NotifyCrxInstallComplete(); | 539 NotifyCrxInstallComplete(); |
| 538 } | 540 } |
| 539 | 541 |
| 540 void CrxInstaller::ReportSuccessFromFileThread() { | 542 void CrxInstaller::ReportSuccessFromFileThread() { |
| 541 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 543 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 542 | 544 |
| 543 // Tracking number of extensions installed by users | 545 // Tracking number of extensions installed by users |
| 544 if (install_cause() == extension_misc::INSTALL_CAUSE_USER_DOWNLOAD) { | 546 if (install_cause() == extension_misc::INSTALL_CAUSE_USER_DOWNLOAD) { |
| 545 UserMetrics::RecordAction( | 547 UserMetrics::RecordAction( |
| 546 UserMetricsAction("Extensions.ExtensionInstalled")); | 548 UserMetricsAction("Extensions.ExtensionInstalled")); |
| 549 |
| 550 static bool default_apps_trial_exists = |
| 551 base::FieldTrialList::TrialExists(kDefaultAppsTrial_Name); |
| 552 if (default_apps_trial_exists) { |
| 553 UserMetrics::RecordComputedAction( |
| 554 base::FieldTrial::MakeName("Extensions.ExtensionInstalled", |
| 555 kDefaultAppsTrial_Name)); |
| 556 } |
| 547 } | 557 } |
| 548 | 558 |
| 549 if (!BrowserThread::PostTask( | 559 if (!BrowserThread::PostTask( |
| 550 BrowserThread::UI, FROM_HERE, | 560 BrowserThread::UI, FROM_HERE, |
| 551 NewRunnableMethod(this, | 561 NewRunnableMethod(this, |
| 552 &CrxInstaller::ReportSuccessFromUIThread))) | 562 &CrxInstaller::ReportSuccessFromUIThread))) |
| 553 NOTREACHED(); | 563 NOTREACHED(); |
| 554 } | 564 } |
| 555 | 565 |
| 556 void CrxInstaller::ReportSuccessFromUIThread() { | 566 void CrxInstaller::ReportSuccessFromUIThread() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 586 // Some users (such as the download shelf) need to know when a | 596 // Some users (such as the download shelf) need to know when a |
| 587 // CRXInstaller is done. Listening for the EXTENSION_* events | 597 // CRXInstaller is done. Listening for the EXTENSION_* events |
| 588 // is problematic because they don't know anything about the | 598 // is problematic because they don't know anything about the |
| 589 // extension before it is unpacked, so they can not filter based | 599 // extension before it is unpacked, so they can not filter based |
| 590 // on the extension. | 600 // on the extension. |
| 591 NotificationService::current()->Notify( | 601 NotificationService::current()->Notify( |
| 592 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 602 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 593 Source<CrxInstaller>(this), | 603 Source<CrxInstaller>(this), |
| 594 NotificationService::NoDetails()); | 604 NotificationService::NoDetails()); |
| 595 } | 605 } |
| OLD | NEW |