Commit 548625f2 authored by benwells's avatar benwells Committed by Commit bot

Remove webstore code for signin that is no longer used.

Now that the webstore does not require sign in for apps, the code to
support the signin as part of install flow is no longer required.

Some code is still needed to support paid apps.

BUG=388083

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

Cr-Commit-Position: refs/heads/master@{#291875}
parent 29cb00fd
...@@ -26,9 +26,6 @@ ...@@ -26,9 +26,6 @@
#include "chrome/browser/extensions/webstore_installer.h" #include "chrome/browser/extensions/webstore_installer.h"
#include "chrome/browser/gpu/gpu_feature_checker.h" #include "chrome/browser/gpu/gpu_feature_checker.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/signin_promo.h"
#include "chrome/browser/signin/signin_tracker_factory.h"
#include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/app_list/app_list_service.h" #include "chrome/browser/ui/app_list/app_list_service.h"
...@@ -37,8 +34,6 @@ ...@@ -37,8 +34,6 @@
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/crx_file/id_util.h" #include "components/crx_file/id_util.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/common/profile_management_switches.h"
#include "content/public/browser/gpu_data_manager.h" #include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/notification_details.h" #include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h" #include "content/public/browser/notification_source.h"
...@@ -73,7 +68,6 @@ namespace InstallBundle = api::webstore_private::InstallBundle; ...@@ -73,7 +68,6 @@ namespace InstallBundle = api::webstore_private::InstallBundle;
namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode; namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode;
namespace LaunchEphemeralApp = api::webstore_private::LaunchEphemeralApp; namespace LaunchEphemeralApp = api::webstore_private::LaunchEphemeralApp;
namespace LaunchEphemeralAppResult = LaunchEphemeralApp::Results; namespace LaunchEphemeralAppResult = LaunchEphemeralApp::Results;
namespace SignIn = api::webstore_private::SignIn;
namespace SetStoreLogin = api::webstore_private::SetStoreLogin; namespace SetStoreLogin = api::webstore_private::SetStoreLogin;
namespace { namespace {
...@@ -319,8 +313,6 @@ const char* WebstorePrivateBeginInstallWithManifest3Function:: ...@@ -319,8 +313,6 @@ const char* WebstorePrivateBeginInstallWithManifest3Function::
return "permission_denied"; return "permission_denied";
case INVALID_ICON_URL: case INVALID_ICON_URL:
return "invalid_icon_url"; return "invalid_icon_url";
case SIGNIN_FAILED:
return "signin_failed";
case ALREADY_INSTALLED: case ALREADY_INSTALLED:
return "already_installed"; return "already_installed";
} }
...@@ -362,18 +354,16 @@ void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess( ...@@ -362,18 +354,16 @@ void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess(
return; return;
} }
SigninManagerBase* signin_manager = content::WebContents* web_contents = GetAssociatedWebContents();
SigninManagerFactory::GetForProfile(GetProfile()); if (!web_contents) // The browser window has gone away.
if (dummy_extension_->is_platform_app() &&
signin_manager &&
signin_manager->GetAuthenticatedUsername().empty() &&
signin_manager->AuthInProgress()) {
signin_tracker_ =
SigninTrackerFactory::CreateForProfile(GetProfile(), this);
return; return;
} install_prompt_.reset(new ExtensionInstallPrompt(web_contents));
install_prompt_->ConfirmWebstoreInstall(
SigninCompletedOrNotNeeded(); this,
dummy_extension_.get(),
&icon_,
ExtensionInstallPrompt::GetDefaultShowDialogCallback());
// Control flow finishes up in InstallUIProceed or InstallUIAbort.
} }
void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseFailure( void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseFailure(
...@@ -403,45 +393,6 @@ void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseFailure( ...@@ -403,45 +393,6 @@ void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseFailure(
Release(); Release();
} }
void WebstorePrivateBeginInstallWithManifest3Function::SigninFailed(
const GoogleServiceAuthError& error) {
signin_tracker_.reset();
SetResultCode(SIGNIN_FAILED);
error_ = error.ToString();
SendResponse(false);
// Matches the AddRef in RunAsync().
Release();
}
void WebstorePrivateBeginInstallWithManifest3Function::SigninSuccess() {
signin_tracker_.reset();
SigninCompletedOrNotNeeded();
}
void WebstorePrivateBeginInstallWithManifest3Function::MergeSessionComplete(
const GoogleServiceAuthError& error) {
// TODO(rogerta): once the embeded inline flow is enabled, the code in
// WebstorePrivateBeginInstallWithManifest3Function::SigninSuccess()
// should move to here.
}
void WebstorePrivateBeginInstallWithManifest3Function::
SigninCompletedOrNotNeeded() {
content::WebContents* web_contents = GetAssociatedWebContents();
if (!web_contents) // The browser window has gone away.
return;
install_prompt_.reset(new ExtensionInstallPrompt(web_contents));
install_prompt_->ConfirmWebstoreInstall(
this,
dummy_extension_.get(),
&icon_,
ExtensionInstallPrompt::GetDefaultShowDialogCallback());
// Control flow finishes up in InstallUIProceed or InstallUIAbort.
}
void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceed() { void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceed() {
// This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in // This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in
// the future we may also want to add time-based expiration, where a whitelist // the future we may also want to add time-based expiration, where a whitelist
...@@ -686,103 +637,6 @@ bool WebstorePrivateIsInIncognitoModeFunction::RunSync() { ...@@ -686,103 +637,6 @@ bool WebstorePrivateIsInIncognitoModeFunction::RunSync() {
return true; return true;
} }
WebstorePrivateSignInFunction::WebstorePrivateSignInFunction()
: signin_manager_(NULL) {}
WebstorePrivateSignInFunction::~WebstorePrivateSignInFunction() {}
bool WebstorePrivateSignInFunction::RunAsync() {
scoped_ptr<SignIn::Params> params = SignIn::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
// This API must be called only in response to a user gesture.
if (!user_gesture()) {
error_ = "user_gesture_required";
SendResponse(false);
return false;
}
// The |continue_url| is required, and must be hosted on the same origin as
// the calling page.
GURL continue_url(params->continue_url);
content::WebContents* web_contents = GetAssociatedWebContents();
if (!continue_url.is_valid() ||
continue_url.GetOrigin() !=
web_contents->GetLastCommittedURL().GetOrigin()) {
error_ = "invalid_continue_url";
SendResponse(false);
return false;
}
// If sign-in is disallowed, give up.
signin_manager_ = SigninManagerFactory::GetForProfile(GetProfile());
if (!signin_manager_ || !signin_manager_->IsSigninAllowed() ||
switches::IsEnableWebBasedSignin()) {
error_ = "signin_is_disallowed";
SendResponse(false);
return false;
}
// If the user is already signed in, there's nothing else to do.
if (!signin_manager_->GetAuthenticatedUsername().empty()) {
SendResponse(true);
return true;
}
// If an authentication is currently in progress, wait for it to complete.
if (signin_manager_->AuthInProgress()) {
SigninManagerFactory::GetInstance()->AddObserver(this);
signin_tracker_ =
SigninTrackerFactory::CreateForProfile(GetProfile(), this).Pass();
AddRef(); // Balanced in the sign-in observer methods below.
return true;
}
GURL signin_url =
signin::GetPromoURLWithContinueURL(signin::SOURCE_WEBSTORE_INSTALL,
false /* auto_close */,
false /* is_constrained */,
continue_url);
web_contents->GetController().LoadURL(signin_url,
content::Referrer(),
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
std::string());
SendResponse(true);
return true;
}
void WebstorePrivateSignInFunction::SigninManagerShutdown(
SigninManagerBase* manager) {
if (manager == signin_manager_)
SigninFailed(GoogleServiceAuthError::AuthErrorNone());
}
void WebstorePrivateSignInFunction::SigninFailed(
const GoogleServiceAuthError& error) {
error_ = "signin_failed";
SendResponse(false);
SigninManagerFactory::GetInstance()->RemoveObserver(this);
Release(); // Balanced in RunAsync().
}
void WebstorePrivateSignInFunction::SigninSuccess() {
// Nothing to do yet. Keep waiting until MergeSessionComplete() is called.
}
void WebstorePrivateSignInFunction::MergeSessionComplete(
const GoogleServiceAuthError& error) {
if (error.state() == GoogleServiceAuthError::NONE) {
SendResponse(true);
} else {
error_ = "merge_session_failed";
SendResponse(false);
}
SigninManagerFactory::GetInstance()->RemoveObserver(this);
Release(); // Balanced in RunAsync().
}
WebstorePrivateLaunchEphemeralAppFunction:: WebstorePrivateLaunchEphemeralAppFunction::
WebstorePrivateLaunchEphemeralAppFunction() {} WebstorePrivateLaunchEphemeralAppFunction() {}
......
...@@ -13,10 +13,8 @@ ...@@ -13,10 +13,8 @@
#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_installer.h" #include "chrome/browser/extensions/webstore_installer.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 "chrome/common/extensions/webstore_install_result.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"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
...@@ -24,7 +22,6 @@ ...@@ -24,7 +22,6 @@
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
class ProfileSyncService; class ProfileSyncService;
class SigninManagerBase;
namespace content { namespace content {
class GpuDataManager; class GpuDataManager;
...@@ -79,8 +76,7 @@ class WebstorePrivateInstallBundleFunction ...@@ -79,8 +76,7 @@ class WebstorePrivateInstallBundleFunction
class WebstorePrivateBeginInstallWithManifest3Function class WebstorePrivateBeginInstallWithManifest3Function
: public ChromeAsyncExtensionFunction, : public ChromeAsyncExtensionFunction,
public ExtensionInstallPrompt::Delegate, public ExtensionInstallPrompt::Delegate,
public WebstoreInstallHelper::Delegate, public WebstoreInstallHelper::Delegate {
public SigninTracker::Observer {
public: public:
DECLARE_EXTENSION_FUNCTION("webstorePrivate.beginInstallWithManifest3", DECLARE_EXTENSION_FUNCTION("webstorePrivate.beginInstallWithManifest3",
WEBSTOREPRIVATE_BEGININSTALLWITHMANIFEST3) WEBSTOREPRIVATE_BEGININSTALLWITHMANIFEST3)
...@@ -112,9 +108,6 @@ class WebstorePrivateBeginInstallWithManifest3Function ...@@ -112,9 +108,6 @@ class WebstorePrivateBeginInstallWithManifest3Function
// Invalid icon url. // Invalid icon url.
INVALID_ICON_URL, INVALID_ICON_URL,
// Signin has failed.
SIGNIN_FAILED,
// An extension with the same extension id has already been installed. // An extension with the same extension id has already been installed.
ALREADY_INSTALLED, ALREADY_INSTALLED,
}; };
...@@ -145,15 +138,6 @@ class WebstorePrivateBeginInstallWithManifest3Function ...@@ -145,15 +138,6 @@ class WebstorePrivateBeginInstallWithManifest3Function
void SetResultCode(ResultCode code); void SetResultCode(ResultCode code);
private: private:
// SigninTracker::Observer override.
virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE;
virtual void SigninSuccess() OVERRIDE;
virtual void MergeSessionComplete(
const GoogleServiceAuthError& error) OVERRIDE;
// Called when signin is complete or not needed.
void SigninCompletedOrNotNeeded();
const char* ResultCodeToString(ResultCode code); const char* ResultCodeToString(ResultCode code);
// These store the input parameters to the function. // These store the input parameters to the function.
...@@ -170,8 +154,6 @@ class WebstorePrivateBeginInstallWithManifest3Function ...@@ -170,8 +154,6 @@ class WebstorePrivateBeginInstallWithManifest3Function
// The class that displays the install prompt. // The class that displays the install prompt.
scoped_ptr<ExtensionInstallPrompt> install_prompt_; scoped_ptr<ExtensionInstallPrompt> install_prompt_;
scoped_ptr<SigninTracker> signin_tracker_;
scoped_ptr<ScopedActiveInstall> scoped_active_install_; scoped_ptr<ScopedActiveInstall> scoped_active_install_;
// The authuser query parameter value which should be used with CRX download // The authuser query parameter value which should be used with CRX download
...@@ -317,39 +299,6 @@ class WebstorePrivateIsInIncognitoModeFunction ...@@ -317,39 +299,6 @@ class WebstorePrivateIsInIncognitoModeFunction
virtual bool RunSync() OVERRIDE; virtual bool RunSync() OVERRIDE;
}; };
class WebstorePrivateSignInFunction : public ChromeAsyncExtensionFunction,
public SigninManagerFactory::Observer,
public SigninTracker::Observer {
public:
DECLARE_EXTENSION_FUNCTION("webstorePrivate.signIn",
WEBSTOREPRIVATE_SIGNINFUNCTION)
WebstorePrivateSignInFunction();
protected:
virtual ~WebstorePrivateSignInFunction();
// ExtensionFunction:
virtual bool RunAsync() OVERRIDE;
// SigninManagerFactory::Observer:
virtual void SigninManagerShutdown(SigninManagerBase* manager) OVERRIDE;
// SigninTracker::Observer:
virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE;
virtual void SigninSuccess() OVERRIDE;
virtual void MergeSessionComplete(const GoogleServiceAuthError& error)
OVERRIDE;
private:
// The sign-in manager for the invoking tab's Chrome Profile. Weak reference.
SigninManagerBase* signin_manager_;
// Tracks changes to sign-in state. Used to notify the page when an existing
// in-progress sign-in completes, either with success or failure.
scoped_ptr<SigninTracker> signin_tracker_;
};
class WebstorePrivateLaunchEphemeralAppFunction class WebstorePrivateLaunchEphemeralAppFunction
: public ChromeAsyncExtensionFunction { : public ChromeAsyncExtensionFunction {
public: public:
......
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
{ {
"name": "result", "name": "result",
"type": "string", "type": "string",
"description": "A string result code, which will be empty upon success. The possible values in the case of errors include 'unknown_error', 'user_cancelled', 'manifest_error', 'icon_error', 'invalid_id', 'permission_denied', 'invalid_icon_url', 'signin_failed', and 'already_installed'." "description": "A string result code, which will be empty upon success. The possible values in the case of errors include 'unknown_error', 'user_cancelled', 'manifest_error', 'icon_error', 'invalid_id', 'permission_denied', 'invalid_icon_url' and 'already_installed'."
} }
] ]
} }
...@@ -258,24 +258,6 @@ ...@@ -258,24 +258,6 @@
} }
] ]
}, },
{
"name": "signIn",
"description": "Signs the user into Chrome.",
"parameters": [
{
"name": "continue_url",
"type": "string",
"description": "The continue URL to navigate to once sign-in completes."
},
{
"name": "callback",
"type": "function",
"description": "Called if the user is already signed in or if the sign-in method was invoked incorrectly (e.g. with an invalid continue URL), sign-in is unavailable (e.g. in Incognito), or the API was not called in response to a user gesture. Upon such a failure, chrome.runtime.lastError will be set to 'invalid_continue_url', 'signin_is_disallowed', 'signin_failed', 'merge_session_failed', or 'user_gesture_required'.",
"optional": true,
"parameters": []
}
]
},
{ {
"name": "getEphemeralAppsEnabled", "name": "getEphemeralAppsEnabled",
"description": "Returns whether the ephemeral apps feature is enabled.", "description": "Returns whether the ephemeral apps feature is enabled.",
......
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