Introduce a stable set of errors for inline install

In addition to a developer-readable string for inline install failures, include
a stable error code. This isn't perfect, since a) the function prototype of
function(error, errorCode) isn't great, and b) we kind of lose track of what
went wrong after a certain point in the install process. Unfortunately, to fix
a) requires either a breaking change or a revamp to our whole error reporting,
and fixing b) requires stable error values at every point in our install
process (which we don't have, and won't anytime soon).

BUG=331887
TBR=benwells@chromium.org (app_list)
TBR=yoshiki@chromium.org (file_manager)

TBRs for trivial, no-functionality changes.

Review URL: https://codereview.chromium.org/384823002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285029 0039d316-1c4b-4281-b951-d872f2087c98
parent 12a3a857
...@@ -132,7 +132,7 @@ void EphemeralAppLauncher::Start() { ...@@ -132,7 +132,7 @@ void EphemeralAppLauncher::Start() {
ExtensionRegistry::Get(profile()) ExtensionRegistry::Get(profile())
->GetExtensionById(id(), ExtensionRegistry::EVERYTHING); ->GetExtensionById(id(), ExtensionRegistry::EVERYTHING);
if (extension) { if (extension) {
webstore_install::Result result = webstore_install::UNKNOWN_ERROR; webstore_install::Result result = webstore_install::OTHER_ERROR;
std::string error; std::string error;
if (!CanLaunchInstalledApp(extension, &result, &error)) { if (!CanLaunchInstalledApp(extension, &result, &error)) {
InvokeCallback(result, error); InvokeCallback(result, error);
...@@ -225,7 +225,7 @@ bool EphemeralAppLauncher::CanLaunchInstalledApp( ...@@ -225,7 +225,7 @@ bool EphemeralAppLauncher::CanLaunchInstalledApp(
void EphemeralAppLauncher::EnableInstalledApp(const Extension* extension) { void EphemeralAppLauncher::EnableInstalledApp(const Extension* extension) {
// Check whether an install is already in progress. // Check whether an install is already in progress.
webstore_install::Result result = webstore_install::UNKNOWN_ERROR; webstore_install::Result result = webstore_install::OTHER_ERROR;
std::string error; std::string error;
if (!EnsureUniqueInstall(&result, &error)) { if (!EnsureUniqueInstall(&result, &error)) {
InvokeCallback(result, error); InvokeCallback(result, error);
...@@ -246,7 +246,7 @@ void EphemeralAppLauncher::EnableInstalledApp(const Extension* extension) { ...@@ -246,7 +246,7 @@ void EphemeralAppLauncher::EnableInstalledApp(const Extension* extension) {
} }
void EphemeralAppLauncher::MaybeLaunchApp() { void EphemeralAppLauncher::MaybeLaunchApp() {
webstore_install::Result result = webstore_install::UNKNOWN_ERROR; webstore_install::Result result = webstore_install::OTHER_ERROR;
std::string error; std::string error;
ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
...@@ -329,7 +329,7 @@ void EphemeralAppLauncher::CheckEphemeralInstallPermitted() { ...@@ -329,7 +329,7 @@ void EphemeralAppLauncher::CheckEphemeralInstallPermitted() {
void EphemeralAppLauncher::OnInstallChecked(int check_failures) { void EphemeralAppLauncher::OnInstallChecked(int check_failures) {
if (!CheckRequestorAlive()) { if (!CheckRequestorAlive()) {
AbortLaunch(webstore_install::UNKNOWN_ERROR, std::string()); AbortLaunch(webstore_install::OTHER_ERROR, std::string());
return; return;
} }
...@@ -410,7 +410,7 @@ void EphemeralAppLauncher::OnManifestParsed() { ...@@ -410,7 +410,7 @@ void EphemeralAppLauncher::OnManifestParsed() {
return; return;
} }
webstore_install::Result result = webstore_install::UNKNOWN_ERROR; webstore_install::Result result = webstore_install::OTHER_ERROR;
std::string error; std::string error;
if (!CheckCommonLaunchCriteria(profile(), extension, &result, &error)) { if (!CheckCommonLaunchCriteria(profile(), extension, &result, &error)) {
AbortLaunch(result, error); AbortLaunch(result, error);
......
...@@ -136,7 +136,7 @@ class LaunchObserver { ...@@ -136,7 +136,7 @@ class LaunchObserver {
LaunchObserver() LaunchObserver()
: done_(false), : done_(false),
waiting_(false), waiting_(false),
result_(webstore_install::UNKNOWN_ERROR) {} result_(webstore_install::OTHER_ERROR) {}
webstore_install::Result result() const { return result_; } webstore_install::Result result() const { return result_; }
const std::string& error() const { return error_; } const std::string& error() const { return error_; }
......
...@@ -282,7 +282,8 @@ bool FileBrowserPrivateInstallWebstoreItemFunction::RunAsync() { ...@@ -282,7 +282,8 @@ bool FileBrowserPrivateInstallWebstoreItemFunction::RunAsync() {
void FileBrowserPrivateInstallWebstoreItemFunction::OnInstallComplete( void FileBrowserPrivateInstallWebstoreItemFunction::OnInstallComplete(
bool success, bool success,
const std::string& error) { const std::string& error,
extensions::webstore_install::Result result) {
drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile());
if (success) { if (success) {
if (logger) { if (logger) {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_MISC_H_ #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_MISC_H_
#include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h" #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
#include "chrome/common/extensions/webstore_install_result.h"
#include "google_apis/drive/gdata_errorcode.h" #include "google_apis/drive/gdata_errorcode.h"
namespace google_apis { namespace google_apis {
...@@ -108,7 +109,9 @@ class FileBrowserPrivateInstallWebstoreItemFunction ...@@ -108,7 +109,9 @@ class FileBrowserPrivateInstallWebstoreItemFunction
// AsyncExtensionFunction overrides. // AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE; virtual bool RunAsync() OVERRIDE;
void OnInstallComplete(bool success, const std::string& error); void OnInstallComplete(bool success,
const std::string& error,
extensions::webstore_install::Result result);
private: private:
std::string webstore_item_id_; std::string webstore_item_id_;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/file_manager/app_installer.h" #include "chrome/browser/chromeos/file_manager/app_installer.h"
#include "chrome/common/extensions/webstore_install_result.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
...@@ -96,7 +97,9 @@ bool AppInstaller::CheckRequestorPermitted( ...@@ -96,7 +97,9 @@ bool AppInstaller::CheckRequestorPermitted(
void AppInstaller::OnWebContentsDestroyed( void AppInstaller::OnWebContentsDestroyed(
content::WebContents* web_contents) { content::WebContents* web_contents) {
callback_.Run(false, kWebContentsDestroyedError); callback_.Run(false,
kWebContentsDestroyedError,
extensions::webstore_install::OTHER_ERROR);
AbortInstall(); AbortInstall();
} }
......
...@@ -828,7 +828,7 @@ void WebstorePrivateLaunchEphemeralAppFunction::OnLaunchComplete( ...@@ -828,7 +828,7 @@ void WebstorePrivateLaunchEphemeralAppFunction::OnLaunchComplete(
case webstore_install::SUCCESS: case webstore_install::SUCCESS:
api_result = LaunchEphemeralAppResult::RESULT_SUCCESS; api_result = LaunchEphemeralAppResult::RESULT_SUCCESS;
break; break;
case webstore_install::UNKNOWN_ERROR: case webstore_install::OTHER_ERROR:
api_result = LaunchEphemeralAppResult::RESULT_UNKNOWN_ERROR; api_result = LaunchEphemeralAppResult::RESULT_UNKNOWN_ERROR;
break; break;
case webstore_install::INVALID_ID: case webstore_install::INVALID_ID:
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
#include "chrome/browser/extensions/chrome_extension_function.h" #include "chrome/browser/extensions/chrome_extension_function.h"
#include "chrome/browser/extensions/extension_install_prompt.h" #include "chrome/browser/extensions/extension_install_prompt.h"
#include "chrome/browser/extensions/webstore_install_helper.h" #include "chrome/browser/extensions/webstore_install_helper.h"
#include "chrome/browser/extensions/webstore_install_result.h"
#include "chrome/browser/extensions/webstore_installer.h" #include "chrome/browser/extensions/webstore_installer.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/common/extensions/api/webstore_private.h" #include "chrome/common/extensions/api/webstore_private.h"
#include "chrome/common/extensions/webstore_install_result.h"
#include "components/signin/core/browser/signin_tracker.h" #include "components/signin/core/browser/signin_tracker.h"
#include "content/public/browser/gpu_data_manager_observer.h" #include "content/public/browser/gpu_data_manager_observer.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
......
...@@ -29,7 +29,7 @@ using content::BrowserThread; ...@@ -29,7 +29,7 @@ using content::BrowserThread;
namespace { namespace {
void PrintPackExtensionMessage(const std::string& message) { void PrintPackExtensionMessage(const std::string& message) {
printf("%s\n", message.c_str()); VLOG(1) << message;
} }
} // namespace } // namespace
...@@ -213,7 +213,9 @@ class AppInstallHelper { ...@@ -213,7 +213,9 @@ class AppInstallHelper {
private: private:
WebstoreStandaloneInstaller::Callback Callback(); WebstoreStandaloneInstaller::Callback Callback();
void OnAppInstallComplete(bool success, const std::string& error); void OnAppInstallComplete(bool success,
const std::string& error,
webstore_install::Result result);
DoneCallback done_callback_; DoneCallback done_callback_;
...@@ -252,7 +254,8 @@ void AppInstallHelper::BeginInstall( ...@@ -252,7 +254,8 @@ void AppInstallHelper::BeginInstall(
} }
void AppInstallHelper::OnAppInstallComplete(bool success, void AppInstallHelper::OnAppInstallComplete(bool success,
const std::string& error) { const std::string& error,
webstore_install::Result result) {
success_ = success; success_ = success;
error_= error; error_= error;
done_callback_.Run(); done_callback_.Run();
......
...@@ -385,8 +385,10 @@ void TabHelper::OnInlineWebstoreInstall(int install_id, ...@@ -385,8 +385,10 @@ void TabHelper::OnInlineWebstoreInstall(int install_id,
return_route_id, this, webstore_item_id, listeners_mask); return_route_id, this, webstore_item_id, listeners_mask);
WebstoreStandaloneInstaller::Callback callback = WebstoreStandaloneInstaller::Callback callback =
base::Bind(&TabHelper::OnInlineInstallComplete, base::Unretained(this), base::Bind(&TabHelper::OnInlineInstallComplete,
install_id, return_route_id); base::Unretained(this),
install_id,
return_route_id);
scoped_refptr<WebstoreInlineInstaller> installer( scoped_refptr<WebstoreInlineInstaller> installer(
webstore_inline_installer_factory_->CreateInstaller( webstore_inline_installer_factory_->CreateInstaller(
web_contents(), web_contents(),
...@@ -516,9 +518,14 @@ WindowController* TabHelper::GetExtensionWindowController() const { ...@@ -516,9 +518,14 @@ WindowController* TabHelper::GetExtensionWindowController() const {
void TabHelper::OnInlineInstallComplete(int install_id, void TabHelper::OnInlineInstallComplete(int install_id,
int return_route_id, int return_route_id,
bool success, bool success,
const std::string& error) { const std::string& error,
webstore_install::Result result) {
Send(new ExtensionMsg_InlineWebstoreInstallResponse( Send(new ExtensionMsg_InlineWebstoreInstallResponse(
return_route_id, install_id, success, success ? std::string() : error)); return_route_id,
install_id,
success,
success ? std::string() : error,
result));
} }
WebContents* TabHelper::GetAssociatedWebContents() const { WebContents* TabHelper::GetAssociatedWebContents() const {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "chrome/browser/extensions/active_tab_permission_granter.h" #include "chrome/browser/extensions/active_tab_permission_granter.h"
#include "chrome/common/extensions/webstore_install_result.h"
#include "chrome/common/web_application_info.h" #include "chrome/common/web_application_info.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
...@@ -224,7 +225,8 @@ class TabHelper : public content::WebContentsObserver, ...@@ -224,7 +225,8 @@ class TabHelper : public content::WebContentsObserver,
virtual void OnInlineInstallComplete(int install_id, virtual void OnInlineInstallComplete(int install_id,
int return_route_id, int return_route_id,
bool success, bool success,
const std::string& error); const std::string& error,
webstore_install::Result result);
// content::NotificationObserver. // content::NotificationObserver.
virtual void Observe(int type, virtual void Observe(int type,
......
...@@ -106,7 +106,9 @@ class WebstoreInlineInstallerForTest : public WebstoreInlineInstaller { ...@@ -106,7 +106,9 @@ class WebstoreInlineInstallerForTest : public WebstoreInlineInstaller {
friend class base::RefCountedThreadSafe<WebstoreStandaloneInstaller>; friend class base::RefCountedThreadSafe<WebstoreStandaloneInstaller>;
static void DummyCallback(bool /*success*/, const std::string& /*error*/) { static void DummyCallback(bool success,
const std::string& error,
webstore_install::Result result) {
} }
ProgrammableInstallPrompt* programmable_prompt_; ProgrammableInstallPrompt* programmable_prompt_;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <vector> #include <vector>
#include "chrome/browser/extensions/webstore_inline_installer.h" #include "chrome/browser/extensions/webstore_inline_installer.h"
#include "chrome/common/extensions/webstore_install_result.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -30,7 +31,9 @@ class TestWebstoreInlineInstaller : public WebstoreInlineInstaller { ...@@ -30,7 +31,9 @@ class TestWebstoreInlineInstaller : public WebstoreInlineInstaller {
virtual ~TestWebstoreInlineInstaller(); virtual ~TestWebstoreInlineInstaller();
}; };
void TestInstallerCallback(bool success, const std::string& error) {} void TestInstallerCallback(bool success,
const std::string& error,
webstore_install::Result result) {}
TestWebstoreInlineInstaller::TestWebstoreInlineInstaller( TestWebstoreInlineInstaller::TestWebstoreInlineInstaller(
content::WebContents* contents, content::WebContents* contents,
......
...@@ -59,7 +59,7 @@ void WebstoreStandaloneInstaller::BeginInstall() { ...@@ -59,7 +59,7 @@ void WebstoreStandaloneInstaller::BeginInstall() {
return; return;
} }
webstore_install::Result result = webstore_install::UNKNOWN_ERROR; webstore_install::Result result = webstore_install::OTHER_ERROR;
std::string error; std::string error;
if (!EnsureUniqueInstall(&result, &error)) { if (!EnsureUniqueInstall(&result, &error)) {
CompleteInstall(result, error); CompleteInstall(result, error);
...@@ -124,7 +124,7 @@ void WebstoreStandaloneInstaller::CompleteInstall( ...@@ -124,7 +124,7 @@ void WebstoreStandaloneInstaller::CompleteInstall(
const std::string& error) { const std::string& error) {
scoped_active_install_.reset(); scoped_active_install_.reset();
if (!callback_.is_null()) if (!callback_.is_null())
callback_.Run(result == webstore_install::SUCCESS, error); callback_.Run(result == webstore_install::SUCCESS, error, result);
Release(); // Matches the AddRef in BeginInstall. Release(); // Matches the AddRef in BeginInstall.
} }
...@@ -306,7 +306,7 @@ void WebstoreStandaloneInstaller::OnWebstoreParseFailure( ...@@ -306,7 +306,7 @@ void WebstoreStandaloneInstaller::OnWebstoreParseFailure(
const std::string& id, const std::string& id,
InstallHelperResultCode result_code, InstallHelperResultCode result_code,
const std::string& error_message) { const std::string& error_message) {
webstore_install::Result install_result = webstore_install::UNKNOWN_ERROR; webstore_install::Result install_result = webstore_install::OTHER_ERROR;
switch (result_code) { switch (result_code) {
case WebstoreInstallHelper::Delegate::MANIFEST_ERROR: case WebstoreInstallHelper::Delegate::MANIFEST_ERROR:
install_result = webstore_install::INVALID_MANIFEST; install_result = webstore_install::INVALID_MANIFEST;
...@@ -400,7 +400,7 @@ void WebstoreStandaloneInstaller::OnExtensionInstallFailure( ...@@ -400,7 +400,7 @@ void WebstoreStandaloneInstaller::OnExtensionInstallFailure(
WebstoreInstaller::FailureReason reason) { WebstoreInstaller::FailureReason reason) {
CHECK_EQ(id_, id); CHECK_EQ(id_, id);
webstore_install::Result install_result = webstore_install::UNKNOWN_ERROR; webstore_install::Result install_result = webstore_install::OTHER_ERROR;
switch (reason) { switch (reason) {
case WebstoreInstaller::FAILURE_REASON_CANCELLED: case WebstoreInstaller::FAILURE_REASON_CANCELLED:
install_result = webstore_install::USER_CANCELLED; install_result = webstore_install::USER_CANCELLED;
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
#include "chrome/browser/extensions/extension_install_prompt.h" #include "chrome/browser/extensions/extension_install_prompt.h"
#include "chrome/browser/extensions/webstore_data_fetcher_delegate.h" #include "chrome/browser/extensions/webstore_data_fetcher_delegate.h"
#include "chrome/browser/extensions/webstore_install_helper.h" #include "chrome/browser/extensions/webstore_install_helper.h"
#include "chrome/browser/extensions/webstore_install_result.h"
#include "chrome/browser/extensions/webstore_installer.h" #include "chrome/browser/extensions/webstore_installer.h"
#include "chrome/common/extensions/webstore_install_result.h"
#include "net/url_request/url_fetcher_delegate.h" #include "net/url_request/url_fetcher_delegate.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
...@@ -52,7 +52,9 @@ class WebstoreStandaloneInstaller ...@@ -52,7 +52,9 @@ class WebstoreStandaloneInstaller
// A callback for when the install process completes, successfully or not. If // A callback for when the install process completes, successfully or not. If
// there was a failure, |success| will be false and |error| may contain a // there was a failure, |success| will be false and |error| may contain a
// developer-readable error message about why it failed. // developer-readable error message about why it failed.
typedef base::Callback<void(bool success, const std::string& error)> Callback; typedef base::Callback<void(bool success,
const std::string& error,
webstore_install::Result result)> Callback;
WebstoreStandaloneInstaller(const std::string& webstore_item_id, WebstoreStandaloneInstaller(const std::string& webstore_item_id,
Profile* profile, Profile* profile,
......
...@@ -215,7 +215,10 @@ void WebstoreResult::StartInstall(bool launch_ephemeral_app) { ...@@ -215,7 +215,10 @@ void WebstoreResult::StartInstall(bool launch_ephemeral_app) {
installer->BeginInstall(); installer->BeginInstall();
} }
void WebstoreResult::InstallCallback(bool success, const std::string& error) { void WebstoreResult::InstallCallback(
bool success,
const std::string& error,
extensions::webstore_install::Result result) {
if (!success) { if (!success) {
LOG(ERROR) << "Failed to install app, error=" << error; LOG(ERROR) << "Failed to install app, error=" << error;
SetIsInstalling(false); SetIsInstalling(false);
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/extensions/install_observer.h" #include "chrome/browser/extensions/install_observer.h"
#include "chrome/browser/extensions/webstore_install_result.h"
#include "chrome/browser/ui/app_list/search/chrome_search_result.h" #include "chrome/browser/ui/app_list/search/chrome_search_result.h"
#include "chrome/common/extensions/webstore_install_result.h"
#include "extensions/browser/extension_registry_observer.h" #include "extensions/browser/extension_registry_observer.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -52,7 +52,9 @@ class WebstoreResult : public ChromeSearchResult, ...@@ -52,7 +52,9 @@ class WebstoreResult : public ChromeSearchResult,
void OnIconLoaded(); void OnIconLoaded();
void StartInstall(bool launch_ephemeral_app); void StartInstall(bool launch_ephemeral_app);
void InstallCallback(bool success, const std::string& error); void InstallCallback(bool success,
const std::string& error,
extensions::webstore_install::Result result);
void LaunchCallback(extensions::webstore_install::Result result, void LaunchCallback(extensions::webstore_install::Result result,
const std::string& error); const std::string& error);
......
...@@ -12,6 +12,84 @@ ...@@ -12,6 +12,84 @@
"type": "string", "type": "string",
"enum": ["installing", "downloading"], "enum": ["installing", "downloading"],
"description": "Enum used to indicate the stage of the installation process. 'downloading' indicates that the necessary files are being downloaded, and 'installing' indicates that the files are downloaded and are being actively installed." "description": "Enum used to indicate the stage of the installation process. 'downloading' indicates that the necessary files are being downloaded, and 'installing' indicates that the files are downloaded and are being actively installed."
},
{
"id": "ErrorCode",
"type": "string",
"description": "Enum of the possible install results, including error codes sent back in the event that an inline installation has failed.",
"enum": [
// Keep this list of enums in sync with
// chrome/common/extensions/webstore_install_result.h and
// chrome/common/extensions/api/webstore/webstore_api_constants.cc!
{
"description": "An uncommon, unrecognized, or unexpected error. In some cases, the readable error string can provide more information.",
"name": "otherError"
},
{
"description": "The operation was aborted as the requestor is no longer alive.",
"name": "aborted"
},
{
"description": "An installation of the same extension is in progress.",
"name": "installInProgress"
},
{
"description": "The installation is not permitted.",
"name": "notPermitted"
},
{
"description": "Invalid Chrome Web Store item ID.",
"name": "invalidId"
},
{
"description": "Failed to retrieve extension metadata from the Web Store.",
"name": "webstoreRequestError"
},
{
"description": "The extension metadata retrieved from the Web Store was invalid.",
"name": "invalidWebstoreResponse"
},
{
"description": "An error occurred while parsing the extension manifest retrieved from the Web Store.",
"name": "invalidManifest"
},
{
"description": "Failed to retrieve the extension's icon from the Web Store, or the icon was invalid.",
"name": "iconError"
},
{
"description": "The user canceled the operation.",
"name": "userCanceled"
},
{
"description": "The extension is blacklisted.",
"name": "blacklisted"
},
{
"description": "Unsatisfied dependencies, such as shared modules.",
"name": "missingDependencies"
},
{
"description": "Unsatisfied requirements, such as webgl.",
"name": "requirementViolations"
},
{
"description": "The extension is blocked by management policies.",
"name": "blockedByPolicy"
},
{
"description": "The launch feature is not available.",
"name": "launchFeatureDisabled"
},
{
"description": "The launch feature is not supported for the extension type.",
"name": "launchUnsupportedExtensionType"
},
{
"description": "A launch of the same extension is in progress.",
"name": " launchInProgress"
}
]
} }
], // types ], // types
"events": [ "events": [
...@@ -67,6 +145,12 @@ ...@@ -67,6 +145,12 @@
"name": "error", "name": "error",
"type": "string", "type": "string",
"description": "The failure detail. You may wish to inspect or log this for debugging purposes, but you should not rely on specific strings being passed back." "description": "The failure detail. You may wish to inspect or log this for debugging purposes, but you should not rely on specific strings being passed back."
},
{
"name": "errorCode",
"$ref": "ErrorCode",
"optional": "true",
"description": "The error code from the stable set of possible errors."
} }
], ],
"description": "This function is invoked when inline installation does not successfully complete. Possible reasons for this include the user canceling the dialog, the linked item not being found in the store, or the install being initiated from a non-verified site." "description": "This function is invoked when inline installation does not successfully complete. Possible reasons for this include the user canceling the dialog, the linked item not being found in the store, or the install being initiated from a non-verified site."
......
...@@ -4,10 +4,41 @@ ...@@ -4,10 +4,41 @@
#include "chrome/common/extensions/api/webstore/webstore_api_constants.h" #include "chrome/common/extensions/api/webstore/webstore_api_constants.h"
#include "base/macros.h"
#include "chrome/common/extensions/webstore_install_result.h"
namespace extensions { namespace extensions {
namespace api { namespace api {
namespace webstore { namespace webstore {
// IMPORTANT: Keep this list in sync with both the definition in
// chrome/common/extensions/api/webstore.json and
// chrome/common/extensions/webstore_install_result.h!
const char* kInstallResultCodes[] = {
"success",
"otherError",
"aborted",
"installInProgress",
"notPermitted",
"invalidId",
"webstoreRequestError",
"invalidWebstoreResponse",
"invalidManifest",
"iconError",
"userCancelled",
"blacklisted",
"missingDependencies",
"requirementViolations",
"blockedByPolicy",
"launchFeatureDisabled",
"launchUnsupportedExtensionType",
"launchInProgress",
};
COMPILE_ASSERT(arraysize(kInstallResultCodes) ==
webstore_install::RESULT_LAST + 1,
must_keep_webstore_install_result_and_api_constants_in_sync);
// The "downloading" stage begins when the installer starts downloading modules // The "downloading" stage begins when the installer starts downloading modules
// for the extension. // for the extension.
const char kInstallStageDownloading[] = "downloading"; const char kInstallStageDownloading[] = "downloading";
......
...@@ -22,6 +22,12 @@ enum InstallStage { ...@@ -22,6 +22,12 @@ enum InstallStage {
INSTALL_STAGE_INSTALLING, INSTALL_STAGE_INSTALLING,
}; };
// Result codes returned by WebstoreStandaloneInstaller and its subclasses.
// IMPORTANT: Keep this list in sync with both the definition in
// chrome/common/extensions/api/webstore.json and
// chrome/common/extensions/webstore_install_result.h!
extern const char* kInstallResultCodes[];
extern const char kInstallStageDownloading[]; extern const char kInstallStageDownloading[];
extern const char kInstallStageInstalling[]; extern const char kInstallStageInstalling[];
extern const char kOnInstallStageChangedMethodName[]; extern const char kOnInstallStageChangedMethodName[];
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "chrome/common/extensions/api/webstore/webstore_api_constants.h" #include "chrome/common/extensions/api/webstore/webstore_api_constants.h"
#include "chrome/common/extensions/webstore_install_result.h"
#include "chrome/common/web_application_info.h" #include "chrome/common/web_application_info.h"
#include "extensions/common/stack_frame.h" #include "extensions/common/stack_frame.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
...@@ -21,6 +22,8 @@ ...@@ -21,6 +22,8 @@
IPC_ENUM_TRAITS_MAX_VALUE(extensions::api::webstore::InstallStage, IPC_ENUM_TRAITS_MAX_VALUE(extensions::api::webstore::InstallStage,
extensions::api::webstore::INSTALL_STAGE_INSTALLING) extensions::api::webstore::INSTALL_STAGE_INSTALLING)
IPC_ENUM_TRAITS_MAX_VALUE(extensions::webstore_install::Result,
extensions::webstore_install::RESULT_LAST)
IPC_STRUCT_TRAITS_BEGIN(extensions::StackFrame) IPC_STRUCT_TRAITS_BEGIN(extensions::StackFrame)
IPC_STRUCT_TRAITS_MEMBER(line_number) IPC_STRUCT_TRAITS_MEMBER(line_number)
...@@ -70,10 +73,11 @@ IPC_MESSAGE_ROUTED1(ExtensionMsg_InlineInstallDownloadProgress, ...@@ -70,10 +73,11 @@ IPC_MESSAGE_ROUTED1(ExtensionMsg_InlineInstallDownloadProgress,
// Send to renderer once the installation mentioned on // Send to renderer once the installation mentioned on
// ExtensionHostMsg_InlineWebstoreInstall is complete. // ExtensionHostMsg_InlineWebstoreInstall is complete.
IPC_MESSAGE_ROUTED3(ExtensionMsg_InlineWebstoreInstallResponse, IPC_MESSAGE_ROUTED4(ExtensionMsg_InlineWebstoreInstallResponse,
int32 /* install id */, int32 /* install id */,
bool /* whether the install was successful */, bool /* whether the install was successful */,
std::string /* error */) std::string /* error */,
extensions::webstore_install::Result /* result */)
// Messages sent from the renderer to the browser. // Messages sent from the renderer to the browser.
......
...@@ -2,20 +2,23 @@ ...@@ -2,20 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_RESULT_H_ #ifndef CHROME_COMMON_EXTENSIONS_WEBSTORE_INSTALL_RESULT_H_
#define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_RESULT_H_ #define CHROME_COMMON_EXTENSIONS_WEBSTORE_INSTALL_RESULT_H_
namespace extensions { namespace extensions {
namespace webstore_install { namespace webstore_install {
// Result codes returned by WebstoreStandaloneInstaller and its subclasses. // Result codes returned by WebstoreStandaloneInstaller and its subclasses.
// IMPORTANT: Keep this list in sync with both the definition in
// chrome/common/extensions/api/webstore.json and
// chrome/common/extensions/api/webstore/webstore_install_constants.cc!
enum Result { enum Result {
// Successful operation. // Successful operation.
SUCCESS, SUCCESS,
// Unknown error. // Unknown error.
UNKNOWN_ERROR, OTHER_ERROR,
// The operation was aborted as the requestor is no longer alive. // The operation was aborted as the requestor is no longer alive.
ABORTED, ABORTED,
...@@ -65,11 +68,15 @@ enum Result { ...@@ -65,11 +68,15 @@ enum Result {
LAUNCH_UNSUPPORTED_EXTENSION_TYPE, LAUNCH_UNSUPPORTED_EXTENSION_TYPE,
// A launch of the same extension is in progress. // A launch of the same extension is in progress.
LAUNCH_IN_PROGRESS LAUNCH_IN_PROGRESS,
// The final (and unused) result type for enum verification.
// New results should go above this entry, and this entry should be updated.
RESULT_LAST = LAUNCH_IN_PROGRESS,
}; };
} // namespace webstore_install } // namespace webstore_install
} // namespace extensions } // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_RESULT_H_ #endif // CHROME_COMMON_EXTENSIONS_WEBSTORE_INSTALL_RESULT_H_
...@@ -202,14 +202,17 @@ bool WebstoreBindings::OnMessageReceived(const IPC::Message& message) { ...@@ -202,14 +202,17 @@ bool WebstoreBindings::OnMessageReceived(const IPC::Message& message) {
void WebstoreBindings::OnInlineWebstoreInstallResponse( void WebstoreBindings::OnInlineWebstoreInstallResponse(
int install_id, int install_id,
bool success, bool success,
const std::string& error) { const std::string& error,
webstore_install::Result result) {
v8::Isolate* isolate = context()->isolate(); v8::Isolate* isolate = context()->isolate();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
v8::Context::Scope context_scope(context()->v8_context()); v8::Context::Scope context_scope(context()->v8_context());
v8::Handle<v8::Value> argv[] = { v8::Handle<v8::Value> argv[] = {
v8::Integer::New(isolate, install_id), v8::Integer::New(isolate, install_id),
v8::Boolean::New(isolate, success), v8::Boolean::New(isolate, success),
v8::String::NewFromUtf8(isolate, error.c_str()) v8::String::NewFromUtf8(isolate, error.c_str()),
v8::String::NewFromUtf8(
isolate, api::webstore::kInstallResultCodes[static_cast<int>(result)])
}; };
context()->module_system()->CallModuleMethod( context()->module_system()->CallModuleMethod(
"webstore", "onInstallResponse", arraysize(argv), argv); "webstore", "onInstallResponse", arraysize(argv), argv);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define CHROME_RENDERER_EXTENSIONS_WEBSTORE_BINDINGS_H_ #define CHROME_RENDERER_EXTENSIONS_WEBSTORE_BINDINGS_H_
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "chrome/common/extensions/webstore_install_result.h"
#include "chrome/renderer/extensions/chrome_v8_extension_handler.h" #include "chrome/renderer/extensions/chrome_v8_extension_handler.h"
#include "extensions/renderer/object_backed_native_handler.h" #include "extensions/renderer/object_backed_native_handler.h"
#include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebFrame.h"
...@@ -26,8 +27,10 @@ class WebstoreBindings : public ObjectBackedNativeHandler, ...@@ -26,8 +27,10 @@ class WebstoreBindings : public ObjectBackedNativeHandler,
private: private:
void Install(const v8::FunctionCallbackInfo<v8::Value>& args); void Install(const v8::FunctionCallbackInfo<v8::Value>& args);
void OnInlineWebstoreInstallResponse( void OnInlineWebstoreInstallResponse(int install_id,
int install_id, bool success, const std::string& error); bool success,
const std::string& error,
webstore_install::Result result);
void OnInlineInstallStageChanged(int stage); void OnInlineInstallStageChanged(int stage);
......
...@@ -46,7 +46,8 @@ Installer.prototype.install = function(url, onSuccess, onFailure) { ...@@ -46,7 +46,8 @@ Installer.prototype.install = function(url, onSuccess, onFailure) {
} }
}; };
Installer.prototype.onInstallResponse = function(installId, success, error) { Installer.prototype.onInstallResponse =
function(installId, success, error, resultCode) {
var pendingInstall = this._pendingInstall; var pendingInstall = this._pendingInstall;
if (!pendingInstall || pendingInstall.installId != installId) { if (!pendingInstall || pendingInstall.installId != installId) {
// TODO(kalman): should this be an error? // TODO(kalman): should this be an error?
...@@ -57,7 +58,7 @@ Installer.prototype.onInstallResponse = function(installId, success, error) { ...@@ -57,7 +58,7 @@ Installer.prototype.onInstallResponse = function(installId, success, error) {
if (success && pendingInstall.onSuccess) if (success && pendingInstall.onSuccess)
pendingInstall.onSuccess(); pendingInstall.onSuccess();
else if (!success && pendingInstall.onFailure) else if (!success && pendingInstall.onFailure)
pendingInstall.onFailure(error); pendingInstall.onFailure(error, resultCode);
} catch (e) { } catch (e) {
console.error('Exception in chrome.webstore.install response handler: ' + console.error('Exception in chrome.webstore.install response handler: ' +
e.stack); e.stack);
......
...@@ -15,8 +15,9 @@ ...@@ -15,8 +15,9 @@
console.log('did not expect install success'); console.log('did not expect install success');
window.domAutomationController.send(false); window.domAutomationController.send(false);
}, },
function(error) { function(error, errorCode) {
if (error.indexOf('verified site') != -1) { if (error.indexOf('verified site') != -1 &&
errorCode == 'notPermitted') {
console.log('Ran test, sending response'); console.log('Ran test, sending response');
window.domAutomationController.send(true); window.domAutomationController.send(true);
console.log('Test complete'); console.log('Test complete');
......
...@@ -22,8 +22,9 @@ ...@@ -22,8 +22,9 @@
console.log('did not expect install success'); console.log('did not expect install success');
window.domAutomationController.send(false); window.domAutomationController.send(false);
}, },
function(error) { function(error, errorCode) {
if (error.indexOf('not supported') != -1) { if (error.indexOf('not supported') != -1 &&
errorCode == 'notPermitted') {
console.log('Ran test, sending response'); console.log('Ran test, sending response');
window.domAutomationController.send(true); window.domAutomationController.send(true);
console.log('Test complete'); console.log('Test complete');
......
...@@ -22,8 +22,9 @@ ...@@ -22,8 +22,9 @@
console.log('did not expect install success'); console.log('did not expect install success');
window.domAutomationController.send(false); window.domAutomationController.send(false);
}, },
function(error) { function(error, errorCode) {
if (error.indexOf('cannot be modified') != -1) { if (error.indexOf('cannot be modified') != -1 &&
errorCode == 'otherError') {
console.log('Ran test, sending response'); console.log('Ran test, sending response');
window.domAutomationController.send(true); window.domAutomationController.send(true);
console.log('Test complete'); console.log('Test complete');
......
...@@ -18,8 +18,9 @@ ...@@ -18,8 +18,9 @@
console.log('Unexpected install success'); console.log('Unexpected install success');
window.domAutomationController.send(false); window.domAutomationController.send(false);
}, },
function(error) { function(error, errorCode) {
if (error.indexOf('Package is invalid') != -1) { if (error.indexOf('Package is invalid') != -1 &&
errorCode == 'otherError') {
window.domAutomationController.send(true); window.domAutomationController.send(true);
} else { } else {
console.log('Unexpected install error: ' + error); console.log('Unexpected install error: ' + error);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment