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

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

Issue 14858037: Move [Get|Set]WebStoreLogin methods from ExtensionPrefs to WebstorePrivateAPI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for CQ Created 7 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_prefs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a8ae144ba42618acfe2c6e54f8d09f1653be36bc..3d279f82c724c19d36c3f59ee5c2dcdc6f5658cd 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
@@ -98,6 +98,10 @@ const char kLocalizedNameKey[] = "localizedName";
const char kLoginKey[] = "login";
const char kManifestKey[] = "manifest";
+// A preference set by the web store to indicate login information for
+// purchased apps.
+const char kWebstoreLogin[] = "extensions.webstore_login";
+
const char kCannotSpecifyIconDataAndUrlError[] =
"You cannot specify both icon data and an icon url";
const char kInvalidIconUrlError[] = "Invalid icon url";
@@ -129,6 +133,21 @@ void EnableAppLauncher(base::Callback<void(bool)> callback) {
#endif
}
+// We allow the web store to set a string containing login information when a
+// purchase is made, so that when a user logs into sync with a different
+// account we can recognize the situation. The Get function returns the login if
+// there was previously stored data, or an empty string otherwise. The Set will
+// overwrite any previous login.
+std::string GetWebstoreLogin(Profile* profile) {
+ if (profile->GetPrefs()->HasPrefPath(kWebstoreLogin))
+ return profile->GetPrefs()->GetString(kWebstoreLogin);
+ return std::string();
+}
+
+void SetWebstoreLogin(Profile* profile, const std::string& login) {
+ profile->GetPrefs()->SetString(kWebstoreLogin, login);
+}
+
} // namespace
// static
@@ -139,8 +158,8 @@ void WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting(
// static
scoped_ptr<WebstoreInstaller::Approval>
- WebstorePrivateApi::PopApprovalForTesting(
- Profile* profile, const std::string& extension_id) {
+WebstorePrivateApi::PopApprovalForTesting(
+ Profile* profile, const std::string& extension_id) {
return g_pending_approvals.Get().PopApproval(profile, extension_id);
}
@@ -589,25 +608,14 @@ bool GetBrowserLoginFunction::RunImpl() {
}
bool GetStoreLoginFunction::RunImpl() {
- ExtensionService* service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
- ExtensionPrefs* prefs = service->extension_prefs();
- std::string login;
- if (prefs->GetWebStoreLogin(&login)) {
- SetResult(Value::CreateStringValue(login));
- } else {
- SetResult(Value::CreateStringValue(std::string()));
- }
+ SetResult(Value::CreateStringValue(GetWebstoreLogin(profile_)));
return true;
}
bool SetStoreLoginFunction::RunImpl() {
std::string login;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &login));
- ExtensionService* service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
- ExtensionPrefs* prefs = service->extension_prefs();
- prefs->SetWebStoreLogin(login);
+ SetWebstoreLogin(profile_, login);
return true;
}
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698