Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/api/webstore_private/webstore_private_api.h" | 5 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "base/metrics/histogram.h" | |
| 11 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "chrome/browser/about_flags.h" | 16 #include "chrome/browser/about_flags.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/extensions/crx_installer.h" | 19 #include "chrome/browser/extensions/crx_installer.h" |
| 19 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 20 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 20 #include "chrome/browser/extensions/extension_prefs.h" | 21 #include "chrome/browser/extensions/extension_prefs.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 std::string GetWebstoreLogin(Profile* profile) { | 177 std::string GetWebstoreLogin(Profile* profile) { |
| 177 if (profile->GetPrefs()->HasPrefPath(kWebstoreLogin)) | 178 if (profile->GetPrefs()->HasPrefPath(kWebstoreLogin)) |
| 178 return profile->GetPrefs()->GetString(kWebstoreLogin); | 179 return profile->GetPrefs()->GetString(kWebstoreLogin); |
| 179 return std::string(); | 180 return std::string(); |
| 180 } | 181 } |
| 181 | 182 |
| 182 void SetWebstoreLogin(Profile* profile, const std::string& login) { | 183 void SetWebstoreLogin(Profile* profile, const std::string& login) { |
| 183 profile->GetPrefs()->SetString(kWebstoreLogin, login); | 184 profile->GetPrefs()->SetString(kWebstoreLogin, login); |
| 184 } | 185 } |
| 185 | 186 |
| 187 void RecordWebstoreExtensionInstallResult(bool success) { | |
| 188 UMA_HISTOGRAM_BOOLEAN("Webstore.ExtensionInstallResult", success); | |
|
asargent_no_longer_on_chrome
2013/11/07 00:18:47
Does the histograms dashboard have an easy way for
jackhou1
2013/11/11 22:59:25
Ah, thanks for pointing this out. The dashboard do
| |
| 189 } | |
| 190 | |
| 186 } // namespace | 191 } // namespace |
| 187 | 192 |
| 188 // static | 193 // static |
| 189 void WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting( | 194 void WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting( |
| 190 WebstoreInstaller::Delegate* delegate) { | 195 WebstoreInstaller::Delegate* delegate) { |
| 191 test_webstore_installer_delegate = delegate; | 196 test_webstore_installer_delegate = delegate; |
| 192 } | 197 } |
| 193 | 198 |
| 194 // static | 199 // static |
| 195 scoped_ptr<WebstoreInstaller::Approval> | 200 scoped_ptr<WebstoreInstaller::Approval> |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 | 575 |
| 571 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallSuccess( | 576 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallSuccess( |
| 572 const std::string& id) { | 577 const std::string& id) { |
| 573 if (test_webstore_installer_delegate) | 578 if (test_webstore_installer_delegate) |
| 574 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); | 579 test_webstore_installer_delegate->OnExtensionInstallSuccess(id); |
| 575 | 580 |
| 576 LOG(INFO) << "Install success, sending response"; | 581 LOG(INFO) << "Install success, sending response"; |
| 577 g_pending_installs.Get().EraseInstall(GetProfile(), id); | 582 g_pending_installs.Get().EraseInstall(GetProfile(), id); |
| 578 SendResponse(true); | 583 SendResponse(true); |
| 579 | 584 |
| 585 RecordWebstoreExtensionInstallResult(true); | |
| 586 | |
| 580 // Matches the AddRef in RunImpl(). | 587 // Matches the AddRef in RunImpl(). |
| 581 Release(); | 588 Release(); |
| 582 } | 589 } |
| 583 | 590 |
| 584 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallFailure( | 591 void WebstorePrivateCompleteInstallFunction::OnExtensionInstallFailure( |
| 585 const std::string& id, | 592 const std::string& id, |
| 586 const std::string& error, | 593 const std::string& error, |
| 587 WebstoreInstaller::FailureReason reason) { | 594 WebstoreInstaller::FailureReason reason) { |
| 588 if (test_webstore_installer_delegate) { | 595 if (test_webstore_installer_delegate) { |
| 589 test_webstore_installer_delegate->OnExtensionInstallFailure( | 596 test_webstore_installer_delegate->OnExtensionInstallFailure( |
| 590 id, error, reason); | 597 id, error, reason); |
| 591 } | 598 } |
| 592 | 599 |
| 593 error_ = error; | 600 error_ = error; |
| 594 LOG(INFO) << "Install failed, sending response"; | 601 LOG(INFO) << "Install failed, sending response"; |
| 595 g_pending_installs.Get().EraseInstall(GetProfile(), id); | 602 g_pending_installs.Get().EraseInstall(GetProfile(), id); |
| 596 SendResponse(false); | 603 SendResponse(false); |
| 597 | 604 |
| 605 RecordWebstoreExtensionInstallResult(false); | |
| 606 | |
| 598 // Matches the AddRef in RunImpl(). | 607 // Matches the AddRef in RunImpl(). |
| 599 Release(); | 608 Release(); |
| 600 } | 609 } |
| 601 | 610 |
| 602 WebstorePrivateEnableAppLauncherFunction:: | 611 WebstorePrivateEnableAppLauncherFunction:: |
| 603 WebstorePrivateEnableAppLauncherFunction() {} | 612 WebstorePrivateEnableAppLauncherFunction() {} |
| 604 | 613 |
| 605 WebstorePrivateEnableAppLauncherFunction:: | 614 WebstorePrivateEnableAppLauncherFunction:: |
| 606 ~WebstorePrivateEnableAppLauncherFunction() {} | 615 ~WebstorePrivateEnableAppLauncherFunction() {} |
| 607 | 616 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 663 return true; | 672 return true; |
| 664 } | 673 } |
| 665 | 674 |
| 666 bool WebstorePrivateIsInIncognitoModeFunction::RunImpl() { | 675 bool WebstorePrivateIsInIncognitoModeFunction::RunImpl() { |
| 667 results_ = IsInIncognitoMode::Results::Create( | 676 results_ = IsInIncognitoMode::Results::Create( |
| 668 GetProfile() != GetProfile()->GetOriginalProfile()); | 677 GetProfile() != GetProfile()->GetOriginalProfile()); |
| 669 return true; | 678 return true; |
| 670 } | 679 } |
| 671 | 680 |
| 672 } // namespace extensions | 681 } // namespace extensions |
| OLD | NEW |