Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2735)

Unified Diff: chrome/browser/extensions/api/webstore_private/webstore_private_api.cc

Issue 196783002: Export a private webstore API to call into the new inline sign-in flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
index 15a5f04c4c782077609fb5293d378bae7d7dd638..ed1337f7d553e4c8de2a582ceca451998e93424e 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
@@ -30,6 +30,8 @@
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/app_list/app_list_util.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/webui/signin/login_ui_service.h"
+#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_l10n_util.h"
#include "chrome/common/pref_names.h"
@@ -58,6 +60,7 @@ namespace GetStoreLogin = api::webstore_private::GetStoreLogin;
namespace GetWebGLStatus = api::webstore_private::GetWebGLStatus;
namespace InstallBundle = api::webstore_private::InstallBundle;
namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode;
+namespace SignIn = api::webstore_private::SignIn;
namespace SetStoreLogin = api::webstore_private::SetStoreLogin;
namespace {
@@ -686,4 +689,37 @@ bool WebstorePrivateIsInIncognitoModeFunction::RunImpl() {
return true;
}
+bool WebstorePrivateSignInFunction::RunImpl() {
Ilya Sherman 2014/03/12 06:34:29 Hui, this CL is not nearly ready for a full review
guohui 2014/03/12 18:17:39 it looks good in general, plz see my comments belo
+ scoped_ptr<SignIn::Params> params = SignIn::Params::Create(*args_);
+ EXTENSION_FUNCTION_VALIDATE(params);
+
+ // The |continue_url| is required.
+ if (!params->continue_url)
+ return false;
+
+ // If sign-in is disallowed, give up.
+ SigninManagerBase* signin_manager =
+ SigninManagerFactory::GetForProfile(GetProfile());
+ if (!signin_manager || !signin_manager->IsSigninAllowed())
+ return false;
Ilya Sherman 2014/03/12 06:34:29 Am I right to be using a SigninManager here?
guohui 2014/03/12 18:17:39 yes, i think so, though i think you need to notify
+
+ // If the user is already signed in, there's nothing else to do.
+ if (!signin_manager->GetAuthenticatedUsername().empty())
+ return true;
Ilya Sherman 2014/03/12 06:34:29 Is it appropriate to bail if the user is already s
guohui 2014/03/12 18:17:39 yup, again we should notify the webstore of the re
+
+ // TODO(isherman): What to do if an authentication is already in progress?
+ // if (signin_manager->AuthInProgress()) ...
Ilya Sherman 2014/03/12 06:34:29 What's the expected behavior if there is already a
guohui 2014/03/12 18:17:39 this means signin is already triggered through a s
+
+ // TODO(isherman): Replace the current tab with the UI, rather than showing it
+ // in a new tab.
Ilya Sherman 2014/03/12 06:34:29 Are you aware of existing code that I can re-use t
guohui 2014/03/12 18:17:39 hmm i think you could simply navigate the current
+ // TODO(isherman): Make use of the |continue_url|.
+ LoginUIService* login_ui_service =
+ LoginUIServiceFactory::GetForProfile(GetProfile());
+ login_ui_service->ShowLoginPopup();
Ilya Sherman 2014/03/12 06:34:29 Is a LoginUIService the best way to show an inline
guohui 2014/03/12 18:17:39 LoginUIService::ShowLoginPopup shows the login UI
+
+ // TODO(isherman): Just for debugging:
+ DLOG(WARNING) << *params->continue_url;
+ return true;
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698